diff --git a/ext/crlib/cr-hook.h b/ext/crlib/cr-hook.h index 3169b82..470f0dc 100644 --- a/ext/crlib/cr-hook.h +++ b/ext/crlib/cr-hook.h @@ -90,10 +90,6 @@ public: hookedBytes_ = makeUnique (CodeLength); } - ~SimpleHook () { - disable (); - } - public: bool patch (void *address, void *replacement) { constexpr uint16 jmp = 0x25ff; diff --git a/ext/crlib/cr-library.h b/ext/crlib/cr-library.h index ab8a890..c00d039 100644 --- a/ext/crlib/cr-library.h +++ b/ext/crlib/cr-library.h @@ -59,7 +59,7 @@ public: #if defined (CR_WINDOWS) handle_ = LoadLibraryA (file.chars ()); #else - handle_ = dlopen (file.chars (), RTLD_LAZY); + handle_ = dlopen (file.chars (), RTLD_NOW | RTLD_DEEPBIND | RTLD_LOCAL); #endif return handle_ != nullptr; } diff --git a/inc/engine.h b/inc/engine.h index bbbe74c..84edc49 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -653,7 +653,7 @@ public: } public: - static SharedLibrary::Handle CR_STDCALL replacement (SharedLibrary::Handle module, const char *function) { + static SharedLibrary::Handle CR_STDCALL CR_STDCALL replacement (SharedLibrary::Handle module, const char *function) { return EntityLinkage::instance ().lookup (module, function); } }; diff --git a/src/config.cpp b/src/config.cpp index 88022ff..15cd042 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -179,7 +179,7 @@ void BotConfig::loadWeaponsConfig () { MemFile file; // weapon data initialization - if (util.openConfig ("weapon.cfg", "Weapon configuration file not found. Loading defaults", &file)) { + if (util.openConfig ("weapon.cfg", "Weapon configuration file not found. Loading defaults.", &file)) { while (file.getLine (line)) { line.trim (); @@ -583,7 +583,7 @@ void BotConfig::loadDifficultyConfig () { }; // avatars inititalization - if (util.openConfig ("difficulty.cfg", "Difficulty config file not found. Defaults loaded.", &file)) { + if (util.openConfig ("difficulty.cfg", "Difficulty config file not found. Loading defaults.", &file)) { while (file.getLine (line)) { if (isCommentLine (line)) { diff --git a/src/engine.cpp b/src/engine.cpp index a692ff9..d8668e7 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -1145,30 +1145,25 @@ float LightMeasure::getSkyColor () { } SharedLibrary::Handle EntityLinkage::lookup (SharedLibrary::Handle module, const char *function) { + static const auto &gamedll = game.lib ().handle (); + static const auto &self = m_self.handle (); + const auto resolve = [&] (SharedLibrary::Handle handle) { return reinterpret_cast (m_dlsym.call (static_cast (handle), function)); }; - // skip any ordinals requests on windows - if (plat.win32 && (static_cast (reinterpret_cast (function) >> 16) & 0xffff) == 0) { - return resolve (module); - } - - static const auto &gamedll = game.lib (); - static const auto &self = m_self; - // if requested module is yapb module, put in cache the looked up symbol - if (self.handle () != module) { + if (self != module || (plat.win32 && (static_cast (reinterpret_cast (function) >> 16) & 0xffff) == 0)) { return resolve (module); } if (m_exports.has (function)) { return m_exports[function]; } - auto botAddr = resolve (self.handle ()); + auto botAddr = resolve (self); if (!botAddr) { - auto gameAddr = resolve (gamedll.handle ()); + auto gameAddr = resolve (gamedll); if (gameAddr) { return m_exports[function] = gameAddr; diff --git a/src/message.cpp b/src/message.cpp index 1b872a4..46138e6 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -421,21 +421,21 @@ MessageDispatcher::MessageDispatcher () { // register text msg cache m_textMsgCache["#CTs_Win"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; - m_textMsgCache["#Bomb_Defused"] = TextMsgCache::NeedHandle; + m_textMsgCache["#Bomb_Defused"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; m_textMsgCache["#Bomb_Planted"] = TextMsgCache::NeedHandle | TextMsgCache::BombPlanted; m_textMsgCache["#Terrorists_Win"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; - m_textMsgCache["#Round_Draw"] = TextMsgCache::NeedHandle; - m_textMsgCache["#All_Hostages_Rescued"] = TextMsgCache::NeedHandle; - m_textMsgCache["#Target_Saved"] = TextMsgCache::NeedHandle; - m_textMsgCache["#Hostages_Not_Rescued"] = TextMsgCache::NeedHandle; - m_textMsgCache["#Terrorists_Not_Escaped"] = TextMsgCache::NeedHandle; - m_textMsgCache["#VIP_Not_Escaped"] = TextMsgCache::NeedHandle; - m_textMsgCache["#Escaping_Terrorists_Neutralized"] = TextMsgCache::NeedHandle; - m_textMsgCache["#VIP_Assassinated"] = TextMsgCache::NeedHandle; - m_textMsgCache["#VIP_Escaped"] = TextMsgCache::NeedHandle; - m_textMsgCache["#Terrorists_Escaped"] = TextMsgCache::NeedHandle; - m_textMsgCache["#CTs_PreventEscape"] = TextMsgCache::NeedHandle; - m_textMsgCache["#Target_Bombed"] = TextMsgCache::NeedHandle; + m_textMsgCache["#Round_Draw"] = TextMsgCache::NeedHandle | TextMsgCache::RestartRound; + m_textMsgCache["#All_Hostages_Rescued"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; + m_textMsgCache["#Target_Saved"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; + m_textMsgCache["#Hostages_Not_Rescued"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; + m_textMsgCache["#Terrorists_Not_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; + m_textMsgCache["#VIP_Not_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; + m_textMsgCache["#Escaping_Terrorists_Neutralized"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; + m_textMsgCache["#VIP_Assassinated"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; + m_textMsgCache["#VIP_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; + m_textMsgCache["#Terrorists_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; + m_textMsgCache["#CTs_PreventEscape"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; + m_textMsgCache["#Target_Bombed"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; m_textMsgCache["#Game_Commencing"] = TextMsgCache::NeedHandle | TextMsgCache::Commencing; m_textMsgCache["#Game_will_restart_in"] = TextMsgCache::NeedHandle | TextMsgCache::RestartRound; m_textMsgCache["#Switch_To_BurstFire"] = TextMsgCache::NeedHandle | TextMsgCache::BurstOn;