Changeset - r659:c4726c05e825
[Not reviewed]
master
0 11 0
darkvater - 19 years ago 2004-12-15 00:31:08
darkvater@openttd.org
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
11 files changed with 55 insertions and 68 deletions:
0 comments (0 inline, 0 general)
console.c
Show inline comments
 
@@ -229,6 +229,8 @@ static void IConsoleWndProc(Window* w, W
 
	}
 
}
 

	
 
extern const char _openttd_revision[];
 

	
 
void IConsoleInit(void)
 
{
 
	uint i;
 
@@ -253,11 +255,7 @@ void IConsoleInit(void)
 
		_iconsole_cbuffer[i] = 0;
 
	}
 
	IConsoleStdLibRegister();
 
	#if defined(WITH_REV)
 
	IConsolePrintF(13, "OpenTTD Game Console Revision 6 - %s", _openttd_revision);
 
	#else
 
	IConsolePrint(13, "OpenTTD Game Console Revision 6");
 
	#endif
 
	IConsolePrint(12, "---------------------------------");
 
	IConsolePrint(12, "use \"help\" for more info");
 
	IConsolePrint(12, "");
network.c
Show inline comments
 
@@ -783,6 +783,8 @@ bool NetworkClientConnectGame(const byte
 
	return _networking;
 
}
 

	
 
extern const char _openttd_revision[];
 

	
 
void NetworkInitGameInfo(void)
 
{
 
	NetworkClientInfo *ci;
network_client.c
Show inline comments
 
@@ -43,6 +43,8 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_CO
 
	NetworkSend_Packet(p, MY_CLIENT);
 
}
 

	
 
extern const char _openttd_revision[];
 

	
 
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
 
{
 
	//
network_gui.c
Show inline comments
 
@@ -68,24 +68,26 @@ static void NetworkTruncateString(char *
 
	}
 
}
 

	
 
extern const char _openttd_revision[];
 

	
 
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
 
{
 
	switch(e->event) {
 
	case WE_PAINT: {
 
		if (_selected_item == NULL)
 
			w->disabled_state = (1<<17) | (1<<18);
 
		else if (!_selected_item->online)
 
			w->disabled_state = (1<<17); // Server offline, join button disabled
 
		else if (_selected_item->info.clients_on == _selected_item->info.clients_max)
 
			w->disabled_state = (1<<17); // Server full, join button disabled
 
#ifdef WITH_REV
 
		else if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
 
			if (strncmp(_selected_item->info.server_revision, "norev000", sizeof(_selected_item->info.server_revision)) != 0)
 
				w->disabled_state = (1<<17); // Revision mismatch, join button disabled
 
		w->disabled_state = 0;
 

	
 
		if (_selected_item == NULL) {
 
			SETBIT(w->disabled_state, 17); SETBIT(w->disabled_state, 18);
 
		} else if (!_selected_item->online) {
 
			SETBIT(w->disabled_state, 17); // Server offline, join button disabled
 
		} else if (_selected_item->info.clients_on == _selected_item->info.clients_max) {
 
			SETBIT(w->disabled_state, 17); // Server full, join button disabled
 

	
 
			// revisions don't match, check if server has no revision; then allow connection
 
		} else if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
 
			if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0)
 
				SETBIT(w->disabled_state, 17); // Revision mismatch, join button disabled
 
		}
 
#endif
 
		else
 
			w->disabled_state = 0;
 

	
 
		SetDParam(0, 0x00);
 
		SetDParam(2, STR_NETWORK_LAN + _network_connection);
 
@@ -105,12 +107,8 @@ static void NetworkGameWindowWndProc(Win
 
			char servername[NETWORK_NAME_LENGTH];
 
			const NetworkGameList *cur_item = _network_game_list;
 
			while (cur_item != NULL) {
 
#ifdef WITH_REV
 
				bool compatible = (strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) == 0);
 
#else
 
				bool compatible = true; // We have no idea if we are compatible...
 
#endif
 
				if (strncmp(cur_item->info.server_revision, "norev000", sizeof(cur_item->info.server_revision)) == 0)
 
				if (strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision)) == 0)
 
					compatible = true;
 

	
 
				if (cur_item == _selected_item)
 
@@ -200,17 +198,15 @@ static void NetworkGameWindowWndProc(Win
 

	
 
			y+=2;
 

	
 
#ifdef WITH_REV
 
			if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
 
				if (strncmp(_selected_item->info.server_revision, "norev000", sizeof(_selected_item->info.server_revision)) != 0)
 
				if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0)
 
					DrawStringMultiCenter(360, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch
 
			} else
 
#endif
 
			if (_selected_item->info.clients_on == _selected_item->info.clients_max)
 
			} else if (_selected_item->info.clients_on == _selected_item->info.clients_max) {
 
				// Show: server full, when clients_on == clients_max
 
				DrawStringMultiCenter(360, y, STR_NETWORK_SERVER_FULL, 2); // server full
 
			else if (_selected_item->info.use_password)
 
			} else if (_selected_item->info.use_password)
 
				DrawStringMultiCenter(360, y, STR_NETWORK_PASSWORD, 2); // password warning
 

	
 
			y+=10;
 
		}
 
	}	break;
network_server.c
Show inline comments
 
@@ -563,6 +563,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)(cs);
 
}
 

	
 
extern const char _openttd_revision[];
 

	
 
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
 
