summaryrefslogtreecommitdiff
path: root/network_gui.c
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 /network_gui.c
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.
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c44
1 files changed, 20 insertions, 24 deletions
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;