DANIEL: Cleanup

This commit is contained in:
John 2015-06-12 17:12:36 +03:00 committed by Loudrob
parent 7046c641ae
commit f0c0c08719
22 changed files with 15 additions and 418 deletions

View file

@ -559,15 +559,12 @@ struct datetime {
dclass ToontownDistrict : DistributedDistrict { dclass ToontownDistrict : DistributedDistrict {
setParentingRules(string, string) broadcast ram; setParentingRules(string, string) broadcast ram;
allowAHNNLog(bool) broadcast required ram;
}; };
dclass ToontownDistrictStats : DistributedObject { dclass ToontownDistrictStats : DistributedObject {
settoontownDistrictId(uint32) broadcast required ram; settoontownDistrictId(uint32) broadcast required ram;
setAvatarCount(uint32) broadcast required ram; setAvatarCount(uint32) broadcast required ram;
setNewAvatarCount(uint32) broadcast required ram;
setInvasionStatus(uint8) broadcast required ram; setInvasionStatus(uint8) broadcast required ram;
setStats : setAvatarCount, setNewAvatarCount;
}; };
dclass DistributedAnimatedProp : DistributedObject { dclass DistributedAnimatedProp : DistributedObject {

View file

@ -1,21 +0,0 @@
from pandac.PandaModules import *
from direct.directnotify.DirectNotifyGlobal import *
import random
from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator
notify = directNotify.newCategory('AvatarDNA')
class AvatarDNA:
def __str__(self):
return 'avatar parent class: type undefined'
def makeNetString(self):
notify.error('called makeNetString on avatarDNA parent class')
def makeFromNetString(self, string):
notify.error('called makeFromNetString on avatarDNA parent class')
def getType(self):
notify.error('Invalid DNA type: ', self.type)
return type

View file

@ -333,4 +333,4 @@ def getPos():
""" """
Return your target's position. Return your target's position.
""" """
return spellbook.getTarget().getPos() return spellbook.getTarget().getPos()

View file

@ -1,9 +1,6 @@
from otp.ai.AIBaseGlobal import * from otp.ai.AIBaseGlobal import *
from otp.otpbase import OTPGlobals from otp.otpbase import OTPGlobals
from direct.fsm import ClassicFSM
from direct.fsm import State
from direct.distributed import DistributedNodeAI from direct.distributed import DistributedNodeAI
from direct.task import Task
class DistributedAvatarAI(DistributedNodeAI.DistributedNodeAI): class DistributedAvatarAI(DistributedNodeAI.DistributedNodeAI):
@ -51,32 +48,6 @@ class DistributedAvatarAI(DistributedNodeAI.DistributedNodeAI):
def getHp(self): def getHp(self):
return self.hp return self.hp
def b_setLocationName(self, locationName):
self.d_setLocationName(locationName)
self.setLocationName(locationName)
def d_setLocationName(self, locationName):
pass
def setLocationName(self, locationName):
self.locationName = locationName
def getLocationName(self):
return self.locationName
def b_setActivity(self, activity):
self.d_setActivity(activity)
self.setActivity(activity)
def d_setActivity(self, activity):
pass
def setActivity(self, activity):
self.activity = activity
def getActivity(self):
return self.activity
def toonUp(self, num): def toonUp(self, num):
if self.hp >= self.maxHp: if self.hp >= self.maxHp:
return return
@ -98,4 +69,4 @@ class DistributedAvatarAI(DistributedNodeAI.DistributedNodeAI):
senderId = self.air.getAvatarIdFromSender() senderId = self.air.getAvatarIdFromSender()
self.air.writeServerEvent('Admin chat warning', senderId, 'using setParentStr to send "%s"' % parentToken) self.air.writeServerEvent('Admin chat warning', senderId, 'using setParentStr to send "%s"' % parentToken)
self.notify.warning('Admin chat warning: %s using setParentStr to send "%s"' % (senderId, parentToken)) self.notify.warning('Admin chat warning: %s using setParentStr to send "%s"' % (senderId, parentToken))
DistributedNodeAI.DistributedNodeAI.setParentStr(self, parentToken) DistributedNodeAI.DistributedNodeAI.setParentStr(self, parentToken)

View file

@ -14,5 +14,4 @@ class DistributedAvatarUD(DistributedObjectUD):
pass pass
def confirmAvOnShard(self, todo0, todo1): def confirmAvOnShard(self, todo0, todo1):
pass pass

View file

@ -10,7 +10,6 @@ class DistributedDistrict(DistributedObject):
self.name = 'NotGiven' self.name = 'NotGiven'
self.available = 0 self.available = 0
self.avatarCount = 0 self.avatarCount = 0
self.newAvatarCount = 0
def announceGenerate(self): def announceGenerate(self):
DistributedObject.announceGenerate(self) DistributedObject.announceGenerate(self)
@ -24,7 +23,6 @@ class DistributedDistrict(DistributedObject):
del self.cr.activeDistrictMap[self.doId] del self.cr.activeDistrictMap[self.doId]
DistributedObject.delete(self) DistributedObject.delete(self)
messenger.send('shardInfoUpdated') messenger.send('shardInfoUpdated')
return
def setAvailable(self, available): def setAvailable(self, available):
self.available = available self.available = available
@ -32,4 +30,4 @@ class DistributedDistrict(DistributedObject):
def setName(self, name): def setName(self, name):
self.name = name self.name = name
messenger.send('shardInfoUpdated') messenger.send('shardInfoUpdated')

View file

@ -1077,10 +1077,10 @@ class OTPClientRepository(ClientRepositoryBase):
def listActiveShards(self): def listActiveShards(self):
list = [] list = []
for s in self.activeDistrictMap.values(): for s in self.activeDistrictMap.values():
if s.available: if s.available:
list.append((s.doId, s.name, s.avatarCount, s.newAvatarCount, list.append((s.doId, s.name, s.avatarCount, s.invasionStatus))
s.invasionStatus))
return list return list

View file

@ -1,9 +0,0 @@
from pandac.PandaModules import *
class CMover:
def __init__(self, objNodePath, fwdSpeed=1, rotSpeed=1):
self.objNodePath = objNodePath
self.fwdSpeed = fwdSpeed
self.rotSpeed = rotSpeed

View file

@ -1,29 +0,0 @@
from pandac.PandaModules import *
from direct.showbase import DirectObject
class Impulse(DirectObject.DirectObject):
def __init__(self):
self.mover = None
self.nodePath = None
return
def destroy(self):
pass
def _process(self, dt):
pass
def _setMover(self, mover):
self.mover = mover
self.nodePath = self.mover.getNodePath()
self.VecType = self.mover.VecType
def _clearMover(self, mover):
if self.mover == mover:
self.mover = None
self.nodePath = None
return
def isCpp(self):
return 0

View file

@ -1,76 +0,0 @@
from pandac.PandaModules import *
from CMover import CMover
from direct.directnotify import DirectNotifyGlobal
from otp.movement.PyVec3 import PyVec3
from direct.showbase import PythonUtil
import __builtin__
class Mover:
notify = DirectNotifyGlobal.directNotify.newCategory('Mover')
SerialNum = 0
Profile = 0
Pstats = 1
PSCCpp = 'App:Show code:moveObjects:MoverC++'
PSCPy = 'App:Show code:moveObjects:MoverPy'
PSCInt = 'App:Show code:moveObjects:MoverIntegrate'
def __init__(self, objNodePath, fwdSpeed = 1, rotSpeed = 1):
CMover.__init__(self, objNodePath, fwdSpeed, rotSpeed)
self.serialNum = Mover.SerialNum
Mover.SerialNum += 1
self.VecType = Vec3
self.impulses = {}
if Mover.Pstats:
self.pscCpp = PStatCollector(Mover.PSCCpp)
self.pscPy = PStatCollector(Mover.PSCPy)
self.pscInt = PStatCollector(Mover.PSCInt)
def destroy(self):
for name, impulse in self.impulses.items():
Mover.notify.debug('removing impulse: %s' % name)
self.removeImpulse(name)
def addImpulse(self, name, impulse):
if impulse.isCpp():
CMover.addCImpulse(self, name, impulse)
else:
self.impulses[name] = impulse
impulse._setMover(self)
def removeImpulse(self, name):
if name not in self.impulses:
if not CMover.removeCImpulse(self, name):
Mover.notify.warning("Mover.removeImpulse: unknown impulse '%s'" % name)
return
self.impulses[name]._clearMover(self)
del self.impulses[name]
def getCollisionEventName(self):
return 'moverCollision-%s' % self.serialNum
def move(self, dt = -1, profile = 0):
if Mover.Profile and not profile:
def func(doMove = self.move):
for i in xrange(10000):
doMove(dt, profile=1)
__builtin__.func = func
PythonUtil.startProfile(cmd='func()', filename='profile', sorts=['cumulative'], callInfo=0)
del __builtin__.func
return
if Mover.Pstats:
self.pscCpp.start()
CMover.processCImpulses(self, dt)
if Mover.Pstats:
self.pscCpp.stop()
self.pscPy.start()
for impulse in self.impulses.values():
impulse._process(self.getDt())
if Mover.Pstats:
self.pscPy.stop()
self.pscInt.start()
CMover.integrate(self)
if Mover.Pstats:
self.pscInt.stop()

View file

@ -1,175 +0,0 @@
from pandac.PandaModules import *
import types
import math
class PyVec3:
Epsilon = 0.0001
ScalarTypes = (types.FloatType, types.IntType, types.LongType)
def __init__(self, *args):
self.assign(*args)
def assign(self, *args):
if len(args) == 1:
arg = args[0]
if type(arg) in PyVec3.ScalarTypes:
x = y = z = arg
elif isinstance(arg, self.__class__):
x = arg.x
y = arg.y
z = arg.z
elif isinstance(arg, VBase3):
x = arg.getX()
y = arg.getY()
z = arg.getZ()
else:
raise TypeError
elif len(args) == 3:
x = args[0]
y = args[1]
z = args[2]
self.x = x
self.y = y
self.z = z
def getX(self):
return self.x
def getY(self):
return self.y
def getZ(self):
return self.z
def setX(self, x):
self.x = x
def setY(self, y):
self.y = y
def setZ(self, z):
self.z = z
def set(self, x, y, z):
self.x = x
self.y = y
self.z = z
def fill(self, s):
self.x = self.y = self.z = s
def length(self):
return math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z)
def lengthSquared(self):
return self.x * self.x + self.y * self.y + self.z * self.z
def normalize(self):
self /= self.length()
def dot(self, other):
return self.x * other.getX() + self.y * other.getY() + self.z * other.getZ()
def _crossResults(self, other):
return (self.y * other.getZ() - self.z * other.getY(), self.z * other.getX() - self.x * other.getZ(), self.x * other.getY() - self.y * other.getX())
def cross(self, other):
return PyVec3(*self._crossResults(other))
def crossInto(self, other):
self.x, self.y, self.z = self._crossResults(other)
def __lt__(a, b):
return a.length() < b.length()
def __le__(a, b):
return a < b or a == b
def __eq__(a, b):
return abs(a.length() - b.length()) < PyVec3.Epsilon
def __ne__(a, b):
return not a == b
def __ge__(a, b):
return a > b or a == b
def __gt__(a, b):
return a.length() > b.length()
def __add__(a, b):
return PyVec3(a.getX() + b.getX(), a.getY() + b.getY(), a.getZ() + b.getZ())
def __sub__(a, b):
return PyVec3(a.getX() - b.getX(), a.getY() - b.getY(), a.getZ() - b.getZ())
def __mul__(a, s):
return PyVec3(a.getX() * s, a.getY() * s, a.getZ() * s)
def __div__(a, s):
return PyVec3(a.getX() / s, a.getY() / s, a.getZ() / s)
def __iadd__(self, other):
self.x += other.getX()
self.y += other.getY()
self.z += other.getZ()
return self
def __isub__(self, other):
self.x -= other.getX()
self.y -= other.getY()
self.z -= other.getZ()
return self
def __imul__(self, s):
self.x *= s
self.y *= s
self.z *= s
return self
def __idiv__(self, s):
self.x /= s
self.y /= s
self.z /= s
return self
def addX(self, s):
self.x += s
def addY(self, s):
self.y += s
def addZ(self, s):
self.z += s
def eq(self, other):
return self == other
def lessThan(self, other):
return self < other
def ne(self, other):
return self != other
def __getitem__(self, i):
if i == 0:
return self.x
elif i == 1:
return self.y
elif i == 2:
return self.z
else:
raise IndexError
def __setitem__(self, i, s):
if i == 0:
self.x = s
elif i == 1:
self.y = s
elif i == 2:
self.z = s
else:
raise IndexError
def __repr__(self):
return 'PyVec3(%s,%s,%s)' % (self.x, self.y, self.z)

View file

@ -13,13 +13,11 @@ class OTPBase(ShowBase):
if not self.idTags: if not self.idTags:
del self.idTags del self.idTags
self.wantNametags = self.config.GetBool('want-nametags', 1) self.wantNametags = self.config.GetBool('want-nametags', 1)
self.fillShardsToIdealPop = self.config.GetBool('fill-shards-to-ideal-pop', 1)
self.wantDynamicShadows = 1 self.wantDynamicShadows = 1
self.stereoEnabled = False self.stereoEnabled = False
self.enviroDR = None self.enviroDR = None
self.enviroCam = None self.enviroCam = None
self.pixelZoomSetup = False self.pixelZoomSetup = False
self.gameOptionsCode = ''
self.whiteList = None self.whiteList = None
if config.GetBool('want-whitelist', True): if config.GetBool('want-whitelist', True):
@ -35,7 +33,6 @@ class OTPBase(ShowBase):
else: else:
base.cam.node().setCameraMask(OTPRender.MainCameraBitmask | OTPRender.EnviroCameraBitmask) base.cam.node().setCameraMask(OTPRender.MainCameraBitmask | OTPRender.EnviroCameraBitmask)
taskMgr.setupTaskChain('net') taskMgr.setupTaskChain('net')
return
def setTaskChainNetThreaded(self): def setTaskChainNetThreaded(self):
if base.config.GetBool('want-threaded-network', 0): if base.config.GetBool('want-threaded-network', 0):

View file

@ -8,12 +8,5 @@ class ToontownDistrict(DistributedDistrict.DistributedDistrict):
def __init__(self, cr): def __init__(self, cr):
DistributedDistrict.DistributedDistrict.__init__(self, cr) DistributedDistrict.DistributedDistrict.__init__(self, cr)
self.avatarCount = 0 self.avatarCount = 0
self.newAvatarCount = 0
self.invasionStatus = 0 self.invasionStatus = 0
self.suitStatus = '' self.suitStatus = ''
def allowAHNNLog(self, allow):
self.allowAHNN = allow
def getAllowAHNNLog(self):
return self.allowAHNN

View file

@ -1,14 +1,10 @@
from direct.directnotify.DirectNotifyGlobal import directNotify from direct.directnotify.DirectNotifyGlobal import directNotify
import time
from otp.distributed.DistributedDistrictAI import DistributedDistrictAI from otp.distributed.DistributedDistrictAI import DistributedDistrictAI
import time
class ToontownDistrictAI(DistributedDistrictAI): class ToontownDistrictAI(DistributedDistrictAI):
notify = directNotify.newCategory('ToontownDistrictAI') notify = directNotify.newCategory('ToontownDistrictAI')
created = 0 created = 0
ahnnLog = 0
def announceGenerate(self): def announceGenerate(self):
DistributedDistrictAI.announceGenerate(self) DistributedDistrictAI.announceGenerate(self)
@ -42,19 +38,6 @@ class ToontownDistrictAI(DistributedDistrictAI):
} }
self.air.netMessenger.send('shardStatus', [self.air.ourChannel, status]) self.air.netMessenger.send('shardStatus', [self.air.ourChannel, status])
def allowAHNNLog(self, ahnnLog):
self.ahnnLog = ahnnLog
def d_allowAHNNLog(self, ahnnLog):
self.sendUpdate('allowAHNNLog', [ahnnLog])
def b_allowAHNNLog(self, ahnnLog):
self.allowAHNNLog(ahnnLog)
self.d_allowAHNNLog(ahnnLog)
def getAllowAHNNLog(self):
return self.ahnnLog
def setName(self, name): def setName(self, name):
DistributedDistrictAI.setName(self, name) DistributedDistrictAI.setName(self, name)
@ -67,4 +50,4 @@ class ToontownDistrictAI(DistributedDistrictAI):
# Send a shard status update containing our availability: # Send a shard status update containing our availability:
status = {'available': bool(available)} status = {'available': bool(available)}
self.air.netMessenger.send('shardStatus', [self.air.ourChannel, status]) self.air.netMessenger.send('shardStatus', [self.air.ourChannel, status])

