A bit of a launcher cleanup, retired ClientStartRemoteDB (we are gonna supply play token directly), and instead of environ, we are now supplying server and token with argparse.

This commit is contained in:
Daniel 2015-03-22 13:34:07 +02:00
parent 5bc056d630
commit 7171f49e3b
8 changed files with 19 additions and 100 deletions

View file

@ -5,39 +5,26 @@ set /P PPYTHON_PATH=<PPYTHON_PATH
echo Choose your game server! echo Choose your game server!
echo #1 - Localhost echo #1 - Localhost
echo #2 - Custom echo #2 - Custom
echo #3 - Custom w/ RemoteDB
echo. echo.
set /P INPUT= set /P INPUT=
set TTU_GAMESERVER=unset set server=unset
if %INPUT%==1 set TTU_GAMESERVER=127.0.0.1 if %INPUT%==1 set server=127.0.0.1
if %TTU_GAMESERVER%==unset ( if %server%==unset (
echo. echo.
set /P TTU_GAMESERVER=Gameserver: set /P server=Gameserver:
) )
echo. echo.
set /P ttuUsername=Username: set /P user=Username:
if %INPUT%==3 (
echo.
set /P ttuPassword=Password:
)
set TTU_PLAYCOOKIE=%ttuUsername%
echo =============================== echo ===============================
echo Starting Toontown United... echo Starting Toontown United...
echo ppython: %PPYTHON_PATH% echo ppython: %PPYTHON_PATH%
echo Username: %ttuUsername% echo Username: %user%
echo Password: %ttuPassword% echo Password: %ttuPassword%
echo Gameserver: %TTU_GAMESERVER% echo Gameserver: %server%
echo =============================== echo ===============================
if %INPUT%==3 ( %PPYTHON_PATH% -m toontown.toonbase.ClientStart %server% %user%
%PPYTHON_PATH% -m toontown.toonbase.ClientStartRemoteDB
) else (
%PPYTHON_PATH% -m toontown.toonbase.ClientStart
)
pause pause

View file

@ -36,9 +36,6 @@ class DummyLauncherBase:
self.downloadDoneTask(None) self.downloadDoneTask(None)
return return
def isTestServer(self):
return base.config.GetBool('is-test-server', 0)
def setPhaseCompleteArray(self, newPhaseComplete): def setPhaseCompleteArray(self, newPhaseComplete):
self.phaseComplete = newPhaseComplete self.phaseComplete = newPhaseComplete

View file

@ -172,8 +172,6 @@ class LauncherBase(DirectObject):
self.notify = directNotify.newCategory('Launcher') self.notify = directNotify.newCategory('Launcher')
self.clock = TrueClock.getGlobalPtr() self.clock = TrueClock.getGlobalPtr()
self.logPrefix = logPrefix self.logPrefix = logPrefix
self.testServerFlag = self.getTestServerFlag()
self.notify.info('isTestServer: %s' % self.testServerFlag)
downloadServerString = launcherConfig.GetString('download-server', '') downloadServerString = launcherConfig.GetString('download-server', '')
if downloadServerString: if downloadServerString:
self.notify.info('Overriding downloadServer to %s.' % downloadServerString) self.notify.info('Overriding downloadServer to %s.' % downloadServerString)
@ -1518,9 +1516,6 @@ class LauncherBase(DirectObject):
self.lastLauncherMsg = msg self.lastLauncherMsg = msg
self.notify.info(msg) self.notify.info(msg)
def isTestServer(self):
return self.testServerFlag
def recordPeriodTimeRemaining(self, secondsRemaining): def recordPeriodTimeRemaining(self, secondsRemaining):
self.setValue(self.PeriodTimeRemainingKey, int(secondsRemaining)) self.setValue(self.PeriodTimeRemainingKey, int(secondsRemaining))

View file

@ -579,11 +579,6 @@ class ClientRepositoryBase(ConnectionRepository):
return None return None
return worldNP return worldNP
def isLive(self):
if base.config.GetBool('force-live', 0):
return True
return not (__dev__ or launcher.isTestServer())
def isLocalId(self, id): def isLocalId(self, id):
# By default, no ID's are local. See also # By default, no ID's are local. See also
# ClientRepository.isLocalId(). # ClientRepository.isLocalId().

View file

@ -428,8 +428,7 @@ class TTChatInputSpeedChat(DirectObject.DirectObject):
def createSpeedChat(self): def createSpeedChat(self):
structure = [] structure = []
if launcher and not launcher.isTestServer() or __dev__: structure.append([TTSCPromotionalMenu, OTPLocalizer.SCMenuPromotion])
structure.append([TTSCPromotionalMenu, OTPLocalizer.SCMenuPromotion])
structure.append([SCEmoteMenu, OTPLocalizer.SCMenuEmotions]) structure.append([SCEmoteMenu, OTPLocalizer.SCMenuEmotions])
structure.append([SCCustomMenu, OTPLocalizer.SCMenuCustom]) structure.append([SCCustomMenu, OTPLocalizer.SCMenuCustom])
structure.append([TTSCResistanceMenu, OTPLocalizer.SCMenuResistance]) structure.append([TTSCResistanceMenu, OTPLocalizer.SCMenuResistance])

View file

