mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-08-22 02:24:59 -05:00
acctcreate returns next userid
This commit is contained in:
@@ -404,6 +404,18 @@ class GamespyDatabase(object):
|
||||
else:
|
||||
return json.loads(r["data"])
|
||||
|
||||
def get_next_available_userid(self):
|
||||
with Transaction(self.conn) as tx:
|
||||
row = tx.queryone("SELECT max(userid) FROM users")
|
||||
r = self.get_dict(row)
|
||||
if r == None:
|
||||
return '0000000000002'#Because all zeroes means Dolphin. Don't wanna get confused during debugging later.
|
||||
else:
|
||||
userid = str(int(json.loads(r['max(userid)'])) + 1)
|
||||
while len(userid) < 13:
|
||||
userid = "0"+userid
|
||||
return userid
|
||||
|
||||
def generate_authtoken(self, userid, data):
|
||||
# Since the auth token passed back to the game will be random, we can make it small enough that there
|
||||
# should never be a crash due to the size of the token.
|
||||
|
||||
@@ -102,6 +102,7 @@ class NasHTTPServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
if action == "acctcreate":
|
||||
# TODO: test for duplicate accounts
|
||||
ret["returncd"] = "002"
|
||||
ret['userid'] = self.server.db.get_next_available_userid()
|
||||
|
||||
logger.log(logging.DEBUG, "acctcreate response to %s", self.client_address)
|
||||
logger.log(logging.DEBUG, ret)
|
||||
|
||||
Reference in New Issue
Block a user