From 4e8ac61955f7abf991b0b3338c7a9a1836c1d73f Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Tue, 30 Sep 2003 20:47:50 +0000 Subject: [PATCH] editor changes are distributed --- direct/src/level/DistributedLevel.py | 6 +++++- direct/src/level/DistributedLevelAI.py | 9 ++++++--- direct/src/level/LevelSpec.py | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/direct/src/level/DistributedLevel.py b/direct/src/level/DistributedLevel.py index 3e7644d062..2faf83cd66 100755 --- a/direct/src/level/DistributedLevel.py +++ b/direct/src/level/DistributedLevel.py @@ -383,6 +383,11 @@ class DistributedLevel(DistributedObject.DistributedObject, if __debug__: # level editing stuff def setAttribChange(self, entId, attribName, valueStr): + entity = self.getEntity(entId) + # the entity might be AI-only + if entity is None: + return + try: value = eval(valueStr) except Exception, e: @@ -390,7 +395,6 @@ class DistributedLevel(DistributedObject.DistributedObject, (lineInfo()[2], entId, attribName, valueStr, e)) raise e - entity = self.getEntity(entId) entity.handleAttribChange(attribName, value) """ diff --git a/direct/src/level/DistributedLevelAI.py b/direct/src/level/DistributedLevelAI.py index 98ae2a2637..e09a38db1a 100755 --- a/direct/src/level/DistributedLevelAI.py +++ b/direct/src/level/DistributedLevelAI.py @@ -77,13 +77,16 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI, if __debug__: # level editors should call this func to tweak attributes of level # entities - def setAttribChange(self, entId, attribName, value): + def setAttribChange(self, entId, attribName, valueStr): # send a copy to the client-side level obj self.sendUpdate('setAttribChange', - [entId, attribName, repr(value)]) + [entId, attribName, valueStr]) entity = self.getEntity(entId) - entity.handleAttribChange(attribName, value) + # the entity might be client-side-only + if entity is not None: + value = eval(valueStr) + entity.handleAttribChange(attribName, value) # send a copy of the entire spec for any new users that # might come in diff --git a/direct/src/level/LevelSpec.py b/direct/src/level/LevelSpec.py index 6f3b8c6eb6..d7b6f98bd5 100755 --- a/direct/src/level/LevelSpec.py +++ b/direct/src/level/LevelSpec.py @@ -76,6 +76,13 @@ class LevelSpec: return self.specDict['scenarios'][scenario][0] if __debug__: + def setAttribEditEventName(self, event): + self.attribEditEventName = event + def setAttribEdit(self, entId, attrib, value): + # broadcast the change to someone else that knows what to do + # with it + messenger.send(self.attribEditEventName, [entId, attrib, value]) + def setAttribChange(self, entId, attrib, value): pass