Added luasnap checkpointing mechanism
This commit is contained in:
@@ -43,9 +43,8 @@ static void l_message(const char *msg)
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
||||
void TextGame::do_lua(const std::string &exp) {
|
||||
lua_State *L = viewer_.get_lua_state();
|
||||
lua_State *L = viewer_.state();
|
||||
int status = luaL_loadbuffer(L, exp.c_str(), exp.size(), "=stdin");
|
||||
assert(status == LUA_OK);
|
||||
globalL = L;
|
||||
@@ -119,6 +118,22 @@ void TextGame::do_choose_command(const StringVec &cmd) {
|
||||
std::cerr << "Choose command (index " << index << ") not implemented yet." << std::endl;
|
||||
}
|
||||
|
||||
void TextGame::do_snapshot_command(const StringVec &cmd) {
|
||||
if (cmd.size() != 1) {
|
||||
std::cerr << "s command (snapshot) takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
viewer_.snapshot();
|
||||
}
|
||||
|
||||
void TextGame::do_rollback_command(const StringVec &cmd) {
|
||||
if (cmd.size() != 1) {
|
||||
std::cerr << "r command (rollback) takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
viewer_.rollback();
|
||||
}
|
||||
|
||||
void TextGame::do_quit_command(const StringVec &cmd) {
|
||||
if (cmd.size() != 1) {
|
||||
std::cerr << "q command (quit) takes no arguments" << std::endl;
|
||||
@@ -133,6 +148,8 @@ void TextGame::do_command(const StringVec &words) {
|
||||
case 'm': do_menu_command(words); break;
|
||||
case 'c': do_choose_command(words); break;
|
||||
case 'q': do_quit_command(words); break;
|
||||
case 's': do_snapshot_command(words); break;
|
||||
case 'r': do_rollback_command(words); break;
|
||||
default:
|
||||
std::cerr << "Unknown command: " << words[0] << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user