diff options
-rw-r--r-- | include/configreader.h | 2 | ||||
-rw-r--r-- | src/inspircd.cpp | 22 |
2 files changed, 15 insertions, 9 deletions
diff --git a/include/configreader.h b/include/configreader.h index babb3511c..05194fbea 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -613,7 +613,7 @@ class CoreExport ServerConfig : public Extensible * makes code simpler. 0AA, 1BB etc with letters are reserved * for services use. */ - int sid; + char sid[MAXBUF]; /** Construct a new ServerConfig */ diff --git a/src/inspircd.cpp b/src/inspircd.cpp index fbb7c7e71..c50d2cb6f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -483,20 +483,25 @@ InspIRCd::InspIRCd(int argc, char** argv) * -- w00t */ /* Generate SID */ - size_t sid = 0; if (Config->sid) { - sid = Config->sid; + // already defined, don't bother } else { + // Generate one + size_t sid = 0; + for (const char* x = Config->ServerName; *x; ++x) sid = 5 * sid + *x; for (const char* y = Config->ServerDesc; *y; ++y) sid = 5 * sid + *y; sid = sid % 999; - Config->sid = sid; + Config->sid[0] = (char)(sid / 100 + 48); + Config->sid[1] = (char)(((sid / 10) % 10) + 48); + Config->sid[2] = (char)(sid % 10 + 48); + //Config->sid = sprintf("%u", sid); } this->InitialiseUID(); @@ -584,16 +589,17 @@ InspIRCd::InspIRCd(int argc, char** argv) /* moved to a function, as UID generation can call this also */ void InspIRCd::InitialiseUID() { - int i; - size_t sid = Config->sid; + int i = 3; - current_uid[0] = sid / 100 + 48; - current_uid[1] = ((sid / 10) % 10) + 48; - current_uid[2] = sid % 10 + 48; + current_uid[0] = Config->sid[0]; + current_uid[1] = Config->sid[1]; + current_uid[2] = Config->sid[2]; /* Initialise UID */ for(i = 3; i < UUID_LENGTH - 1; i++) current_uid[i] = 'A'; + + current_uid[UUID_LENGTH] = '\0'; } int InspIRCd::Run() |