diff options
author | Adam <Adam@anope.org> | 2011-04-30 15:01:04 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-05-16 04:10:18 -0400 |
commit | fd21c36725fc52fd186e058bb2b5f6c4c37b81bb (patch) | |
tree | 503c81b1634922bdba484df173a70680bd0f2768 /src/servers.cpp | |
parent | b999c6ca53d6b1dfd54688d21718293858f6bcc7 (diff) |
Fixed some logic fail in ts6_uid_retrieve
Diffstat (limited to 'src/servers.cpp')
-rw-r--r-- | src/servers.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/servers.cpp b/src/servers.cpp index 5b4058476..a1935c109 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -313,6 +313,17 @@ void do_server(const Anope::string &source, const Anope::string &servername, uns FOREACH_MOD(I_OnNewServer, OnNewServer(newserver)); } +static inline char nextID(char &c) +{ + if (c == 'Z') + c = '0'; + else if (c != '9') + ++c; + else + c = 'A'; + return c; +} + /** Recieve the next UID in our list * @return The UID */ @@ -322,22 +333,11 @@ const Anope::string ts6_uid_retrieve() return ""; static Anope::string current_uid = "AAAAAA"; - static unsigned current_len = current_uid.length() - 1; while (finduser(Config->Numeric + current_uid) != NULL) { - char &curChar = current_uid[current_len]; - if (curChar == 'Z') - curChar = '0'; - else if (curChar != '9') - ++curChar; - else - { - curChar = 'A'; - if (--current_len == 0) - current_len = current_uid.length(); - } - + int current_len = current_uid.length() - 1; + while (current_len >= 0 && nextID(current_uid[current_len--]) == 'A'); } return Config->Numeric + current_uid; @@ -352,22 +352,11 @@ const Anope::string ts6_sid_retrieve() return ""; static Anope::string current_sid = Config->Numeric; - static unsigned current_len = current_sid.length() - 1; while (Server::Find(current_sid) != NULL) { - char &curChar = current_sid[current_len]; - if (curChar == 'Z') - curChar = '0'; - else if (curChar != '9') - ++curChar; - else - { - curChar = 'A'; - if (--current_len == 0) - current_len = current_sid.length(); - } - + int current_len = current_sid.length() - 1; + while (current_len >= 0 && nextID(current_sid[current_len--]) == 'A'); } return current_sid; |