summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-19 19:17:15 +0000
committertruelight <truelight@openttd.org>2004-12-19 19:17:15 +0000
commit5e25f6b2363d4749ba1459780b0845622675c3d2 (patch)
tree7244f7d8365796d85de171906a009b7922ee7340
parent44c299ae5d7dd9d21846a622c25aa985127d8d34 (diff)
downloadopenttd-5e25f6b2363d4749ba1459780b0845622675c3d2.tar.xz
(svn r1176) -Fix: [Network] PlayerBasedMenu's caused crashes when a company went bankrupt
-rw-r--r--main_gui.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/main_gui.c b/main_gui.c
index 6994767ed..c8fec2574 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -667,9 +667,11 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
// We have a new entry at the top of the list of menu 9 when networking
// so keep that in count
- if (!_networking || (WP(w,menu_d).main_button == 9 && index > 0)) {
- index = GetPlayerIndexFromMenu(index-1)+1;
- }
+ if (_networking && WP(w,menu_d).main_button == 9) {
+ if (index > 0)
+ index = GetPlayerIndexFromMenu(index - 1) + 1;
+ } else
+ index = GetPlayerIndexFromMenu(index);
if (index < 0) {
Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
@@ -692,11 +694,11 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e)
// We have a new entry at the top of the list of menu 9 when networking
// so keep that in count
- if (index != -1) {
- if (!_networking || (WP(w,menu_d).main_button == 9 && index != 0)) {
- index = GetPlayerIndexFromMenu(index-1)+1;
- }
- }
+ if (_networking && WP(w,menu_d).main_button == 9) {
+ if (index > 0)
+ index = GetPlayerIndexFromMenu(index - 1) + 1;
+ } else
+ index = GetPlayerIndexFromMenu(index);
if (index == -1 || index == WP(w,menu_d).sel_index)
return;
@@ -748,9 +750,13 @@ static Window *PopupMainPlayerToolbMenu(Window *w, int x, int main_button, int g
w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
w->flags4 &= ~WF_WHITE_BORDER_MASK;
WP(w,menu_d).item_count = 0;
- WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : 0;
- if (_networking && main_button == 9 && _local_player != OWNER_SPECTATOR) {
- WP(w,menu_d).sel_index++;
+ WP(w,menu_d).sel_index = (_local_player != OWNER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
+ if (_networking && main_button == 9) {
+ if (_local_player != OWNER_SPECTATOR)
+ WP(w,menu_d).sel_index++;
+ else
+ /* Select client list by default for spectators */
+ WP(w,menu_d).sel_index = 0;
}
WP(w,menu_d).action_id = main_button;
WP(w,menu_d).main_button = main_button;