diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index fc57ce4124..e99275533c 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -207,9 +207,7 @@ class DistributedObject(DistributedObjectBase, EnforcesCalldowns): generated and all of its required fields filled in. """ assert self.notify.debug('announceGenerate(): %s' % (self.doId)) - if self.activeState != ESGenerated: - self.activeState = ESGenerated - messenger.send(self.uniqueName("generate"), [self]) + @calldownEnforced def disable(self): @@ -281,14 +279,24 @@ class DistributedObject(DistributedObjectBase, EnforcesCalldowns): """ return self.doId + + #This message was moved out of announce generate + #to avoid ordering issues. + def postGenerateMessage(self): + if self.activeState != ESGenerated: + self.activeState = ESGenerated + messenger.send(self.uniqueName("generate"), [self]) + def updateRequiredFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) self.announceGenerate() + self.postGenerateMessage() def updateAllRequiredFields(self, dclass, di): dclass.receiveUpdateAllRequired(self, di) self.announceGenerate() - + self.postGenerateMessage() + def updateRequiredOtherFields(self, dclass, di): # First, update the required fields dclass.receiveUpdateBroadcastRequired(self, di) @@ -296,7 +304,8 @@ class DistributedObject(DistributedObjectBase, EnforcesCalldowns): # Announce generate after updating all the required fields, # but before we update the non-required fields. self.announceGenerate() - + self.postGenerateMessage() + dclass.receiveUpdateOther(self, di) def sendUpdate(self, fieldName, args = [], sendToId = None): diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py index 49751745ae..5e44f14e79 100644 --- a/direct/src/distributed/DistributedObjectAI.py +++ b/direct/src/distributed/DistributedObjectAI.py @@ -186,8 +186,6 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns): Called after the object has been generated and all of its required fields filled in. Overwrite when needed. """ - self.__generated = True - messenger.send(self.uniqueName("generate"), [self]) def addInterest(self, zoneId, note="", event=None): self.air.addInterest(self.getDoId(), zoneId, note, event) @@ -257,19 +255,27 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns): # Inheritors should override pass + def postGenerateMessage(self): + self.__generated = True + messenger.send(self.uniqueName("generate"), [self]) + def updateRequiredFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) self.announceGenerate() - + self.postGenerateMessage() + def updateAllRequiredFields(self, dclass, di): dclass.receiveUpdateAllRequired(self, di) self.announceGenerate() + self.postGenerateMessage() def updateRequiredOtherFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) # Announce generate after updating all the required fields, # but before we update the non-required fields. self.announceGenerate() + self.postGenerateMessage() + dclass.receiveUpdateOther(self, di) def updateAllRequiredOtherFields(self, dclass, di): @@ -277,6 +283,8 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns): # Announce generate after updating all the required fields, # but before we update the non-required fields. self.announceGenerate() + self.postGenerateMessage() + dclass.receiveUpdateOther(self, di) def sendSetZone(self, zoneId): @@ -375,7 +383,8 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns): self.air.generateWithRequired(self, parentId, zoneId, optionalFields) self.generate() self.announceGenerate() - + self.postGenerateMessage() + # this is a special generate used for estates, or anything else that # needs to have a hard coded doId as assigned by the server def generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields=[]): @@ -389,7 +398,8 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns): self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields) self.generate() self.announceGenerate() - + self.postGenerateMessage() + def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None): assert self.notify.debugStateCall(self) # have we already allocated a doId? @@ -409,6 +419,7 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns): self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields) self.generate() self.announceGenerate() + self.postGenerateMessage() @calldownEnforced def generate(self): diff --git a/direct/src/distributed/DistributedObjectOV.py b/direct/src/distributed/DistributedObjectOV.py index 3f5a4c3d85..e79eb8e573 100755 --- a/direct/src/distributed/DistributedObjectOV.py +++ b/direct/src/distributed/DistributedObjectOV.py @@ -126,9 +126,6 @@ class DistributedObjectOV(DistributedObjectBase): generated and all of its required fields filled in. """ assert self.notify.debug('announceGenerate(): %s' % (self.doId)) - if self.activeState != ESGenerated: - self.activeState = ESGenerated - messenger.send(self.uniqueName("generate"), [self]) def disable(self): """ @@ -187,13 +184,21 @@ class DistributedObjectOV(DistributedObjectBase): """ return self.doId + def postGenerateMessage(self): + if self.activeState != ESGenerated: + self.activeState = ESGenerated + messenger.send(self.uniqueName("generate"), [self]) + + def updateRequiredFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) self.announceGenerate() + self.postGenerateMessage() def updateAllRequiredFields(self, dclass, di): dclass.receiveUpdateAllRequired(self, di) self.announceGenerate() + self.postGenerateMessage() def updateRequiredOtherFields(self, dclass, di): # First, update the required fields @@ -202,7 +207,8 @@ class DistributedObjectOV(DistributedObjectBase): # Announce generate after updating all the required fields, # but before we update the non-required fields. self.announceGenerate() - + self.postGenerateMessage() + dclass.receiveUpdateOther(self, di) def getCacheable(self): diff --git a/direct/src/distributed/DistributedObjectUD.py b/direct/src/distributed/DistributedObjectUD.py index 09c59df172..1531db89db 100755 --- a/direct/src/distributed/DistributedObjectUD.py +++ b/direct/src/distributed/DistributedObjectUD.py @@ -166,6 +166,8 @@ class DistributedObjectUD(DistributedObjectBase): of its required fields filled in. Overwrite when needed. """ self.__generated = True + + def postGenerateMessage(self): messenger.send(self.uniqueName("generate"), [self]) def addInterest(self, zoneId, note="", event=None): @@ -195,16 +197,20 @@ class DistributedObjectUD(DistributedObjectBase): def updateRequiredFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) self.announceGenerate() + self.postGenerateMessage() def updateAllRequiredFields(self, dclass, di): dclass.receiveUpdateAllRequired(self, di) self.announceGenerate() + self.postGenerateMessage() def updateRequiredOtherFields(self, dclass, di): dclass.receiveUpdateBroadcastRequired(self, di) # Announce generate after updating all the required fields, # but before we update the non-required fields. self.announceGenerate() + self.postGenerateMessage() + dclass.receiveUpdateOther(self, di) def updateAllRequiredOtherFields(self, dclass, di): @@ -212,6 +218,8 @@ class DistributedObjectUD(DistributedObjectBase): # Announce generate after updating all the required fields, # but before we update the non-required fields. self.announceGenerate() + self.postGenerateMessage() + dclass.receiveUpdateOther(self, di) def sendSetZone(self, zoneId): @@ -300,7 +308,8 @@ class DistributedObjectUD(DistributedObjectBase): ## self.zoneId = zoneId self.generate() self.announceGenerate() - + self.postGenerateMessage() + def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None): assert self.notify.debugStateCall(self) # have we already allocated a doId?