mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
many modules fixes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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++);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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));
|
||||
|
||||
|
Reference in New Issue
Block a user