From 1c74fac58eba525b420b6d7ac7cc63a2034e75e8 Mon Sep 17 00:00:00 2001 From: Open Toontown Date: Sun, 17 Nov 2019 16:57:18 -0500 Subject: [PATCH] general: fix some more crashes --- libotp/settings/Settings.py | 24 +++++++++++++++++++ toontown/ai/NewsManagerAI.py | 15 ++++++++++++ toontown/ai/ToontownAIRepository.py | 6 +++++ .../distributed/ToontownClientRepository.py | 6 +++-- toontown/fishing/FishBrowser.py | 8 +++---- toontown/fishing/FishPanel.py | 4 ++-- toontown/fishing/FishPicker.py | 6 ++--- toontown/shtiker/DirectNewsFrame.py | 2 +- toontown/shtiker/IssueFrame.py | 1 - toontown/shtiker/MapPage.py | 3 ++- toontown/shtiker/OptionsPage.py | 14 +++++++---- toontown/toon/DistributedToon.py | 1 + toontown/town/Street.py | 1 + 13 files changed, 72 insertions(+), 19 deletions(-) diff --git a/libotp/settings/Settings.py b/libotp/settings/Settings.py index 8edf12c..dd5a29f 100644 --- a/libotp/settings/Settings.py +++ b/libotp/settings/Settings.py @@ -7,18 +7,34 @@ class Settings: def readSettings(): pass # todo + @staticmethod + def writeSettings(): + pass # lol not yet + @staticmethod def getWindowedMode(): return 1 + @staticmethod + def setMusic(_): + pass + @staticmethod def getMusic(): return 1 + @staticmethod + def setSfx(_): + pass + @staticmethod def getSfx(): return 1 + @staticmethod + def setToonChatSounds(_): + pass + @staticmethod def getToonChatSounds(): return 1 @@ -43,10 +59,18 @@ class Settings: def doSavedSettingsExist(): return 0 + @staticmethod + def setAcceptingNewFriends(_): + pass + @staticmethod def getAcceptingNewFriends(): return 1 + @staticmethod + def setAcceptingNonFriendWhispers(_): + pass + @staticmethod def getAcceptingNonFriendWhispers(): return 1 diff --git a/toontown/ai/NewsManagerAI.py b/toontown/ai/NewsManagerAI.py index 74618c6..67e5d56 100644 --- a/toontown/ai/NewsManagerAI.py +++ b/toontown/ai/NewsManagerAI.py @@ -3,3 +3,18 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI class NewsManagerAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('NewsManagerAI') + + def getWeeklyCalendarHolidays(self): + return [] + + def getYearlyCalendarHolidays(self): + return [] + + def getOncelyCalendarHolidays(self): + return [] + + def getRelativelyCalendarHolidays(self): + return [] + + def getMultipleStartHolidays(self): + return [] diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 0551fb8..63d02fa 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -4,6 +4,7 @@ from otp.distributed.OtpDoGlobals import * from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository from toontown.distributed.ToontownDistrictAI import ToontownDistrictAI from toontown.ai.HolidayManagerAI import HolidayManagerAI +from toontown.ai.NewsManagerAI import NewsManagerAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI from toontown.uberdog.DistributedInGameNewsMgrAI import DistributedInGameNewsMgrAI @@ -17,6 +18,7 @@ class ToontownAIRepository(ToontownInternalRepository): self.districtId = None self.district = None self.holidayManager = None + self.newsManager = None self.zoneDataStore = None self.inGameNewsMgr = None self.catalogManager = None @@ -59,6 +61,10 @@ class ToontownAIRepository(ToontownInternalRepository): Creates "global" (distributed) objects. """ + # Generate our news manager... + self.newsManager = NewsManagerAI(self) + self.newsManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + # Generate our in-game news manager... self.inGameNewsMgr = DistributedInGameNewsMgrAI(self) self.inGameNewsMgr.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) diff --git a/toontown/distributed/ToontownClientRepository.py b/toontown/distributed/ToontownClientRepository.py index b92ccfc..215d7ed 100644 --- a/toontown/distributed/ToontownClientRepository.py +++ b/toontown/distributed/ToontownClientRepository.py @@ -524,7 +524,8 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): self.handlerArgs = {'hoodId': hoodId, 'zoneId': zoneId, 'avId': avId} - self.handler = self.handleTutorialQuestion + if not self.astronSupport: + self.handler = self.handleTutorialQuestion self.__requestSkipTutorial(hoodId, zoneId, avId) def __requestSkipTutorial(self, hoodId, zoneId, avId): @@ -551,7 +552,8 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): return def enterTutorialQuestion(self, hoodId, zoneId, avId): - self.handler = self.handleTutorialQuestion + if not self.astronSupport: + self.handler = self.handleTutorialQuestion self.__requestTutorial(hoodId, zoneId, avId) def handleTutorialQuestion(self, msgType, di): diff --git a/toontown/fishing/FishBrowser.py b/toontown/fishing/FishBrowser.py index 2d14372..71e65ea 100644 --- a/toontown/fishing/FishBrowser.py +++ b/toontown/fishing/FishBrowser.py @@ -10,9 +10,9 @@ class FishBrowser(DirectScrolledList): notify = DirectNotifyGlobal.directNotify.newCategory('FishBrowser') def __init__(self, parent = aspect2d, **kw): - self.parent = parent + self._parent = parent gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') - optiondefs = (('parent', self.parent, None), + optiondefs = (('parent', self._parent, None), ('relief', None, None), ('incButton_image', (gui.find('**/FndsLst_ScrollUp'), gui.find('**/FndsLst_ScrollDN'), @@ -43,14 +43,14 @@ class FishBrowser(DirectScrolledList): def destroy(self): DirectScrolledList.destroy(self) - self.parent = None + self._parent = None return def update(self): pass def show(self): - if not self.parent.isHidden(): + if not self._parent.isHidden(): self['items'][self.index].show() DirectScrolledList.show(self) diff --git a/toontown/fishing/FishPanel.py b/toontown/fishing/FishPanel.py index c2a31a1..3df3478 100644 --- a/toontown/fishing/FishPanel.py +++ b/toontown/fishing/FishPanel.py @@ -27,7 +27,7 @@ class FishPanel(DirectFrame): self.initialiseoptions(FishPanel) self.doneEvent = doneEvent self.fish = fish - self.parent = parent + self._parent = parent self.photo = None return @@ -37,7 +37,7 @@ class FishPanel(DirectFrame): self.photo = None self.fish = None DirectFrame.destroy(self) - self.parent = None + self._parent = None return def load(self): diff --git a/toontown/fishing/FishPicker.py b/toontown/fishing/FishPicker.py index ae1a3e5..9396f9c 100644 --- a/toontown/fishing/FishPicker.py +++ b/toontown/fishing/FishPicker.py @@ -10,10 +10,10 @@ class FishPicker(DirectScrolledList): def __init__(self, parent = aspect2d, **kw): self.fishList = [] - self.parent = parent + self._parent = parent self.shown = 0 gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') - optiondefs = (('parent', self.parent, None), + optiondefs = (('parent', self._parent, None), ('relief', None, None), ('incButton_image', (gui.find('**/FndsLst_ScrollUp'), gui.find('**/FndsLst_ScrollDN'), @@ -58,7 +58,7 @@ class FishPicker(DirectScrolledList): def destroy(self): DirectScrolledList.destroy(self) - self.parent = None + self._parent = None self.fishList = [] self.fishPanel = None return diff --git a/toontown/shtiker/DirectNewsFrame.py b/toontown/shtiker/DirectNewsFrame.py index 612c246..088b009 100644 --- a/toontown/shtiker/DirectNewsFrame.py +++ b/toontown/shtiker/DirectNewsFrame.py @@ -103,7 +103,7 @@ class DirectNewsFrame(DirectObject.DirectObject): newsDirAsFile = vfs.getFile(Filename(newsDir)) fileList = newsDirAsFile.scanDirectory() fileNames = fileList.getFiles() - self.notify.debug('filenames=%s' % fileNames) + self.notify.debug('filenames=%s' % str(fileNames)) homeFileNames = set([]) for name in fileNames: self.notify.debug('processing %s' % name) diff --git a/toontown/shtiker/IssueFrame.py b/toontown/shtiker/IssueFrame.py index 1e80b3d..e21a878 100644 --- a/toontown/shtiker/IssueFrame.py +++ b/toontown/shtiker/IssueFrame.py @@ -35,7 +35,6 @@ class IssueFrame(DirectFrame): DirectFrame.__init__(self, frameColor=(1, 1, 1, 0), frameSize=self.FrameDimensions, relief=DGG.FLAT, parent=parent) self.hide() self.accept('newsSnapshot', self.doSnapshot) - self.parent = parent self.newsDir = newsDir self.dateStr = dateStr self.myIssueIndex = myIssueIndex diff --git a/toontown/shtiker/MapPage.py b/toontown/shtiker/MapPage.py index eae2a0c..e022839 100644 --- a/toontown/shtiker/MapPage.py +++ b/toontown/shtiker/MapPage.py @@ -1,6 +1,7 @@ import ShtikerPage from toontown.toonbase import ToontownGlobals from direct.showbase import PythonUtil +from otp.otpbase import PythonUtil as OTPPythonUtil from toontown.hood import ZoneUtil from direct.gui.DirectGui import * from pandac.PandaModules import * @@ -239,7 +240,7 @@ class MapPage(ShtikerPage.ShtikerPage): messenger.send(self.doneEvent) def __hoverCallback(self, inside, hoodIndex, pos): - alpha = PythonUtil.choice(inside, 0.25, 1.0) + alpha = OTPPythonUtil.choice(inside, 0.25, 1.0) try: clouds = self.clouds[hoodIndex] except ValueError: diff --git a/toontown/shtiker/OptionsPage.py b/toontown/shtiker/OptionsPage.py index c4da4c3..cc6f611 100644 --- a/toontown/shtiker/OptionsPage.py +++ b/toontown/shtiker/OptionsPage.py @@ -128,12 +128,14 @@ class OptionsTabPage(DirectFrame): 'DirectX8': Settings.DX8} def __init__(self, parent = aspect2d): + self._parent = parent self.currentSizeIndex = None - DirectFrame.__init__(self, parent=parent, relief=None, pos=(0.0, 0.0, 0.0), scale=(1.0, 1.0, 1.0)) + DirectFrame.__init__(self, parent=self._parent, relief=None, pos=(0.0, 0.0, 0.0), scale=(1.0, 1.0, 1.0)) self.load() return def destroy(self): + self._parent = None DirectFrame.destroy(self) return @@ -206,7 +208,7 @@ class OptionsTabPage(DirectFrame): self.speedChatStyleText.enter() self.speedChatStyleIndex = base.localAvatar.getSpeedChatStyleIndex() self.updateSpeedChatStyle() - if self.parent.book.safeMode: + if self._parent.book.safeMode: self.exitButton.hide() else: self.exitButton.show() @@ -453,7 +455,7 @@ class OptionsTabPage(DirectFrame): def __handleExitShowWithConfirm(self): self.confirm = TTDialog.TTGlobalDialog(doneEvent='confirmDone', message=TTLocalizer.OptionsPageExitConfirm, style=TTDialog.TwoChoice) self.confirm.show() - self.parent.doneStatus = {'mode': 'exit', + self._parent.doneStatus = {'mode': 'exit', 'exitTo': 'closeShard'} self.accept('confirmDone', self.__handleConfirm) @@ -464,18 +466,20 @@ class OptionsTabPage(DirectFrame): del self.confirm if status == 'ok': base.cr._userLoggingOut = True - messenger.send(self.parent.doneEvent) + messenger.send(self._parent.doneEvent) class CodesTabPage(DirectFrame): notify = DirectNotifyGlobal.directNotify.newCategory('CodesTabPage') def __init__(self, parent = aspect2d): - DirectFrame.__init__(self, parent=parent, relief=None, pos=(0.0, 0.0, 0.0), scale=(1.0, 1.0, 1.0)) + self._parent = parent + DirectFrame.__init__(self, parent=self._parent, relief=None, pos=(0.0, 0.0, 0.0), scale=(1.0, 1.0, 1.0)) self.load() return def destroy(self): + self._parent = None DirectFrame.destroy(self) return diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 09d077c..22b3ce4 100644 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libotp import * from toontown.toonbase.ToontownGlobals import * from direct.distributed.ClockDelta import * from direct.interval.IntervalGlobal import * diff --git a/toontown/town/Street.py b/toontown/town/Street.py index 7ba7d30..b9879be 100644 --- a/toontown/town/Street.py +++ b/toontown/town/Street.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libotp import * from toontown.battle.BattleProps import * from toontown.battle.BattleSounds import * from toontown.distributed.ToontownMsgTypes import *