[UserInfo] Clear overrides when user disconnects

This commit is contained in:
Diavolo 2022-06-04 18:52:46 +02:00
parent 854949a34f
commit fe0cbacdea
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 7 additions and 4 deletions

View File

@ -311,10 +311,13 @@ namespace Components
* Should be called when a client drops from the server * Should be called when a client drops from the server
* but not "between levels" (Quake-III-Arena) * but not "between levels" (Quake-III-Arena)
*/ */
void Bots::ClientDisconnect_Hk(int clientNum) void Bots::ClientDisconnect_Hk(const int clientNum)
{ {
g_botai[clientNum].active = false; g_botai[clientNum].active = false;
// Clear the overrides for UserInfo
UserInfo::ClearClientOverrides(clientNum);
// Call original function // Call original function
Utils::Hook::Call<void(int)>(0x4AA430)(clientNum); Utils::Hook::Call<void(int)>(0x4AA430)(clientNum);
} }

View File

@ -7,15 +7,15 @@ namespace Components
public: public:
UserInfo(); UserInfo();
static void ClearClientOverrides(int client);
static void ClearAllOverrides();
private: private:
using userInfoMap = std::unordered_map<std::string, std::string>; using userInfoMap = std::unordered_map<std::string, std::string>;
static std::unordered_map<int, userInfoMap> UserInfoOverrides; static std::unordered_map<int, userInfoMap> UserInfoOverrides;
static void SV_GetUserInfo_Stub(int index, char* buffer, int bufferSize); static void SV_GetUserInfo_Stub(int index, char* buffer, int bufferSize);
static void ClearClientOverrides(int client);
static void ClearAllOverrides();
static void AddScriptMethods(); static void AddScriptMethods();
}; };
} }