本文整理汇总了C++中IRollbackManager::getRevertActions方法的典型用法代码示例。如果您正苦于以下问题:C++ IRollbackManager::getRevertActions方法的具体用法?C++ IRollbackManager::getRevertActions怎么用?C++ IRollbackManager::getRevertActions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRollbackManager
的用法示例。
在下文中一共展示了IRollbackManager::getRevertActions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l_rollback_revert_actions_by
// rollback_revert_actions_by(actor, seconds) -> bool, log messages
int ModApiBasic::l_rollback_revert_actions_by(lua_State *L)
{
std::string actor = luaL_checkstring(L, 1);
int seconds = luaL_checknumber(L, 2);
Server *server = getServer(L);
IRollbackManager *rollback = server->getRollbackManager();
std::list<RollbackAction> actions = rollback->getRevertActions(actor, seconds);
std::list<std::string> log;
bool success = server->rollbackRevertActions(actions, &log);
// Push boolean result
lua_pushboolean(L, success);
// Get the table insert function and push the log table
lua_getglobal(L, "table");
lua_getfield(L, -1, "insert");
int table_insert = lua_gettop(L);
lua_newtable(L);
int table = lua_gettop(L);
for(std::list<std::string>::const_iterator i = log.begin();
i != log.end(); i++)
{
lua_pushvalue(L, table_insert);
lua_pushvalue(L, table);
lua_pushstring(L, i->c_str());
if(lua_pcall(L, 2, 0, 0))
script_error(L, "error: %s", lua_tostring(L, -1));
}
lua_remove(L, -2); // Remove table
lua_remove(L, -2); // Remove insert
return 2;
}
示例2: l_rollback_revert_actions_by
// rollback_revert_actions_by(actor, seconds) -> bool, log messages
int ModApiRollback::l_rollback_revert_actions_by(lua_State *L)
{
std::string actor = luaL_checkstring(L, 1);
int seconds = luaL_checknumber(L, 2);
Server *server = getServer(L);
IRollbackManager *rollback = server->getRollbackManager();
// If rollback is disabled, tell it's not a success.
if (rollback == NULL) {
lua_pushboolean(L, false);
lua_newtable(L);
return 2;
}
std::list<RollbackAction> actions = rollback->getRevertActions(actor, seconds);
std::list<std::string> log;
bool success = server->rollbackRevertActions(actions, &log);
// Push boolean result
lua_pushboolean(L, success);
lua_createtable(L, log.size(), 0);
unsigned long i = 0;
for(std::list<std::string>::const_iterator iter = log.begin();
iter != log.end(); ++i, ++iter) {
lua_pushnumber(L, i);
lua_pushstring(L, iter->c_str());
lua_settable(L, -3);
}
return 2;
}