Browse Source

editor changes are distributed

Darren Ranalli 22 years ago
parent
commit
4e8ac61955

+ 5 - 1
direct/src/level/DistributedLevel.py

@@ -383,6 +383,11 @@ class DistributedLevel(DistributedObject.DistributedObject,
     if __debug__:
     if __debug__:
         # level editing stuff
         # level editing stuff
         def setAttribChange(self, entId, attribName, valueStr):
         def setAttribChange(self, entId, attribName, valueStr):
+            entity = self.getEntity(entId)
+            # the entity might be AI-only
+            if entity is None:
+                return
+            
             try:
             try:
                 value = eval(valueStr)
                 value = eval(valueStr)
             except Exception, e:
             except Exception, e:
@@ -390,7 +395,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
                        (lineInfo()[2], entId, attribName, valueStr, e))
                        (lineInfo()[2], entId, attribName, valueStr, e))
                 raise e
                 raise e
                 
                 
-            entity = self.getEntity(entId)
             entity.handleAttribChange(attribName, value)
             entity.handleAttribChange(attribName, value)
 
 
         """
         """

+ 6 - 3
direct/src/level/DistributedLevelAI.py

@@ -77,13 +77,16 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
     if __debug__:
     if __debug__:
         # level editors should call this func to tweak attributes of level
         # level editors should call this func to tweak attributes of level
         # entities
         # entities
-        def setAttribChange(self, entId, attribName, value):
+        def setAttribChange(self, entId, attribName, valueStr):
             # send a copy to the client-side level obj
             # send a copy to the client-side level obj
             self.sendUpdate('setAttribChange',
             self.sendUpdate('setAttribChange',
-                            [entId, attribName, repr(value)])
+                            [entId, attribName, valueStr])
             
             
             entity = self.getEntity(entId)
             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
             # send a copy of the entire spec for any new users that
             # might come in
             # might come in

+ 7 - 0
direct/src/level/LevelSpec.py

@@ -76,6 +76,13 @@ class LevelSpec:
         return self.specDict['scenarios'][scenario][0]
         return self.specDict['scenarios'][scenario][0]
 
 
     if __debug__:
     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):
         def setAttribChange(self, entId, attrib, value):
             pass
             pass