diff --git a/console.c b/console.c index 57f7c25bc6..0fd2bc39d8 100644 --- a/console.c +++ b/console.c @@ -229,6 +229,8 @@ static void IConsoleWndProc(Window* w, WindowEvent* e) } } +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, ""); diff --git a/network.c b/network.c index c031051b6a..af4b3b8eae 100644 --- a/network.c +++ b/network.c @@ -783,6 +783,8 @@ bool NetworkClientConnectGame(const byte* host, unsigned short port) return _networking; } +extern const char _openttd_revision[]; + void NetworkInitGameInfo(void) { NetworkClientInfo *ci; diff --git a/network_client.c b/network_client.c index 747464425d..72342014b1 100644 --- a/network_client.c +++ b/network_client.c @@ -43,6 +43,8 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO) NetworkSend_Packet(p, MY_CLIENT); } +extern const char _openttd_revision[]; + DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN) { // diff --git a/network_gui.c b/network_gui.c index 2d39bcbf07..8257e8db03 100644 --- a/network_gui.c +++ b/network_gui.c @@ -68,24 +68,26 @@ static void NetworkTruncateString(char *name, const int max_width) } } +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(Window *w, WindowEvent *e) 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(Window *w, WindowEvent *e) 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; diff --git a/network_server.c b/network_server.c index cc0b6b4529..c7f1cb16a2 100644 --- a/network_server.c +++ b/network_server.c @@ -563,6 +563,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO) 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_JOIN) 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_JOIN) return; } } -#endif NetworkRecv_string(p, name, sizeof(name)); playas = NetworkRecv_uint8(p); diff --git a/strings.c b/strings.c index 14ed34ff04..24a9391a11 100644 --- a/strings.c +++ b/strings.c @@ -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, const byte *str) 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: diff --git a/ttd.c b/ttd.c index 2339337d6d..94722239d5 100644 --- a/ttd.c +++ b/ttd.c @@ -28,11 +28,6 @@ #include -/* Define the _openttd_revision tag if it is not defined */ -#ifndef WITH_REV - const char _openttd_revision[] = "norev000"; -#endif - void GameLoop(); void IncreaseSpriteLRU(); diff --git a/ttd.h b/ttd.h index 0265d21f12..478bce30ef 100644 --- a/ttd.h +++ b/ttd.h @@ -1,6 +1,7 @@ #ifndef TTD_H #define TTD_H +#define NOREV_STRING "norev000" // FIXME: Include only where really needed. // include sprites #include "table/sprites.h" diff --git a/ttd.vcproj b/ttd.vcproj index 0c93a1ffe3..3ffd06557d 100644 --- a/ttd.vcproj +++ b/ttd.vcproj @@ -453,10 +453,9 @@ BasicRuntimeChecks="3"/> - - - + + - - @@ -588,11 +584,14 @@ + + + RelativePath=".\newgrf.c"> @@ -1172,9 +1171,6 @@ - - @@ -1187,11 +1183,14 @@ + + + RelativePath=".\newgrf.h"> diff --git a/variables.h b/variables.h index ad69bc3752..667bd4a834 100644 --- a/variables.h +++ b/variables.h @@ -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) diff --git a/win32.c b/win32.c index 7177d72a8a..dd6e76e6b3 100644 --- a/win32.c +++ b/win32.c @@ -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");