(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.

This commit is contained in:
darkvater
2004-12-15 00:31:08 +00:00
parent bc13fd26d5
commit c21659ae7e
11 changed files with 55 additions and 68 deletions

View File

@@ -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;