/[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.8 by nicov, Wed Aug 13 15:51:56 2003 UTC revision 1.9 by thunder, Wed Aug 13 16:18:34 2003 UTC
# Line 63  Line 63 
63        _position = position;        _position = position;
64      }      }
65        
66      [[NSNotificationCenter defaultCenter]
67        postNotificationName:@"updateObject" object: _game];
68    
69    return self;    return self;
70  }  }
71    
# Line 74  Line 77 
77  }  }
78    
79  /**  /**
80     * Returns the game.
81     */
82    - (HgGame *) game
83    {
84      return _game;
85    }
86    
87    /**
88   * Returns the object identifier.   * Returns the object identifier.
89   */   */
90  - (unsigned) identifier  - (unsigned) identifier
# Line 109  Line 120 
120     * FIXME - check position     * FIXME - check position
121     */     */
122    //[_position mapContainsPosition: position]    //[_position mapContainsPosition: position]
123      
124    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter]
125      postNotificationName:@"updateObject" object:self];      postNotificationName:@"updateObject" object: _game];
126        
127    _position = position;    _position = position;
128  }  }
# Line 131  Line 142 
142  - (void) setOrientation: (coord_t)orientation  - (void) setOrientation: (coord_t)orientation
143  {  {
144    [[NSNotificationCenter defaultCenter]    [[NSNotificationCenter defaultCenter]
145      postNotificationName:@"updateObject" object:self];      postNotificationName:@"updateObject" object: _game];
146    
147    _orientation = orientation;    _orientation = orientation;
148  }  }
# Line 164  Line 175 
175    /* FIXME - not implemented */      /* FIXME - not implemented */  
176  }  }
177    
178    @end
179    
180    @implementation HgObject (NSCoding)
181    
182  /**  /**
183   * NSCoding method   * NSCoding method
184   * to encode and decode objects   * to encode and decode objects
185   */     */
186  - (void)encodeWithCoder: (NSCoder *)encoder  - (void)encodeWithCoder: (NSCoder *)encoder
187  {  {
188    [encoder encodeValueOfObjCType: "I" at: &_identifier];    [encoder encodeValueOfObjCType: "I" at: &_identifier];
# Line 180  Line 195 
195  {  {
196    [decoder decodeValueOfObjCType: "I" at: &_identifier];    [decoder decodeValueOfObjCType: "I" at: &_identifier];
197    NSNumber *numIdent = [NSNumber numberWithInt: _identifier];    NSNumber *numIdent = [NSNumber numberWithInt: _identifier];
198      
199    HgObject *object = [[_game objects] objectForKey: numIdent];    HgGame *current = [HgGame currentGame];
200      HgObject *object = [[current objects] objectForKey: numIdent];
201      
202    if (object != nil)    if (object != nil)
203      {      {
204        DESTROY(self);        DESTROY(self);
# Line 192  Line 208 
208      {      {
209        self = [super init];        self = [super init];
210      }      }
211      
212    if (self != nil)    if (self != nil)
213      {      {
214        [decoder decodeValueOfObjCType: @encode(coord_t) at: &_position];        [decoder decodeValueOfObjCType: @encode(coord_t) at: &_position];
# Line 203  Line 219 
219    return self;    return self;
220  }  }
221    
   
222  @end  @end

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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