From 0ff2d05ba6b94c5346e6e3e528118fadae1cb126 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 7 Jan 2020 23:45:10 +0000 Subject: Minor improvements to the codepage module. - Cache the codepage name on load and restore on unload. - Make origisnick constant. - Fix the size of the casemap in memcmp call. --- src/modules/m_codepage.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 1c3ac02da..911a4781e 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -62,8 +62,11 @@ class ModuleCodepage // The character map which was set before this module was loaded. const unsigned char* origcasemap; + // The name of the character map which was set before this module was loaded. + const std::string origcasemapname; + // The IsNick handler which was set before this module was loaded. - TR1NS::function origisnick; + const TR1NS::function origisnick; template void RehashHashmap(T& hashmap) @@ -87,7 +90,7 @@ class ModuleCodepage void CheckRehash(unsigned char* prevmap) { - if (!memcmp(prevmap, national_case_insensitive_map, sizeof(origcasemap))) + if (!memcmp(prevmap, national_case_insensitive_map, UCHAR_MAX)) return; RehashHashmap(ServerInstance->Users.clientlist); @@ -98,6 +101,7 @@ class ModuleCodepage public: ModuleCodepage() : origcasemap(national_case_insensitive_map) + , origcasemapname(ServerInstance->Config->CaseMapping) , origisnick(ServerInstance->IsNick) { } @@ -107,6 +111,7 @@ class ModuleCodepage ServerInstance->IsNick = origisnick; CheckInvalidNick(); + ServerInstance->Config->CaseMapping = origcasemapname; national_case_insensitive_map = origcasemap; CheckRehash(casemap); } -- cgit v1.2.3