Ignore:
Timestamp:
10/11/09 10:34:47 (10 years ago)
Author:
eliedebrauwer
Message:

Ticket #66: Patch by saritor, eliedebrauwer & kaydeth cross map teleporting is now possible, we extended the objects within gamestate to make use of double hashing (f(obj_id,map_id)->object). Going back to a previously loaded map is still broken (camera issue). Also extended map.xml and map2.xml in order to make it possible to go back and forth between these two maps. comment[s:trac, t:66]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/gamestate.py

    r313 r314  
    2424        self.PC = None 
    2525        self.objects = {} 
    26         self.current_map = None 
     26        self.current_map_file = None 
    2727        self.current_map_name = None 
    2828         
     
    3232           @param map: The map name. 
    3333           @returns: The list of objects on this map.""" 
    34         return [i for i in self.objects.values() if i.map_id == map_id] 
     34        return [i for i in self.objects[map_id].values() if map_id in self.objects] 
    3535     
    36     def getObjectById(self, id): 
    37         """Gets an object by it's id 
    38            @type id: String 
    39            @param id: The id of the object. 
     36    def getObjectById(self, obj_id, map_id): 
     37        """Gets an object by its object id and map id 
     38           @type obj_id: String 
     39           @param obj_id: The id of the object. 
     40           @type map_id: String 
     41           @param map_id: It id of the map containing the object. 
    4042           @returns: The object or None.""" 
    41         if id in self.objects: 
    42             return self.objects[id] 
     43        if not map_id in self.objects: 
     44            self.objects[map_id] = {} 
     45        if obj_id in self.objects[map_id]: 
     46            return self.objects[map_id][obj_id] 
    4347 
Note: See TracChangeset for help on using the changeset viewer.