diff options
author | Simon Howard | 2011-09-20 19:57:39 +0000 |
---|---|---|
committer | Simon Howard | 2011-09-20 19:57:39 +0000 |
commit | e5336a1bdc44021605c20f9c50876b6cb5c90f9a (patch) | |
tree | 06eaf7884d51e0318f2a2c32c404f31a0dff74ee | |
parent | 7b1aff6c464f28e7d5f8b10fd33b15f5d15122a6 (diff) | |
download | chocolate-doom-e5336a1bdc44021605c20f9c50876b6cb5c90f9a.tar.gz chocolate-doom-e5336a1bdc44021605c20f9c50876b6cb5c90f9a.tar.bz2 chocolate-doom-e5336a1bdc44021605c20f9c50876b6cb5c90f9a.zip |
Auto-select IWAD based on query response from server.
Subversion-branch: /branches/v2-branch
Subversion-revision: 2387
-rw-r--r-- | src/setup/multiplayer.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index d3a77639..91335c6c 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -769,12 +769,36 @@ static txt_window_action_t *JoinGameAction(void) return action; } -static void SelectQueryAddress(TXT_UNCAST_ARG(button), TXT_UNCAST_ARG(addr)) +static void SelectQueryAddress(TXT_UNCAST_ARG(button), + TXT_UNCAST_ARG(querydata)) { TXT_CAST_ARG(txt_button_t, button); + TXT_CAST_ARG(net_querydata_t, querydata); + int i; + + // Set address to connect to: free(connect_address); connect_address = strdup(button->label); + + // Auto-choose IWAD if there is already a player connected. + + if (querydata->num_players > 0 + && !(querydata->gamemission == doom && querydata->gamemode == shareware)) + { + for (i = 0; found_iwads[i] != NULL; ++i) + { + if (found_iwads[i]->mode == querydata->gamemode + && found_iwads[i]->mission == querydata->gamemission) + { + found_iwad_selected = i; + break; + } + } + } + + // Finished with search. + TXT_CloseWindow(query_window); } @@ -794,7 +818,7 @@ static void QueryResponseCallback(net_addr_t *addr, TXT_AddWidgets(results_table, TXT_NewLabel(ping_time_str), TXT_NewButton2(NET_AddrToString(addr), - SelectQueryAddress, addr), + SelectQueryAddress, querydata), TXT_NewLabel(description), NULL); |