{
 
	char name[NETWORK_NAME_LENGTH];
 
@@ -576,10 +578,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 

	
 
	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)
 
	// Check if the client has WITH_REV enabled
 
	if (strncmp("norev000", client_revision, sizeof(client_revision)) != 0) {
 
	// Check if the client has revision control enabled
 
	if (strncmp(NOREV_STRING, client_revision, sizeof(client_revision)) != 0) {
 
		if (strncmp(_network_game_info.server_revision, client_revision, sizeof(_network_game_info.server_revision) - 1) != 0) {
 
			// Different revisions!!
 
			SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
 
@@ -587,7 +587,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
			return;
 
		}
 
	}
 
#endif
 

	
 
	NetworkRecv_string(p, name, sizeof(name));
 
	playas = NetworkRecv_uint8(p);
strings.c
Show inline comments
 
@@ -20,6 +20,14 @@ static byte *_langpack;
 
static uint _langtab_num[32]; // Offset into langpack offs
 
static uint _langtab_start[32]; // Offset into langpack offs
 

	
 
#if defined(WITH_REV)
 
	extern const char _openttd_revision[];
 
#elif defined(WITH_REV_HACK)
 
	const char _openttd_revision[] = WITH_REV_HACK;
 
#else
 
	const char _openttd_revision[] = NOREV_STRING;
 
#endif
 

	
 
typedef byte *PlayerNameGeneratorProc(byte *buffr);
 

	
 
typedef struct {
 
@@ -433,9 +441,7 @@ static byte *DecodeString(byte *buff, co
 
				buff = FormatNoCommaNumber(buff, GetParamInt32());
 
				break;
 
			case 2: /* {REV} */
 
#ifdef WITH_REV
 
				buff = str_cat(buff, (const byte*)_openttd_revision);
 
#endif
 
				break;
 
			case 3: { /* {SHORTCARGO} */
 
				// Short description of cargotypes. Layout:
ttd.c
Show inline comments
 
@@ -28,11 +28,6 @@
 

	
 
#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();
ttd.h
Show inline comments
 
#ifndef TTD_H
 
#define TTD_H
 

	
 
#define NOREV_STRING "norev000"
 
// FIXME: Include only where really needed.
 
// include sprites
 
#include "table/sprites.h"
ttd.vcproj
Show inline comments
 
@@ -453,10 +453,9 @@
 
						BasicRuntimeChecks="3"/>
 
				</FileConfiguration>
 
			</File>
 
                        <File
 
                                RelativePath=".\md5.c">
 
                        </File>
 
 
			<File
 
				RelativePath=".\md5.c">
 
			</File>
 
			<File
 
				RelativePath="minilzo.c">
 
				<FileConfiguration
 
@@ -577,9 +576,6 @@
 
				</FileConfiguration>
 
			</File>
 
			<File
 
				RelativePath=".\newgrf.c">
 
			</File>
 
			<File
 
				RelativePath=".\network_client.c">
 
			</File>
 
			<File
 
@@ -589,10 +585,13 @@
 
				RelativePath=".\network_gamelist.c">
 
			</File>
 
			<File
 
				RelativePath=".\network_server.c">
 
			</File>
 
			<File
 
				RelativePath=".\network_udp.c">
 
			</File>
 
			<File
 
				RelativePath=".\network_server.c">
 
				RelativePath=".\newgrf.c">
 
			</File>
 
			<File
 
				RelativePath="oldloader.c">
 
@@ -1173,9 +1172,6 @@
 
				RelativePath=".\network.h">
 
			</File>
 
			<File
 
				RelativePath=".\newgrf.h">
 
			</File>
 
			<File
 
				RelativePath=".\network_client.h">
 
			</File>
 
			<File
 
@@ -1188,10 +1184,13 @@
 
				RelativePath=".\network_gamelist.h">
 
			</File>
 
			<File
 
				RelativePath=".\network_server.h">
 
			</File>
 
			<File
 
				RelativePath=".\network_udp.h">
 
			</File>
 
			<File
 
				RelativePath=".\network_server.h">
 
				RelativePath=".\newgrf.h">
 
			</File>
 
			<File
 
				RelativePath="news.h">
variables.h
Show inline comments
 
@@ -426,13 +426,6 @@ VARDEF int _debug_grf_level;
 
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)
win32.c
Show inline comments
 
@@ -15,11 +15,6 @@
 

	
 
#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;
 
@@ -446,6 +441,8 @@ static void RegisterWndClass()
 
	}
 
}
 

	
 
extern const char _openttd_revision[];
 

	
 
static void MakeWindow(bool full_screen)
 
{
 
	_fullscreen = full_screen;
 
@@ -504,10 +501,9 @@ static void MakeWindow(bool full_screen)
 
			SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
 
		} else {
 
			char Windowtitle[50] = "OpenTTD ";
 
			#ifdef WITH_REV
 
				// also show revision number/release in window title
 
				strncat(Windowtitle, _openttd_revision, sizeof(Windowtitle)-(strlen(Windowtitle) + 1));
 
			#endif
 
			// also show revision number/release in window title
 
			strncat(Windowtitle, _openttd_revision, sizeof(Windowtitle)-(strlen(Windowtitle) + 1));
 

	
 
			_wnd.main_wnd = CreateWindow("TTD", Windowtitle, style, x, y, w, h, 0, 0, _inst, 0);
 
			if (_wnd.main_wnd == NULL)
 
				error("CreateWindow failed");
0 comments (0 inline, 0 general)