diff options
author | truelight <truelight@openttd.org> | 2004-12-20 16:02:01 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2004-12-20 16:02:01 +0000 |
commit | 5f25a0788a319c16d331ce4dcbdbc874ab8e0536 (patch) | |
tree | 0af8a168a8079b09ae4398464cf72f5fa503a523 /network_gui.c | |
parent | 7460764d91f842789a643e82360d4a4b09bc22b3 (diff) | |
download | openttd-5f25a0788a319c16d331ce4dcbdbc874ab8e0536.tar.xz |
(svn r1186) -Fix: [Network] You can now join a company on a server where a company
went bankrupt, without joining the wrong company (or even failing to do so)
Diffstat (limited to 'network_gui.c')
-rw-r--r-- | network_gui.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/network_gui.c b/network_gui.c index 2e92f5db1..8bb3f01f6 100644 --- a/network_gui.c +++ b/network_gui.c @@ -614,6 +614,21 @@ static void ShowNetworkStartServerWindow(void) WP(w,querystr_d).buf = _edit_str_buf; } +static byte NetworkLobbyFindCompanyIndex(byte pos) +{ + byte i; + /* Scroll through all _network_player_info and get the 'pos' item + that is not empty */ + for (i = 0; i < MAX_PLAYERS; i++) { + if (_network_player_info[i].company_name[0] != '\0') { + if (pos-- == 0) + return i; + } + } + + return 0; +} + static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) { switch(e->event) { @@ -638,10 +653,11 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) GfxFillRect(11, 41, 139, 165, 0xD7); pos = w->vscroll.pos; while (pos < _network_lobby_company_count) { - if (_selected_company_item == pos) + byte index = NetworkLobbyFindCompanyIndex(pos); + if (_selected_company_item == index) GfxFillRect(11, y - 1, 139, y + 10, 155); // show highlighted item with a different colour - DoDrawString(_network_player_info[pos].company_name, 13, y, 2); + DoDrawString(_network_player_info[index].company_name, 13, y, 2); pos++; y += NET_PRC__SIZE_OF_ROW_COMPANY; @@ -728,6 +744,8 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) return; } + _selected_company_item = NetworkLobbyFindCompanyIndex(_selected_company_item); + SetWindowDirty(w); break; case 7: /* Join company */ |