summaryrefslogtreecommitdiff
path: root/src/account-server/accountclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/account-server/accountclient.cpp')
-rw-r--r--src/account-server/accountclient.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/account-server/accountclient.cpp b/src/account-server/accountclient.cpp
index df1b034c..822cbed5 100644
--- a/src/account-server/accountclient.cpp
+++ b/src/account-server/accountclient.cpp
@@ -20,9 +20,32 @@
#include "account-server/accountclient.h"
+/**
+ * Generates a random string containing lowercase and uppercase characters as
+ * well as numbers.
+ */
+static std::string getRandomString(int length)
+{
+ std::string s;
+ s.resize(length);
+ for (int i = 0; i < length; ++i)
+ {
+ int r = rand() % 62;
+ if (r < 10)
+ s[i] = '0' + r;
+ else if (r < 36)
+ s[i] = 'a' + r - 10;
+ else
+ s[i] = 'A' + r - 36;
+ }
+
+ return s;
+}
+
AccountClient::AccountClient(ENetPeer *peer):
NetComputer(peer),
status(CLIENT_LOGIN),
- version(0)
+ version(0),
+ token(getRandomString(8))
{
}