(svn r3434) - Correctly update all network information when pressing refresh in the lobby. Also always allow the join button to a server unless all clients are used up (otherwise you can always join an existing company

This commit is contained in:
Darkvater 2006-01-26 12:56:05 +00:00
parent 952f246433
commit 8721b05453

View File

@ -112,15 +112,8 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
SETBIT(w->disabled_state, 16); // Server offline, join button disabled SETBIT(w->disabled_state, 16); // Server offline, join button disabled
} else if (sel->info.clients_on >= sel->info.clients_max) { } else if (sel->info.clients_on >= sel->info.clients_max) {
SETBIT(w->disabled_state, 16); // Server full, join button disabled SETBIT(w->disabled_state, 16); // Server full, join button disabled
} else if (sel->info.companies_on >= sel->info.companies_max &&
sel->info.spectators_on >= sel->info.spectators_max) {
SETBIT(w->disabled_state, 16);
} else if (sel->info.companies_on >= sel->info.companies_max &&
sel->info.spectators_on >= sel->info.spectators_max) {
SETBIT(w->disabled_state, 17);
// revisions don't match, check if server has no revision; then allow connection
} else if (!sel->info.compatible) { } else if (!sel->info.compatible) {
// revisions don't match, check if server has no revision; then allow connection
SETBIT(w->disabled_state, 16); // Revision mismatch, join button disabled SETBIT(w->disabled_state, 16); // Revision mismatch, join button disabled
} }
@ -300,7 +293,6 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
break; break;
case 16: /* Join Game */ case 16: /* Join Game */
if (_selected_item != NULL) { if (_selected_item != NULL) {
memcpy(&_network_game_info, &_selected_item->info, sizeof(NetworkGameInfo));
snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&_selected_item->ip)); snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&_selected_item->ip));
_network_last_port = _selected_item->port; _network_last_port = _selected_item->port;
ShowNetworkLobbyWindow(); ShowNetworkLobbyWindow();
@ -668,7 +660,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
break; break;
case WE_PAINT: { case WE_PAINT: {
const NetworkGameInfo *gi = &_network_game_info; const NetworkGameInfo *gi = &_selected_item->info;
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos; int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos;
w->disabled_state = (_selected_company_item == -1) ? 1 << 7 : 0; w->disabled_state = (_selected_company_item == -1) ? 1 << 7 : 0;
@ -681,7 +673,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w); DrawWindowWidgets(w);
SetDParamStr(0, _selected_item->info.server_name); SetDParamStr(0, gi->server_name);
DrawString(10, 22, STR_NETWORK_PREPARE_TO_JOIN, 2); DrawString(10, 22, STR_NETWORK_PREPARE_TO_JOIN, 2);
// draw company list // draw company list
@ -776,7 +768,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
return; return;
} }
_selected_company_item += w->vscroll.pos; _selected_company_item += w->vscroll.pos;
if (_selected_company_item >= _network_game_info.companies_on) { if (_selected_company_item >= _selected_item->info.companies_on) {
_selected_company_item = -1; _selected_company_item = -1;
SetWindowDirty(w); SetWindowDirty(w);
return; return;
@ -801,9 +793,14 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
NetworkClientConnectGame(_network_last_host, _network_last_port); NetworkClientConnectGame(_network_last_host, _network_last_port);
break; break;
case 10: /* Refresh */ case 10: /* Refresh */
NetworkQueryServer(_network_last_host, _network_last_port, false); NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
NetworkQueryServer(_network_last_host, _network_last_port, false); // company info
break; break;
} break; } break;
case WE_MESSAGE:
SetWindowDirty(w);
break;
} }
} }