fix: some round messages doesn't get handled.

misc: cosmetic changes.
This commit is contained in:
dmitry 2020-06-18 09:28:43 +03:00
commit 6b8f8db4de
6 changed files with 23 additions and 32 deletions

View file

@ -90,10 +90,6 @@ public:
hookedBytes_ = makeUnique <uint8 []> (CodeLength); hookedBytes_ = makeUnique <uint8 []> (CodeLength);
} }
~SimpleHook () {
disable ();
}
public: public:
bool patch (void *address, void *replacement) { bool patch (void *address, void *replacement) {
constexpr uint16 jmp = 0x25ff; constexpr uint16 jmp = 0x25ff;

View file

@ -59,7 +59,7 @@ public:
#if defined (CR_WINDOWS) #if defined (CR_WINDOWS)
handle_ = LoadLibraryA (file.chars ()); handle_ = LoadLibraryA (file.chars ());
#else #else
handle_ = dlopen (file.chars (), RTLD_LAZY); handle_ = dlopen (file.chars (), RTLD_NOW | RTLD_DEEPBIND | RTLD_LOCAL);
#endif #endif
return handle_ != nullptr; return handle_ != nullptr;
} }

View file

@ -653,7 +653,7 @@ public:
} }
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); return EntityLinkage::instance ().lookup (module, function);
} }
}; };

View file

@ -179,7 +179,7 @@ void BotConfig::loadWeaponsConfig () {
MemFile file; MemFile file;
// weapon data initialization // 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)) { while (file.getLine (line)) {
line.trim (); line.trim ();
@ -583,7 +583,7 @@ void BotConfig::loadDifficultyConfig () {
}; };
// avatars inititalization // 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)) { while (file.getLine (line)) {
if (isCommentLine (line)) { if (isCommentLine (line)) {

View file

@ -1145,30 +1145,25 @@ float LightMeasure::getSkyColor () {
} }
SharedLibrary::Handle EntityLinkage::lookup (SharedLibrary::Handle module, const char *function) { 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) { const auto resolve = [&] (SharedLibrary::Handle handle) {
return reinterpret_cast <SharedLibrary::Handle> (m_dlsym.call <decltype (HOOK_FUNCTION)> (static_cast <HOOK_CAST> (handle), function)); return reinterpret_cast <SharedLibrary::Handle> (m_dlsym.call <decltype (HOOK_FUNCTION)> (static_cast <HOOK_CAST> (handle), function));
}; };
// skip any ordinals requests on windows
if (plat.win32 && (static_cast <uint16> (reinterpret_cast <uint32> (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 requested module is yapb module, put in cache the looked up symbol
if (self.handle () != module) { if (self != module || (plat.win32 && (static_cast <uint16> (reinterpret_cast <uint32> (function) >> 16) & 0xffff) == 0)) {
return resolve (module); return resolve (module);
} }
if (m_exports.has (function)) { if (m_exports.has (function)) {
return m_exports[function]; return m_exports[function];
} }
auto botAddr = resolve (self.handle ()); auto botAddr = resolve (self);
if (!botAddr) { if (!botAddr) {
auto gameAddr = resolve (gamedll.handle ()); auto gameAddr = resolve (gamedll);
if (gameAddr) { if (gameAddr) {
return m_exports[function] = gameAddr; return m_exports[function] = gameAddr;

View file

@ -421,21 +421,21 @@ MessageDispatcher::MessageDispatcher () {
// register text msg cache // register text msg cache
m_textMsgCache["#CTs_Win"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin; 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["#Bomb_Planted"] = TextMsgCache::NeedHandle | TextMsgCache::BombPlanted;
m_textMsgCache["#Terrorists_Win"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin; m_textMsgCache["#Terrorists_Win"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin;
m_textMsgCache["#Round_Draw"] = TextMsgCache::NeedHandle; m_textMsgCache["#Round_Draw"] = TextMsgCache::NeedHandle | TextMsgCache::RestartRound;
m_textMsgCache["#All_Hostages_Rescued"] = TextMsgCache::NeedHandle; m_textMsgCache["#All_Hostages_Rescued"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin;
m_textMsgCache["#Target_Saved"] = TextMsgCache::NeedHandle; m_textMsgCache["#Target_Saved"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin;
m_textMsgCache["#Hostages_Not_Rescued"] = TextMsgCache::NeedHandle; m_textMsgCache["#Hostages_Not_Rescued"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin;
m_textMsgCache["#Terrorists_Not_Escaped"] = TextMsgCache::NeedHandle; m_textMsgCache["#Terrorists_Not_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin;
m_textMsgCache["#VIP_Not_Escaped"] = TextMsgCache::NeedHandle; m_textMsgCache["#VIP_Not_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin;
m_textMsgCache["#Escaping_Terrorists_Neutralized"] = TextMsgCache::NeedHandle; m_textMsgCache["#Escaping_Terrorists_Neutralized"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin;
m_textMsgCache["#VIP_Assassinated"] = TextMsgCache::NeedHandle; m_textMsgCache["#VIP_Assassinated"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin;
m_textMsgCache["#VIP_Escaped"] = TextMsgCache::NeedHandle; m_textMsgCache["#VIP_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin;
m_textMsgCache["#Terrorists_Escaped"] = TextMsgCache::NeedHandle; m_textMsgCache["#Terrorists_Escaped"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin;
m_textMsgCache["#CTs_PreventEscape"] = TextMsgCache::NeedHandle; m_textMsgCache["#CTs_PreventEscape"] = TextMsgCache::NeedHandle | TextMsgCache::CounterWin;
m_textMsgCache["#Target_Bombed"] = TextMsgCache::NeedHandle; m_textMsgCache["#Target_Bombed"] = TextMsgCache::NeedHandle | TextMsgCache::TerroristWin;
m_textMsgCache["#Game_Commencing"] = TextMsgCache::NeedHandle | TextMsgCache::Commencing; m_textMsgCache["#Game_Commencing"] = TextMsgCache::NeedHandle | TextMsgCache::Commencing;
m_textMsgCache["#Game_will_restart_in"] = TextMsgCache::NeedHandle | TextMsgCache::RestartRound; m_textMsgCache["#Game_will_restart_in"] = TextMsgCache::NeedHandle | TextMsgCache::RestartRound;
m_textMsgCache["#Switch_To_BurstFire"] = TextMsgCache::NeedHandle | TextMsgCache::BurstOn; m_textMsgCache["#Switch_To_BurstFire"] = TextMsgCache::NeedHandle | TextMsgCache::BurstOn;