Changeset 498


Ignore:
Timestamp:
02/26/10 07:17:59 (10 years ago)
Author:
b0rland_parpg
Message:

Patch by b0rland

  • Fixed the saving/loading mechanism. All NPCs and objects work correctly after game load
  • Eventually the game still segfaults. Couldn't catch that yet

[t:200]

File:
1 edited

Legend:

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

    r479 r498  
    8484        self.game_state = pickle.load(f) 
    8585        f.close() 
    86          
    87         # Recreate all the behaviours. These can't be saved because FIFE 
    88         # objects cannot be pickled 
    89         for map_id in self.game_state.objects: 
    90             for (object_id, obj) in self.game_state.objects[map_id].items(): 
    91                 if obj.trueAttr("NPC") or obj.trueAttr("AnimatedContainer"): 
    92                     obj.createBehaviour(self.view.active_map.agent_layer) 
    93  
    94         # Fix the player behaviour 
    95         self.game_state.PC.createBehaviour(self.view.active_map.agent_layer) 
    96          
    97         # In most maps we'll create the PC Instance internally. In these 
    98         # cases we need a target position 
     86 
    9987        self.target_position = self.game_state.saved_pc_coordinates 
    100          
     88 
    10189        # Load the current map 
    10290        if self.game_state.current_map_file: 
    10391            self.loadMap(self.game_state.current_map_name, \ 
    104                          self.game_state.current_map_file)  
     92                         self.game_state.current_map_file)          
     93 
     94        # Recreate all the behaviours. These can't be saved because FIFE 
     95        # objects cannot be pickled 
     96         
     97        for map_id in self.game_state.objects: 
     98            for (object_id, obj) in self.game_state.objects[map_id].iteritems(): 
     99                if obj.trueAttr("NPC") or obj.trueAttr("AnimatedContainer"): 
     100                    obj.createBehaviour(self.view.active_map.agent_layer) 
     101                    obj.setup() 
     102       
     103        # In most maps we'll create the PC Instance internally. In these 
     104        # cases we need a target position 
    105105             
    106106    def createObject (self, layer, attributes, instance): 
Note: See TracChangeset for help on using the changeset viewer.