summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-12-15 00:31:08 +0000
committerdarkvater <darkvater@openttd.org>2004-12-15 00:31:08 +0000
commitc58549d512495568afcc2a6a8ecef8325c4aac33 (patch)
treeabede9dde98130661ade81d3386600bcf406e07b
parent6cb53e7d34b75ba4c2938dbb623ba100c74c0798 (diff)
downloadopenttd-c58549d512495568afcc2a6a8ecef8325c4aac33.tar.xz
(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.
-rw-r--r--console.c6
-rw-r--r--network.c2
-rw-r--r--network_client.c2
-rw-r--r--network_gui.c44
-rw-r--r--network_server.c9
-rw-r--r--strings.c10
-rw-r--r--ttd.c5
-rw-r--r--ttd.h1
-rw-r--r--ttd.vcproj23
-rw-r--r--variables.h7
-rw-r--r--win32.c14
11 files changed, 55 insertions, 68 deletions
diff --git a/console.c b/console.c
index 57f7c25bc..0fd2bc39d 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 c031051b6..af4b3b8ea 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 747464425..72342014b 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 2d39bcbf0..8257e8db0 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 cc0b6b452..c7f1cb16a 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 14ed34ff0..24a9391a1 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 2339337d6..94722239d 100644
--- a/ttd.c
+++ b/ttd.c
@@ -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();
diff --git a/ttd.h b/ttd.h
index 0265d21f1..478bce30e 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 0c93a1ffe..3ffd06557 100644
--- a/ttd.vcproj
+++ b/ttd.vcproj
@@ -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">
diff --git a/variables.h b/variables.h
index ad69bc375..667bd4a83 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 7177d72a8..dd6e76e6b 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");