Refactoring step:
Move where game completion is set so we can get rid of a bunch of passed-in object references,
This commit is contained in:
parent
9da345a882
commit
417a01a805
6 changed files with 10 additions and 12 deletions
|
@ -1591,9 +1591,7 @@ void advance_unit(const game_data& info,
|
|||
game_events::fire("post_advance",loc);
|
||||
}
|
||||
|
||||
void check_victory(unit_map& units,
|
||||
std::vector<team>& teams,
|
||||
game_state& gamestate)
|
||||
void check_victory(unit_map& units, std::vector<team>& teams)
|
||||
{
|
||||
std::vector<int> seen_leaders;
|
||||
for(unit_map::const_iterator i = units.begin();
|
||||
|
@ -1651,7 +1649,6 @@ void check_victory(unit_map& units,
|
|||
std::cout << "\n";
|
||||
}
|
||||
|
||||
gamestate.completion = found_player ? "victory" : "defeat";
|
||||
LOG_NG << "throwing end level exception...\n";
|
||||
throw end_level_exception(found_player ? VICTORY : DEFEAT);
|
||||
}
|
||||
|
|
|
@ -252,9 +252,7 @@ gamemap::location under_leadership(const unit_map& units,
|
|||
//! Checks to see if a side has won, and will throw
|
||||
//! an end_level_exception if one has.
|
||||
//! Will also remove control of villages from sides with dead leaders.
|
||||
void check_victory(unit_map& units,
|
||||
std::vector<team>& teams,
|
||||
game_state &gamestate);
|
||||
void check_victory(unit_map& units, std::vector<team>& teams);
|
||||
|
||||
//! Gets the time of day at a certain tile.
|
||||
//! Certain tiles may have a time of day that differs
|
||||
|
|
|
@ -1091,7 +1091,7 @@ void ai_interface::attack_enemy(const location& u, const location& target, int w
|
|||
}
|
||||
}
|
||||
|
||||
check_victory(info_.units,info_.teams,info_.game_state_);
|
||||
check_victory(info_.units,info_.teams);
|
||||
raise_enemy_attacked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1416,7 +1416,7 @@ bool mouse_handler::attack_enemy_(unit_map::iterator attacker, unit_map::iterato
|
|||
current_route_.steps.clear();
|
||||
gui_->set_route(NULL);
|
||||
|
||||
check_victory(units_,teams_,game_state_);
|
||||
check_victory(units_,teams_);
|
||||
|
||||
gui_->draw();
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector<config*>& st
|
|||
exit(0);
|
||||
}
|
||||
if (end_level.result == DEFEAT || end_level.result == VICTORY) {
|
||||
gamestate_.completion = (end_level.result == VICTORY) ? "victory" : "defeat";
|
||||
// If we're a player, and the result is victory/defeat, then send
|
||||
// a message to notify the server of the reason for the game ending.
|
||||
if (!obs) {
|
||||
|
@ -234,6 +235,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector<config*>& st
|
|||
log.quit(status_.turn());
|
||||
return end_level.result;
|
||||
} else if(end_level.result == DEFEAT) {
|
||||
gamestate_.completion = "defeat";
|
||||
log.defeat(status_.turn());
|
||||
try {
|
||||
game_events::fire("defeat");
|
||||
|
@ -247,6 +249,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector<config*>& st
|
|||
} else if (end_level.result == VICTORY ||
|
||||
end_level.result == LEVEL_CONTINUE ||
|
||||
end_level.result == LEVEL_CONTINUE_NO_SAVE) {
|
||||
gamestate_.completion = "victory";
|
||||
try {
|
||||
game_events::fire("victory");
|
||||
} catch(end_level_exception&) {
|
||||
|
@ -420,7 +423,7 @@ void playsingle_controller::play_turn(bool save)
|
|||
}
|
||||
|
||||
finish_side_turn();
|
||||
check_victory(units_,teams_,gamestate_);
|
||||
check_victory(units_,teams_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -698,7 +698,7 @@ bool do_replay(game_display& disp, const gamemap& map, const game_data& gameinfo
|
|||
//if there are no more advancing units, then we check for victory,
|
||||
//in case the battle that led to advancement caused the end of scenario
|
||||
if(advancing_units.empty()) {
|
||||
check_victory(units,teams,state_of_game);
|
||||
check_victory(units,teams);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
@ -1060,7 +1060,7 @@ bool do_replay(game_display& disp, const gamemap& map, const game_data& gameinfo
|
|||
//check victory now if we don't have any advancements. If we do have advancements,
|
||||
//we don't check until the advancements are processed.
|
||||
if(advancing_units.empty()) {
|
||||
check_victory(units,teams,state_of_game);
|
||||
check_victory(units,teams);
|
||||
}
|
||||
fix_shroud = !replayer.is_skipping();
|
||||
} else if((child = cfg->child("fire_event")) != NULL) {
|
||||
|
|
Loading…
Add table
Reference in a new issue