/[hegemonie]/hegemonie/Map/MapTerrain.m
ViewVC logotype

Diff of /hegemonie/Map/MapTerrain.m

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

revision 1.6 by gabby, Thu Jul 24 13:32:12 2003 UTC revision 1.7 by el_doc, Tue Aug 19 08:36:24 2003 UTC
# Line 29  Line 29 
29  #include <Foundation/NSDebug.h>  #include <Foundation/NSDebug.h>
30  #include <AppKit/NSBitmapImageRep.h>  #include <AppKit/NSBitmapImageRep.h>
31    
32    #include "Common/Coord.h"
33  #include "Map/MapTerrain.h"  #include "Map/MapTerrain.h"
34    
 /**  
  * returns a number n such as 0 <= n < max  
  * aroundTheWorld(-1) = max - 1  
  * aroundTheWorld(max) = 0  
  * aroundTheWorld(max + 1) = 1  
  */  
 int  
 aroundTheWorld (int n, int max)  
 {  
   NSCParameterAssert (max > 0);  
   
   if (n < 0)  
     return (max + ((n + 1) % max) - 1);  
   else  
     return (n % max);  
 }  
   
35    
36  /**  /**
37   * The terrain stores a heightField which can be displayed   * The terrain stores a heightField which can be displayed
# Line 159  aroundTheWorld (int n, int max) Line 143  aroundTheWorld (int n, int max)
143  /**  /**
144   * Returns a pointer to the tab, assuming position to be a valid one   * Returns a pointer to the tab, assuming position to be a valid one
145   */   */
146  - (u_int8_t *) _tabAtPosition: (map_coord_t)position  - (u_int8_t *) _tabAtPosition: (coord2DInt_t)position
147  {  {
148     NSParameterAssert (position.x >= 0);     NSParameterAssert (position.x >= 0);
149     NSParameterAssert (position.x < _xLength);     NSParameterAssert (position.x < _xLength);
# Line 175  aroundTheWorld (int n, int max) Line 159  aroundTheWorld (int n, int max)
159   * If the coordinates go beyond the edge of the map,   * If the coordinates go beyond the edge of the map,
160   * they pass on other side by modulo.   * they pass on other side by modulo.
161   */   */
162  - (u_int8_t *) _heightAtPosition: (map_coord_t)position  - (u_int8_t *) _heightAtPosition: (coord2DInt_t)position
163  {  {
164    return [self _tabAtPosition:    return [self _tabAtPosition:
165                   MakeMapCoord (aroundTheWorld(position.x, _xLength),                   MakeCoord2DInt (aroundTheWorld(position.x, _xLength),
166                                 aroundTheWorld(position.z, _zLength))];                                   aroundTheWorld(position.z, _zLength))];
167  }  }
168    
169  /**  /**
# Line 187  aroundTheWorld (int n, int max) Line 171  aroundTheWorld (int n, int max)
171   * position may be any positive or negative coordinate:   * position may be any positive or negative coordinate:
172   * it turns around the toric map by modulo.   * it turns around the toric map by modulo.
173   */   */
174  - (u_int8_t) heightAtPosition: (map_coord_t)position  - (u_int8_t) heightAtPosition: (coord2DInt_t)position
175  {  {
176    return *[self _heightAtPosition: position];    return *[self _heightAtPosition: position];
177  }  }
# Line 214  aroundTheWorld (int n, int max) Line 198  aroundTheWorld (int n, int max)
198   * If the coordinates go beyond the edge of the map,   * If the coordinates go beyond the edge of the map,
199   * they pass on other side by modulo.   * they pass on other side by modulo.
200   */   */
201  - (void) setHeightAtPosition: (map_coord_t)position  - (void) setHeightAtPosition: (coord2DInt_t)position
202                      toHeight: (u_int8_t)height                      toHeight: (u_int8_t)height
203  {  {
204    *[self _heightAtPosition: position] = height;    *[self _heightAtPosition: position] = height;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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