diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 495720ebe7..756ca27bea 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -34,7 +34,7 @@ PStatCollector DCClass::_generate_pcollector("App:Show code:readerPollTask:Gener #endif // CPPPARSER ConfigVariableBool dc_multiple_inheritance -("dc-multiple-inheritance", false, +("dc-multiple-inheritance", true, PRC_DESC("Set this true to support multiple inheritance in the dc file. " "If this is false, the old way, multiple inheritance is not " "supported, but field numbers will be numbered sequentially, " @@ -977,7 +977,7 @@ ai_format_generate(PyObject *distobj, int do_id, // Parent is a bit overloaded; this parent is not about inheritance, // this one is about the visibility container parent, i.e. the zone // parent: - if (parent_id) { // if wantOtpServer: + if (parent_id) { packer.raw_pack_uint32(parent_id); } packer.raw_pack_uint32(zone_id); diff --git a/direct/src/distributed/ClientRepository.py b/direct/src/distributed/ClientRepository.py index 8147391fd9..3633cbae24 100644 --- a/direct/src/distributed/ClientRepository.py +++ b/direct/src/distributed/ClientRepository.py @@ -32,10 +32,9 @@ class ClientRepository(ConnectionRepository): self.setClientDatagram(1) self.recorder = base.recorder - if wantOtpServer: - # this is used to imulate the old setzone behavior - # with set locationa and set interest - self.old_setzone_interest_handle = None + # this is used to emulate the old setzone behavior + # with set locationa and set interest + self.old_setzone_interest_handle = None self.readDCFile() self.cache=CRCache.CRCache() @@ -192,10 +191,9 @@ class ClientRepository(ConnectionRepository): return time.time() + self.serverDelta def handleGenerateWithRequired(self, di): - if wantOtpServer: - parentId = di.getUint32() - zoneId = di.getUint32() - assert parentId == self.GameGlobalsId or parentId in self.doId2do + parentId = di.getUint32() + zoneId = di.getUint32() + assert parentId == self.GameGlobalsId or parentId in self.doId2do # Get the class Id classId = di.getUint16() # Get the DO Id @@ -204,17 +202,13 @@ class ClientRepository(ConnectionRepository): dclass = self.dclassesByNumber[classId] dclass.startGenerate() # Create a new distributed object, and put it in the dictionary - if wantOtpServer: - distObj = self.generateWithRequiredFields(dclass, doId, di, parentId, zoneId) - else: - distObj = self.generateWithRequiredFields(dclass, doId, di) + distObj = self.generateWithRequiredFields(dclass, doId, di, parentId, zoneId) dclass.stopGenerate() def handleGenerateWithRequiredOther(self, di): - if wantOtpServer: - parentId = di.getUint32() - zoneId = di.getUint32() - assert parentId == self.GameGlobalsId or parentId in self.doId2do + parentId = di.getUint32() + zoneId = di.getUint32() + assert parentId == self.GameGlobalsId or parentId in self.doId2do # Get the class Id classId = di.getUint16() # Get the DO Id @@ -223,14 +217,10 @@ class ClientRepository(ConnectionRepository): dclass = self.dclassesByNumber[classId] dclass.startGenerate() # Create a new distributed object, and put it in the dictionary - if wantOtpServer: - distObj = self.generateWithRequiredOtherFields(dclass, doId, di, parentId, zoneId) - else: - distObj = self.generateWithRequiredOtherFields(dclass, doId, di) + distObj = self.generateWithRequiredOtherFields(dclass, doId, di, parentId, zoneId) dclass.stopGenerate() def handleGenerateWithRequiredOtherOwner(self, di): - assert wantOtpServer # Get the class Id classId = di.getUint16() # Get the DO Id @@ -247,10 +237,9 @@ class ClientRepository(ConnectionRepository): def handleQuietZoneGenerateWithRequired(self, di): # Special handler for quiet zone generates -- we need to filter - if wantOtpServer: - parentId = di.getUint32() - zoneId = di.getUint32() - assert parentId in self.doId2do + parentId = di.getUint32() + zoneId = di.getUint32() + assert parentId in self.doId2do # Get the class Id classId = di.getUint16() # Get the DO Id @@ -258,49 +247,32 @@ class ClientRepository(ConnectionRepository): # Look up the dclass dclass = self.dclassesByNumber[classId] dclass.startGenerate() - # If the class is a neverDisable class (which implies uberzone) we - # should go ahead and generate it even though we are in the quiet zone - if not wantOtpServer: - if dclass.getClassDef().neverDisable: - # Create a new distributed object, and put it in the dictionary - distObj = self.generateWithRequiredFields(dclass, doId, di) - else: - distObj = self.generateWithRequiredFields(dclass, doId, di, parentId, zoneId) + distObj = self.generateWithRequiredFields(dclass, doId, di, parentId, zoneId) dclass.stopGenerate() def handleQuietZoneGenerateWithRequiredOther(self, di): # Special handler for quiet zone generates -- we need to filter - if wantOtpServer: - parentId = di.getUint32() - zoneId = di.getUint32() - assert parentId in self.doId2do + parentId = di.getUint32() + zoneId = di.getUint32() + assert parentId in self.doId2do # Get the class Id classId = di.getUint16() # Get the DO Id doId = di.getUint32() # Look up the dclass dclass = self.dclassesByNumber[classId] - # If the class is a neverDisable class (which implies uberzone) we - # should go ahead and generate it even though we are in the quiet zone dclass.startGenerate() - if not wantOtpServer: - if dclass.getClassDef().neverDisable: - # Create a new distributed object, and put it in the dictionary - distObj = self.generateWithRequiredOtherFields(dclass, doId, di) - else: - distObj = self.generateWithRequiredOtherFields(dclass, doId, di, parentId, zoneId) + distObj = self.generateWithRequiredOtherFields(dclass, doId, di, parentId, zoneId) dclass.stopGenerate() - # wantOtpServer: remove the None defaults when we remove this config variable - def generateWithRequiredFields(self, dclass, doId, di, parentId = None, zoneId = None): + def generateWithRequiredFields(self, dclass, doId, di, parentId, zoneId): if self.doId2do.has_key(doId): # ...it is in our dictionary. # Just update it. distObj = self.doId2do[doId] assert(distObj.dclass == dclass) distObj.generate() - if wantOtpServer: - distObj.setLocation(parentId, zoneId) + distObj.setLocation(parentId, zoneId) distObj.updateRequiredFields(dclass, di) # updateRequiredFields calls announceGenerate elif self.cache.contains(doId): @@ -312,8 +284,7 @@ class ClientRepository(ConnectionRepository): self.doId2do[doId] = distObj # and update it. distObj.generate() - if wantOtpServer: - distObj.setLocation(parentId, zoneId) + distObj.setLocation(parentId, zoneId) distObj.updateRequiredFields(dclass, di) # updateRequiredFields calls announceGenerate else: @@ -331,12 +302,10 @@ class ClientRepository(ConnectionRepository): # Update the required fields distObj.generateInit() # Only called when constructed distObj.generate() - if wantOtpServer: - distObj.setLocation(parentId, zoneId) + distObj.setLocation(parentId, zoneId) distObj.updateRequiredFields(dclass, di) # updateRequiredFields calls announceGenerate - if wantOtpServer: - print "New DO:%s, dclass:%s"%(doId, dclass.getName()) + print "New DO:%s, dclass:%s"%(doId, dclass.getName()) return distObj ## def generateGlobalObject(self, doId, dcname): @@ -359,11 +328,10 @@ class ClientRepository(ConnectionRepository): ## # Update the required fields ## distObj.generateInit() # Only called when constructed ## distObj.generate() - ## if wantOtpServer: - ## # TODO: ROGER: where should we get parentId and zoneId? - ## parentId = None - ## zoneId = None - ## distObj.setLocation(parentId, zoneId) + ## # TODO: ROGER: where should we get parentId and zoneId? + ## parentId = None + ## zoneId = None + ## distObj.setLocation(parentId, zoneId) ## # updateRequiredFields calls announceGenerate ## return distObj @@ -375,8 +343,7 @@ class ClientRepository(ConnectionRepository): distObj = self.doId2do[doId] assert(distObj.dclass == dclass) distObj.generate() - if wantOtpServer: - distObj.setLocation(parentId, zoneId) + distObj.setLocation(parentId, zoneId) distObj.updateRequiredOtherFields(dclass, di) # updateRequiredOtherFields calls announceGenerate elif self.cache.contains(doId): @@ -388,8 +355,7 @@ class ClientRepository(ConnectionRepository): self.doId2do[doId] = distObj # and update it. distObj.generate() - if wantOtpServer: - distObj.setLocation(parentId, zoneId) + distObj.setLocation(parentId, zoneId) distObj.updateRequiredOtherFields(dclass, di) # updateRequiredOtherFields calls announceGenerate else: @@ -407,8 +373,7 @@ class ClientRepository(ConnectionRepository): # Update the required fields distObj.generateInit() # Only called when constructed distObj.generate() - if wantOtpServer: - distObj.setLocation(parentId, zoneId) + distObj.setLocation(parentId, zoneId) distObj.updateRequiredOtherFields(dclass, di) # updateRequiredOtherFields calls announceGenerate return distObj @@ -573,45 +538,26 @@ class ClientRepository(ConnectionRepository): self.handleServerHeartbeat(di) elif msgType == CLIENT_SYSTEM_MESSAGE: self.handleSystemMessage(di) - elif wantOtpServer: - if msgType == CLIENT_CREATE_OBJECT_REQUIRED: - self.handleGenerateWithRequired(di) - elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER: - self.handleGenerateWithRequiredOther(di) - elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER_OWNER: - self.handleGenerateWithRequiredOtherOwner(di) - elif msgType == CLIENT_OBJECT_UPDATE_FIELD: - self.handleUpdateField(di) - elif msgType == CLIENT_OBJECT_DISABLE: - self.handleDisable(di) - elif msgType == CLIENT_OBJECT_DISABLE_OWNER: - self.handleDisable(di, ownerView=True) - elif msgType == CLIENT_OBJECT_DELETE_RESP: - self.handleDelete(di) - elif msgType == CLIENT_DONE_INTEREST_RESP: - self.handleInterestDoneMessage(di) - elif msgType == CLIENT_QUERY_ONE_FIELD_RESP: - self.handleQueryOneFieldResp(di) - elif msgType == CLIENT_OBJECT_LOCATION: - self.handleObjectLocation(di) - else: - currentLoginState = self.loginFSM.getCurrentState() - if currentLoginState: - currentLoginStateName = currentLoginState.getName() - else: - currentLoginStateName = "None" - currentGameState = self.gameFSM.getCurrentState() - if currentGameState: - currentGameStateName = currentGameState.getName() - else: - currentGameStateName = "None" - ClientRepository.notify.warning( - "Ignoring unexpected message type: " + - str(msgType) + - " login state: " + - currentLoginStateName + - " game state: " + - currentGameStateName) + elif msgType == CLIENT_CREATE_OBJECT_REQUIRED: + self.handleGenerateWithRequired(di) + elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER: + self.handleGenerateWithRequiredOther(di) + elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER_OWNER: + self.handleGenerateWithRequiredOtherOwner(di) + elif msgType == CLIENT_OBJECT_UPDATE_FIELD: + self.handleUpdateField(di) + elif msgType == CLIENT_OBJECT_DISABLE: + self.handleDisable(di) + elif msgType == CLIENT_OBJECT_DISABLE_OWNER: + self.handleDisable(di, ownerView=True) + elif msgType == CLIENT_OBJECT_DELETE_RESP: + self.handleDelete(di) + elif msgType == CLIENT_DONE_INTEREST_RESP: + self.handleInterestDoneMessage(di) + elif msgType == CLIENT_QUERY_ONE_FIELD_RESP: + self.handleQueryOneFieldResp(di) + elif msgType == CLIENT_OBJECT_LOCATION: + self.handleObjectLocation(di) else: currentLoginState = self.loginFSM.getCurrentState() if currentLoginState: @@ -695,16 +641,6 @@ class ClientRepository(ConnectionRepository): # send the message self.send(datagram) - if not wantOtpServer: - def sendSetShardMsg(self, shardId): - datagram = PyDatagram() - # Add message type - datagram.addUint16(CLIENT_SET_SHARD) - # Add shard id - datagram.addUint32(shardId) - # send the message - self.send(datagram) - def getObjectsOfClass(self, objClass): """ returns dict of doId:object, containing all objects that inherit from 'class'. returned dict is safely mutable. """ @@ -724,72 +660,45 @@ class ClientRepository(ConnectionRepository): doDict[doId] = do return doDict - if wantOtpServer: - def sendEmulateSetZoneMsg(self, zoneId, visibleZoneList=None, - parentIdin=None, event=None): - """ - This Will Move The avatar and set an interest to that location .. - """ - parentId = parentIdin - if parentId is None: - parentId = base.localAvatar.defaultShard + def sendEmulateSetZoneMsg(self, zoneId, visibleZoneList=None, + parentIdin=None, event=None): + """ + This Will Move The avatar and set an interest to that location .. + """ + parentId = parentIdin + if parentId is None: + parentId = base.localAvatar.defaultShard - # move the avatar - self.sendSetLocation(base.localAvatar.doId,parentId,zoneId) + # move the avatar + self.sendSetLocation(base.localAvatar.doId,parentId,zoneId) - # move the interest - InterestZones = zoneId - if visibleZoneList is not None: - InterestZones = visibleZoneList + # move the interest + InterestZones = zoneId + if visibleZoneList is not None: + InterestZones = visibleZoneList - if(self.old_setzone_interest_handle == None): - self.old_setzone_interest_handle = self.addInterest( - parentId, InterestZones, "OldSetZone Imulator", event) - else: - self.alterInterest(self.old_setzone_interest_handle, - parentId, InterestZones, "OldSetZone Imulator", event) + if(self.old_setzone_interest_handle == None): + self.old_setzone_interest_handle = self.addInterest( + parentId, InterestZones, "OldSetZone Imulator", event) + else: + self.alterInterest(self.old_setzone_interest_handle, + parentId, InterestZones, "OldSetZone Imulator", event) - def sendEmulateSetZoneOff(self): - MyAvID = base.localAvatar.doId - self.sendSetLocation(MyAvID,0,0) - if self.old_setzone_interest_handle is not None: - self.removeInterest(self.old_setzone_interest_handle) - self.old_setzone_interest_handle = None + def sendEmulateSetZoneOff(self): + MyAvID = base.localAvatar.doId + self.sendSetLocation(MyAvID,0,0) + if self.old_setzone_interest_handle is not None: + self.removeInterest(self.old_setzone_interest_handle) + self.old_setzone_interest_handle = None - def sendSetLocation(self,doId,parentId,zoneId): - datagram = PyDatagram() - datagram.addUint16(CLIENT_OBJECT_LOCATION) - datagram.addUint32(doId) - datagram.addUint32(parentId) - datagram.addUint32(zoneId) - self.send(datagram) - - else: - def sendSetZoneMsg(self, zoneId, visibleZoneList=None): - datagram = PyDatagram() - # Add message type - datagram.addUint16(CLIENT_SET_ZONE) - # Add zone id - datagram.addUint32(zoneId) - - # if we have an explicit list of visible zones, add them - if visibleZoneList is not None: - vzl = list(visibleZoneList) - vzl.sort() - assert PythonUtil.uniqueElements(vzl) - for zone in vzl: - datagram.addUint32(zone) - - # send the message - self.send(datagram) - - assert self.setZonesRequested >= self.setZonesReceived - self.setZonesRequested += 1 - - # override if desired - def handleSetZoneDone(self): - pass + def sendSetLocation(self,doId,parentId,zoneId): + datagram = PyDatagram() + datagram.addUint16(CLIENT_OBJECT_LOCATION) + datagram.addUint32(doId) + datagram.addUint32(parentId) + datagram.addUint32(zoneId) + self.send(datagram) def handleDatagram(self, di): if self.notify.getDebug(): @@ -799,10 +708,6 @@ class ClientRepository(ConnectionRepository): msgType = self.getMsgType() - if not wantOtpServer: - if msgType == CLIENT_DONE_SET_ZONE_RESP: - self.handleSetZoneDone() - if self.handler == None: self.handleMessageType(msgType, di) else: diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index 65f2221dea..ece6c54371 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -183,10 +183,9 @@ class DistributedObject(PandaObject): if self.activeState != ESDisabled: self.activeState = ESDisabled self.__callbacks = {} - if wantOtpServer: - #self.cr.deleteObjectLocation(self.doId, self.parentId, self.zoneId) - self.setLocation(None, None) - # TODO: disable my children + #self.cr.deleteObjectLocation(self.doId, self.parentId, self.zoneId) + self.setLocation(None, None) + # TODO: disable my children def isDisabled(self): """ @@ -371,86 +370,85 @@ class DistributedObject(PandaObject): else: assert(self.notify.debug('doneBarrier(%s) ignored; no active barrier.' % (name))) - if wantOtpServer: - def addInterest(self, zoneId, note="", event=None): - self.cr.addInterest(self.getDoId(), zoneId, note, event) + def addInterest(self, zoneId, note="", event=None): + self.cr.addInterest(self.getDoId(), zoneId, note, event) - def b_setLocation(self, parentId, zoneId): - self.d_setLocation(parentId, zoneId) - self.setLocation(parentId, zoneId) + def b_setLocation(self, parentId, zoneId): + self.d_setLocation(parentId, zoneId) + self.setLocation(parentId, zoneId) - def d_setLocation(self, parentId, zoneId): - self.cr.sendSetLocation(self.doId, parentId, zoneId) - - def setLocation(self, parentId, zoneId): - # Prevent Duplicate SetLocations for being Called - if (self.parentId == parentId) and (self.zoneId == zoneId): - return + def d_setLocation(self, parentId, zoneId): + self.cr.sendSetLocation(self.doId, parentId, zoneId) - #self.notify.info("setLocation: %s parentId: %s zoneId: %s" % (self.doId, parentId, zoneId)) - # parentId can be 'None', e.g. when an object is being disabled - oldParentId = self.parentId - oldZoneId = self.zoneId - parentIsNew = (oldParentId != parentId) + def setLocation(self, parentId, zoneId): + # Prevent Duplicate SetLocations for being Called + if (self.parentId == parentId) and (self.zoneId == zoneId): + return - # notify any existing parent that we're moving away - if (oldParentId is not None) and parentIsNew: - oldParentObj = self.cr.doId2do.get(oldParentId) - if oldParentObj: - oldParentObj.handleChildLeave(self, oldZoneId) + #self.notify.info("setLocation: %s parentId: %s zoneId: %s" % (self.doId, parentId, zoneId)) + # parentId can be 'None', e.g. when an object is being disabled + oldParentId = self.parentId + oldZoneId = self.zoneId + parentIsNew = (oldParentId != parentId) - # The store must run first so we know the old location - self.parentId = parentId - self.zoneId = zoneId - self.cr.storeObjectLocation(self.doId, parentId, zoneId) + # notify any existing parent that we're moving away + if (oldParentId is not None) and parentIsNew: + oldParentObj = self.cr.doId2do.get(oldParentId) + if oldParentObj: + oldParentObj.handleChildLeave(self, oldZoneId) - # 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. - if (self.parentId is not None) and parentIsNew: - parentObj = self.cr.doId2do.get(parentId) - if parentObj: - parentObj.handleChildArrive(self, zoneId) - - def getLocation(self): - try: - if self.parentId == 0 and self.zoneId == 0: - return None - # This is a -1 stuffed into a uint32 - if self.parentId == 0xffffffff and self.zoneId == 0xffffffff: - return None - return (self.parentId, self.zoneId) - except AttributeError: + # The store must run first so we know the old location + self.parentId = parentId + self.zoneId = zoneId + self.cr.storeObjectLocation(self.doId, parentId, zoneId) + + # 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. + if (self.parentId is not None) and parentIsNew: + parentObj = self.cr.doId2do.get(parentId) + if parentObj: + parentObj.handleChildArrive(self, zoneId) + + def getLocation(self): + try: + if self.parentId == 0 and self.zoneId == 0: return None - - def handleChildArrive(self, childObj, zoneId): - self.notify.debugCall() - # A new child has just setLocation beneath us. Give us a - # chance to run code when a new child sets location to us. For - # example, we may want to scene graph reparent the child to - # some subnode we own. - ## zone=self.children.setdefault(zoneId, {}) - ## zone[childObj.doId]=childObj - - # Inheritors should override - pass - - def handleChildLeave(self, childObj, zoneId): - self.notify.debugCall() - # A child is about to setLocation away from us. Give us a - # chance to run code just before a child sets location away from us. - ## zone=self.children[zoneId] - ## del zone[childObj.doId] - ## if not len(zone): - ## del self.children[zoneId] - - # Inheritors should override - pass - - def getParentObj(self): - if self.parentId is None: + # This is a -1 stuffed into a uint32 + if self.parentId == 0xffffffff and self.zoneId == 0xffffffff: return None - return self.cr.doId2do.get(self.parentId) + return (self.parentId, self.zoneId) + except AttributeError: + return None + + def handleChildArrive(self, childObj, zoneId): + self.notify.debugCall() + # A new child has just setLocation beneath us. Give us a + # chance to run code when a new child sets location to us. For + # example, we may want to scene graph reparent the child to + # some subnode we own. + ## zone=self.children.setdefault(zoneId, {}) + ## zone[childObj.doId]=childObj + + # Inheritors should override + pass + + def handleChildLeave(self, childObj, zoneId): + self.notify.debugCall() + # A child is about to setLocation away from us. Give us a + # chance to run code just before a child sets location away from us. + ## zone=self.children[zoneId] + ## del zone[childObj.doId] + ## if not len(zone): + ## del self.children[zoneId] + + # Inheritors should override + pass + + def getParentObj(self): + if self.parentId is None: + return None + return self.cr.doId2do.get(self.parentId) def isLocal(self): # This returns true if the distributed object is "local," diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py index aa6f6ad7ae..5c11d79867 100644 --- a/direct/src/distributed/DistributedObjectAI.py +++ b/direct/src/distributed/DistributedObjectAI.py @@ -175,71 +175,55 @@ class DistributedObjectAI(DirectObject): self.__generated = True messenger.send(self.uniqueName("generate"), [self]) - if wantOtpServer: - def addInterest(self, zoneId, note="", event=None): - self.air.addInterest(self.getDoId(), zoneId, note, event) + def addInterest(self, zoneId, note="", event=None): + self.air.addInterest(self.getDoId(), zoneId, note, event) - def b_setLocation(self, parentId, zoneId): - self.d_setLocation(parentId, zoneId) - self.setLocation(parentId, zoneId) + def b_setLocation(self, parentId, zoneId): + self.d_setLocation(parentId, zoneId) + self.setLocation(parentId, zoneId) - def d_setLocation(self, parentId, zoneId): - self.air.sendSetLocation(self, parentId, zoneId) + def d_setLocation(self, parentId, zoneId): + self.air.sendSetLocation(self, parentId, zoneId) - def setLocation(self, parentId, zoneId): - # Prevent Duplicate SetLocations for being Called - if (self.parentId == parentId) and (self.zoneId == zoneId): - return + def setLocation(self, parentId, zoneId): + # Prevent Duplicate SetLocations for being Called + if (self.parentId == parentId) and (self.zoneId == zoneId): + return - oldParentId = self.parentId - oldZoneId = self.zoneId - if ((oldParentId != parentId) or - (oldZoneId != zoneId)): - #print "%s location is now %s, %s (%s)"%(self.doId, parentId, zoneId, self) - self.zoneId = zoneId - self.parentId = parentId - self.air.changeDOZoneInTables(self, parentId, zoneId, oldParentId, oldZoneId) - messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId]) - # if we are not going into the quiet zone, send a 'logical' zone - # change message - if zoneId != DistributedObjectAI.QuietZone: - lastLogicalZone = oldZoneId - if oldZoneId == DistributedObjectAI.QuietZone: - lastLogicalZone = self.lastNonQuietZone - self.handleLogicalZoneChange(zoneId, lastLogicalZone) - self.lastNonQuietZone = zoneId - self.air.storeObjectLocation(self.doId, parentId, zoneId) - - # Set the initial values of parentId,zoneId - def setInitLocation(self, parentId, zoneId): - self.parentId=parentId - self.zoneId=zoneId - - def getLocation(self): - try: - if self.parentId <= 0 and self.zoneId <= 0: - return None - # This is a -1 stuffed into a uint32 - if self.parentId == 0xffffffff and self.zoneId == 0xffffffff: - return None - return (self.parentId, self.zoneId) - except AttributeError: - return None - - else: - # NON OTP - def handleZoneChange(self, newZoneId, oldZoneId): - self.zoneId = newZoneId - self.air.changeDOZoneInTables(self, newZoneId, oldZoneId) - messenger.send(self.getZoneChangeEvent(), [newZoneId, oldZoneId]) - # if we are not going into the quiet zone, send a 'logical' zone change - # message - if newZoneId != DistributedObjectAI.QuietZone: + oldParentId = self.parentId + oldZoneId = self.zoneId + if ((oldParentId != parentId) or + (oldZoneId != zoneId)): + #print "%s location is now %s, %s (%s)"%(self.doId, parentId, zoneId, self) + self.zoneId = zoneId + self.parentId = parentId + self.air.changeDOZoneInTables(self, parentId, zoneId, oldParentId, oldZoneId) + messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId]) + # if we are not going into the quiet zone, send a 'logical' zone + # change message + if zoneId != DistributedObjectAI.QuietZone: lastLogicalZone = oldZoneId if oldZoneId == DistributedObjectAI.QuietZone: lastLogicalZone = self.lastNonQuietZone - self.handleLogicalZoneChange(newZoneId, lastLogicalZone) - self.lastNonQuietZone = newZoneId + self.handleLogicalZoneChange(zoneId, lastLogicalZone) + self.lastNonQuietZone = zoneId + self.air.storeObjectLocation(self.doId, parentId, zoneId) + + # Set the initial values of parentId,zoneId + def setInitLocation(self, parentId, zoneId): + self.parentId=parentId + self.zoneId=zoneId + + def getLocation(self): + try: + if self.parentId <= 0 and self.zoneId <= 0: + return None + # This is a -1 stuffed into a uint32 + if self.parentId == 0xffffffff and self.zoneId == 0xffffffff: + return None + return (self.parentId, self.zoneId) + except AttributeError: + return None def updateRequiredFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) @@ -300,113 +284,78 @@ class DistributedObjectAI(DirectObject): if self.air: self.air.sendUpdate(self, fieldName, args) - if wantOtpServer: - def GetPuppetConnectionChannel(self, doId): - return doId + (1L << 32) + def GetPuppetConnectionChannel(self, doId): + return doId + (1L << 32) - def GetAccountIDFromChannelCode(self, channel): - return channel >> 32 + def GetAccountIDFromChannelCode(self, channel): + return channel >> 32 - def GetAvatarIDFromChannelCode(self, channel): - return channel & 0xffffffffL + def GetAvatarIDFromChannelCode(self, channel): + return channel & 0xffffffffL - def sendUpdateToAvatarId(self, avId, fieldName, args): - assert self.notify.debugStateCall(self) - channelId = self.GetPuppetConnectionChannel(avId) - self.sendUpdateToChannel(channelId, fieldName, args) - else: - def sendUpdateToAvatarId(self, avId, fieldName, args): - assert self.notify.debugStateCall(self) - channelId = avId + 1 - self.sendUpdateToChannel(channelId, fieldName, args) + def sendUpdateToAvatarId(self, avId, fieldName, args): + assert self.notify.debugStateCall(self) + channelId = self.GetPuppetConnectionChannel(avId) + self.sendUpdateToChannel(channelId, fieldName, args) def sendUpdateToChannel(self, channelId, fieldName, args): assert self.notify.debugStateCall(self) if self.air: self.air.sendUpdateToChannel(self, channelId, fieldName, args) - if wantOtpServer: - def generateWithRequired(self, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - self.__preallocDoId = 0 - return self.generateWithRequiredAndId( - self.doId, zoneId, optionalFields) + def generateWithRequired(self, zoneId, optionalFields=[]): + assert self.notify.debugStateCall(self) + # have we already allocated a doId? + if self.__preallocDoId: + self.__preallocDoId = 0 + return self.generateWithRequiredAndId( + self.doId, zoneId, optionalFields) - # The repository is the one that really does the work - parentId = self.air.districtId - self.parentId = parentId - self.zoneId = zoneId - self.air.generateWithRequired(self, parentId, zoneId, optionalFields) - self.generate() - else: - def generateWithRequired(self, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - self.__preallocDoId = 0 - return self.generateWithRequiredAndId( - self.doId, zoneId, optionalFields) - - # The repository is the one that really does the work - self.air.generateWithRequired(self, zoneId, optionalFields) - self.zoneId = zoneId - self.generate() + # The repository is the one that really does the work + parentId = self.air.districtId + self.parentId = parentId + self.zoneId = zoneId + self.air.generateWithRequired(self, parentId, zoneId, optionalFields) + self.generate() # this is a special generate used for estates, or anything else that # needs to have a hard coded doId as assigned by the server - if wantOtpServer: - def generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - assert doId == self.__preallocDoId - self.__preallocDoId = 0 + def generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields=[]): + assert self.notify.debugStateCall(self) + # have we already allocated a doId? + if self.__preallocDoId: + assert doId == self.__preallocDoId + self.__preallocDoId = 0 - # The repository is the one that really does the work - self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields) - self.parentId = parentId - self.zoneId = zoneId - self.generate() - self.announceGenerate() - else: - def generateWithRequiredAndId(self, doId, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - assert doId == self.__preallocDoId - self.__preallocDoId = 0 + # The repository is the one that really does the work + self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields) + self.parentId = parentId + self.zoneId = zoneId + self.generate() + self.announceGenerate() - # The repository is the one that really does the work - self.air.generateWithRequiredAndId(self, doId, zoneId, optionalFields) - self.zoneId = zoneId - self.generate() - self.announceGenerate() + def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None): + assert self.notify.debugStateCall(self) + # have we already allocated a doId? + if self.__preallocDoId: + assert doId is None or doId == self.__preallocDoId + doId=self.__preallocDoId + self.__preallocDoId = 0 - if wantOtpServer: - def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - assert doId is None or doId == self.__preallocDoId - doId=self.__preallocDoId - self.__preallocDoId = 0 + # Assign it an id + if doId is None: + self.doId = self.air.allocateChannel() + else: + self.doId = doId + # Put the new DO in the dictionaries + self.air.addDOToTables(self, location=(parentId,zoneId)) + # Send a generate message + self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields) - # Assign it an id - if doId is None: - self.doId = self.air.allocateChannel() - else: - self.doId = doId - # Put the new DO in the dictionaries - self.air.addDOToTables(self, location=(parentId,zoneId)) - # Send a generate message - self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields) - - assert not hasattr(self, 'parentId') or self.parentId is None - self.parentId = parentId - self.zoneId = zoneId - self.generate() + assert not hasattr(self, 'parentId') or self.parentId is None + self.parentId = parentId + self.zoneId = zoneId + self.generate() def generate(self): """ @@ -414,39 +363,30 @@ class DistributedObjectAI(DirectObject): other networked info in this function. """ assert self.notify.debugStateCall(self) - if wantOtpServer: - self.air.storeObjectLocation(self.doId, self.parentId, self.zoneId) + self.air.storeObjectLocation(self.doId, self.parentId, self.zoneId) - if wantOtpServer: - def generateInit(self, repository=None): - """ - First generate (not from cache). - """ - assert self.notify.debugStateCall(self) + def generateInit(self, repository=None): + """ + First generate (not from cache). + """ + assert self.notify.debugStateCall(self) - def generateTargetChannel(self, repository): - """ - Who to send this to for generate messages - """ - if hasattr(self, "dbObject"): - return self.doId - return repository.serverId + def generateTargetChannel(self, repository): + """ + Who to send this to for generate messages + """ + if hasattr(self, "dbObject"): + return self.doId + return repository.serverId def sendGenerateWithRequired(self, repository, parentId, zoneId, optionalFields=[]): assert self.notify.debugStateCall(self) - if not wantOtpServer: - dg = self.dclass.aiFormatGenerate( - self, self.doId, 0, zoneId, - repository.districtId, - repository.ourChannel, - optionalFields) - else: - dg = self.dclass.aiFormatGenerate( - self, self.doId, parentId, zoneId, - #repository.serverId, - self.generateTargetChannel(repository), - repository.ourChannel, - optionalFields) + dg = self.dclass.aiFormatGenerate( + self, self.doId, parentId, zoneId, + #repository.serverId, + self.generateTargetChannel(repository), + repository.ourChannel, + optionalFields) repository.send(dg) def initFromServerResponse(self, valDict): diff --git a/direct/src/distributed/DistributedObjectUD.py b/direct/src/distributed/DistributedObjectUD.py index a384f2bbfe..8de9dac5aa 100755 --- a/direct/src/distributed/DistributedObjectUD.py +++ b/direct/src/distributed/DistributedObjectUD.py @@ -170,71 +170,55 @@ class DistributedObjectUD(DirectObject): self.__generated = True messenger.send(self.uniqueName("generate"), [self]) - if wantOtpServer: - def addInterest(self, zoneId, note="", event=None): - self.air.addInterest(self.getDoId(), zoneId, note, event) + def addInterest(self, zoneId, note="", event=None): + self.air.addInterest(self.getDoId(), zoneId, note, event) - def b_setLocation(self, parentId, zoneId): - self.d_setLocation(parentId, zoneId) - self.setLocation(parentId, zoneId) + def b_setLocation(self, parentId, zoneId): + self.d_setLocation(parentId, zoneId) + self.setLocation(parentId, zoneId) - def d_setLocation(self, parentId, zoneId): - self.air.sendSetLocation(self, parentId, zoneId) + def d_setLocation(self, parentId, zoneId): + self.air.sendSetLocation(self, parentId, zoneId) - def setLocation(self, parentId, zoneId): - # Prevent Duplicate SetLocations for being Called - if (self.parentId == parentId) and (self.zoneId == zoneId): - return + def setLocation(self, parentId, zoneId): + # Prevent Duplicate SetLocations for being Called + if (self.parentId == parentId) and (self.zoneId == zoneId): + return - oldParentId = self.parentId - oldZoneId = self.zoneId - if ((oldParentId != parentId) or - (oldZoneId != zoneId)): - #print "%s location is now %s, %s (%s)"%(self.doId, parentId, zoneId, self) - self.zoneId = zoneId - self.parentId = parentId - self.air.changeDOZoneInTables(self, parentId, zoneId, oldParentId, oldZoneId) - messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId]) - # if we are not going into the quiet zone, send a 'logical' zone - # change message - if zoneId != DistributedObjectUD.QuietZone: - lastLogicalZone = oldZoneId - if oldZoneId == DistributedObjectUD.QuietZone: - lastLogicalZone = self.lastNonQuietZone - self.handleLogicalZoneChange(zoneId, lastLogicalZone) - self.lastNonQuietZone = zoneId - self.air.storeObjectLocation(self.doId, parentId, zoneId) - - # Set the initial values of parentId,zoneId - def setInitLocation(self, parentId, zoneId): - self.parentId=parentId - self.zoneId=zoneId - - def getLocation(self): - try: - if self.parentId <= 0 and self.zoneId <= 0: - return None - # This is a -1 stuffed into a uint32 - if self.parentId == 0xffffffff and self.zoneId == 0xffffffff: - return None - return (self.parentId, self.zoneId) - except AttributeError: - return None - - else: - # NON OTP - def handleZoneChange(self, newZoneId, oldZoneId): - self.zoneId = newZoneId - self.air.changeDOZoneInTables(self, newZoneId, oldZoneId) - messenger.send(self.getZoneChangeEvent(), [newZoneId, oldZoneId]) - # if we are not going into the quiet zone, send a 'logical' zone change - # message - if newZoneId != DistributedObjectUD.QuietZone: + oldParentId = self.parentId + oldZoneId = self.zoneId + if ((oldParentId != parentId) or + (oldZoneId != zoneId)): + #print "%s location is now %s, %s (%s)"%(self.doId, parentId, zoneId, self) + self.zoneId = zoneId + self.parentId = parentId + self.air.changeDOZoneInTables(self, parentId, zoneId, oldParentId, oldZoneId) + messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId]) + # if we are not going into the quiet zone, send a 'logical' zone + # change message + if zoneId != DistributedObjectUD.QuietZone: lastLogicalZone = oldZoneId if oldZoneId == DistributedObjectUD.QuietZone: lastLogicalZone = self.lastNonQuietZone - self.handleLogicalZoneChange(newZoneId, lastLogicalZone) - self.lastNonQuietZone = newZoneId + self.handleLogicalZoneChange(zoneId, lastLogicalZone) + self.lastNonQuietZone = zoneId + self.air.storeObjectLocation(self.doId, parentId, zoneId) + + # Set the initial values of parentId,zoneId + def setInitLocation(self, parentId, zoneId): + self.parentId=parentId + self.zoneId=zoneId + + def getLocation(self): + try: + if self.parentId <= 0 and self.zoneId <= 0: + return None + # This is a -1 stuffed into a uint32 + if self.parentId == 0xffffffff and self.zoneId == 0xffffffff: + return None + return (self.parentId, self.zoneId) + except AttributeError: + return None def updateRequiredFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) @@ -295,113 +279,78 @@ class DistributedObjectUD(DirectObject): if self.air: self.air.sendUpdate(self, fieldName, args) - if wantOtpServer: - def GetPuppetConnectionChannel(self, doId): - return doId + (1L << 32) + def GetPuppetConnectionChannel(self, doId): + return doId + (1L << 32) - def GetAccountIDFromChannelCode(self, channel): - return channel >> 32 + def GetAccountIDFromChannelCode(self, channel): + return channel >> 32 - def GetAvatarIDFromChannelCode(self, channel): - return channel & 0xffffffffL + def GetAvatarIDFromChannelCode(self, channel): + return channel & 0xffffffffL - def sendUpdateToAvatarId(self, avId, fieldName, args): - assert self.notify.debugStateCall(self) - channelId = self.GetPuppetConnectionChannel(avId) - self.sendUpdateToChannel(channelId, fieldName, args) - else: - def sendUpdateToAvatarId(self, avId, fieldName, args): - assert self.notify.debugStateCall(self) - channelId = avId + 1 - self.sendUpdateToChannel(channelId, fieldName, args) + def sendUpdateToAvatarId(self, avId, fieldName, args): + assert self.notify.debugStateCall(self) + channelId = self.GetPuppetConnectionChannel(avId) + self.sendUpdateToChannel(channelId, fieldName, args) def sendUpdateToChannel(self, channelId, fieldName, args): assert self.notify.debugStateCall(self) if self.air: self.air.sendUpdateToChannel(self, channelId, fieldName, args) - if wantOtpServer: - def generateWithRequired(self, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - self.__preallocDoId = 0 - return self.generateWithRequiredAndId( - self.doId, zoneId, optionalFields) + def generateWithRequired(self, zoneId, optionalFields=[]): + assert self.notify.debugStateCall(self) + # have we already allocated a doId? + if self.__preallocDoId: + self.__preallocDoId = 0 + return self.generateWithRequiredAndId( + self.doId, zoneId, optionalFields) - # The repository is the one that really does the work - parentId = self.air.districtId - self.parentId = parentId - self.zoneId = zoneId - self.air.generateWithRequired(self, parentId, zoneId, optionalFields) - self.generate() - else: - def generateWithRequired(self, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - self.__preallocDoId = 0 - return self.generateWithRequiredAndId( - self.doId, zoneId, optionalFields) - - # The repository is the one that really does the work - self.air.generateWithRequired(self, zoneId, optionalFields) - self.zoneId = zoneId - self.generate() + # The repository is the one that really does the work + parentId = self.air.districtId + self.parentId = parentId + self.zoneId = zoneId + self.air.generateWithRequired(self, parentId, zoneId, optionalFields) + self.generate() # this is a special generate used for estates, or anything else that # needs to have a hard coded doId as assigned by the server - if wantOtpServer: - def generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - assert doId == self.__preallocDoId - self.__preallocDoId = 0 + def generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields=[]): + assert self.notify.debugStateCall(self) + # have we already allocated a doId? + if self.__preallocDoId: + assert doId == self.__preallocDoId + self.__preallocDoId = 0 - # The repository is the one that really does the work - self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields) - self.parentId = parentId - self.zoneId = zoneId - self.generate() - self.announceGenerate() - else: - def generateWithRequiredAndId(self, doId, zoneId, optionalFields=[]): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - assert doId == self.__preallocDoId - self.__preallocDoId = 0 + # The repository is the one that really does the work + self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields) + self.parentId = parentId + self.zoneId = zoneId + self.generate() + self.announceGenerate() - # The repository is the one that really does the work - self.air.generateWithRequiredAndId(self, doId, zoneId, optionalFields) - self.zoneId = zoneId - self.generate() - self.announceGenerate() + def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None): + assert self.notify.debugStateCall(self) + # have we already allocated a doId? + if self.__preallocDoId: + assert doId is None or doId == self.__preallocDoId + doId=self.__preallocDoId + self.__preallocDoId = 0 - if wantOtpServer: - def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None): - assert self.notify.debugStateCall(self) - # have we already allocated a doId? - if self.__preallocDoId: - assert doId is None or doId == self.__preallocDoId - doId=self.__preallocDoId - self.__preallocDoId = 0 + # Assign it an id + if doId is None: + self.doId = self.air.allocateChannel() + else: + self.doId = doId + # Put the new DO in the dictionaries + self.air.addDOToTables(self, location=(parentId,zoneId)) + # Send a generate message + self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields) - # Assign it an id - if doId is None: - self.doId = self.air.allocateChannel() - else: - self.doId = doId - # Put the new DO in the dictionaries - self.air.addDOToTables(self, location=(parentId,zoneId)) - # Send a generate message - self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields) - - assert not hasattr(self, 'parentId') or self.parentId is None - self.parentId = parentId - self.zoneId = zoneId - self.generate() + assert not hasattr(self, 'parentId') or self.parentId is None + self.parentId = parentId + self.zoneId = zoneId + self.generate() def generate(self): """ @@ -409,39 +358,30 @@ class DistributedObjectUD(DirectObject): other networked info in this function. """ assert self.notify.debugStateCall(self) - if wantOtpServer: - self.air.storeObjectLocation(self.doId, self.parentId, self.zoneId) + self.air.storeObjectLocation(self.doId, self.parentId, self.zoneId) - if wantOtpServer: - def generateInit(self, repository=None): - """ - First generate (not from cache). - """ - assert self.notify.debugStateCall(self) + def generateInit(self, repository=None): + """ + First generate (not from cache). + """ + assert self.notify.debugStateCall(self) - def generateTargetChannel(self, repository): - """ - Who to send this to for generate messages - """ - if hasattr(self, "dbObject"): - return self.doId - return repository.serverId + def generateTargetChannel(self, repository): + """ + Who to send this to for generate messages + """ + if hasattr(self, "dbObject"): + return self.doId + return repository.serverId def sendGenerateWithRequired(self, repository, parentId, zoneId, optionalFields=[]): assert self.notify.debugStateCall(self) - if not wantOtpServer: - dg = self.dclass.aiFormatGenerate( - self, self.doId, 0, zoneId, - repository.districtId, - repository.ourChannel, - optionalFields) - else: - dg = self.dclass.aiFormatGenerate( - self, self.doId, parentId, zoneId, - #repository.serverId, - self.generateTargetChannel(repository), - repository.ourChannel, - optionalFields) + dg = self.dclass.aiFormatGenerate( + self, self.doId, parentId, zoneId, + #repository.serverId, + self.generateTargetChannel(repository), + repository.ourChannel, + optionalFields) repository.send(dg) def initFromServerResponse(self, valDict): diff --git a/direct/src/distributed/DoCollectionManager.py b/direct/src/distributed/DoCollectionManager.py index 5664f0640f..a055cf860a 100755 --- a/direct/src/distributed/DoCollectionManager.py +++ b/direct/src/distributed/DoCollectionManager.py @@ -6,17 +6,15 @@ class DoCollectionManager: def __init__(self): # Dict of {DistributedObject ids : DistributedObjects} self.doId2do = {} - # for OTP: (parentId, zoneId) to dict of doId->DistributedObjectAI - # for NON-OTP: zoneId to dict of doId->DistributedObjectAI + # (parentId, zoneId) to dict of doId->DistributedObjectAI self.zoneId2doIds={} if self.hasOwnerView(): # Dict of {DistributedObject ids : DistributedObjects} for 'owner' views of objects self.doId2ownerView = {} - if wantOtpServer: - # Dict of { - # parent DistributedObject id: - # { zoneIds : [child DistributedObject ids] }} - self.__doHierarchy = {} + # Dict of { + # parent DistributedObject id: + # { zoneIds : [child DistributedObject ids] }} + self.__doHierarchy = {} def getDo(self, doId): return self.doId2do.get(doId) @@ -159,220 +157,151 @@ class DoCollectionManager: 'zoneId2doIds table not empty: %s' % self.zoneId2doIds) self.zoneId2doIds = {} - if wantOtpServer: - def handleObjectLocation(self, di): - # CLIENT_OBJECT_LOCATION - doId = di.getUint32() - parentId = di.getUint32() - zoneId = di.getUint32() - obj = self.doId2do.get(doId) - if obj is not None: - self.notify.debug( - "handleObjectLocation: doId: %s parentId: %s zoneId: %s"% - (doId, parentId, zoneId)) - # Let the object finish the job - obj.setLocation(parentId, zoneId) - self.storeObjectLocation(doId, parentId, zoneId) - else: - self.notify.warning( - "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 handleObjectLocation(self, di): + # CLIENT_OBJECT_LOCATION + doId = di.getUint32() + parentId = di.getUint32() + zoneId = di.getUint32() + obj = self.doId2do.get(doId) + if obj is not None: + self.notify.debug( + "handleObjectLocation: doId: %s parentId: %s zoneId: %s"% + (doId, parentId, zoneId)) + # Let the object finish the job + obj.setLocation(parentId, zoneId) + self.storeObjectLocation(doId, parentId, zoneId) + else: + self.notify.warning( + "handleObjectLocation: Asked to update non-existent obj: %s" % (doId)) - def storeObjectLocation(self, doId, parentId, zoneId): - if (parentId is None) or (zoneId is None): - # Do not store null values - return - # TODO: check current location - obj = self.doId2do.get(doId) - if obj is not None: - oldParentId = obj.parentId - oldZoneId = obj.zoneId + 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) - if oldParentId != parentId: - # Remove old location - parentZoneDict = self.__doHierarchy.get(oldParentId) - if parentZoneDict is not None: - zoneDoSet = parentZoneDict.get(oldZoneId) - if zoneDoSet is not None and doId in zoneDoSet: - zoneDoSet.remove(doId) - if len(zoneDoSet) == 0: - del parentZoneDict[oldZoneId] - # Add to new location - parentZoneDict = self.__doHierarchy.setdefault(parentId, {}) - zoneDoSet = parentZoneDict.setdefault(zoneId, set()) - zoneDoSet.add(doId) + def storeObjectLocation(self, doId, parentId, zoneId): + if (parentId is None) or (zoneId is None): + # Do not store null values + return + # TODO: check current location + obj = self.doId2do.get(doId) + if obj is not None: + oldParentId = obj.parentId + oldZoneId = obj.zoneId - def deleteObjectLocation(self, objId, parentId, zoneId): - # Do not worry about null values - if ((parentId is None) or (zoneId is None)): - return - parentZoneDict = self.__doHierarchy.get(parentId) - assert(parentZoneDict is not None, "deleteObjectLocation: parentId: %s not found" % (parentId)) - objList = parentZoneDict.get(zoneId) - assert(objList is not None, "deleteObjectLocation: zoneId: %s not found" % (zoneId)) - assert(objId in objList, "deleteObjectLocation: objId: %s not found" % (objId)) - if len(objList) == 1: - # If this is the last obj in this zone, delete the entire entry - del parentZoneDict[zoneId] - else: - # Just remove the object - objList.remove(objId) + if oldParentId != parentId: + # Remove old location + parentZoneDict = self.__doHierarchy.get(oldParentId) + if parentZoneDict is not None: + zoneDoSet = parentZoneDict.get(oldZoneId) + if zoneDoSet is not None and doId in zoneDoSet: + zoneDoSet.remove(doId) + if len(zoneDoSet) == 0: + del parentZoneDict[oldZoneId] + # Add to new location + parentZoneDict = self.__doHierarchy.setdefault(parentId, {}) + zoneDoSet = parentZoneDict.setdefault(zoneId, set()) + zoneDoSet.add(doId) + + def deleteObjectLocation(self, objId, parentId, zoneId): + # Do not worry about null values + if ((parentId is None) or (zoneId is None)): + return + parentZoneDict = self.__doHierarchy.get(parentId) + assert(parentZoneDict is not None, "deleteObjectLocation: parentId: %s not found" % (parentId)) + objList = parentZoneDict.get(zoneId) + assert(objList is not None, "deleteObjectLocation: zoneId: %s not found" % (zoneId)) + assert(objId in objList, "deleteObjectLocation: objId: %s not found" % (objId)) + if len(objList) == 1: + # If this is the last obj in this zone, delete the entire entry + del parentZoneDict[zoneId] + else: + # Just remove the object + objList.remove(objId) - if wantOtpServer: - def addDOToTables(self, do, location=None, ownerView=False): - assert self.notify.debugStateCall(self) - assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse - if not ownerView: - if location is None: - location = (do.parentId, do.zoneId) + def addDOToTables(self, do, location=None, ownerView=False): + assert self.notify.debugStateCall(self) + assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse + if not ownerView: + if location is None: + location = (do.parentId, do.zoneId) - doTable = self.getDoTable(ownerView) - - #assert do.doId not in doTable - if do.doId in doTable: - print "ignoring repeated object %s" % (do.doId) - return - - doTable[do.doId]=do + doTable = self.getDoTable(ownerView) - if not ownerView: - if self.isValidLocationTuple(location): - assert do.doId not in self.zoneId2doIds.get(location,{}) - self.zoneId2doIds.setdefault(location, {}) - self.zoneId2doIds[location][do.doId]=do + #assert do.doId not in doTable + if do.doId in doTable: + print "ignoring repeated object %s" % (do.doId) + return - def isValidLocationTuple(self, location): - return (location is not None - and location != (0xffffffff, 0xffffffff) - and location != (0, 0)) - else: - # NON OTP - def addDOToTables(self, do, zoneId=None): - assert self.notify.debugStateCall(self) - if zoneId is None: - zoneId = do.zoneId + doTable[do.doId]=do - assert do.doId not in self.doId2do - self.doId2do[do.doId]=do + if not ownerView: + if self.isValidLocationTuple(location): + assert do.doId not in self.zoneId2doIds.get(location,{}) + self.zoneId2doIds.setdefault(location, {}) + self.zoneId2doIds[location][do.doId]=do - if zoneId is not None: - assert do.doId not in self.zoneId2doIds.get(zoneId,{}) - self.zoneId2doIds.setdefault(zoneId, {}) - self.zoneId2doIds[zoneId][do.doId]=do - - if wantOtpServer: - def removeDOFromTables(self, do): - assert self.notify.debugStateCall(self) - assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse - #assert do.doId in self.doId2do - location = do.getLocation() - if location is not None: - if location not in self.zoneId2doIds: - self.notify.warning( - 'dobj %s (%s) has invalid location: %s' % - (do, do.doId, location)) - else: - assert do.doId in self.zoneId2doIds[location] - del self.zoneId2doIds[location][do.doId] - if len(self.zoneId2doIds[location]) == 0: - del self.zoneId2doIds[location] - if do.doId in self.doId2do: - del self.doId2do[do.doId] - else: - def removeDOFromTables(self, do): - assert self.notify.debugStateCall(self) - assert do.doId in self.doId2do - if do.zoneId is not None: - if do.zoneId not in self.zoneId2doIds: - self.notify.warning( - 'dobj %s (%s) has invalid zoneId: %s' % - (do, do.doId, do.zoneId)) - else: - assert do.doId in self.zoneId2doIds[do.zoneId] - del(self.zoneId2doIds[do.zoneId][do.doId]) - if len(self.zoneId2doIds[do.zoneId]) == 0: - del self.zoneId2doIds[do.zoneId] + def isValidLocationTuple(self, location): + return (location is not None + and location != (0xffffffff, 0xffffffff) + and location != (0, 0)) + def removeDOFromTables(self, do): + assert self.notify.debugStateCall(self) + assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse + #assert do.doId in self.doId2do + location = do.getLocation() + if location is not None: + if location not in self.zoneId2doIds: + self.notify.warning( + 'dobj %s (%s) has invalid location: %s' % + (do, do.doId, location)) + else: + assert do.doId in self.zoneId2doIds[location] + del self.zoneId2doIds[location][do.doId] + if len(self.zoneId2doIds[location]) == 0: + del self.zoneId2doIds[location] + if do.doId in self.doId2do: del self.doId2do[do.doId] - if wantOtpServer: - def changeDOZoneInTables(self, do, newParentId, newZoneId, oldParentId, oldZoneId): - assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse - oldLocation = (oldParentId, oldZoneId) - newLocation = (newParentId, newZoneId) - # HACK: DistributedGuildMemberUD starts in -1,-1, which isnt ever put in the - # zoneId2doIds table - if self.isValidLocationTuple(oldLocation): - assert self.notify.debugStateCall(self) - assert oldLocation in self.zoneId2doIds - assert do.doId in self.zoneId2doIds[oldLocation] - assert do.doId not in self.zoneId2doIds.get(newLocation,{}) - # remove from old zone - del(self.zoneId2doIds[oldLocation][do.doId]) - if len(self.zoneId2doIds[oldLocation]) == 0: - del self.zoneId2doIds[oldLocation] - if self.isValidLocationTuple(newLocation): - # add to new zone - self.zoneId2doIds.setdefault(newLocation, {}) - self.zoneId2doIds[newLocation][do.doId]=do - - def getObjectsInZone(self, location): - """ call this to get a dict of doId:distObj for a zone. - Creates a shallow copy, so you can do whatever you want with the - dict. """ + def changeDOZoneInTables(self, do, newParentId, newZoneId, oldParentId, oldZoneId): + assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse + oldLocation = (oldParentId, oldZoneId) + newLocation = (newParentId, newZoneId) + # HACK: DistributedGuildMemberUD starts in -1,-1, which isnt ever put in the + # zoneId2doIds table + if self.isValidLocationTuple(oldLocation): assert self.notify.debugStateCall(self) - return copy.copy(self.zoneId2doIds.get(location, {})) - - def getObjectsOfClassInZone(self, location, objClass): - """ returns dict of doId:object for a zone, containing all objects - that inherit from 'class'. returned dict is safely mutable. """ - assert self.notify.debugStateCall(self) - doDict = {} - for doId, do in self.zoneId2doIds.get(location, {}).items(): - if isinstance(do, objClass): - doDict[doId] = do - return doDict - - else: - # NON OTP - - def changeDOZoneInTables(self, do, newZoneId, oldZoneId): - ##print "changeDOZoneInTables:%s, dclass:%s, newZoneId:%s OldZoneId:%s"%(do.doId, do.dclass.getName(), newZoneId,oldZoneId) - - assert self.notify.debugStateCall(self) - assert oldZoneId in self.zoneId2doIds - assert do.doId in self.zoneId2doIds[oldZoneId] - assert do.doId not in self.zoneId2doIds.get(newZoneId,{}) + assert oldLocation in self.zoneId2doIds + assert do.doId in self.zoneId2doIds[oldLocation] + assert do.doId not in self.zoneId2doIds.get(newLocation,{}) # remove from old zone - del(self.zoneId2doIds[oldZoneId][do.doId]) - if len(self.zoneId2doIds[oldZoneId]) == 0: - del self.zoneId2doIds[oldZoneId] + del(self.zoneId2doIds[oldLocation][do.doId]) + if len(self.zoneId2doIds[oldLocation]) == 0: + del self.zoneId2doIds[oldLocation] + if self.isValidLocationTuple(newLocation): # add to new zone - self.zoneId2doIds.setdefault(newZoneId, {}) - self.zoneId2doIds[newZoneId][do.doId]=do + self.zoneId2doIds.setdefault(newLocation, {}) + self.zoneId2doIds[newLocation][do.doId]=do - def getObjectsInZone(self, zoneId): - """ call this to get a dict of doId:distObj for a zone. - Creates a shallow copy, so you can do whatever you want with the - dict. """ - assert self.notify.debugStateCall(self) - return copy.copy(self.zoneId2doIds.get(zoneId, {})) + def getObjectsInZone(self, location): + """ call this to get a dict of doId:distObj for a zone. + Creates a shallow copy, so you can do whatever you want with the + dict. """ + assert self.notify.debugStateCall(self) + return copy.copy(self.zoneId2doIds.get(location, {})) - def getObjectsOfClassInZone(self, zoneId, objClass): - """ returns dict of doId:object for a zone, containing all objects - that inherit from 'class'. returned dict is safely mutable. """ - assert self.notify.debugStateCall(self) - doDict = {} - for doId, do in self.zoneId2doIds.get(zoneId, {}).items(): - if isinstance(do, objClass): - doDict[doId] = do - return doDict + def getObjectsOfClassInZone(self, location, objClass): + """ returns dict of doId:object for a zone, containing all objects + that inherit from 'class'. returned dict is safely mutable. """ + assert self.notify.debugStateCall(self) + doDict = {} + for doId, do in self.zoneId2doIds.get(location, {}).items(): + if isinstance(do, objClass): + doDict[doId] = do + return doDict diff --git a/direct/src/distributed/MsgTypes.py b/direct/src/distributed/MsgTypes.py index e63221e713..ba57905185 100644 --- a/direct/src/distributed/MsgTypes.py +++ b/direct/src/distributed/MsgTypes.py @@ -29,11 +29,7 @@ CLIENT_OBJECT_DISABLE_OWNER = 26 CLIENT_OBJECT_DISABLE_OWNER_RESP = 26 CLIENT_OBJECT_DELETE = 27 CLIENT_OBJECT_DELETE_RESP = 27 -if not wantOtpServer: - CLIENT_SET_ZONE = 29 CLIENT_REMOVE_ZONE = 30 -if not wantOtpServer: - CLIENT_SET_SHARD = 31 CLIENT_SET_AVATAR = 32 CLIENT_CREATE_OBJECT_REQUIRED = 34 CLIENT_CREATE_OBJECT_REQUIRED_RESP = 34 @@ -49,10 +45,7 @@ CLIENT_DISCONNECT = 37 CLIENT_CHANGE_IP_ADDRESS_RESP = 45 CLIENT_GET_STATE = 46 CLIENT_GET_STATE_RESP = 47 -if wantOtpServer: - CLIENT_DONE_INTEREST_RESP = 48 -else: - CLIENT_DONE_SET_ZONE_RESP = 48 +CLIENT_DONE_INTEREST_RESP = 48 CLIENT_DELETE_AVATAR = 49 @@ -89,14 +82,13 @@ CLIENT_GET_PET_DETAILS = 81 CLIENT_GET_PET_DETAILS_RESP = 82 # (Proposed new message): CLIENT_SET_WORLD_POS = 83 -if wantOtpServer: - CLIENT_ADD_INTEREST = 97 - # This is no longer supported. Alter just calls ADD_INTEREST - # CLIENT_ALTER_INTEREST = 98 - CLIENT_REMOVE_INTEREST = 99 - CLIENT_QUERY_ONE_FIELD = 101 - CLIENT_OBJECT_LOCATION = 102 - CLIENT_QUERY_ONE_FIELD_RESP = 103 +CLIENT_ADD_INTEREST = 97 +# This is no longer supported. Alter just calls ADD_INTEREST +# CLIENT_ALTER_INTEREST = 98 +CLIENT_REMOVE_INTEREST = 99 +CLIENT_QUERY_ONE_FIELD = 101 +CLIENT_OBJECT_LOCATION = 102 +CLIENT_QUERY_ONE_FIELD_RESP = 103 # These messages are ignored when the client is headed to the quiet zone QUIET_ZONE_IGNORED_LIST = [ diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 6410267494..312f72007c 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -239,7 +239,6 @@ class ShowBase(DirectObject.DirectObject): __builtins__["cvMgr"] = ConfigVariableManager.getGlobalPtr() __builtins__["pandaSystem"] = PandaSystem.getGlobalPtr() __builtins__["__dev__"] = base.config.GetBool('want-dev', 0) - __builtins__["wantOtpServer"] = base.config.GetBool('want-otp-server', 0) __builtins__["wantUberdog"] = base.config.GetBool('want-uberdog', 1) if __debug__: __builtins__["deltaProfiler"] = DeltaProfiler.DeltaProfiler("ShowBase")