diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-01-03 13:04:10 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-01-03 13:04:10 +0000 |
commit | ce5bee9a3e154674558ab627b282f1572ce4e594 (patch) | |
tree | 98a391437fe7e88199aacd2e4f20323c90e2b7e8 | |
parent | 287d60fc83a043a78c4a4ad7c07322238ec52881 (diff) |
Patch turning Config->sid from size_t to char **. This also undoes the total fuckery that occurs when someone tries to specify <server:id>. Automatic generation is not yet tested.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8619 e03df62e-2008-0410-955e-edbf42e46eb7
-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() |