minigame: fix more minigame crashes
This commit is contained in:
parent
03a246bec4
commit
455a8000ca
5 changed files with 20 additions and 21 deletions
|
@ -3,7 +3,6 @@ from direct.interval.IntervalGlobal import *
|
|||
from direct.showbase import DirectObject
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
import types
|
||||
|
||||
class MovingPlatform(DirectObject.DirectObject, NodePath):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('MovingPlatform')
|
||||
|
@ -19,8 +18,8 @@ class MovingPlatform(DirectObject.DirectObject, NodePath):
|
|||
if type(parentToken) == int:
|
||||
parentToken = ToontownGlobals.SPDynamic + parentToken
|
||||
self.parentToken = parentToken
|
||||
self.name = 'MovingPlatform-%s' % parentToken
|
||||
self.assign(hidden.attachNewNode(self.name))
|
||||
self._name = 'MovingPlatform-%s' % parentToken
|
||||
self.assign(hidden.attachNewNode(self._name))
|
||||
self.model = model.copyTo(self)
|
||||
self.ownsModel = 1
|
||||
floorList = self.model.findAllMatches('**/%s' % floorNodeName)
|
||||
|
@ -28,14 +27,14 @@ class MovingPlatform(DirectObject.DirectObject, NodePath):
|
|||
MovingPlatform.notify.warning('no floors in model')
|
||||
return
|
||||
for floor in floorList:
|
||||
floor.setName(self.name)
|
||||
floor.setName(self._name)
|
||||
|
||||
if parentingNode == None:
|
||||
parentingNode = self
|
||||
base.cr.parentMgr.registerParent(self.parentToken, parentingNode)
|
||||
self.parentingNode = parentingNode
|
||||
self.accept('enter%s' % self.name, self.__handleEnter)
|
||||
self.accept('exit%s' % self.name, self.__handleExit)
|
||||
self.accept('enter%s' % self._name, self.__handleEnter)
|
||||
self.accept('exit%s' % self._name, self.__handleExit)
|
||||
return
|
||||
|
||||
def destroy(self):
|
||||
|
@ -50,31 +49,31 @@ class MovingPlatform(DirectObject.DirectObject, NodePath):
|
|||
del self.parentingNode
|
||||
|
||||
def getEnterEvent(self):
|
||||
return '%s-enter' % self.name
|
||||
return '%s-enter' % self._name
|
||||
|
||||
def getExitEvent(self):
|
||||
return '%s-exit' % self.name
|
||||
return '%s-exit' % self._name
|
||||
|
||||
def releaseLocalToon(self):
|
||||
if self.hasLt:
|
||||
self.__releaseLt()
|
||||
|
||||
def __handleEnter(self, collEntry):
|
||||
self.notify.debug('on movingPlatform %s' % self.name)
|
||||
self.notify.debug('on movingPlatform %s' % self._name)
|
||||
self.__grabLt()
|
||||
messenger.send(self.getEnterEvent())
|
||||
|
||||
def __handleExit(self, collEntry):
|
||||
self.notify.debug('off movingPlatform %s' % self.name)
|
||||
self.notify.debug('off movingPlatform %s' % self._name)
|
||||
self.__releaseLt()
|
||||
messenger.send(self.getExitEvent())
|
||||
|
||||
def __handleOnFloor(self, collEntry):
|
||||
if collEntry.getIntoNode().getName() == self.name:
|
||||
if collEntry.getIntoNode().getName() == self._name:
|
||||
self.__handleEnter(collEntry)
|
||||
|
||||
def __handleOffFloor(self, collEntry):
|
||||
if collEntry.getIntoNode().getName() == self.name:
|
||||
if collEntry.getIntoNode().getName() == self._name:
|
||||
self.__handleExit(collEntry)
|
||||
|
||||
def __grabLt(self):
|
||||
|
|
|
@ -56,7 +56,7 @@ def getRingPoints(segCount, centerX, centerY, radius, thickness = 2.0, wideX = 1
|
|||
def addRing(attachNode, color, vertexCount, radius, layer = 0, thickness = 1.0):
|
||||
targetGN = GeomNode('target Circle')
|
||||
zFloat = 0.025
|
||||
targetCircleShape = getRingPoints(5 + vertexCount, 0.0, 0.0, radius, thickness)
|
||||
targetCircleShape = getRingPoints(5 + int(vertexCount), 0.0, 0.0, radius, thickness)
|
||||
gFormat = GeomVertexFormat.getV3cp()
|
||||
targetCircleVertexData = GeomVertexData('holds my vertices', gFormat, Geom.UHDynamic)
|
||||
targetCircleVertexWriter = GeomVertexWriter(targetCircleVertexData, 'vertex')
|
||||
|
@ -82,7 +82,7 @@ def addRing(attachNode, color, vertexCount, radius, layer = 0, thickness = 1.0):
|
|||
def addCircle(attachNode, color, vertexCount, radius, layer = 0):
|
||||
targetGN = GeomNode('target Circle')
|
||||
zFloat = 0.025
|
||||
targetCircleShape = getCirclePoints(5 + vertexCount, 0.0, 0.0, radius)
|
||||
targetCircleShape = getCirclePoints(5 + int(vertexCount), 0.0, 0.0, radius)
|
||||
gFormat = GeomVertexFormat.getV3cp()
|
||||
targetCircleVertexData = GeomVertexData('holds my vertices', gFormat, Geom.UHDynamic)
|
||||
targetCircleVertexWriter = GeomVertexWriter(targetCircleVertexData, 'vertex')
|
||||
|
@ -1154,7 +1154,7 @@ class DistributedTargetGame(DistributedMinigame):
|
|||
self.ticker = 0.0
|
||||
powerDiv = 0.05
|
||||
self.power -= 1.0 + 0.2 * (self.power * powerDiv * (self.power * powerDiv))
|
||||
if timeDiff > 0.5:
|
||||
if timeDiff is not None and timeDiff > 0.5:
|
||||
self.power = self.powerBar['value']
|
||||
self.signalLaunch = 0
|
||||
if self.power > 120:
|
||||
|
|
|
@ -351,7 +351,7 @@ class DistributedVineGame(DistributedMinigame):
|
|||
if newPosZ < -100 or newPosZ > 1000:
|
||||
self.notify.warning('invalid posZ for %d, forcing to 0' % avId)
|
||||
newPosZ = 0
|
||||
if newVelX < -1000 or newVelX > 1000:
|
||||
if newVelX is not None and (newVelX < -1000 or newVelX > 1000):
|
||||
self.notify.warning('invalid velX %s for %d, forcing to 0' % (newVelX, avId))
|
||||
newVelX = 0
|
||||
if newVelZ < -1000 or newVelZ > 1000:
|
||||
|
|
|
@ -249,11 +249,11 @@ class DistributedVineGameAI(DistributedMinigameAI):
|
|||
pass
|
||||
if not newFacingRight == 0 and not newFacingRight == 1:
|
||||
newFacingRight = 1
|
||||
if newPosX and (newPosX < -1000 or newPosX > 2000):
|
||||
if newPosX is not None and (newPosX < -1000 or newPosX > 2000):
|
||||
newPosX = 0
|
||||
if newPosZ and (newPosZ < -100 or newPosZ > 1000):
|
||||
if newPosZ is not None and (newPosZ < -100 or newPosZ > 1000):
|
||||
newPosZ = 0
|
||||
if newVelX < -1000 or newVelX > 1000:
|
||||
if newVelX is not None and (newVelX < -1000 or newVelX > 1000):
|
||||
newVelX = 0
|
||||
if newVelZ < -1000 or newVelZ > 1000:
|
||||
newVelZ = 0
|
||||
|
|
|
@ -66,7 +66,7 @@ class MazeSuit(DirectObject):
|
|||
self.startWalkAnim()
|
||||
self.occupiedTiles = [(self.nextTX, self.nextTY)]
|
||||
n = 20
|
||||
self.nextThinkTic = self.serialNum * self.ticFreq / n
|
||||
self.nextThinkTic = int(self.serialNum * self.ticFreq / n)
|
||||
self.fromPos = Point3(0, 0, 0)
|
||||
self.toPos = Point3(0, 0, 0)
|
||||
self.fromHpr = Point3(0, 0, 0)
|
||||
|
@ -187,7 +187,7 @@ class MazeSuit(DirectObject):
|
|||
if curTic < self.nextThinkTic:
|
||||
return []
|
||||
else:
|
||||
r = list(range(int(self.nextThinkTic), curTic + 1, self.ticPeriod))
|
||||
r = list(range(self.nextThinkTic, curTic + 1, self.ticPeriod))
|
||||
self.lastTicBeforeRender = r[-1]
|
||||
return r
|
||||
|
||||
|
|
Loading…
Reference in a new issue