Fix crash in GUI2 multiplayer test
Because the join script attempts to join the game immediately after it has been found, it tried to join the game before it had been added to the games_ vector (from games_by_id_). In addition to that, the check for if there is such a game had an off-by-one error. The two bugs, in combination, caused the game to index an empty vector. Even if the STL implementation doesn't immediately crash the game, it's going to crash later when it tries to interpret garbage data as the game information. Fixed by making the game update the games_ vector immediately after fetching games from the server, and also fixing the off-by-one error.
This commit is contained in:
parent
3366e9c683
commit
cd779200a1
1 changed files with 13 additions and 12 deletions
|
@ -856,6 +856,18 @@ void tlobby_main::post_show(twindow& /*window*/)
|
|||
|
||||
void tlobby_main::network_handler()
|
||||
{
|
||||
try {
|
||||
config data;
|
||||
if (wesnothd_connection_.receive_data(data)) {
|
||||
process_network_data(data);
|
||||
}
|
||||
}
|
||||
catch (wesnothd_error& e) {
|
||||
LOG_LB << "caught wesnothd_error in network_handler: " << e.message
|
||||
<< "\n";
|
||||
throw;
|
||||
}
|
||||
|
||||
if(gamelist_dirty_ && !delay_gamelist_update_
|
||||
&& (SDL_GetTicks() - last_gamelist_update_
|
||||
> game_config::lobby_refresh)) {
|
||||
|
@ -871,17 +883,6 @@ void tlobby_main::network_handler()
|
|||
update_gamelist_filter();
|
||||
update_playerlist();
|
||||
}
|
||||
|
||||
try {
|
||||
config data;
|
||||
if(wesnothd_connection_.receive_data(data)) {
|
||||
process_network_data(data);
|
||||
}
|
||||
} catch(wesnothd_error& e) {
|
||||
LOG_LB << "caught wesnothd_error in network_handler: " << e.message
|
||||
<< "\n";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void tlobby_main::process_network_data(const config& data)
|
||||
|
@ -1003,7 +1004,7 @@ static bool handle_addon_requirements_gui(CVideo& v, const std::vector<game_info
|
|||
|
||||
bool tlobby_main::do_game_join(int idx, bool observe)
|
||||
{
|
||||
if(idx < 0 || idx > static_cast<int>(lobby_info_.games().size())) {
|
||||
if(idx < 0 || idx >= static_cast<int>(lobby_info_.games().size())) {
|
||||
ERR_LB << "Requested join/observe of a game with index out of range: "
|
||||
<< idx << ", games size is " << lobby_info_.games().size()
|
||||
<< "\n";
|
||||
|
|
Loading…
Add table
Reference in a new issue