Browse Source

addInterest

Dave Schuyler 21 years ago
parent
commit
1c6e830453
1 changed files with 28 additions and 15 deletions
  1. 28 15
      direct/src/distributed/DistributedObjectAI.py

+ 28 - 15
direct/src/distributed/DistributedObjectAI.py

@@ -10,7 +10,7 @@ from PyDatagramIterator import PyDatagramIterator
 class DistributedObjectAI(DirectObject.DirectObject):
 class DistributedObjectAI(DirectObject.DirectObject):
     notify = directNotify.newCategory("DistributedObjectAI")
     notify = directNotify.newCategory("DistributedObjectAI")
     QuietZone = 1
     QuietZone = 1
-    
+
     def __init__(self, air):
     def __init__(self, air):
         try:
         try:
             self.DistributedObjectAI_initialized
             self.DistributedObjectAI_initialized
@@ -105,14 +105,14 @@ class DistributedObjectAI(DirectObject.DirectObject):
         Returns true if the object has been deleted,
         Returns true if the object has been deleted,
         or if it is brand new and hasn't yet been generated.
         or if it is brand new and hasn't yet been generated.
         """
         """
-        return (self.air == None)
+        return self.air == None
 
 
     def isGenerated(self):
     def isGenerated(self):
         """
         """
         Returns true if the object has been generated
         Returns true if the object has been generated
         """
         """
         return hasattr(self, 'zoneId')
         return hasattr(self, 'zoneId')
-    
+
     def getDoId(self):
     def getDoId(self):
         """
         """
         Return the distributed object id
         Return the distributed object id
@@ -134,11 +134,24 @@ class DistributedObjectAI(DirectObject.DirectObject):
         of its required fields filled in. Overwrite when needed.
         of its required fields filled in. Overwrite when needed.
         """
         """
         pass
         pass
-    
+
+    if wantOtpServer:
+        def addInterest(self, zoneId, note="", event=None):
+            self.air.addInterest(self.getDoId(), zoneId, note, event)
+
+        if 0: # this is untested:
+            def setLocation(self, parentId, zoneId):
+                # The store must run first so we know the old location
+                self.air.storeObjectLocation(self.doId, parentId, zoneId)
+                self.__location = (parentId, zoneId)
+
+            def getLocation(self):
+                return self.__location
+
     def updateRequiredFields(self, dclass, di):
     def updateRequiredFields(self, dclass, di):
         dclass.receiveUpdateBroadcastRequired(self, di)
         dclass.receiveUpdateBroadcastRequired(self, di)
         self.announceGenerate()
         self.announceGenerate()
-    
+
     def updateAllRequiredFields(self, dclass, di):
     def updateAllRequiredFields(self, dclass, di):
         dclass.receiveUpdateAllRequired(self, di)
         dclass.receiveUpdateAllRequired(self, di)
         self.announceGenerate()
         self.announceGenerate()
@@ -171,7 +184,7 @@ class DistributedObjectAI(DirectObject.DirectObject):
         # arguments are newZoneId, oldZoneId
         # arguments are newZoneId, oldZoneId
         # does not include the quiet zone.
         # does not include the quiet zone.
         return 'DOLogicalChangeZone-%s' % self.doId
         return 'DOLogicalChangeZone-%s' % self.doId
-    
+
     def handleZoneChange(self, newParentId, newZoneId, oldParentId, oldZoneId):
     def handleZoneChange(self, newParentId, newZoneId, oldParentId, oldZoneId):
         if wantOtpServer:
         if wantOtpServer:
             assert oldParentId == self.parentId
             assert oldParentId == self.parentId
@@ -232,12 +245,12 @@ class DistributedObjectAI(DirectObject.DirectObject):
 
 
     def generateWithRequired(self, zoneId, optionalFields=[]):
     def generateWithRequired(self, zoneId, optionalFields=[]):
         assert self.notify.debugStateCall(self)
         assert self.notify.debugStateCall(self)
-        # have we already allocated a doId?      
+        # have we already allocated a doId?
         if self.__preallocDoId:
         if self.__preallocDoId:
             self.__preallocDoId = 0
             self.__preallocDoId = 0
             return self.generateWithRequiredAndId(
             return self.generateWithRequiredAndId(
                 self.doId, zoneId, optionalFields)
                 self.doId, zoneId, optionalFields)
-            
+
         # The repository is the one that really does the work
         # The repository is the one that really does the work
         self.air.generateWithRequired(self, zoneId, optionalFields)
         self.air.generateWithRequired(self, zoneId, optionalFields)
         if wantOtpServer:
         if wantOtpServer:
@@ -275,7 +288,7 @@ class DistributedObjectAI(DirectObject.DirectObject):
                 assert doId is None or doId == self.__preallocDoId
                 assert doId is None or doId == self.__preallocDoId
                 doId=self.__preallocDoId
                 doId=self.__preallocDoId
                 self.__preallocDoId = 0
                 self.__preallocDoId = 0
-                
+
             # The repository is the one that really does the work
             # The repository is the one that really does the work
             self.air.sendGenerateOtpObject(
             self.air.sendGenerateOtpObject(
                     self, parentId, zoneId, optionalFields, doId=doId)
                     self, parentId, zoneId, optionalFields, doId=doId)
@@ -325,7 +338,7 @@ class DistributedObjectAI(DirectObject.DirectObject):
                     repository.ourChannel,
                     repository.ourChannel,
                     optionalFields)
                     optionalFields)
         repository.send(dg)
         repository.send(dg)
-            
+
     def initFromServerResponse(self, valDict):
     def initFromServerResponse(self, valDict):
         assert self.notify.debugStateCall(self)
         assert self.notify.debugStateCall(self)
         # This is a special method used for estates, etc., which get
         # This is a special method used for estates, etc., which get
@@ -349,13 +362,13 @@ class DistributedObjectAI(DirectObject.DirectObject):
             return
             return
         self.air.requestDelete(self)
         self.air.requestDelete(self)
         self._DOAI_requestedDelete = True
         self._DOAI_requestedDelete = True
-        
+
     def taskName(self, taskString):
     def taskName(self, taskString):
         return (taskString + "-" + str(self.getDoId()))
         return (taskString + "-" + str(self.getDoId()))
 
 
     def uniqueName(self, idString):
     def uniqueName(self, idString):
         return (idString + "-" + str(self.getDoId()))
         return (idString + "-" + str(self.getDoId()))
-    
+
     def validate(self, avId, bool, msg):
     def validate(self, avId, bool, msg):
         if not bool:
         if not bool:
             self.air.writeServerEvent('suspicious', avId, msg)
             self.air.writeServerEvent('suspicious', avId, msg)
@@ -369,7 +382,7 @@ class DistributedObjectAI(DirectObject.DirectObject):
         # made it through.  There may be multiple barriers waiting
         # made it through.  There may be multiple barriers waiting
         # simultaneously on different lists of avatars, although they
         # simultaneously on different lists of avatars, although they
         # should have different names.
         # should have different names.
-        
+
         from toontown.ai import ToonBarrier
         from toontown.ai import ToonBarrier
         context = self.__nextBarrierContext
         context = self.__nextBarrierContext
         # We assume the context number is passed as a uint16.
         # We assume the context number is passed as a uint16.
@@ -433,5 +446,5 @@ class DistributedObjectAI(DirectObject.DirectObject):
             callback(avIds)
             callback(avIds)
         else:
         else:
             self.notify.warning("Unexpected completion from barrier %s" % (context))
             self.notify.warning("Unexpected completion from barrier %s" % (context))
-        
-        
+
+