many modules fixes

This commit is contained in:
Eduardo Bart
2012-06-03 21:28:19 -03:00
parent cfa7db77da
commit 296f2a17c4
11 changed files with 31 additions and 23 deletions

View File

@@ -70,7 +70,7 @@ void ModuleManager::discoverModulesPath()
for(const std::string& dir : possibleModulesDirs) {
// try to add module directory
if(g_resources.addToSearchPath(dir, false)) {
g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str()));
//g_logger.info(stdext::format("Using modules directory '%s'", dir.c_str()));
found = true;
break;
}
@@ -88,7 +88,7 @@ void ModuleManager::discoverModulesPath()
for(const std::string& dir : possibleAddonsDirs) {
// try to add module directory
if(g_resources.addToSearchPath(dir, true)) {
g_logger.info(stdext::format("Using addons directory '%s'", dir.c_str()));
//g_logger.info(stdext::format("Using addons directory '%s'", dir.c_str()));
found = true;
break;
}

View File

@@ -252,7 +252,7 @@ void push_luavalue(const OTMLNodePtr& node)
int currentIndex = 1;
for(const OTMLNodePtr& cnode : node->children()) {
push_otml_subnode_luavalue(cnode);
if(cnode->isUnique()) {
if(cnode->isUnique() && !cnode->tag().empty()) {
g_lua.setField(cnode->tag());
} else
g_lua.rawSeti(currentIndex++);

View File

@@ -43,11 +43,7 @@ Game::Game()
void Game::resetGameStates()
{
#ifdef BOT_PROTECTION
m_denyBotCall = true;
#else
m_denyBotCall = false;
#endif
m_dead = false;
m_serverBeat = 50;
m_canReportBugs = false;
@@ -66,8 +62,6 @@ void Game::resetGameStates()
m_containers.clear();
m_vips.clear();
m_gmActions.clear();
m_worldName = "";
}
void Game::processConnectionError(const boost::system::error_code& error)
@@ -133,6 +127,9 @@ void Game::processGameEnd()
// reset game state
resetGameStates();
m_worldName = "";
m_characterName = "";
// clean map creatures
g_map.cleanDynamicThings();
}
@@ -407,6 +404,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName);
m_characterName = characterName;
m_worldName = worldName;
}
@@ -1024,12 +1022,14 @@ void Game::mount(bool mount)
bool Game::checkBotProtection()
{
#ifdef BOT_PROTECTION
// accepts calls comming from a stacktrace containing only C++ functions,
// if the stacktrace contains a lua function, then only accept if the engine is processing an input event
if(g_lua.isInCppCallback() && !g_app->isOnInputEvent() && m_denyBotCall) {
if(m_denyBotCall && g_lua.isInCppCallback() && !g_app->isOnInputEvent()) {
g_logger.error(g_lua.traceback("caught a lua call to a bot protected game function, the call was canceled"));
return false;
}
#endif
return true;
}

View File

@@ -244,8 +244,6 @@ public:
bool canPerformGameAction();
bool canReportBugs() { return m_canReportBugs; }
bool checkBotProtection();
void enableBotCall() { m_denyBotCall = false; }
void disableBotCall() { m_denyBotCall = true; }
bool isOnline() { return !!m_localPlayer; }
bool isDead() { return m_dead; }
@@ -261,9 +259,14 @@ public:
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
int getProtocolVersion() { return PROTOCOL; }
std::string getCharacterName() { return m_characterName; }
std::string getWorldName() { return m_worldName; }
std::vector<uint8> getGMActions() { return m_gmActions; }
protected:
void enableBotCall() { m_denyBotCall = false; }
void disableBotCall() { m_denyBotCall = true; }
private:
void setAttackingCreature(const CreaturePtr& creature);
void setFollowingCreature(const CreaturePtr& creature);
@@ -283,6 +286,7 @@ private:
bool m_safeFight;
bool m_canReportBugs;
std::vector<uint8> m_gmActions;
std::string m_characterName;
std::string m_worldName;
std::bitset<Otc::LastGameFeature> m_features;
int m_clientVersion;

View File

@@ -164,6 +164,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_game", "getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game));
g_lua.bindClassStaticFunction("g_game", "getProtocolGame", std::bind(&Game::getProtocolGame, &g_game));
g_lua.bindClassStaticFunction("g_game", "getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game));
g_lua.bindClassStaticFunction("g_game", "getCharacterName", std::bind(&Game::getCharacterName, &g_game));
g_lua.bindClassStaticFunction("g_game", "getWorldName", std::bind(&Game::getWorldName, &g_game));
g_lua.bindClassStaticFunction("g_game", "getGMActions", std::bind(&Game::getGMActions, &g_game));