X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fserver.cpp;h=66b175a1ad5d9785aed9cab63d78b75f5aeb3a4f;hb=ee641f3f229143940fbe359ac98863edfdf249ce;hp=d4797dce692bfb73101fa0345b1bc7afc62ddba1;hpb=48f7fa6b11a0a6b1526c54914e60ddbe51ede8c4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/server.cpp b/src/server.cpp index d4797dce6..66b175a1a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -66,24 +66,13 @@ void RehashHandler::Call(const std::string &reason) } } -std::string InspIRCd::GetVersionString(bool operstring) +std::string InspIRCd::GetVersionString(bool getFullVersion) { - char versiondata[MAXBUF]; - if (operstring) - { - std::string sename = SE->GetName(); - snprintf(versiondata,MAXBUF,"%s %s :%s [%s,%s,%s]",VERSION, Config->ServerName.c_str(), SYSTEM,REVISION, sename.c_str(), Config->sid.c_str()); - } - else - snprintf(versiondata,MAXBUF,"%s %s :%s",BRANCH,Config->ServerName.c_str(),Config->CustomVersion.c_str()); - return versiondata; + if (getFullVersion) + return VERSION " " + Config->ServerName + " :" SYSTEM " [" REVISION "," + SE->GetName() + "," + Config->sid + "]"; + return BRANCH " " + Config->ServerName + " :" + Config->CustomVersion; } -const char InspIRCd::LogHeader[] = - "Log started for " VERSION " (" REVISION ", " MODULE_INIT_STR ")" - " - compiled on " SYSTEM; - - std::string UIDGenerator::GenerateSID(const std::string& servername, const std::string& serverdesc) { unsigned int sid = 0; @@ -94,6 +83,7 @@ std::string UIDGenerator::GenerateSID(const std::string& servername, const std:: sid = 5 * sid + *i; std::string sidstr = ConvToStr(sid % 1000); + sidstr.insert(0, 3 - sidstr.length(), '0'); return sidstr; } @@ -106,35 +96,30 @@ void UIDGenerator::IncrementUID(unsigned int pos) * A again, in an iterative fashion.. so.. * AAA9 -> AABA, and so on. -- w00t */ - if ((pos == 3) && (current_uid[3] == '9')) + + // If we hit Z, wrap around to 0. + if (current_uid[pos] == 'Z') + { + current_uid[pos] = '0'; + } + else if (current_uid[pos] == '9') { - // At pos 3, if we hit '9', we've run out of available UIDs, and need to reset to AAA..AAA. - for (int i = 3; i < UUID_LENGTH-1; i++) + /* + * Or, if we hit 9, wrap around to pos = 'A' and (pos - 1)++, + * e.g. A9 -> BA -> BB .. + */ + current_uid[pos] = 'A'; + if (pos == 3) { - current_uid[i] = 'A'; + // At pos 3, if we hit '9', we've run out of available UIDs, and reset to AAA..AAA. + return; } + this->IncrementUID(pos - 1); } else { - // If we hit Z, wrap around to 0. - if (current_uid[pos] == 'Z') - { - current_uid[pos] = '0'; - } - else if (current_uid[pos] == '9') - { - /* - * Or, if we hit 9, wrap around to pos = 'A' and (pos - 1)++, - * e.g. A9 -> BA -> BB .. - */ - current_uid[pos] = 'A'; - this->IncrementUID(pos - 1); - } - else - { - // Anything else, nobody gives a shit. Just increment. - current_uid[pos]++; - } + // Anything else, nobody gives a shit. Just increment. + current_uid[pos]++; } } @@ -148,15 +133,10 @@ void UIDGenerator::init(const std::string& sid) * -- w */ + current_uid.resize(UUID_LENGTH, '9'); current_uid[0] = sid[0]; current_uid[1] = sid[1]; current_uid[2] = sid[2]; - - for (int i = 3; i < (UUID_LENGTH - 1); i++) - current_uid[i] = '9'; - - // Null terminator. Important. - current_uid[UUID_LENGTH - 1] = '\0'; } /* @@ -167,7 +147,7 @@ std::string UIDGenerator::GetUID() while (1) { // Add one to the last UID - this->IncrementUID(UUID_LENGTH - 2); + this->IncrementUID(UUID_LENGTH - 1); if (!ServerInstance->FindUUID(current_uid)) break;