From 568eb60cca4b0221dc7f1eec860c9330e4831def Mon Sep 17 00:00:00 2001 From: Loudrob Date: Fri, 15 May 2015 08:27:32 -0400 Subject: [PATCH] what if i like environ --- client.bat | 16 ++++++++-------- toontown/launcher/TTULauncher.py | 22 +++++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/client.bat b/client.bat index c7f10165..be98c80c 100644 --- a/client.bat +++ b/client.bat @@ -10,23 +10,23 @@ echo. set /P INPUT= set server=unset -if %INPUT%==1 set server=127.0.0.1 -if %INPUT%==3 set server=71.200.196.180 +if %INPUT%==1 set TTU_GAMESERVER=127.0.0.1 +if %INPUT%==3 set TTU_GAMESERVER=71.200.196.180 -if %server%==unset ( +if %TTU_GAMESERVER%==unset ( echo. - set /P server=Gameserver: + set /P TTU_GAMESERVER=Gameserver: ) echo. -set /P user=Username: +set /P TTU_PLAYCOOKIE=Username: echo =============================== echo Starting Toontown United... echo ppython: %PPYTHON_PATH% -echo Username: %user% -echo Gameserver: %server% +echo Username: %TTU_PLAYCOOKIE% +echo Gameserver: %TTU_GAMESERVER% echo =============================== -%PPYTHON_PATH% -m toontown.toonbase.ClientStart %user% %server% +%PPYTHON_PATH% -m toontown.toonbase.ClientStart pause \ No newline at end of file diff --git a/toontown/launcher/TTULauncher.py b/toontown/launcher/TTULauncher.py index 15d81d44..5393cfc8 100644 --- a/toontown/launcher/TTULauncher.py +++ b/toontown/launcher/TTULauncher.py @@ -1,6 +1,8 @@ from pandac.PandaModules import * from direct.directnotify import DirectNotifyGlobal -import os, sys, time, argparse +import os +import sys +import time class LogAndOutput: def __init__(self, orig, log): @@ -21,13 +23,9 @@ class TTULauncher: notify = DirectNotifyGlobal.directNotify.newCategory('TTULauncher') def __init__(self): - self.logPrefix = 'united-' self.http = HTTPClient() - - parser = argparse.ArgumentParser() - parser.add_argument('token') - parser.add_argument('server') - self.args = parser.parse_args() + + self.logPrefix = 'united-' ltime = 1 and time.localtime() logSuffix = '%02d%02d%02d_%02d%02d%02d' % (ltime[0] - 2000, ltime[1], ltime[2], ltime[3], ltime[4], ltime[5]) @@ -45,10 +43,16 @@ class TTULauncher: sys.stderr = logErr def getPlayToken(self): - return self.args.token + return self.getValue('TTU_PLAYCOOKIE') def getGameServer(self): - return self.args.server + return self.getValue('TTU_GAMESERVER') + + def getValue(self, key, default = None): + return os.environ.get(key, default) + + def setValue(self, key, value): + os.environ[key] = str(value) def setPandaErrorCode(self): pass