Fixed a problem where two [recall]s in a SP game...

...could get an out of sync recruitment. Problem spotted by Ivanovic.
This commit is contained in:
Mark de Wever 2007-12-31 13:42:29 +00:00
parent 9ff5682180
commit 1953f3f8e0
4 changed files with 16 additions and 8 deletions

View file

@ -7,6 +7,9 @@ Version 1.3.13+svn:
* fixed timer bell not always playing (bug #10559)
* user interface
* the apple key works a shortcut modifier again (bug #10586)
* WML engine:
* Fixed a problem where two [recall]s in a SP game could get an out of sync
recruitment
* miscellaneous and bug fixes:
* when loading a unit some traits didn't get applied correctly but got
fixed in a later state. This could lead to some units not leveling

View file

@ -120,9 +120,10 @@ bool can_recruit_on(const gamemap& map, const gamemap::location& leader, const g
return true;
}
std::string recruit_unit(const gamemap& map, int side,
unit_map& units, unit new_unit,
gamemap::location& recruit_location, bool show, bool need_castle, bool full_movement)
std::string recruit_unit(const gamemap& map, const int side, unit_map& units,
unit new_unit, gamemap::location& recruit_location,
const bool show, const bool need_castle, const bool full_movement,
const bool wml_recall)
{
const events::command_disabler disable_commands;
@ -189,6 +190,9 @@ std::string recruit_unit(const gamemap& map, int side,
const config* ran_results = get_random_results();
if(ran_results != NULL) {
// When recalling from WML there should be no random results, if we use
// random we might get the replay out of sync.
assert(!wml_recall);
const std::string rc = (*ran_results)["checksum"];
if(rc != checksum) {
ERR_NG << "SYNC: In recruit " << new_unit.id() <<
@ -204,7 +208,7 @@ std::string recruit_unit(const gamemap& map, int side,
}
}
} else {
} else if(wml_recall == false) {
config cfg;
cfg["checksum"] = checksum;
set_random_results(cfg);

View file

@ -53,9 +53,10 @@ bool can_recruit_on(const gamemap& map, const gamemap::location& leader, const g
// If the unit cannot be recruited, then a human-readable message
// describing the reason will be returned.
// On success, the return string is empty.
std::string recruit_unit(const gamemap& map, int team, unit_map& units,
unit u, gamemap::location& recruit_location,bool show=false,
bool need_castle=true, bool full_movement=false);
std::string recruit_unit(const gamemap& map, const int side, unit_map& units,
unit u, gamemap::location& recruit_location,const bool show=false,
const bool need_castle=true, const bool full_movement=false,
const bool wml_recall=false);
//! Computes the statistics of a battle between an attacker and a defender unit.
class battle_context

View file

@ -1569,7 +1569,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
unit to_recruit(*u);
avail.erase(u); // Erase before recruiting, since recruiting can fire more events
unit_mutations++;
recruit_unit(*game_map,index+1,*units,to_recruit,loc,utils::string_bool(cfg["show"],true),false,true);
recruit_unit(*game_map,index+1,*units,to_recruit,loc,utils::string_bool(cfg["show"],true),false,true,true);
unit_recalled = true;
break;
}