formatting
This commit is contained in:
parent
df0c99f67b
commit
1cb18155d0
|
|
@ -32,10 +32,10 @@ class CartesianGridBase:
|
|||
return zoneId
|
||||
|
||||
def getGridSizeFromSphereRadius(self, sphereRadius, cellWidth, gridRadius):
|
||||
# NOTE: This ensures that the grid is at least a "gridRadius" number of cells
|
||||
# larger than the trigger sphere that loads the grid. This gives us some
|
||||
# room to start setting interest to the grid before we expect to see any objects
|
||||
# on it.
|
||||
# NOTE: This ensures that the grid is at least a "gridRadius" number
|
||||
# of cells larger than the trigger sphere that loads the grid. This
|
||||
# gives us some room to start setting interest to the grid before we
|
||||
# expect to see any objects on it.
|
||||
sphereRadius = max(sphereRadius, gridRadius*cellWidth)
|
||||
return 2 * (sphereRadius // cellWidth)
|
||||
|
||||
|
|
|
|||
|
|
@ -71,8 +71,10 @@ class DistributedCartesianGrid(DistributedNode, CartesianGridBase):
|
|||
self.stopProcessVisibility()
|
||||
self.visAvatar = avatar
|
||||
self.visZone = None
|
||||
self.gridVisContext = self.cr.addInterest(self.getDoId(), 0, self.uniqueName("visibility"))
|
||||
taskMgr.add(self.processVisibility, self.taskName("processVisibility"))
|
||||
self.gridVisContext = self.cr.addInterest(
|
||||
self.getDoId(), 0, self.uniqueName("visibility"))
|
||||
taskMgr.add(
|
||||
self.processVisibility, self.taskName("processVisibility"))
|
||||
|
||||
def stopProcessVisibility(self, clearAll=False):
|
||||
taskMgr.remove(self.taskName("processVisibility"))
|
||||
|
|
@ -95,7 +97,8 @@ class DistributedCartesianGrid(DistributedNode, CartesianGridBase):
|
|||
y = pos[1] + dx
|
||||
col = x // self.cellWidth
|
||||
row = y // self.cellWidth
|
||||
assert self.notify.debug("processVisibility: %s: avatar pos: %s %s" % (self.doId, x, y))
|
||||
assert self.notify.debug(
|
||||
"processVisibility: %s: avatar pos: %s %s" % (self.doId, x, y))
|
||||
if (row < 0) or (col < 0) or (row > self.gridSize) or (col > self.gridSize):
|
||||
assert self.notify.debug("processVisibility: %s: not on the grid" % (self.doId))
|
||||
# If we are viewingRadius away from this entire grid,
|
||||
|
|
@ -110,26 +113,34 @@ class DistributedCartesianGrid(DistributedNode, CartesianGridBase):
|
|||
assert self.notify.debug("processVisibility: %s: row: %s col: %s zoneId: %s" %
|
||||
(self.doId, row, col, zoneId))
|
||||
if (zoneId == self.visZone):
|
||||
assert self.notify.debug("processVisibility: %s: interest did not change" % (self.doId))
|
||||
assert self.notify.debug(
|
||||
"processVisibility: %s: interest did not change" % (self.doId))
|
||||
return Task.cont
|
||||
else:
|
||||
assert self.notify.debug("processVisibility: %s: new interest" % (self.doId))
|
||||
assert self.notify.debug(
|
||||
"processVisibility: %s: new interest" % (self.doId))
|
||||
self.visZone = zoneId
|
||||
if not self.gridVisContext:
|
||||
self.gridVisContext = self.cr.addInterest(self.getDoId(), self.visZone,
|
||||
self.uniqueName("visibility"))
|
||||
self.gridVisContext = self.cr.addInterest(
|
||||
self.getDoId(), self.visZone,
|
||||
self.uniqueName("visibility"))
|
||||
else:
|
||||
assert self.notify.debug("processVisibility: %s: altering interest to zoneId: %s" %
|
||||
(self.doId, zoneId))
|
||||
self.cr.alterInterest(self.gridVisContext, self.getDoId(), self.visZone)
|
||||
# If the visAvatar is parented to this grid, also do a setLocation
|
||||
assert self.notify.debug(
|
||||
"processVisibility: %s: altering interest to zoneId: %s" %
|
||||
(self.doId, zoneId))
|
||||
self.cr.alterInterest(
|
||||
self.gridVisContext, self.getDoId(), self.visZone)
|
||||
# If the visAvatar is parented to this grid, also do a
|
||||
# setLocation
|
||||
parentId = self.visAvatar.parentId
|
||||
oldZoneId = self.visAvatar.zoneId
|
||||
assert self.notify.debug(
|
||||
"processVisibility: %s: parentId: %s oldZoneId: %s" %
|
||||
(self.doId, parentId, oldZoneId))
|
||||
if parentId == self.doId:
|
||||
assert self.notify.debug("processVisibility: %s: changing location" % (self.doId))
|
||||
assert self.notify.debug(
|
||||
"processVisibility: %s: changing location" %
|
||||
(self.doId))
|
||||
self.handleAvatarZoneChange(self.visAvatar, zoneId)
|
||||
return Task.cont
|
||||
|
||||
|
|
|
|||
|
|
@ -120,10 +120,12 @@ class DistributedObjectAI(DistributedObjectBase):
|
|||
barrier.cleanup()
|
||||
self.__barriers = {}
|
||||
|
||||
# DCR: I've re-enabled this block of code so that Toontown's AI won't leak channels.
|
||||
# DCR: I've re-enabled this block of code so that Toontown's
|
||||
# AI won't leak channels.
|
||||
# Let me know if it causes trouble.
|
||||
### Asad: As per Roger's suggestion, turn off the following block until a solution is
|
||||
### Thought out of how to prevent this delete message or to handle this message better
|
||||
### Asad: As per Roger's suggestion, turn off the following
|
||||
### block until a solution is thought out of how to prevent
|
||||
### this delete message or to handle this message better
|
||||
# TODO: do we still need this check?
|
||||
if not hasattr(self, "doNotDeallocateChannel"):
|
||||
if self.air:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ PREVIOUS_START = CMetaInterval.RSPreviousBegin
|
|||
TRACK_START = CMetaInterval.RSLevelBegin
|
||||
|
||||
class MetaInterval(CMetaInterval):
|
||||
|
||||
# This is a Python-C++ hybrid class. MetaInterval is a Python
|
||||
# extension of the C++ class CMetaInterval, which adds some
|
||||
# Python-specific features (like list management).
|
||||
|
|
@ -24,7 +23,8 @@ class MetaInterval(CMetaInterval):
|
|||
SequenceNum = 1
|
||||
def __init__(self, *ivals, **kw):
|
||||
#if __debug__:
|
||||
# self.debugInitTraceback = PythonUtil.StackTrace("create interval", 1, 10)
|
||||
# self.debugInitTraceback = PythonUtil.StackTrace(
|
||||
# "create interval", 1, 10)
|
||||
|
||||
name = None
|
||||
#if len(ivals) == 2 and isinstance(ivals[1], types.StringType):
|
||||
|
|
|
|||
Loading…
Reference in New Issue