X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_codepage.cpp;h=7a20e6e52dc6f695597f7d6e897354d96762e225;hb=3151d60c1ecc9462e4c335282ee6c31672f45111;hp=1c3ac02dad4382813bb286aed1e17fc04d44ecdb;hpb=3dd446de4155227d423e83628a10195e46b385aa;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 1c3ac02da..7a20e6e52 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -2,7 +2,6 @@ * InspIRCd -- Internet Relay Chat Daemon * * Copyright (C) 2020 Sadie Powell - * Copyright (C) 2014 Googolplexed * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -62,8 +61,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 +89,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 +100,7 @@ class ModuleCodepage public: ModuleCodepage() : origcasemap(national_case_insensitive_map) + , origcasemapname(ServerInstance->Config->CaseMapping) , origisnick(ServerInstance->IsNick) { } @@ -107,8 +110,11 @@ class ModuleCodepage ServerInstance->IsNick = origisnick; CheckInvalidNick(); + ServerInstance->Config->CaseMapping = origcasemapname; national_case_insensitive_map = origcasemap; CheckRehash(casemap); + + ServerInstance->ISupport.Build(); } void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE @@ -127,7 +133,7 @@ class ModuleCodepage unsigned char begin = tag->getUInt("begin", tag->getUInt("index", 0), 1, UCHAR_MAX); if (!begin) throw ModuleException(" tag without index or begin specified at " + tag->getTagLocation()); - + unsigned char end = tag->getUInt("end", begin, 1, UCHAR_MAX); if (begin > end) throw ModuleException(" must be lower than at " + tag->getTagLocation()); @@ -185,6 +191,8 @@ class ModuleCodepage ServerInstance->Config->CaseMapping = name; national_case_insensitive_map = casemap; CheckRehash(newcasemap); + + ServerInstance->ISupport.Build(); } Version GetVersion() CXX11_OVERRIDE @@ -206,7 +214,7 @@ class ModuleCodepage if (casemap[i] != i) linkdata << static_cast(i) << casemap[i] << ','; - return Version("Provides support for custom 8-bit codepages", VF_COMMON | VF_VENDOR, linkdata.str()); + return Version("Allows the server administrator to define what characters are allowed in nicknames and how characters should be compared in a case insensitive way.", VF_COMMON | VF_VENDOR, linkdata.str()); } }; MODULE_INIT(ModuleCodepage)