View file

@ -76,14 +76,6 @@ class ToontownDistrictStats(DistributedObject.DistributedObject):
if self.toontownDistrictId in self.cr.activeDistrictMap: if self.toontownDistrictId in self.cr.activeDistrictMap:
self.cr.activeDistrictMap[self.toontownDistrictId].avatarCount = avatarCount self.cr.activeDistrictMap[self.toontownDistrictId].avatarCount = avatarCount
def setNewAvatarCount(self, newAvatarCount):
if self.toontownDistrictId in self.cr.activeDistrictMap:
self.cr.activeDistrictMap[self.toontownDistrictId].newAvatarCount = newAvatarCount
def setInvasionStatus(self, invasionStatus): def setInvasionStatus(self, invasionStatus):
if self.toontownDistrictId in self.cr.activeDistrictMap: if self.toontownDistrictId in self.cr.activeDistrictMap:
self.cr.activeDistrictMap[self.toontownDistrictId].invasionStatus = invasionStatus self.cr.activeDistrictMap[self.toontownDistrictId].invasionStatus = invasionStatus
def setStats(self, avatarCount, newAvatarCount):
self.setAvatarCount(avatarCount)
self.setNewAvatarCount(newAvatarCount)

View file

@ -6,7 +6,6 @@ class ToontownDistrictStatsAI(DistributedObjectAI):
districtId = 0 districtId = 0
avatarCount = 0 avatarCount = 0
newAvatarCount = 0
invasionStatus = 0 invasionStatus = 0
def announceGenerate(self): def announceGenerate(self):
@ -51,19 +50,6 @@ class ToontownDistrictStatsAI(DistributedObjectAI):
def getAvatarCount(self): def getAvatarCount(self):
return self.avatarCount return self.avatarCount
def setNewAvatarCount(self, newAvatarCount):
self.newAvatarCount = newAvatarCount
def d_setNewAvatarCount(self, newAvatarCount):
self.sendUpdate('setNewAvatarCount', [newAvatarCount])
def b_setNewAvatarCount(self, newAvatarCount):
self.setNewAvatarCount(newAvatarCount)
self.d_setNewAvatarCount(newAvatarCount)
def getNewAvatarCount(self):
return self.newAvatarCount
def setInvasionStatus(self, invasionStatus): def setInvasionStatus(self, invasionStatus):
self.invasionStatus = invasionStatus self.invasionStatus = invasionStatus
@ -75,4 +61,4 @@ class ToontownDistrictStatsAI(DistributedObjectAI):
self.d_setInvasionStatus(invasionStatus) self.d_setInvasionStatus(invasionStatus)
def getInvasionStatus(self): def getInvasionStatus(self):
return self.invasionStatus return self.invasionStatus

