diff --git a/astron/dclass/toon.dc b/astron/dclass/toon.dc index 1e5ae21b..801bf693 100644 --- a/astron/dclass/toon.dc +++ b/astron/dclass/toon.dc @@ -77,6 +77,7 @@ from toontown.shtiker import NewbiePurchaseManager/AI from toontown.safezone import SafeZoneManager/AI from toontown.tutorial import TutorialManager/AI from toontown.catalog import CatalogManager/AI +from toontown.catalog import AccountDate/AI from toontown.safezone import DistributedTreasure/AI from toontown.coghq import DistributedCashbotBossTreasure/AI from toontown.building import DistributedTrophyMgr/AI @@ -1529,6 +1530,11 @@ dclass CatalogManager : DistributedObject { startCatalog() airecv clsend; }; +dclass AccountDate : DistributedObject { + requestDate() airecv clsend; + requestDateResult(string); +}; + dclass DistributedMyTest : DistributedObject { setMyTest(uint16) broadcast; }; diff --git a/otp/distributed/DCClassImports.py b/otp/distributed/DCClassImports.py index 95bbd8d3..0ef5c0e6 100644 --- a/otp/distributed/DCClassImports.py +++ b/otp/distributed/DCClassImports.py @@ -2,7 +2,7 @@ from pandac.PandaModules import * -hashVal = 2495436342L +hashVal = 2127944587 from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot @@ -33,7 +33,7 @@ from toontown.fishing import DistributedFishingPond, DistributedFishingTarget, D from toontown.minigame import DistributedMinigame, DistributedMinigameTemplate, DistributedRaceGame, DistributedCannonGame, DistributedPhotoGame, DistributedPatternGame, DistributedRingGame, DistributedTagGame, DistributedMazeGame, DistributedTugOfWarGame, DistributedCatchGame, DistributedDivingGame, DistributedTargetGame, DistributedTravelGame, DistributedPairingGame, DistributedVineGame, DistributedIceGame, DistributedCogThiefGame, DistributedTwoDGame from toontown.racing import DistributedVehicle, DistributedStartingBlock, DistributedRace, DistributedKartPad, DistributedRacePad, DistributedViewPad, DistributedStartingBlock, DistributedLeaderBoard, DistributedGag, DistributedProjectile from toontown.distributed.NonRepeatableRandomSourceUD import NonRepeatableRandomSourceUD -from toontown.catalog import CatalogManager +from toontown.catalog import CatalogManager, AccountDate from toontown.ai.DistributedHydrantZeroMgr import DistributedHydrantZeroMgr from toontown.rpc.AwardManager import AwardManager from toontown.parties import DistributedParty, DistributedPartyActivity, DistributedPartyTeamActivity, DistributedPartyCannon, DistributedPartyCannonActivity, DistributedPartyCatchActivity, DistributedPartyWinterCatchActivity, DistributedPartyCogActivity, DistributedPartyWinterCogActivity, DistributedPartyFireworksActivity, DistributedPartyDanceActivityBase, DistributedPartyDanceActivity, DistributedPartyDance20Activity, DistributedPartyValentineDanceActivity, DistributedPartyValentineDance20Activity, DistributedPartyTrampolineActivity, DistributedPartyValentineTrampolineActivity, DistributedPartyVictoryTrampolineActivity, DistributedPartyWinterTrampolineActivity, DistributedPartyTugOfWarActivity, DistributedPartyJukeboxActivityBase, DistributedPartyJukeboxActivity, DistributedPartyJukebox40Activity, DistributedPartyValentineJukeboxActivity, DistributedPartyValentineJukebox40Activity diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index b06bf018..35c96eff 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -16,6 +16,7 @@ from toontown.ai.HolidayManagerAI import HolidayManagerAI from toontown.ai.NewsManagerAI import NewsManagerAI from toontown.ai.QuestManagerAI import QuestManagerAI from toontown.ai import BankManagerAI +from toontown.catalog.AccountDateAI import AccountDateAI from toontown.building.DistributedBuildingQueryMgrAI import DistributedBuildingQueryMgrAI from toontown.building.DistributedTrophyMgrAI import DistributedTrophyMgrAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI @@ -119,6 +120,8 @@ class ToontownAIRepository(ToontownInternalRepository): self.holidayManager = HolidayManagerAI(self) self.codeRedemptionMgr = TTCodeRedemptionMgrAI(self) self.codeRedemptionMgr.generateWithRequired(2) + self.accountDateMgr = AccountDateAI(self) + self.accountDateMgr.generateWithRequired(2) self.buildingQueryMgr = DistributedBuildingQueryMgrAI(self) self.buildingQueryMgr.generateWithRequired(2) self.groupManager.generateWithRequired(2) diff --git a/toontown/catalog/AccountDate.py b/toontown/catalog/AccountDate.py new file mode 100644 index 00000000..610227e1 --- /dev/null +++ b/toontown/catalog/AccountDate.py @@ -0,0 +1,39 @@ +from direct.distributed.DistributedObject import DistributedObject +from direct.directnotify.DirectNotifyGlobal import directNotify +from datetime import datetime + +class AccountDate(DistributedObject): + neverDisable = 1 + notify = directNotify.newCategory('AccountDate') + + def __init__(self, cr): + DistributedObject.__init__(self, cr) + self.accountDays = 0 + + def announceGenerate(self): + DistributedObject.announceGenerate(self) + base.cr.accountDateMgr = self + taskMgr.doMethodLater(10, self.requestDate, 'request-task') + + def delete(self): + if hasattr(base.cr, 'accountDateMgr'): + if base.cr.accountDateMgr is self: + del base.cr.accountDateMgr + DistributedObject.delete(self) + + def getAccountDays(self): + return self.accountDays + + def requestDate(self, task=None): + self.sendUpdate('requestDate') + + if task is not None: + return task.done + + def requestDateResult(self, result): + if result is None: + notify.warning('Invalid response from server.') + self.accountDays = 0 + else: + date = datetime.strptime(result, "%a %b %d %H:%M:%S %Y") + self.accountDays = (datetime.now() - date).days \ No newline at end of file diff --git a/toontown/catalog/AccountDateAI.py b/toontown/catalog/AccountDateAI.py new file mode 100644 index 00000000..654048ea --- /dev/null +++ b/toontown/catalog/AccountDateAI.py @@ -0,0 +1,23 @@ +from direct.directnotify import DirectNotifyGlobal +from direct.distributed.DistributedObjectAI import DistributedObjectAI + +class AccountDateAI(DistributedObjectAI): + notify = DirectNotifyGlobal.directNotify.newCategory("AccountDateAI") + + def announceGenerate(self): + DistributedObjectAI.announceGenerate(self) + + def requestDate(self): + avId = self.air.getAvatarIdFromSender() + av = self.air.doId2do.get(avId) + + if not av: + return + + def callback(dclass, fields): + if dclass is not None and dclass == self.air.dclassesByName['AccountAI'] and fields.has_key('CREATED'): + self.sendUpdateToAvatarId(avId, 'requestDateResult', [fields.get('CREATED')]) + else: + self.sendUpdateToAvatarId(avId, 'requestDateResult', [None]) + + self.air.dbInterface.queryObject(self.air.dbId, av.DISLid, callback) \ No newline at end of file diff --git a/toontown/toon/LocalToon.py b/toontown/toon/LocalToon.py index da9c89b8..980b8797 100644 --- a/toontown/toon/LocalToon.py +++ b/toontown/toon/LocalToon.py @@ -1852,14 +1852,8 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): self.inventory.updateTotalPropsText() def getAccountDays(self): - days = 0 - defaultDays = base.cr.config.GetInt('account-days', -1) - if defaultDays >= 0: - days = defaultDays - elif hasattr(base.cr, 'accountDays'): - days = base.cr.accountDays - return days - + return base.cr.accountDateMgr.getAccountDays() + def hasActiveBoardingGroup(self): if hasattr(localAvatar, 'boardingParty') and localAvatar.boardingParty: return localAvatar.boardingParty.hasActiveGroup(localAvatar.doId)