Add wesnoth.log_replay which adds stuff to the saved game in [upload_log]
This commit is contained in:
parent
abb47d13ab
commit
ac6a62046e
4 changed files with 28 additions and 0 deletions
|
@ -799,6 +799,11 @@ void play_controller::process_keyup_event(const SDL_Event& event)
|
|||
}
|
||||
}
|
||||
|
||||
replay& play_controller::get_replay() {
|
||||
assert(replay_);
|
||||
return *replay_.get();
|
||||
}
|
||||
|
||||
void play_controller::save_game()
|
||||
{
|
||||
if(save_blocker::try_block()) {
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
void save_replay();
|
||||
void save_replay_auto(const std::string& filename);
|
||||
void save_map();
|
||||
replay& get_replay();
|
||||
|
||||
void init_side_begin();
|
||||
|
||||
|
|
|
@ -3120,6 +3120,26 @@ int game_lua_kernel::intf_remove_tile_overlay(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int game_lua_kernel::intf_log_replay(lua_State* L) {
|
||||
replay& recorder = play_controller_.get_replay();
|
||||
const int nargs = lua_gettop(L);
|
||||
if(nargs < 2 || nargs > 3) {
|
||||
return luaL_error(L, "Wrong number of arguments to ai.log_replay() - should be 2 or 3 arguments.");
|
||||
}
|
||||
const std::string key = nargs == 2 ? luaL_checkstring(L, 1) : luaL_checkstring(L, 2);
|
||||
config cfg;
|
||||
if(nargs == 2) {
|
||||
recorder.add_log_data(key, luaL_checkstring(L, 2));
|
||||
} else if(luaW_toconfig(L, 3, cfg)) {
|
||||
recorder.add_log_data(luaL_checkstring(L, 1), key, cfg);
|
||||
} else if(!lua_isstring(L, 3)) {
|
||||
return luaL_argerror(L, 3, "accepts only string or config");
|
||||
} else {
|
||||
recorder.add_log_data(luaL_checkstring(L, 1), key, luaL_checkstring(L, 3));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Adding new events
|
||||
int game_lua_kernel::intf_add_event(lua_State *L)
|
||||
{
|
||||
|
@ -4110,6 +4130,7 @@ game_lua_kernel::game_lua_kernel(game_state & gs, play_controller & pc, reports
|
|||
{ "kill", &dispatch<&game_lua_kernel::intf_kill > },
|
||||
{ "label", &dispatch<&game_lua_kernel::intf_label > },
|
||||
{ "lock_view", &dispatch<&game_lua_kernel::intf_lock_view > },
|
||||
{ "log_replay", &dispatch<&game_lua_kernel::intf_log_replay > },
|
||||
{ "log", &dispatch<&game_lua_kernel::intf_log > },
|
||||
{ "match_location", &dispatch<&game_lua_kernel::intf_match_location > },
|
||||
{ "match_side", &dispatch<&game_lua_kernel::intf_match_side > },
|
||||
|
|
|
@ -171,6 +171,7 @@ class game_lua_kernel : public lua_kernel_base
|
|||
int intf_log(lua_State *L);
|
||||
int intf_toggle_fog(lua_State *L, const bool clear);
|
||||
int intf_get_fog_or_shroud(lua_State *L, bool fog);
|
||||
int intf_log_replay(lua_State* L);
|
||||
|
||||
//private helpers
|
||||
std::string synced_state();
|
||||
|
|
Loading…
Add table
Reference in a new issue