add functions in replay
these will be used in synced_context.cpp. this commit is part of pr 121.
This commit is contained in:
parent
fef7c49e83
commit
8f00786fb6
2 changed files with 31 additions and 0 deletions
|
@ -285,6 +285,12 @@ void replay::add_countdown_update(int value, int team)
|
|||
val["team"] = team;
|
||||
cmd->add_child("countdown_update",val);
|
||||
}
|
||||
void replay::add_synced_command(const std::string& name, const config& command)
|
||||
{
|
||||
config* const cmd = add_command();
|
||||
cmd->add_child(name,command);
|
||||
LOG_REPLAY << "add_synced_command: \n" << cmd->debug() << "\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -605,6 +611,23 @@ struct async_cmd
|
|||
int num;
|
||||
};
|
||||
|
||||
config& replay::get_last_real_command()
|
||||
{
|
||||
for (int cmd_num = pos_ - 1; cmd_num >= 0; --cmd_num)
|
||||
{
|
||||
config &c = command(cmd_num);
|
||||
if (c["dependent"].to_bool(false) || !c["undo"].to_bool(true) || c["async"].to_bool(false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
ERR_REPLAY << "replay::get_last_real_command called with not existant command.\n";
|
||||
assert(false && "replay::get_last_real_command called with not existant command.");
|
||||
//this code can never be reached because of the assert above so no need to return something.
|
||||
throw "assert didnt work :o";
|
||||
}
|
||||
|
||||
void replay::undo()
|
||||
{
|
||||
std::vector<async_cmd> async_cmds;
|
||||
|
|
|
@ -74,6 +74,14 @@ public:
|
|||
int defender_lvl, const size_t turn, const time_of_day &t);
|
||||
void add_auto_shroud(bool turned_on);
|
||||
void update_shroud();
|
||||
|
||||
void add_synced_command(const std::string& name, const config& command);
|
||||
/*
|
||||
returns a reference to the newest config that us not dependent or has undo =no
|
||||
|
||||
*/
|
||||
config& get_last_real_command();
|
||||
|
||||
void add_seed(const char* child_name, int seed);
|
||||
void user_input(const std::string &, const config &);
|
||||
void add_label(const terrain_label*);
|
||||
|
|
Loading…
Add table
Reference in a new issue