print object type when DoHierarchy gets an error

This commit is contained in:
Darren Ranalli 2006-08-23 03:21:34 +00:00
parent c6b8cb9cd6
commit 00e0c59f0f
5 changed files with 55 additions and 53 deletions

View File

@ -192,7 +192,7 @@ class DistributedObjectAI(DistributedObjectBase):
oldParentId = self.parentId
oldZoneId = self.zoneId
self.air.storeObjectLocation(self.doId, parentId, zoneId)
self.air.storeObjectLocation(self, parentId, zoneId)
if ((oldParentId != parentId) or
(oldZoneId != zoneId)):
messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId])

View File

@ -172,7 +172,7 @@ class DistributedObjectOV(DistributedObjectBase):
assert self.notify.debugStateCall(self)
self.activeState = ESGenerating
# this has already been set at this point
#self.cr.storeObjectLocation(self.doId, self.parentId, self.zoneId)
#self.cr.storeObjectLocation(self, self.parentId, self.zoneId)
def generateInit(self):
"""

View File

@ -179,7 +179,7 @@ class DistributedObjectUD(DistributedObjectBase):
self.air.sendSetLocation(self, parentId, zoneId)
def setLocation(self, parentId, zoneId):
self.air.storeObjectLocation(self.doId, parentId, zoneId)
self.air.storeObjectLocation(self, parentId, zoneId)
def getLocation(self):
try:
@ -330,7 +330,7 @@ class DistributedObjectUD(DistributedObjectBase):
other networked info in this function.
"""
assert self.notify.debugStateCall(self)
self.air.storeObjectLocation(self.doId, self.parentId, self.zoneId)
self.air.storeObjectLocation(self, self.parentId, self.zoneId)
def generateInit(self, repository=None):
"""

View File

@ -191,48 +191,43 @@ class DoCollectionManager:
else:
self.notify.warning('handleSetLocation: object %s not present' % self.getMsgChannel())
def storeObjectLocation(self, doId, parentId, zoneId, object=None):
if (object == None):
object = self.doId2do.get(doId)
if object is None:
self.notify.warning('storeObjectLocation: object %s not present' % doId)
else:
oldParentId = object.parentId
oldZoneId = object.zoneId
if ((None not in (oldParentId, oldZoneId)) and
((oldParentId != parentId) or (oldZoneId != zoneId))):
# Remove old location
self.deleteObjectLocation(doId, oldParentId, oldZoneId)
elif oldParentId == parentId and oldZoneId == zoneId:
# object is already at that parent and zone
return
if (parentId is None) or (zoneId is None):
# Do not store null values
return
# Add to new location
self._doHierarchy.storeObjectLocation(doId, parentId, zoneId)
# this check doesn't work because of global UD objects;
# should they have a location?
#assert len(self._doHierarchy) == len(self.doId2do)
def storeObjectLocation(self, object, parentId, zoneId):
oldParentId = object.parentId
oldZoneId = object.zoneId
if ((None not in (oldParentId, oldZoneId)) and
((oldParentId != parentId) or (oldZoneId != zoneId))):
# Remove old location
self.deleteObjectLocation(object, oldParentId, oldZoneId)
elif oldParentId == parentId and oldZoneId == zoneId:
# object is already at that parent and zone
return
if (parentId is None) or (zoneId is None):
# Do not store null values
return
# Add to new location
self._doHierarchy.storeObjectLocation(object, parentId, zoneId)
# this check doesn't work because of global UD objects;
# should they have a location?
#assert len(self._doHierarchy) == len(self.doId2do)
# Set the new parent and zone on the object
object.parentId = parentId
object.zoneId = zoneId
# Set the new parent and zone on the object
object.parentId = parentId
object.zoneId = zoneId
if 1:
# Do we still need this
if oldParentId != parentId:
# Give the parent a chance to run code when a new child
# sets location to it. For example, the parent may want to
# scene graph reparent the child to some subnode it owns.
parentObj = self.doId2do.get(parentId)
if parentObj is not None:
parentObj.handleChildArrive(object, zoneId)
elif parentId not in (0, self.getGameDoId()):
self.notify.warning('storeObjectLocation(%s): parent %s not present' %
(doId, parentId))
if 1:
# Do we still need this
if oldParentId != parentId:
# Give the parent a chance to run code when a new child
# sets location to it. For example, the parent may want to
# scene graph reparent the child to some subnode it owns.
parentObj = self.doId2do.get(parentId)
if parentObj is not None:
parentObj.handleChildArrive(object, zoneId)
elif parentId not in (0, self.getGameDoId()):
self.notify.warning('storeObjectLocation(%s): parent %s not present' %
(doId, parentId))
def deleteObjectLocation(self, doId, parentId, zoneId):
def deleteObjectLocation(self, object, parentId, zoneId):
# Do not worry about null values
if (parentId is None) or (zoneId is None):
return
@ -241,11 +236,10 @@ class DoCollectionManager:
# notify any existing parent that we're moving away
oldParentObj = self.doId2do.get(parentId)
obj = self.doId2do.get(doId)
if oldParentObj is not None and obj is not None:
oldParentObj.handleChildLeave(obj, zoneId)
if oldParentObj is not None:
oldParentObj.handleChildLeave(object, zoneId)
self._doHierarchy.deleteObjectLocation(doId, parentId, zoneId)
self._doHierarchy.deleteObjectLocation(object, parentId, zoneId)
def addDOToTables(self, do, location=None, ownerView=False):
assert self.notify.debugStateCall(self)
@ -270,7 +264,7 @@ class DoCollectionManager:
if not ownerView:
if self.isValidLocationTuple(location):
self.storeObjectLocation(do.doId, location[0], location[1])
self.storeObjectLocation(do, location[0], location[1])
##assert do.doId not in self.zoneId2doIds.get(location, {})
##self.zoneId2doIds.setdefault(location, {})
##self.zoneId2doIds[location][do.doId]=do
@ -289,7 +283,7 @@ class DoCollectionManager:
assert self.notify.debugStateCall(self)
#assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse
#assert do.doId in self.doId2do
self.deleteObjectLocation(do.doId, do.parentId, do.zoneId)
self.deleteObjectLocation(do, do.parentId, do.zoneId)
## location = do.getLocation()
## if location is not None:
## if location not in self.zoneId2doIds:

View File

@ -58,17 +58,25 @@ class DoHierarchy:
r = a
return r
def storeObjectLocation(self, doId, parentId, zoneId):
def storeObjectLocation(self, do, parentId, zoneId):
assert self.notify.debugCall()
assert doId not in self._allDoIds
doId = do.doId
if doId in self._allDoIds:
self.notify.error(
'storeObjectLocation(%s %s) already in _allDoIds' % (
do.__class__.__name__, do.doId))
parentZoneDict = self._table.setdefault(parentId, {})
zoneDoSet = parentZoneDict.setdefault(zoneId, set())
zoneDoSet.add(doId)
self._allDoIds.add(doId)
def deleteObjectLocation(self, doId, parentId, zoneId):
def deleteObjectLocation(self, do, parentId, zoneId):
assert self.notify.debugCall()
#assert doId in self._allDoIds
doId = do.doId
if doId not in self._allDoIds:
self.notify.warning(
'deleteObjectLocation(%s %s) not in _allDoIds' % (
do.__class__.__name__, do.doId))
# jbutler: temp hack to get by the assert, this will be fixed soon
if (doId not in self._allDoIds):
return