View file

@ -117,7 +117,7 @@ class ShardPage(ShtikerPage.ShtikerPage):
curShardTuples.sort(compareShardTuples) curShardTuples.sort(compareShardTuples)
actualShardId = base.localAvatar.defaultShard actualShardId = base.localAvatar.defaultShard
for i in xrange(len(curShardTuples)): for i in xrange(len(curShardTuples)):
shardId, name, pop, WVPop, invasionStatus = curShardTuples[i] shardId, name, pop, invasionStatus = curShardTuples[i]
if shardId == actualShardId: if shardId == actualShardId:
self.currentBTP = buttonTuple[0] self.currentBTP = buttonTuple[0]
self.currentBTL = buttonTuple[1] self.currentBTL = buttonTuple[1]
@ -478,19 +478,17 @@ class ShardPage(ShtikerPage.ShtikerPage):
actualShardName = None actualShardName = None
anyChanges = 0 anyChanges = 0
totalPop = 0 totalPop = 0
totalWVPop = 0
currentMap = {} currentMap = {}
self.shardButtons = [] self.shardButtons = []
for i in xrange(len(curShardTuples)): for i in xrange(len(curShardTuples)):
shardId, name, pop, WVPop, invasionStatus = curShardTuples[i] shardId, name, pop, invasionStatus = curShardTuples[i]
if shardId == actualShardId: if shardId == actualShardId:
actualShardName = name actualShardName = name
totalPop += pop totalPop += pop
totalWVPop += WVPop
currentMap[shardId] = 1 currentMap[shardId] = 1
buttonTuple = self.shardButtonMap.get(shardId) buttonTuple = self.shardButtonMap.get(shardId)

