Changeset 302 for trunk/game


Ignore:
Timestamp:
10/03/09 13:44:58 (10 years ago)
Author:
eliedebrauwer
Message:

Ticket #73: Patch by Elie De Brauwer, partial fix of load/save, this fixes the map load failure but does not fix the failure to load/save PC and NPC behaviour comment[s:trac, t:73]

Location:
trunk/game
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/run.py

    r283 r302  
    4343    def __init__(self, engine, world, model): 
    4444        """Initialise the instance. 
    45            @type engine: ??? 
     45           @type engine: engine.Engine 
    4646           @param engine: ??? 
    47            @type world: ??? 
     47           @type world: world.World 
    4848           @param world: ??? 
    4949           @type model: engine.Engine 
  • trunk/game/scripts/engine.py

    r295 r302  
    101101        f.close() 
    102102        if self.gameState.currentMap: 
    103             self.loadMap(self.gameState.currentMap)  
     103            self.loadMap(self.gameState.currentMapName, self.gameState.currentMap)  
    104104 
    105105    def createObject (self, layer, attributes, instance): 
     
    244244    def loadMap(self, map_name, map_file): 
    245245        """Load a new map. TODO: needs some error checking 
     246           @type map_name: string 
     247           @param map_name: Name of the map to load 
    246248           @type map_file: string 
    247            @param map_file: Name of map file to load 
     249           @param map_file: Filename of map file to load 
    248250           @return: None""" 
    249251        self.gameState.currentMap = map_file 
     252        self.gameState.currentMapName= map_name 
    250253        self.view.loadMap(map_name, str(map_file)) 
    251254        self.view.setActiveMap(map_name) 
     
    256259        self.view.activeMap.addPC(self.gameState.PC.behaviour.agent) 
    257260        self.gameState.PC.start() 
     261 
    258262 
    259263    def handleMouseClick(self,position): 
  • trunk/game/scripts/gamestate.py

    r262 r302  
    2525        self.objects = {} 
    2626        self.currentMap = None 
     27        self.currentMapName = None 
    2728         
    2829    def getObjectsFromMap(self, map_id): 
  • trunk/game/scripts/world.py

    r294 r302  
    9898 
    9999    def loadMap(self, mapname, filename): 
    100         """Loads a map an stores it under the given name in the maps list. 
     100        """Loads a map and stores it under the given name in the maps list. 
     101           @type mapname: text 
     102           @param mapname: The name of the map to load  
     103           @type filename: text 
     104           @param filename: File which contains the map to be loaded 
     105           @return: None 
    101106        """ 
    102         map = Map(self.engine, self.data) 
    103          
    104         """Need to set active map before we load it because the map  
    105         loader uses call backs that expect to find an active map.  
    106         This needs to be reworked. 
    107         """ 
    108         self.maps[mapname] = map 
    109         self.setActiveMap(mapname) 
    110  
    111         map.load(filename) 
    112  
     107        if not mapname in self.maps: 
     108            """Need to set active map before we load it because the map  
     109            loader uses call backs that expect to find an active map.  
     110            This needs to be reworked. 
     111            """ 
     112            map = Map(self.engine, self.data) 
     113            self.maps[mapname] = map         
     114            self.setActiveMap(mapname) 
     115            map.load(filename) 
    113116     
    114117    def setActiveMap(self, mapname): 
    115118        """Sets the active map that is to be rendered. 
     119           @type mapname: text 
     120           @param mapname: The name of the map to load  
     121           @return: None 
    116122        """ 
    117123        self.activeMap = self.maps[mapname] 
Note: See TracChangeset for help on using the changeset viewer.