set location for quests

This commit is contained in:
Dave Schuyler 2005-06-09 04:00:28 +00:00
parent 383cfb4704
commit ddef13c674

View File

@ -141,28 +141,39 @@ class DoCollectionManager:
self.notify.warning( self.notify.warning(
"handleObjectLocation: Asked to update non-existent obj: %s" % (doId)) "handleObjectLocation: Asked to update non-existent obj: %s" % (doId))
def handleSetLocation(self, di):
# This was initially added because creating a distributed quest
# object would cause a message like this to be generated.
assert self.notify.debugStateCall(self)
parentId = di.getUint32()
zoneId = di.getUint32()
distObj = self.doId2do.get(self.getMsgChannel())
if distObj is not None:
distObj.setLocation(parentId, zoneId)
def storeObjectLocation(self, doId, parentId, zoneId): def storeObjectLocation(self, doId, parentId, zoneId):
if (parentId is None) or (zoneId is None): if (parentId is None) or (zoneId is None):
# Do not store null values # Do not store null values
return return
# TODO: check current location # TODO: check current location
obj = self.doId2do.get(doId) obj = self.doId2do.get(doId)
oldParentId = obj.parentId if obj is not None:
oldZoneId = obj.zoneId oldParentId = obj.parentId
oldZoneId = obj.zoneId
if oldParentId != parentId: if oldParentId != parentId:
# Remove old location # Remove old location
parentZoneDict = self.__doHierarchy.get(oldParentId) parentZoneDict = self.__doHierarchy.get(oldParentId)
if parentZoneDict is not None: if parentZoneDict is not None:
zoneDoSet = parentZoneDict.get(oldZoneId) zoneDoSet = parentZoneDict.get(oldZoneId)
if zoneDoSet is not None and doId in zoneDoSet: if zoneDoSet is not None and doId in zoneDoSet:
zoneDoSet.remove(doId) zoneDoSet.remove(doId)
if len(zoneDoSet) == 0: if len(zoneDoSet) == 0:
del parentZoneDict[oldZoneId] del parentZoneDict[oldZoneId]
# Add to new location # Add to new location
parentZoneDict = self.__doHierarchy.setdefault(parentId, {}) parentZoneDict = self.__doHierarchy.setdefault(parentId, {})
zoneDoSet = parentZoneDict.setdefault(zoneId, set()) zoneDoSet = parentZoneDict.setdefault(zoneId, set())
zoneDoSet.add(doId) zoneDoSet.add(doId)
## if oldParentId == parentId: ## if oldParentId == parentId:
## # Case 1: Same parent, new zone ## # Case 1: Same parent, new zone