Skip to content

Commit

Permalink
guard against invalid [scenario]playing_team
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed Mar 16, 2020
1 parent a3859e4 commit 0cdb3e5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/game_state.cpp
Expand Up @@ -191,6 +191,11 @@ void game_state::init(const config& level, play_controller & pc)
LOG_NG << "initialized teams... " << (SDL_GetTicks() - pc.ticks()) << std::endl;

board_.teams_.resize(level.child_count("side"));
if (player_number_ > static_cast<int>(board_.teams_.size())) {
ERR_NG << "invalid player number " << player_number_ << " #sides=" << board_.teams_.size() << "\n";
player_number_ = 1;
// in case there are no teams, using player_number_ migh still cause problems later.
}

std::vector<team_builder_ptr> team_builders;

Expand Down

0 comments on commit 0cdb3e5

Please sign in to comment.