changeset 127:18623b5c2b45

Fixed that dropped items cannot be picked up.
author KarstenBock@gmx.net
date Fri, 07 Oct 2011 14:36:36 +0200
parents f7543a85c2ea
children a93b38d7e02b
files gamemodel.py objects/action.py
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gamemodel.py	Fri Oct 07 14:16:21 2011 +0200
+++ b/gamemodel.py	Fri Oct 07 14:36:36 2011 +0200
@@ -669,15 +669,17 @@
     def updateObjectDB(self, world):
         """Updates the values in the object database with the worlds values"""
         
+        all_agents = self.agents[self.ALL_AGENTS_KEY]
         for entity in world.entities:
             identifier = entity.general.identifier
             agent_data = {}
             map_id = self.game_state.getMapOfObject(identifier)
             if map_id:
-                if self.agents[self.ALL_AGENTS_KEY].has_key(identifier):
+                if all_agents.has_key(identifier):
                     agent_data = self.agents[self.ALL_AGENTS_KEY][identifier]
                 else:
                     agent_data = self.agents[map_id][identifier]
+
             else:
                 if not self.items.has_key(identifier):
                     self.items[identifier] = {}
@@ -704,7 +706,8 @@
                             inst = layer.getInstance(identifier)
                             loc = inst.getLocation().getExactLayerCoordinates()
                             agent_data["Position"] = (loc.x, loc.y, loc.z)
-                            agent_data["Map"] = map_id
+                            if all_agents.has_key(identifier):
+                                agent_data["Map"] = map_id
                             agent_data["Rotation"]  = inst.getRotation()
                     elif name == "container" and hasattr(comp_vals, 
                                                          "children"):
--- a/objects/action.py	Fri Oct 07 14:16:21 2011 +0200
+++ b/objects/action.py	Fri Oct 07 14:36:36 2011 +0200
@@ -432,8 +432,10 @@
                   )
         agent_values["Position"] = (coords.x, coords.y)
         agent_values["Rotation"] = 0
+        agent_values["Map"] = map_name
         self.model.deleteObject(identifier)
-        self.model.addAgent(map_name, {identifier: agent_values})
+        self.model.addAgent(self.model.ALL_AGENTS_KEY, 
+                            {identifier: agent_values})
         self.model.placeAgents(self.item.entity.world)
         self.model.updateObjectDB(self.item.entity.world)
         super(DropItemAction, self).execute()