maelstrom (1.4.3-L3.0.6-8.1) netlogic/netplay.cpp

Summary

 netlogic/netplay.cpp |   42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

    
download this patch

Patch contents

--- maelstrom-1.4.3-L3.0.6.orig/netlogic/netplay.cpp
+++ maelstrom-1.4.3-L3.0.6/netlogic/netplay.cpp
@@ -210,7 +210,7 @@
 		}
 		/* Add ourselves if needed */
 		if ( gNumPlayers == 0 ) {
-			AddPlayer("1");
+			AddPlayer((char*)"1");
 			gNumPlayers = 1;
 			FoundUs = 1;
 		}
@@ -506,16 +506,16 @@
 	char *message = NULL;
 
 	/* Our address server connection is through TCP */
-	Message("Connecting to Address Server");
+	Message((char*)"Connecting to Address Server");
 	sock = SDLNet_TCP_Open(&ServAddr);
 	if ( sock == NULL ) {
-		ErrorMessage("Connection failed");
+		ErrorMessage((char*)"Connection failed");
 		return(-1);
 	}
 	socketset = SDLNet_AllocSocketSet(1);
 	if ( socketset == NULL ) {
 		status = -1;
-		message = "Couldn't create socket set";
+		message = (char*)"Couldn't create socket set";
 		goto done;
 	}
 	SDLNet_TCP_AddSocket(socketset, sock);
@@ -528,11 +528,11 @@
 	len += 1;
 	if ( SDLNet_TCP_Send(sock, sendbuf, len) != len ) {
 		status = -1;
-		message = "Socket write error";
+		message = (char*)"Socket write error";
 		goto done;
 	}
 
-	Message("Waiting for other players");
+	Message((char*)"Waiting for other players");
 	status = 0;
 	len = 0;
 	lenread = 0;
@@ -558,7 +558,7 @@
 		if ( len <= 0 ) {
 			waiting = 0;
 			status = -1;
-			message = "Error reading player addresses";
+			message = (char*)"Error reading player addresses";
 			continue;
 		}
 		lenread += len;
@@ -570,7 +570,7 @@
 		if ( netbuf[0] <= 1 ) {
 			waiting = 0;
 			status = -1;
-			message = "Error: Short server packet!";
+			message = (char*)"Error: Short server packet!";
 			continue;
 		}
 		switch ( netbuf[1] ) {
@@ -667,10 +667,10 @@
 	/* Wait for Ack's */
 	for ( nleft=gNumPlayers, n=0; nleft; ) {
 		/* Show a status */
-		strcpy(message, "Waiting for players:");
+		strncpy(message, "Waiting for players:", sizeof(message));
 		for ( i=0; i<gNumPlayers; ++i ) {
-			if ( ! acked[i] )
-				sprintf(&message[strlen(message)], " %d", i+1);
+		  if ( ! acked[i] )
+		    snprintf(&message[strlen(message)], (BUFSIZ - strlen(message)), " %d", i+1);
 		}
 		Message(message);
 
@@ -699,7 +699,7 @@
 
 		/* We are guaranteed that there is data here */
 		if ( SDLNet_UDP_Recv(gNetFD, &sent) <= 0 ) {
-			ErrorMessage("Network error receiving packets");
+			ErrorMessage((char*)"Network error receiving packets");
 			return(-1);
 		}
 
@@ -724,13 +724,13 @@
 
 			/* Check the player... */
 			if ( (i != gOurPlayer) && (netbuf[1] == gOurPlayer) ) {
-				/* Print message, sleep 3 seconds absolutely */
-				sprintf(message, 
-	"Error: Another player (%d) thinks they are player 1!\r\n", i+1);
-				ErrorMessage(message);
-				/* Suck up retransmission packets */
-				SuckPackets();
-				return(-1);
+			  /* Print message, sleep 3 seconds absolutely */
+			  snprintf(message, sizeof(message),  
+				   "Error: Another player (%d) thinks they are player 1!\r\n", i+1);
+			  ErrorMessage(message);
+			  /* Suck up retransmission packets */
+			  SuckPackets();
+			  return(-1);
 			}
 
 			/* Check them off our list.. */
@@ -755,7 +755,7 @@
 		return(AlertServer(Wave, Lives, Turbo));
 
 	/* Get ready to wait for server */
-	Message("Awaiting Player 1 (server)");
+	Message((char*)"Awaiting Player 1 (server)");
 	sent.data = netbuf;
 	sent.maxlen = sizeof(netbuf);
 
@@ -776,7 +776,7 @@
 
 		/* We are guaranteed that there is data here */
 		if ( SDLNet_UDP_Recv(gNetFD, &sent) <= 0 ) {
-			ErrorMessage("Network error receiving packets");
+			ErrorMessage((char*)"Network error receiving packets");
 			return(-1);
 		}