From 8df97582b28d13f069d445f28401bab78ca6d861 Mon Sep 17 00:00:00 2001 From: Open Toontown <57279094+opentoontown@users.noreply.github.com> Date: Wed, 19 Jan 2022 14:31:52 -0500 Subject: [PATCH] more DeprecationWarning removal --- otp/avatar/DistributedPlayer.py | 16 ++++++---------- otp/avatar/LocalAvatar.py | 23 ++++++++--------------- otp/chat/TalkAssistant.py | 6 +++--- otp/login/LoginScreen.py | 11 +++++------ toontown/battle/BattleBase.py | 8 ++------ toontown/battle/BattleProps.py | 4 ++-- toontown/toon/NPCToons.py | 8 +++----- toontown/toon/Toon.py | 32 ++++++++++++++------------------ toontown/toon/ToonHead.py | 19 +++++++++---------- 9 files changed, 52 insertions(+), 75 deletions(-) diff --git a/otp/avatar/DistributedPlayer.py b/otp/avatar/DistributedPlayer.py index dbfa9c5..b7f6a5c 100644 --- a/otp/avatar/DistributedPlayer.py +++ b/otp/avatar/DistributedPlayer.py @@ -1,20 +1,16 @@ -from pandac.PandaModules import * +from panda3d.core import * from panda3d.otp import WhisperPopup from panda3d.otp import CFQuicktalker, CFPageButton, CFQuitButton, CFSpeech, CFThought, CFTimeout from otp.chat import ChatGarbler -import string -from direct.task import Task from otp.otpbase import OTPLocalizer from otp.speedchat import SCDecoders -from direct.showbase import PythonUtil from otp.avatar import DistributedAvatar -import time from otp.avatar import Avatar, PlayerBase from otp.chat import TalkAssistant from otp.otpbase import OTPGlobals from otp.avatar.Avatar import teleportNotify from otp.distributed.TelemetryLimited import TelemetryLimited -if base.config.GetBool('want-chatfilter-hacks', 0): +if ConfigVariableBool('want-chatfilter-hacks', 0).value: from otp.switchboard import badwordpy import os badwordpy.init(os.environ.get('OTP') + '\\src\\switchboard\\', '') @@ -44,7 +40,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa self.DISLid = 0 self.accessLevel = 0 self.autoRun = 0 - self.whiteListEnabled = base.config.GetBool('whitelist-chat-enabled', 1) + self.whiteListEnabled = ConfigVariableBool('whitelist-chat-enabled', 1).value return @@ -224,8 +220,8 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa if self.cr.wantMagicWords and len(chatString) > 0 and chatString[0] == '~': messenger.send('magicWord', [chatString]) else: - if base.config.GetBool('want-chatfilter-hacks', 0): - if base.config.GetBool('want-chatfilter-drop-offending', 0): + if ConfigVariableBool('want-chatfilter-hacks', 0).value: + if ConfigVariableBool('want-chatfilter-drop-offending', 0).value: if badwordpy.test(chatString): return else: @@ -351,7 +347,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa teleportNotify.debug('party is ending') self.d_teleportResponse(self.doId, 0, 0, 0, 0, sendToId=requesterId) return - if self.__teleportAvailable and not self.ghostMode and base.config.GetBool('can-be-teleported-to', 1): + if self.__teleportAvailable and not self.ghostMode and ConfigVariableBool('can-be-teleported-to', 1).value: teleportNotify.debug('teleport initiation successful') self.setSystemMessage(requesterId, OTPLocalizer.WhisperComingToVisit % avatar.getName()) messenger.send('teleportQuery', [avatar, self]) diff --git a/otp/avatar/LocalAvatar.py b/otp/avatar/LocalAvatar.py index 31cfd45..2b689cc 100644 --- a/otp/avatar/LocalAvatar.py +++ b/otp/avatar/LocalAvatar.py @@ -1,40 +1,33 @@ -from pandac.PandaModules import * +from panda3d.core import * from panda3d.otp import Nametag, WhisperPopup from direct.gui.DirectGui import * from direct.showbase.PythonUtil import * from direct.interval.IntervalGlobal import * from direct.showbase.InputStateGlobal import inputState -from pandac.PandaModules import * -from . import Avatar from direct.controls import ControlManager from . import DistributedAvatar from direct.task import Task -from . import PositionExaminer from otp.otpbase import OTPGlobals -from otp.otpbase import OTPRender import math -import string import random from direct.directnotify import DirectNotifyGlobal from direct.distributed import DistributedSmoothNode -from direct.gui import DirectGuiGlobals from otp.otpbase import OTPLocalizer from direct.controls.GhostWalker import GhostWalker from direct.controls.GravityWalker import GravityWalker from direct.controls.ObserverWalker import ObserverWalker -from direct.controls.PhysicsWalker import PhysicsWalker from direct.controls.SwimWalker import SwimWalker from direct.controls.TwoDWalker import TwoDWalker class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.DistributedSmoothNode): notify = DirectNotifyGlobal.directNotify.newCategory('LocalAvatar') - wantDevCameraPositions = base.config.GetBool('want-dev-camera-positions', 0) - wantMouse = base.config.GetBool('want-mouse', 0) - sleepTimeout = base.config.GetInt('sleep-timeout', 120) - swimTimeout = base.config.GetInt('afk-timeout', 600) - __enableMarkerPlacement = base.config.GetBool('place-markers', 0) - acceptingNewFriends = base.config.GetBool('accepting-new-friends', 1) - acceptingNonFriendWhispers = base.config.GetBool('accepting-non-friend-whispers', 0) + wantDevCameraPositions = ConfigVariableBool('want-dev-camera-positions', 0).value + wantMouse = ConfigVariableBool('want-mouse', 0).value + sleepTimeout = ConfigVariableInt('sleep-timeout', 120).value + swimTimeout = ConfigVariableInt('afk-timeout', 600).value + __enableMarkerPlacement = ConfigVariableBool('place-markers', 0).value + acceptingNewFriends = ConfigVariableBool('accepting-new-friends', 1).value + acceptingNonFriendWhispers = ConfigVariableBool('accepting-non-friend-whispers', 0).value def __init__(self, cr, chatMgr, talkAssistant = None, passMessagesThrough = False): try: diff --git a/otp/chat/TalkAssistant.py b/otp/chat/TalkAssistant.py index 2118a8e..66464d9 100644 --- a/otp/chat/TalkAssistant.py +++ b/otp/chat/TalkAssistant.py @@ -4,7 +4,7 @@ from otp.otpbase import OTPLocalizer from direct.directnotify import DirectNotifyGlobal from otp.otpbase import OTPGlobals from otp.speedchat import SCDecoders -from pandac.PandaModules import * +from panda3d.core import * from otp.chat.TalkMessage import TalkMessage from otp.chat.TalkHandle import TalkHandle import time @@ -16,7 +16,7 @@ ThoughtPrefix = '.' class TalkAssistant(DirectObject.DirectObject): ExecNamespace = None notify = DirectNotifyGlobal.directNotify.newCategory('TalkAssistant') - execChat = base.config.GetBool('exec-chat', 0) + execChat = ConfigVariableBool('exec-chat', 0).value def __init__(self): self.logWhispers = 1 @@ -25,7 +25,7 @@ class TalkAssistant(DirectObject.DirectObject): self.zeroTimeDay = time.time() self.zeroTimeGame = globalClock.getRealTime() self.floodThreshold = 10.0 - self.useWhiteListFilter = base.config.GetBool('white-list-filter-openchat', 0) + self.useWhiteListFilter = ConfigVariableBool('white-list-filter-openchat', 0).value self.lastWhisperDoId = None self.lastWhisperPlayerId = None self.lastWhisper = None diff --git a/otp/login/LoginScreen.py b/otp/login/LoginScreen.py index d0aa927..b13be96 100644 --- a/otp/login/LoginScreen.py +++ b/otp/login/LoginScreen.py @@ -2,14 +2,13 @@ import json import os import time from datetime import datetime -from pandac.PandaModules import * +from panda3d.core import * from direct.distributed.MsgTypes import * from direct.gui.DirectGui import * from direct.fsm import StateData from direct.fsm import ClassicFSM from direct.fsm import State from direct.directnotify import DirectNotifyGlobal -from direct.task import Task from otp.otpgui import OTPDialog from otp.otpbase import OTPLocalizer from otp.otpbase import OTPGlobals @@ -17,8 +16,8 @@ from otp.uberdog.AccountDetailRecord import AccountDetailRecord, SubDetailRecord from . import GuiScreen class LoginScreen(StateData.StateData, GuiScreen.GuiScreen): - AutoLoginName = base.config.GetString('%s-auto-login%s' % (game.name, os.getenv('otp_client', '')), '') - AutoLoginPassword = base.config.GetString('%s-auto-password%s' % (game.name, os.getenv('otp_client', '')), '') + AutoLoginName = ConfigVariableString('%s-auto-login%s' % (game.name, os.getenv('otp_client', '')), '').value + AutoLoginPassword = ConfigVariableString('%s-auto-password%s' % (game.name, os.getenv('otp_client', '')), '').value notify = DirectNotifyGlobal.directNotify.newCategory('LoginScreen') ActiveEntryColor = Vec4(1, 1, 1, 1) InactiveEntryColor = Vec4(0.8, 0.8, 0.8, 1) @@ -439,11 +438,11 @@ class LoginScreen(StateData.StateData, GuiScreen.GuiScreen): self.cr.whiteListChatEnabled = 1 else: self.cr.whiteListChatEnabled = 0 - self.lastLoggedInStr = base.config.GetString('last-logged-in', '') + self.lastLoggedInStr = ConfigVariableString('last-logged-in', '').value self.cr.lastLoggedIn = datetime.now() if hasattr(self.cr, 'toontownTimeManager'): self.cr.lastLoggedIn = self.cr.toontownTimeManager.convertStrToToontownTime(self.lastLoggedInStr) - self.cr.withParentAccount = base.config.GetBool('dev-with-parent-account', 0) + self.cr.withParentAccount = ConfigVariableBool('dev-with-parent-account', 0).value self.notify.info('Login response return code %s' % returnCode) if returnCode == 0: self.__handleLoginSuccess() diff --git a/toontown/battle/BattleBase.py b/toontown/battle/BattleBase.py index 37f883a..eb08e4f 100644 --- a/toontown/battle/BattleBase.py +++ b/toontown/battle/BattleBase.py @@ -1,7 +1,6 @@ -from pandac.PandaModules import * +from panda3d.core import * from toontown.toonbase.ToontownBattleGlobals import * from direct.task.Timer import * -import math import functools from direct.directnotify import DirectNotifyGlobal from toontown.toon import NPCToons @@ -58,10 +57,7 @@ TOON_FIRE_SUIT_DELAY = 1.0 REWARD_TIMEOUT = 120 FLOOR_REWARD_TIMEOUT = 4 BUILDING_REWARD_TIMEOUT = 300 -try: - CLIENT_INPUT_TIMEOUT = base.config.GetFloat('battle-input-timeout', TTLocalizer.BBbattleInputTimeout) -except: - CLIENT_INPUT_TIMEOUT = simbase.config.GetFloat('battle-input-timeout', TTLocalizer.BBbattleInputTimeout) +CLIENT_INPUT_TIMEOUT = ConfigVariableDouble('battle-input-timeout', TTLocalizer.BBbattleInputTimeout).value def levelAffectsGroup(track, level): return attackAffectsGroup(track, level) diff --git a/toontown/battle/BattleProps.py b/toontown/battle/BattleProps.py index d717b37..d4033fb 100644 --- a/toontown/battle/BattleProps.py +++ b/toontown/battle/BattleProps.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * from direct.actor import Actor from direct.directnotify import DirectNotifyGlobal from otp.otpbase import OTPGlobals @@ -237,7 +237,7 @@ class PropPool: self.propCache = [] self.propStrings = {} self.propTypes = {} - self.maxPoolSize = base.config.GetInt('prop-pool-size', 8) + self.maxPoolSize = ConfigVariableInt('prop-pool-size', 8).value for p in Props: phase = p[0] propName = p[1] diff --git a/toontown/toon/NPCToons.py b/toontown/toon/NPCToons.py index f56e0fc..eb53801 100644 --- a/toontown/toon/NPCToons.py +++ b/toontown/toon/NPCToons.py @@ -1,13 +1,11 @@ -from pandac.PandaModules import * +from panda3d.core import * from panda3d.otp import * from toontown.toonbase import ToontownGlobals -import random from toontown.hood import ZoneUtil from . import ToonDNA from toontown.toonbase import TTLocalizer from toontown.toonbase import ToontownBattleGlobals -import sys, os -import string +import os QUEST_MOVIE_CLEAR = 0 QUEST_MOVIE_REJECT = 1 QUEST_MOVIE_COMPLETE = 2 @@ -11488,7 +11486,7 @@ try: except: config = base.config -if config.GetBool('want-new-toonhall', 1): +if ConfigVariableBool('want-new-toonhall', 1).value: NPCToonDict[2001] = (2513, lnames[2001], ('dss', diff --git a/toontown/toon/Toon.py b/toontown/toon/Toon.py index ea017e2..28d2c6a 100644 --- a/toontown/toon/Toon.py +++ b/toontown/toon/Toon.py @@ -4,25 +4,21 @@ from . import ToonDNA from direct.task.Task import Task from toontown.suit import SuitDNA from direct.actor import Actor -import string from .ToonHead import * -from pandac.PandaModules import * +from panda3d.core import * from panda3d.otp import * from direct.interval.IntervalGlobal import * from direct.directnotify import DirectNotifyGlobal from toontown.toonbase import ToontownGlobals from otp.otpbase import OTPLocalizer from toontown.toonbase import TTLocalizer -import random from toontown.effects import Wake -from . import TTEmote from otp.avatar import Emote from . import Motion from toontown.hood import ZoneUtil from toontown.battle import SuitBattleGlobals from otp.otpbase import OTPGlobals from toontown.effects import DustCloud -from direct.showbase.PythonUtil import Functor from toontown.distributed import DelayDelete from . import AccessoryGlobals import importlib @@ -164,7 +160,7 @@ Phase6AnimList = (('headdown-putt', 'headdown-putt'), Phase9AnimList = (('push', 'push'),) Phase10AnimList = (('leverReach', 'leverReach'), ('leverPull', 'leverPull'), ('leverNeutral', 'leverNeutral')) Phase12AnimList = () -if not base.config.GetBool('want-new-anims', 1): +if not ConfigVariableBool('want-new-anims', 1).value: LegDict = {'s': '/models/char/dogSS_Shorts-legs-', 'm': '/models/char/dogMM_Shorts-legs-', 'l': '/models/char/dogLL_Shorts-legs-'} @@ -193,7 +189,7 @@ else: def loadModels(): global Preloaded - preloadAvatars = base.config.GetBool('preload-avatars', 0) + preloadAvatars = ConfigVariableBool('preload-avatars', 0).value if preloadAvatars: def loadTex(path): @@ -461,7 +457,7 @@ def unloadDialog(): class Toon(Avatar.Avatar, ToonHead): notify = DirectNotifyGlobal.directNotify.newCategory('Toon') - afkTimeout = base.config.GetInt('afk-timeout', 600) + afkTimeout = ConfigVariableInt('afk-timeout', 600).value def __init__(self): try: @@ -648,7 +644,7 @@ class Toon(Avatar.Avatar, ToonHead): def parentToonParts(self): if self.hasLOD(): for lodName in self.getLODNames(): - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.getPart('torso', lodName).find('**/def_head').isEmpty(): self.attach('head', 'torso', 'def_head', lodName) else: @@ -675,12 +671,12 @@ class Toon(Avatar.Avatar, ToonHead): def setLODs(self): self.setLODNode() - levelOneIn = base.config.GetInt('lod1-in', 20) - levelOneOut = base.config.GetInt('lod1-out', 0) - levelTwoIn = base.config.GetInt('lod2-in', 80) - levelTwoOut = base.config.GetInt('lod2-out', 20) - levelThreeIn = base.config.GetInt('lod3-in', 280) - levelThreeOut = base.config.GetInt('lod3-out', 80) + levelOneIn = ConfigVariableInt('lod1-in', 20).value + levelOneOut = ConfigVariableInt('lod1-out', 0).value + levelTwoIn = ConfigVariableInt('lod2-in', 80).value + levelTwoOut = ConfigVariableInt('lod2-out', 20).value + levelThreeIn = ConfigVariableInt('lod3-in', 280).value + levelThreeOut = ConfigVariableInt('lod3-out', 80).value self.addLOD(1000, levelOneIn, levelOneOut) self.addLOD(500, levelTwoIn, levelTwoOut) self.addLOD(250, levelThreeIn, levelThreeOut) @@ -705,14 +701,14 @@ class Toon(Avatar.Avatar, ToonHead): self.leftHand = None for lodName in self.getLODNames(): hand = self.getPart('torso', lodName).find('**/joint_Rhold') - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.getPart('torso', lodName).find('**/def_joint_right_hold').isEmpty(): hand = self.getPart('torso', lodName).find('**/def_joint_right_hold') else: hand = self.getPart('torso', lodName).find('**/joint_Rhold') self.rightHands.append(hand) rightHand = rightHand.instanceTo(hand) - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.getPart('torso', lodName).find('**/def_joint_left_hold').isEmpty(): hand = self.getPart('torso', lodName).find('**/def_joint_left_hold') else: @@ -2044,7 +2040,7 @@ class Toon(Avatar.Avatar, ToonHead): self.startLookAround() self.openEyes() self.startBlink() - if config.GetBool('stuck-sleep-fix', 1): + if ConfigVariableBool('stuck-sleep-fix', 1).value: doClear = SLEEP_STRING in (self.nametag.getChat(), self.nametag.getStompText()) else: doClear = self.nametag.getChat() == SLEEP_STRING diff --git a/toontown/toon/ToonHead.py b/toontown/toon/ToonHead.py index 7a0769b..cabe008 100644 --- a/toontown/toon/ToonHead.py +++ b/toontown/toon/ToonHead.py @@ -1,14 +1,13 @@ from direct.actor import Actor from direct.task import Task from toontown.toonbase import ToontownGlobals -import string import random -from pandac.PandaModules import * +from panda3d.core import * from direct.interval.IntervalGlobal import * from direct.fsm.ClassicFSM import ClassicFSM from direct.fsm.State import State from direct.directnotify import DirectNotifyGlobal -if not base.config.GetBool('want-new-anims', 1): +if not ConfigVariableBool('want-new-anims', 1).value: HeadDict = {'dls': '/models/char/dogMM_Shorts-head-', 'dss': '/models/char/dogMM_Skirt-head-', 'dsl': '/models/char/dogSS_Shorts-head-', @@ -567,7 +566,7 @@ class ToonHead(Actor.Actor): if self.hasLOD(): for lodName in self.getLODNames(): self.drawInFront('eyes*', 'head-front*', mode, lodName=lodName) - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('**/joint_pupil*').isEmpty(): self.drawInFront('joint_pupil*', 'eyes*', -1, lodName=lodName) else: @@ -582,7 +581,7 @@ class ToonHead(Actor.Actor): self.__lod500Eyes = None else: self.__lod500Eyes.setColorOff() - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('**/joint_pupilL*').isEmpty(): self.__lod500lPupil = self.__lod500Eyes.find('**/joint_pupilL*') self.__lod500rPupil = self.__lod500Eyes.find('**/joint_pupilR*') @@ -596,7 +595,7 @@ class ToonHead(Actor.Actor): self.__lod250Eyes = None else: self.__lod250Eyes.setColorOff() - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('**/joint_pupilL*').isEmpty(): self.__lod250lPupil = self.__lod250Eyes.find('**/joint_pupilL*') self.__lod250rPupil = self.__lod250Eyes.find('**/joint_pupilR*') @@ -608,7 +607,7 @@ class ToonHead(Actor.Actor): self.__lod250rPupil = self.__lod250Eyes.find('**/joint_pupilR*') else: self.drawInFront('eyes*', 'head-front*', mode) - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('joint_pupil*').isEmpty(): self.drawInFront('joint_pupil*', 'eyes*', -1) else: @@ -620,7 +619,7 @@ class ToonHead(Actor.Actor): self.__eyes.setColorOff() self.__lpupil = None self.__rpupil = None - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('**/joint_pupilL*').isEmpty(): if self.getLOD(1000): lp = self.getLOD(1000).find('**/joint_pupilL*') @@ -1170,7 +1169,7 @@ class ToonHead(Actor.Actor): if lodName == '1000' or lodName == '500': filePrefix = DogMuzzleDict[style.head] muzzles = loader.loadModel('phase_3' + filePrefix + lodName) - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('**/' + lodName + '/**/__Actor_head/def_head').isEmpty(): muzzles.reparentTo(self.find('**/' + lodName + '/**/__Actor_head/def_head')) else: @@ -1196,7 +1195,7 @@ class ToonHead(Actor.Actor): muzzle = self.find('**/muzzle*') filePrefix = DogMuzzleDict[style.head] muzzles = loader.loadModel('phase_3' + filePrefix + '1000') - if base.config.GetBool('want-new-anims', 1): + if ConfigVariableBool('want-new-anims', 1).value: if not self.find('**/def_head').isEmpty(): muzzles.reparentTo(self.find('**/def_head')) else: