/[hegemonie]/hegemonie/GameEngine/HgObject.m
ViewVC logotype

Diff of /hegemonie/GameEngine/HgObject.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by thunder, Tue Aug 19 16:26:39 2003 UTC revision 1.14 by nicov, Wed Aug 20 13:24:01 2003 UTC
# Line 26  Line 26 
26  #include <Foundation/NSCoder.h>  #include <Foundation/NSCoder.h>
27  #include <Foundation/NSValue.h>  #include <Foundation/NSValue.h>
28  #include <Foundation/NSNotification.h>  #include <Foundation/NSNotification.h>
29    #include <Foundation/NSValue.h>
30    
31  #include "GameEngine/HgObject.h"  #include "GameEngine/HgObject.h"
32  #include "GameEngine/HgGame.h"  #include "GameEngine/HgGame.h"
33    #include "GameEngine/HgPlayer.h"
34    
35  /**  /**
36   * HgObject stores all principal caracteritic wich belongs to the   * HgObject stores all principal caracteritic wich belongs to the
# Line 73  Line 75 
75    static unsigned lastIdentifier = 0;    static unsigned lastIdentifier = 0;
76    
77    NSParameterAssert (game);    NSParameterAssert (game);
78    
79    /*    /*
80     * FIXME - needs to be checked     * FIXME - needs to be checked
81     */     */
# Line 85  Line 88 
88        _delegate = nil;        _delegate = nil;
89        [self setPosition:  position];        [self setPosition:  position];
90        _game = RETAIN(game);        _game = RETAIN(game);
91        _player = RETAIN(player);        
92          if (player != nil)
93            _playerIdentifier = [[NSNumber alloc]
94                                  initWithUnsignedInt: [player identifier]];
95          else
96            _playerIdentifier = nil;
97      }      }
98        
99    return self;    return self;
# Line 95  Line 103 
103  {  {
104    RELEASE(_delegate);    RELEASE(_delegate);
105    RELEASE(_game);    RELEASE(_game);
106    RELEASE(_player);    RELEASE(_playerIdentifier);
107    
108    [super dealloc];    [super dealloc];
109  }  }
110    
111  /**  /**
  * Returns the player.  
  */  
 - (HgPlayer *) player  
 {  
   return _player;  
 }  
   
 /**  
112   * Returns the object identifier.   * Returns the object identifier.
113   */   */
114  - (unsigned) identifier  - (unsigned) identifier
# Line 203  Line 203 
203    return _game;    return _game;
204  }  }
205    
206    /**
207     * Returns the player associated with the current object.
208     */
209    - (HgPlayer *) player
210    {
211      return [[_game players] objectForKey: _playerIdentifier];
212    }
213    
214  @end  @end
215    
216  @implementation HgObject (NSCoding)  @implementation HgObject (NSCoding)
# Line 215  Line 223 
223    [encoder encodeValueOfObjCType: "I" at: &_identifier];    [encoder encodeValueOfObjCType: "I" at: &_identifier];
224    [encoder encodeValueOfObjCType: @encode(coord_t) at: &_position];    [encoder encodeValueOfObjCType: @encode(coord_t) at: &_position];
225    [encoder encodeValueOfObjCType: @encode(coord_t) at: &_orientation];    [encoder encodeValueOfObjCType: @encode(coord_t) at: &_orientation];
226      [encoder encodeValueOfObjCType: @encode(NSNumber) at: &_playerIdentifier];
227  }  }
228    
229  - (id)initWithCoder: (NSCoder *)decoder  - (id)initWithCoder: (NSCoder *)decoder
# Line 239  Line 248 
248      {      {
249        [decoder decodeValueOfObjCType: @encode(coord_t) at: &_position];        [decoder decodeValueOfObjCType: @encode(coord_t) at: &_position];
250        [decoder decodeValueOfObjCType: @encode(coord_t) at: &_orientation];        [decoder decodeValueOfObjCType: @encode(coord_t) at: &_orientation];
251          [decoder decodeValueOfObjCType: @encode(NSNumber) at:&_playerIdentifier];
252      }      }
253        
254    return self;    return self;

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26