fixed some bugs with loading replays

This commit is contained in:
uid68803 2004-01-02 20:20:48 +00:00
parent d937865d0c
commit 9c92bed05e
3 changed files with 18 additions and 9 deletions

View file

@ -87,9 +87,6 @@ LEVEL_RESULT play_game(display& disp, game_state& state, config& game_config,
while(res == REPLAY) {
state = recorder.get_save_info();
if(!recorder.empty()) {
recorder.start_replay();
}
res = play_level(units_data,game_config,scenario,
video,state,story);
@ -383,13 +380,19 @@ int play_game(int argc, char** argv)
recorder = replay(state.replay_data);
std::cerr << "has starting position: " << (state.starting_pos.child("side") ? "yes" : "no") << "\n";
//only play replay data if the user has selected to view the replay,
//or if there is no starting position data to use.
if(!show_replay && state.starting_pos.child("side") != NULL) {
std::cerr << "setting replay to end...\n";
recorder.set_to_end();
}
if(!recorder.at_end())
std::cerr << "recorder is not at the end!!!\n";
} else {
recorder.start_replay();
if(!recorder.at_end()) {
//set whether the replay is to be skipped or not
if(show_replay) {
recorder.set_skip(0);

View file

@ -170,7 +170,8 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& game_config,
gui.scroll_to_tile(map.starting_position(1).x,map.starting_position(1).y,
display::WARP);
bool replaying = (recorder.empty() == false);
bool replaying = (recorder.at_end() == false);
std::cerr << "replaying: ???" << (replaying ? "yes" : "no") << "\n";
//if a team is specified whose turn it is, it means we're loading a game
//instead of starting a fresh one

View file

@ -460,9 +460,14 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
const gamemap::location loc(*child);
recruit_unit(map,team_num,units,state_of_game.available_units[val],loc);
state_of_game.available_units.erase(state_of_game.available_units.begin()+val);
current_team.spend_gold(game_config::recall_cost);
if(val >= 0 && val < int(state_of_game.available_units.size())) {
recruit_unit(map,team_num,units,state_of_game.available_units[val],loc);
state_of_game.available_units.erase(state_of_game.available_units.begin()+val);
current_team.spend_gold(game_config::recall_cost);
} else {
std::cerr << "illegal recall\n";
throw replay::error();
}
}
else if((child = cfg->child("move")) != NULL) {