From a47f6a2e289fcc0cb4bb3856664457ecaf2c4caf Mon Sep 17 00:00:00 2001 From: John Cote Date: Mon, 28 Jun 2021 22:02:41 -0400 Subject: [PATCH] uberdog: Generate Toontown time manager, implement getLastLoggedInStr --- otp/login/AstronLoginManagerUD.py | 7 ++++++- toontown/parties/ToontownTimeManager.py | 3 +-- toontown/uberdog/ToontownUDRepository.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/otp/login/AstronLoginManagerUD.py b/otp/login/AstronLoginManagerUD.py index 44754b1..af41023 100644 --- a/otp/login/AstronLoginManagerUD.py +++ b/otp/login/AstronLoginManagerUD.py @@ -265,7 +265,12 @@ class LoginOperation(GameOperation): self._handleDone() def getLastLoggedInStr(self): - return '' # TODO + lastLoggedInStr = '' + if hasattr(self.loginManager.air, 'toontownTimeManager') and self.loginManager.air.toontownTimeManager: + lastLoggedInStr = datetime.strftime(self.loginManager.air.toontownTimeManager.getCurServerDateTime(), + self.loginManager.air.toontownTimeManager.formatStr) + + return lastLoggedInStr def getAccountCreationDate(self): accountCreationDate = self.account.get('CREATED', '') diff --git a/toontown/parties/ToontownTimeManager.py b/toontown/parties/ToontownTimeManager.py index 55cecc1..5b41a33 100644 --- a/toontown/parties/ToontownTimeManager.py +++ b/toontown/parties/ToontownTimeManager.py @@ -1,11 +1,10 @@ import time from datetime import datetime, timedelta import pytz -from direct.distributed import DistributedObject from direct.directnotify import DirectNotifyGlobal from toontown.toonbase import TTLocalizer -class ToontownTimeManager(DistributedObject.DistributedObject): +class ToontownTimeManager: notify = DirectNotifyGlobal.directNotify.newCategory('ToontownTimeManager') ClockFormat = '%I:%M:%S %p' formatStr = '%Y-%m-%d %H:%M:%S' diff --git a/toontown/uberdog/ToontownUDRepository.py b/toontown/uberdog/ToontownUDRepository.py index fddb242..98fa2bb 100644 --- a/toontown/uberdog/ToontownUDRepository.py +++ b/toontown/uberdog/ToontownUDRepository.py @@ -1,8 +1,11 @@ +import time + from direct.directnotify import DirectNotifyGlobal from otp.distributed.DistributedDirectoryAI import DistributedDirectoryAI from otp.distributed.OtpDoGlobals import * from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository +from toontown.parties.ToontownTimeManager import ToontownTimeManager # TODO: Remove Astron dependence. @@ -12,6 +15,7 @@ class ToontownUDRepository(ToontownInternalRepository): def __init__(self, baseChannel, serverId): ToontownInternalRepository.__init__(self, baseChannel, serverId, dcSuffix='UD') + self.toontownTimeManager = None self.astronLoginManager = None def handleConnected(self): @@ -22,12 +26,21 @@ class ToontownUDRepository(ToontownInternalRepository): rootObj = DistributedDirectoryAI(self) rootObj.generateWithRequiredAndId(self.getGameDoId(), 0, 0) + # Create our local objects. + self.notify.info('Creating local objects...') + self.createLocals() + # Create our global objects. self.notify.info('Creating global objects...') self.createGlobals() self.notify.info('UberDOG server is ready.') + def createLocals(self): + # Create our Toontown time manager... + self.toontownTimeManager = ToontownTimeManager(serverTimeUponLogin=int(time.time()), + globalClockRealTimeUponLogin=globalClock.getRealTime()) + def createGlobals(self): # Create our Astron login manager... self.astronLoginManager = self.generateGlobalObject(OTP_DO_ID_ASTRON_LOGIN_MANAGER, 'AstronLoginManager')