View file

@ -5,7 +5,6 @@ from toontown.toonbase import TTLocalizer, ToontownGlobals
import random import random
from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator from direct.distributed.PyDatagramIterator import PyDatagramIterator
from otp.avatar import AvatarDNA
notify = directNotify.newCategory('SuitDNA') notify = directNotify.newCategory('SuitDNA')
suitHeadTypes = ['f', suitHeadTypes = ['f',
'p', 'p',
@ -171,7 +170,7 @@ def getSuitsInDept(dept):
end = start + suitsPerDept end = start + suitsPerDept
return suitHeadTypes[start:end] return suitHeadTypes[start:end]
class SuitDNA(AvatarDNA.AvatarDNA): class SuitDNA:
def __init__(self, str = None, type = None, dna = None, r = None, b = None, g = None): def __init__(self, str = None, type = None, dna = None, r = None, b = None, g = None):
if str != None: if str != None:

View file

@ -4884,10 +4884,6 @@ def getZone():
zone = invoker.zoneId zone = invoker.zoneId
return 'ZoneID: %s' % (zone) return 'ZoneID: %s' % (zone)
@magicWord(category=CATEGORY_PROGRAMMER)
def getPos():
return 'Pos: %s' % spellbook.getInvoker().getPos()
@magicWord(category=CATEGORY_MODERATOR, types=[int]) @magicWord(category=CATEGORY_MODERATOR, types=[int])
def nametagStyle(nametagStyle): def nametagStyle(nametagStyle):
currentAccess = spellbook.getInvokerAccess() currentAccess = spellbook.getInvokerAccess()

View file

@ -3,7 +3,6 @@ from pandac.PandaModules import *
from direct.directnotify.DirectNotifyGlobal import * from direct.directnotify.DirectNotifyGlobal import *
from direct.distributed.PyDatagram import PyDatagram from direct.distributed.PyDatagram import PyDatagram
from direct.distributed.PyDatagramIterator import PyDatagramIterator from direct.distributed.PyDatagramIterator import PyDatagramIterator
from otp.avatar import AvatarDNA
notify = directNotify.newCategory('ToonDNA') notify = directNotify.newCategory('ToonDNA')
mergeMATTailor = config.GetBool('want-mat-all-tailors', 0) mergeMATTailor = config.GetBool('want-mat-all-tailors', 0)
toonSpeciesTypes = ['d', toonSpeciesTypes = ['d',
@ -2436,7 +2435,7 @@ def isValidAccessory(itemIdx, textureIdx, colorIdx, which):
return False return False
class ToonDNA(AvatarDNA.AvatarDNA): class ToonDNA:
def __init__(self, str = None, type = None, dna = None, r = None, b = None, g = None): def __init__(self, str = None, type = None, dna = None, r = None, b = None, g = None):
if str != None: if str != None:

View file

@ -212,7 +212,6 @@ class ToonTeleportPanel(DirectFrame):
self.shardId = shardId self.shardId = shardId
self.hoodId = hoodId self.hoodId = hoodId
self.zoneId = zoneId self.zoneId = zoneId
return
def exitOtherShard(self): def exitOtherShard(self):
self.bYes.hide() self.bYes.hide()