From 1377fabfee72994531df274248ed0ce6de483dd2 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Oct 2014 21:11:14 +0200 Subject: m_nationalchars Rebuild core hashmaps when the national_case_insensitive_map changes Issue #923 --- src/modules/m_nationalchars.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/modules') diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp index b43b6e2b6..20e4eaa9e 100644 --- a/src/modules/m_nationalchars.cpp +++ b/src/modules/m_nationalchars.cpp @@ -228,11 +228,24 @@ class ModuleNationalChars : public Module caller2 rememberer; bool forcequit; const unsigned char * lowermap_rememberer; + unsigned char prev_map[256]; + + void CheckRehash() + { + // See if anything changed + if (!memcmp(prev_map, national_case_insensitive_map, sizeof(prev_map))) + return; + + memcpy(prev_map, national_case_insensitive_map, sizeof(prev_map)); + + ServerInstance->RehashUsersAndChans(); + } public: ModuleNationalChars() : rememberer(ServerInstance->IsNick), lowermap_rememberer(national_case_insensitive_map) { + memcpy(prev_map, national_case_insensitive_map, sizeof(prev_map)); } void init() @@ -265,6 +278,7 @@ class ModuleNationalChars : public Module loadtables(charset, tables, 8, 5); forcequit = tag->getBool("forcequit"); CheckForceQuit("National character set changed"); + CheckRehash(); } void CheckForceQuit(const char * message) @@ -286,6 +300,7 @@ class ModuleNationalChars : public Module ServerInstance->IsNick = rememberer; national_case_insensitive_map = lowermap_rememberer; CheckForceQuit("National characters module unloaded"); + CheckRehash(); } virtual Version GetVersion() -- cgit v1.2.3