summaryrefslogtreecommitdiff
path: root/network_gui.c
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-10-03 02:08:15 +0000
committerbelugas <belugas@openttd.org>2006-10-03 02:08:15 +0000
commit753b5724001079c3352d23a911488044884dcf5b (patch)
treedc2a5593c6d3da96528beb914da8807aea2325e7 /network_gui.c
parente383584988a99dbdfbcd4a63b1f11213a4274355 (diff)
downloadopenttd-753b5724001079c3352d23a911488044884dcf5b.tar.xz
(svn r6619) -Codechange: Use accessors for disabled_state.
Another step toward merging XTDwidget. The only two files not converted (window.h and widget.c) will be done at the very last commit)
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/network_gui.c b/network_gui.c
index 5f843c05a..c3b36693c 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -238,18 +238,12 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
}
if (ld->flags & VL_RESORT) SortNetworkGameList(&WP(w, network_ql_d));
- w->disabled_state = 0;
-
- if (sel == NULL) {
- SETBIT(w->disabled_state, 16); SETBIT(w->disabled_state, 17);
- } else if (!sel->online) {
- SETBIT(w->disabled_state, 16); // Server offline, join button disabled
- } else if (sel->info.clients_on >= sel->info.clients_max) {
- SETBIT(w->disabled_state, 16); // Server full, join button disabled
- } 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
- }
+ SetWindowWidgetDisabledState(w, 17, sel == NULL);
+ /* Join Button disabling conditions */
+ SetWindowWidgetDisabledState(w, 16, sel == NULL || // no Selected Server
+ !sel->online || // Server offline
+ sel->info.clients_on >= sel->info.clients_max || // Server full
+ !sel->info.compatible); // Revision mismatch
SetDParam(0, 0x00);
SetDParam(7, _lan_internet_types_dropdown[_network_lan_internet]);
@@ -823,14 +817,12 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
const NetworkGameInfo *gi = &nd->server->info;
int y = NET_PRC__OFFSET_TOP_WIDGET_COMPANY, pos;
- w->disabled_state = 0;
-
- if (nd->company == (byte)-1) SETBIT(w->disabled_state, 7);
- if (gi->companies_on >= gi->companies_max) SETBIT(w->disabled_state, 8);
- if (gi->spectators_on >= gi->spectators_max) SETBIT(w->disabled_state, 9);
+ SetWindowWidgetDisabledState(w, 7, nd->company == (byte)-1);
+ SetWindowWidgetDisabledState(w, 8, gi->companies_on >= gi->companies_max);
/* You can not join a server as spectator when it has no companies active..
* it causes some nasty crashes */
- if (gi->companies_on == 0) SETBIT(w->disabled_state, 9);
+ SetWindowWidgetDisabledState(w, 9, gi->spectators_on >= gi->spectators_max ||
+ gi->companies_on == 0);
DrawWindowWidgets(w);