network.c
changeset 4912 d04b3f2bca70
parent 4908 64afa4a8aa79
child 4943 c2005edc4f84
--- a/network.c	Sat Oct 21 23:08:17 2006 +0000
+++ b/network.c	Sat Oct 21 23:31:34 2006 +0000
@@ -131,54 +131,54 @@
 
 	switch (action) {
 		case NETWORK_ACTION_JOIN:
-			GetString(temp, STR_NETWORK_CLIENT_JOINED);
+			GetString(temp, STR_NETWORK_CLIENT_JOINED, lastof(temp));
 			snprintf(message, sizeof(message), "*** %s %s", name, temp);
 			break;
 		case NETWORK_ACTION_LEAVE:
-			GetString(temp, STR_NETWORK_ERR_LEFT);
+			GetString(temp, STR_NETWORK_ERR_LEFT, lastof(temp));
 			snprintf(message, sizeof(message), "*** %s %s (%s)", name, temp, buf);
 			break;
 		case NETWORK_ACTION_GIVE_MONEY:
 			if (self_send) {
 				SetDParamStr(0, name);
 				SetDParam(1, atoi(buf));
-				GetString(temp, STR_NETWORK_GAVE_MONEY_AWAY);
+				GetString(temp, STR_NETWORK_GAVE_MONEY_AWAY, lastof(temp));
 				snprintf(message, sizeof(message), "*** %s", temp);
 			} else {
 				SetDParam(0, atoi(buf));
-				GetString(temp, STR_NETWORK_GIVE_MONEY);
+				GetString(temp, STR_NETWORK_GIVE_MONEY, lastof(temp));
 				snprintf(message, sizeof(message), "*** %s %s", name, temp);
 			}
 			break;
 		case NETWORK_ACTION_CHAT_COMPANY:
 			if (self_send) {
 				SetDParamStr(0, name);
-				GetString(temp, STR_NETWORK_CHAT_TO_COMPANY);
+				GetString(temp, STR_NETWORK_CHAT_TO_COMPANY, lastof(temp));
 				snprintf(message, sizeof(message), "%s %s", temp, buf);
 			} else {
 				SetDParamStr(0, name);
-				GetString(temp, STR_NETWORK_CHAT_COMPANY);
+				GetString(temp, STR_NETWORK_CHAT_COMPANY, lastof(temp));
 				snprintf(message, sizeof(message), "%s %s", temp, buf);
 			}
 			break;
 		case NETWORK_ACTION_CHAT_CLIENT:
 			if (self_send) {
 				SetDParamStr(0, name);
-				GetString(temp, STR_NETWORK_CHAT_TO_CLIENT);
+				GetString(temp, STR_NETWORK_CHAT_TO_CLIENT, lastof(temp));
 				snprintf(message, sizeof(message), "%s %s", temp, buf);
 			} else {
 				SetDParamStr(0, name);
-				GetString(temp, STR_NETWORK_CHAT_CLIENT);
+				GetString(temp, STR_NETWORK_CHAT_CLIENT, lastof(temp));
 				snprintf(message, sizeof(message), "%s %s", temp, buf);
 			}
 			break;
 		case NETWORK_ACTION_NAME_CHANGE:
-			GetString(temp, STR_NETWORK_NAME_CHANGE);
+			GetString(temp, STR_NETWORK_NAME_CHANGE, lastof(temp));
 			snprintf(message, sizeof(message), "*** %s %s %s", name, temp, buf);
 			break;
 		default:
 			SetDParamStr(0, name);
-			GetString(temp, STR_NETWORK_CHAT_ALL);
+			GetString(temp, STR_NETWORK_CHAT_ALL, lastof(temp));
 			snprintf(message, sizeof(message), "%s %s", temp, buf);
 			break;
 	}
@@ -260,7 +260,7 @@
  * @param buf buffer where the error message will be stored
  * @param err NetworkErrorCode
  * @return returns a pointer to the error message (buf) */
-char *GetNetworkErrorMsg(char *buf, NetworkErrorCode err)
+char* GetNetworkErrorMsg(char* buf, NetworkErrorCode err, const char* last)
 {
 	/* List of possible network errors, used by
 	 * PACKET_SERVER_ERROR and PACKET_CLIENT_ERROR */
@@ -283,7 +283,7 @@
 
 	if (err >= lengthof(network_error_strings)) err = 0;
 
-	return GetString(buf, network_error_strings[err]);
+	return GetString(buf, network_error_strings[err], last);
 }
 
 /* Count the number of active clients connected */
@@ -599,7 +599,7 @@
 
 		NetworkGetClientName(client_name, sizeof(client_name), cs);
 
-		GetNetworkErrorMsg(str, errorno);
+		GetNetworkErrorMsg(str, errorno, lastof(str));
 
 		NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str);