@ -573,16 +573,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
def dumpAllSubShardObjects(self): def dumpAllSubShardObjects(self):
if self.KeepSubShardObjects: if self.KeepSubShardObjects:
return return
isNotLive = not base.cr.isLive()
if isNotLive:
try:
localAvatar
except:
self.notify.info('dumpAllSubShardObjects')
else:
self.notify.info('dumpAllSubShardObjects: defaultShard is %s' % localAvatar.defaultShard)
ignoredClasses = ('MagicWordManager', 'TimeManager', 'DistributedDistrict', 'FriendManager', 'NewsManager', 'ToontownMagicWordManager', 'WelcomeValleyManager', 'DistributedTrophyMgr', 'CatalogManager', 'DistributedBankMgr', 'EstateManager', 'RaceManager', 'SafeZoneManager', 'DeleteManager', 'TutorialManager', 'ToontownDistrict', 'DistributedDeliveryManager', 'DistributedPartyManager', 'AvatarFriendsManager', 'TTCodeRedemptionMgr')
messenger.send('clientCleanup') messenger.send('clientCleanup')
for avId, pad in self.__queryAvatarMap.items(): for avId, pad in self.__queryAvatarMap.items():
pad.delayDelete.destroy() pad.delayDelete.destroy()
@ -592,16 +582,8 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
doIds = self.doId2do.keys() doIds = self.doId2do.keys()
for doId in doIds: for doId in doIds:
obj = self.doId2do[doId] obj = self.doId2do[doId]
if isNotLive:
ignoredClass = obj.__class__.__name__ in ignoredClasses
if not ignoredClass and obj.parentId != localAvatar.defaultShard:
self.notify.info('dumpAllSubShardObjects: %s %s parent %s is not defaultShard' % (obj.__class__.__name__, obj.doId, obj.parentId))
if obj.parentId == localAvatar.defaultShard and obj is not localAvatar: if obj.parentId == localAvatar.defaultShard and obj is not localAvatar:
if obj.neverDisable: if not obj.neverDisable:
if isNotLive:
if not ignoredClass:
self.notify.warning('dumpAllSubShardObjects: neverDisable set for %s %s' % (obj.__class__.__name__, obj.doId))
else:
self.deleteObject(doId) self.deleteObject(doId)
self._deletedSubShardDoIds.add(doId) self._deletedSubShardDoIds.add(doId)
if obj.getDelayDeleteCount() != 0: if obj.getDelayDeleteCount() != 0:
@ -618,8 +600,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
s += '\n could not delete %s (%s), delayDeletes=%s' % (safeRepr(obj), itype(obj), obj.getDelayDeleteNames()) s += '\n could not delete %s (%s), delayDeletes=%s' % (safeRepr(obj), itype(obj), obj.getDelayDeleteNames())
self.notify.error(s) self.notify.error(s)
if isNotLive:
self.notify.info('dumpAllSubShardObjects: doIds left: %s' % self.doId2do.keys())
def _removeCurrentShardInterest(self, callback): def _removeCurrentShardInterest(self, callback):
if self.old_setzone_interest_handle is None: if self.old_setzone_interest_handle is None:

View file

@ -1,9 +1,7 @@
from pandac.PandaModules import * from pandac.PandaModules import *
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from otp.launcher.LauncherBase import LauncherBase from otp.launcher.LauncherBase import LauncherBase
import os import os, sys, time, argparse
import sys
import time
class LogAndOutput: class LogAndOutput:
def __init__(self, orig, log): def __init__(self, orig, log):
@ -24,9 +22,13 @@ class TTULauncher(LauncherBase):
notify = DirectNotifyGlobal.directNotify.newCategory('ToontownDummyLauncher') notify = DirectNotifyGlobal.directNotify.newCategory('ToontownDummyLauncher')
def __init__(self): def __init__(self):
self.http = HTTPClient()
self.logPrefix = 'united-' self.logPrefix = 'united-'
self.http = HTTPClient()
parser = argparse.ArgumentParser()
parser.add_argument('token')
parser.add_argument('server')
self.args = parser.parse_args()
ltime = 1 and time.localtime() ltime = 1 and time.localtime()
logSuffix = '%02d%02d%02d_%02d%02d%02d' % (ltime[0] - 2000, ltime[1], ltime[2], logSuffix = '%02d%02d%02d_%02d%02d%02d' % (ltime[0] - 2000, ltime[1], ltime[2],
@ -46,10 +48,10 @@ class TTULauncher(LauncherBase):
sys.stderr = logErr sys.stderr = logErr
def getPlayToken(self): def getPlayToken(self):
return self.getValue('TTU_PLAYCOOKIE') return self.args.token
def getGameServer(self): def getGameServer(self):
return self.getValue('TTU_GAMESERVER') return self.args.server
def setPandaErrorCode(self, code): def setPandaErrorCode(self, code):
pass pass
@ -69,15 +71,9 @@ class TTULauncher(LauncherBase):
def getVerifyFiles(self): def getVerifyFiles(self):
return config.GetInt('launcher-verify', 0) return config.GetInt('launcher-verify', 0)
def getTestServerFlag(self):
return self.getValue('IS_TEST_SERVER', 0)
def isDownloadComplete(self): def isDownloadComplete(self):
return 1 return 1
def isTestServer(self):
return 0
def getPhaseComplete(self, phase): def getPhaseComplete(self, phase):
return 1 return 1

View file

@ -1,30 +0,0 @@
#!/usr/bin/env python2
import json
import os
import requests
from pandac.PandaModules import *
username = os.environ['ttiUsername']
password = os.environ['ttiPassword']
distribution = ConfigVariableString('distribution', 'dev').getValue()
accountServerEndpoint = ConfigVariableString(
'account-server-endpoint',
'https://toontownunited.com/api/').getValue()
request = requests.post(
accountServerEndpoint + 'login/',
data={'n': username, 'p': password, 'dist': distribution})
try:
response = json.loads(request.text)
except ValueError:
print "Couldn't verify account credentials."
else:
if not response['success']:
print response['reason']
else:
os.environ['TTU_PLAYCOOKIE'] = response['token']
# Start the game:
import toontown.toonbase.ClientStart