Atrinik Server  4.0
Macros
Map layer looping macros

Macros

#define FOR_MAP_LAYER_BEGIN(_m, _x, _y, _layer, _sub_layer, _obj)
 
#define FOR_MAP_LAYER_BREAK
 
#define FOR_MAP_LAYER_END
 

Detailed Description

Macros used for looping through objects on a specific map square and layer.

Macro Definition Documentation

#define FOR_MAP_LAYER_BEGIN (   _m,
  _x,
  _y,
  _layer,
  _sub_layer,
  _obj 
)
Value:
{ \
int __sub_layer; \
object *__tmp, *__next; \
tag_t __next_tag; \
for (__sub_layer = ((_sub_layer) == -1 ? 0 : (_sub_layer)); __sub_layer < ((_layer) == LAYER_SYS ? 1 : ((_sub_layer) == -1 ? NUM_SUB_LAYERS : ((_sub_layer) + 1))); __sub_layer++) \
{ \
for (__tmp = (_layer) == LAYER_SYS ? GET_MAP_OB((_m), (_x), (_y)) : GET_MAP_OB_LAYER((_m), (_x), (_y), (_layer), __sub_layer); __tmp && __tmp->layer == (_layer) && __tmp->sub_layer == __sub_layer; __tmp = __next) \
{ \
__next = __tmp->above; \
__next_tag = 0; \
if (__next) \
{ \
__next_tag = __next->count; \
} \
(_obj) = __tmp;
#define LAYER_SYS
Definition: map.h:47
#define NUM_SUB_LAYERS
Definition: map.h:71

The loop constructor.

Parameters
_mMap.
_xX position.
_yY position.
_layerLayer, one of Layer types.
_sub_layerWhich sub-layer to look for. If -1, will search all sub-layers.
_objVariable of an object pointer (does not need to be initialized); will contain the found object, if any.
Warning
Does not support stacking.
Note
Use FOR_MAP_LAYER_BREAK to break out, instead of the traditional 'break'.

Definition at line 1630 of file define.h.

#define FOR_MAP_LAYER_BREAK
Value:
__sub_layer = NUM_SUB_LAYERS; \
break; \
#define NUM_SUB_LAYERS
Definition: map.h:71

Break out of the loop.

Definition at line 1650 of file define.h.

#define FOR_MAP_LAYER_END
Value:
if (__next && !OBJECT_VALID(__next, __next_tag)) \
{ \
} \
} \
} \
}
#define FOR_MAP_LAYER_BREAK
Definition: define.h:1650
#define OBJECT_VALID(_ob_, _count_)
Definition: object.h:548

End the loop.

Definition at line 1657 of file define.h.