(svn r1090) -Fix: Made the _openttd_revision variable global, and with that
authortruelight
Tue, 14 Dec 2004 20:27:00 +0000
changeset 656 e3e435079efa
parent 655 1c4eff980c54
child 657 d4d36b4853ec
(svn r1090) -Fix: Made the _openttd_revision variable global, and with that
hopefully killed the windows-revision problem. If WITH_REV is defined,
for both Windows as *nix system _openttd_revision is filled with normal
info, else _openttd_revision is set to 'norev000'
-Fix: Small possible server-crash
console.c
network.c
network_client.c
network_gui.c
network_server.c
strings.c
ttd.c
variables.h
win32.c
--- a/console.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/console.c	Tue Dec 14 20:27:00 2004 +0000
@@ -232,14 +232,6 @@
 void IConsoleInit(void)
 {
 	uint i;
-#ifdef WITH_REV_HACK
-	#define WITH_REV
-	const char _openttd_revision[] = WITH_REV_HACK;
-#else
-	#if defined(WITH_REV)
-	extern char _openttd_revision[];
-	#endif
-#endif
 	_iconsole_output_file = NULL;
 	_iconsole_color_default = 1;
 	_iconsole_color_error = 3;
@@ -604,7 +596,7 @@
 			if (cmdline[i] == '+') {
 				// all params seperated: "[param 1]" "[param 2]"
 				t=1;
-				while ((tokens[t]!=NULL) && (t<20) && 
+				while ((tokens[t]!=NULL) && (t<20) &&
 						((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
 					int l2 = strlen(tokens[t]);
 					*linestream = '"';
@@ -623,7 +615,7 @@
 				t=1;
 				*linestream = '"';
 				linestream++;
-				while ((tokens[t]!=NULL) && (t<20) && 
+				while ((tokens[t]!=NULL) && (t<20) &&
 						((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
 					int l2 = strlen(tokens[t]);
 					memcpy(linestream,tokens[t],l2);
@@ -640,7 +632,7 @@
 				// one specific parameter: %A = [param 1] %B = [param 2] ...
 				int l2;
 				t = ((byte)cmdline[i]) - 64;
-				if ((t<20) && (tokens[t]!=NULL) && 
+				if ((t<20) && (tokens[t]!=NULL) &&
 						((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
 					l2 = strlen(tokens[t]);
 					*linestream = '"';
--- a/network.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/network.c	Tue Dec 14 20:27:00 2004 +0000
@@ -785,16 +785,6 @@
 
 void NetworkInitGameInfo(void)
 {
-#ifdef WITH_REV_HACK
-	#define WITH_REV
-	const char _openttd_revision[] = WITH_REV_HACK;
-#else
-	#if defined(WITH_REV)
-		extern char _openttd_revision[];
-	#else
-		const char _openttd_revision[] = "norev000";
-	#endif
-#endif
 	NetworkClientInfo *ci;
 
 	ttd_strlcpy(_network_game_info.server_name, _network_server_name, sizeof(_network_game_info.server_name));
--- a/network_client.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/network_client.c	Tue Dec 14 20:27:00 2004 +0000
@@ -56,16 +56,6 @@
 	//    String: Unique id to find the player back in server-listing
 	//
 
-#ifdef WITH_REV_HACK
-	#define WITH_REV
-	const char _openttd_revision[] = WITH_REV_HACK;
-#else
-	#if defined(WITH_REV)
-		extern char _openttd_revision[];
-	#else
-		const char _openttd_revision[] = "norev000";
-	#endif
-#endif
 	Packet *p;
 	_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
 	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
--- a/network_gui.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/network_gui.c	Tue Dec 14 20:27:00 2004 +0000
@@ -47,15 +47,6 @@
 static NetworkGameList *_selected_item = NULL;
 static int8 _selected_company_item = -1;
 
-#ifdef WITH_REV_HACK
-	#define WITH_REV
-	const char _openttd_revision[] = WITH_REV_HACK;
-#else
-	#ifdef WITH_REV
-		extern char _openttd_revision[];
-	#endif
-#endif
-
 // Truncates a string to max_width (via GetStringWidth) and adds 3 dots
 //  at the end of the name.
 static void NetworkTruncateString(char *name, const int max_width)
--- a/network_server.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/network_server.c	Tue Dec 14 20:27:00 2004 +0000
@@ -577,7 +577,7 @@
 	NetworkRecv_string(p, client_revision, sizeof(client_revision));
 
 	//  Too bad, when WITH_REV is disabled, we can not compare the version.
-#if defined(WITH_REV) || defined (WITH_REV_HACK)
+#if defined(WITH_REV)
 	// Check if the client has WITH_REV enabled
 	if (strncmp("norev000", client_revision, sizeof(client_revision)) != 0) {
 		if (strncmp(_network_game_info.server_revision, client_revision, sizeof(_network_game_info.server_revision) - 1) != 0) {
@@ -1215,6 +1215,9 @@
 
 	ci = NetworkFindClientInfoFromIndex(client_index);
 
+	if (ci == NULL)
+		return;
+
 	FOR_ALL_CLIENTS(cs) {
 		SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
 	}
--- a/strings.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/strings.c	Tue Dec 14 20:27:00 2004 +0000
@@ -20,15 +20,6 @@
 static uint _langtab_num[32]; // Offset into langpack offs
 static uint _langtab_start[32]; // Offset into langpack offs
 
-#ifdef WITH_REV_HACK
-	#define WITH_REV
-	const char _openttd_revision[] = WITH_REV_HACK;
-#else
-	#ifdef WITH_REV
-	extern const char _openttd_revision[];
-	#endif
-#endif
-
 typedef byte *PlayerNameGeneratorProc(byte *buffr);
 
 typedef struct {
--- a/ttd.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/ttd.c	Tue Dec 14 20:27:00 2004 +0000
@@ -28,6 +28,11 @@
 
 #include <stdarg.h>
 
+/* Define the _openttd_revision tag if it is not defined */
+#ifndef WITH_REV
+	const char _openttd_revision[] = "norev000";
+#endif
+
 void GameLoop();
 
 void IncreaseSpriteLRU();
@@ -645,7 +650,7 @@
 	// initialize the ingame console
 	IConsoleInit();
 	IConsoleCmdExec("exec scripts/autoexec.scr 0");
-	
+
 	InitPlayerRandoms();
 
 #ifdef ENABLE_NETWORK
--- a/variables.h	Tue Dec 14 20:21:52 2004 +0000
+++ b/variables.h	Tue Dec 14 20:27:00 2004 +0000
@@ -426,6 +426,13 @@
 VARDEF int _debug_ai_level;
 VARDEF int _debug_net_level;
 
+/* Make the revision tag global */
+extern const char _openttd_revision[];
+#ifdef WITH_REV_HACK
+	/* Special rules for Windows */
+	#define WITH_REV
+#endif
+
 void CDECL debug(const char *s, ...);
 #ifdef NO_DEBUG_MESSAGES
 	#define DEBUG(name, level)
--- a/win32.c	Tue Dec 14 20:21:52 2004 +0000
+++ b/win32.c	Tue Dec 14 20:27:00 2004 +0000
@@ -15,6 +15,11 @@
 
 #define SMART_PALETTE_ANIM
 
+/* Declare the revision tag for Windows */
+#ifdef WITH_REV_HACK
+	const char _openttd_revision[] = WITH_REV_HACK;
+#endif
+
 static struct {
 	HWND main_wnd;
 	HBITMAP dib_sect;
@@ -499,9 +504,8 @@
 			SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
 		} else {
 			char Windowtitle[50] = "OpenTTD ";
-			#ifdef WITH_REV_HACK
+			#ifdef WITH_REV
 				// also show revision number/release in window title
-				extern const char _openttd_revision[];
 				strncat(Windowtitle, _openttd_revision, sizeof(Windowtitle)-(strlen(Windowtitle) + 1));
 			#endif
 			_wnd.main_wnd = CreateWindow("TTD", Windowtitle, style, x, y, w, h, 0, 0, _inst, 0);