… | |
… | |
63 | * where it is known the map is not tiled or the values are known |
63 | * where it is known the map is not tiled or the values are known |
64 | * consistent (eg, op->map, op->x, op->y) |
64 | * consistent (eg, op->map, op->x, op->y) |
65 | */ |
65 | */ |
66 | // all those macros are herewith declared legacy |
66 | // all those macros are herewith declared legacy |
67 | #define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags () |
67 | #define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags () |
68 | #define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light |
|
|
69 | #define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bot |
68 | #define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bot |
70 | #define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top |
69 | #define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top |
71 | #define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] |
70 | #define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] |
72 | #define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block |
71 | #define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block |
73 | #define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow |
72 | #define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow |
… | |
… | |
110 | * particular space (was map, floor, floor2, map_ob), |
109 | * particular space (was map, floor, floor2, map_ob), |
111 | * have this structure take care of that information. |
110 | * have this structure take care of that information. |
112 | * This puts it all in one place, and should also make it easier |
111 | * This puts it all in one place, and should also make it easier |
113 | * to extend information about a space. |
112 | * to extend information about a space. |
114 | */ |
113 | */ |
|
|
114 | INTERFACE_CLASS (mapspace) |
115 | struct mapspace |
115 | struct mapspace |
116 | { |
116 | { |
|
|
117 | object *ACC (RW, bot); |
117 | object *bot, *top; /* lowest/highest object on this space */ |
118 | object *ACC (RW, top); /* lowest/highest object on this space */ |
118 | object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ |
119 | object *ACC (RW, faces_obj[MAP_LAYERS]);/* face objects for the 3 layers */ |
119 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
120 | uint8 flags_; /* flags about this space (see the P_ values above) */ |
120 | sint8 light; /* How much light this space provides */ |
121 | sint8 ACC (RW, light); /* How much light this space provides */ |
121 | MoveType move_block; /* What movement types this space blocks */ |
122 | MoveType ACC (RW, move_block); /* What movement types this space blocks */ |
122 | MoveType move_slow; /* What movement types this space slows */ |
123 | MoveType ACC (RW, move_slow); /* What movement types this space slows */ |
123 | MoveType move_on; /* What movement types are activated */ |
124 | MoveType ACC (RW, move_on); /* What movement types are activated */ |
124 | MoveType move_off; /* What movement types are activated */ |
125 | MoveType ACC (RW, move_off); /* What movement types are activated */ |
125 | |
126 | |
126 | void update_ (); |
127 | void update_ (); |
127 | void update () |
128 | MTH void update () |
128 | { |
129 | { |
129 | if (!(flags_ & P_UPTODATE)) |
130 | if (!(flags_ & P_UPTODATE)) |
130 | update_ (); |
131 | update_ (); |
131 | } |
132 | } |
132 | |
133 | |
133 | uint8 flags () |
134 | MTH uint8 flags () |
134 | { |
135 | { |
135 | update (); |
136 | update (); |
136 | return flags_; |
137 | return flags_; |
137 | } |
138 | } |
|
|
139 | |
|
|
140 | MTH void invalidate () |
|
|
141 | { |
|
|
142 | flags_ = 0; |
|
|
143 | } |
138 | |
144 | |
139 | // maybe only inline quick flags_ checking? |
|
|
140 | object *player () |
145 | MTH object *player () |
141 | { |
146 | { |
142 | // search from the top, because players are usually on top |
147 | object *op; |
143 | // make usually == always and this non-amortized O(1) |
148 | |
144 | // could gte rid of P_PLAYER, too, then |
|
|
145 | if (flags () & P_PLAYER) |
149 | if (flags () & P_PLAYER) |
146 | for (object *op = top; op; op = op->below) |
150 | for (op = top; op->type != PLAYER; op = op->below) |
147 | if (op->type == PLAYER) |
151 | ; |
148 | return op; |
152 | else |
|
|
153 | op = 0; |
149 | |
154 | |
150 | return 0; |
155 | return op; |
151 | } |
156 | } |
152 | |
157 | |
153 | // return the item volume on this mapspace in cm³ |
158 | // return the item volume on this mapspace in cm³ |
154 | uint64 volume () const; |
159 | MTH uint64 volume () const; |
155 | |
160 | |
156 | bool blocks (MoveType mt) const |
161 | bool blocks (MoveType mt) const |
157 | { |
162 | { |
158 | return move_block && (mt & move_block) == mt; |
163 | return move_block && (mt & move_block) == mt; |
159 | } |
164 | } |
… | |
… | |
333 | static maptile *find_async (const char *path, maptile *original = 0, bool load = true);//PERL |
338 | static maptile *find_async (const char *path, maptile *original = 0, bool load = true);//PERL |
334 | static maptile *find_sync (const char *path, maptile *original = 0);//PERL |
339 | static maptile *find_sync (const char *path, maptile *original = 0);//PERL |
335 | static maptile *find_style_sync (const char *dir, const char *file = 0);//PERL |
340 | static maptile *find_style_sync (const char *dir, const char *file = 0);//PERL |
336 | object *pick_random_object (rand_gen &gen = rndm) const; |
341 | object *pick_random_object (rand_gen &gen = rndm) const; |
337 | |
342 | |
338 | mapspace const &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } |
343 | mapspace &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } |
339 | mapspace &at (uint32 x, uint32 y) { return spaces [x * height + y]; } |
|
|
340 | }; |
344 | }; |
341 | |
345 | |
342 | /* This is used by get_rangevector to determine where the other |
346 | /* This is used by get_rangevector to determine where the other |
343 | * creature is. get_rangevector takes into account map tiling, |
347 | * creature is. get_rangevector takes into account map tiling, |
344 | * so you just can not look the the map coordinates and get the |
348 | * so you just can not look the the map coordinates and get the |