Atrinik Server  4.0
Macros
Object looping macros

Macros

#define FOR_INV_PREPARE(op_, it_)
 
#define FOR_INV_FINISH()
 
#define FOR_ABOVE_PREPARE(op_, it_)
 
#define FOR_ABOVE_FINISH()
 
#define FOR_BELOW_PREPARE(op_, it_)
 
#define FOR_BELOW_FINISH()
 
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
 
#define FOR_MAP_FINISH()
 
#define FOR_OB_AND_ABOVE_PREPARE(op_)   FOR_OB_PREPARE(op_, above, __LINE__)
 
#define FOR_OB_AND_ABOVE_FINISH()   FOR_OB_FINISH()
 
#define FOR_OB_AND_BELOW_PREPARE(op_)   FOR_OB_PREPARE(op_, below, __LINE__)
 
#define FOR_OB_AND_BELOW_FINISH()   FOR_OB_FINISH()
 
#define FOR_OB_PREPARE(op_, field_, suffix_)   FOR_OB_PREPARE2(op_, field_, suffix_)
 
#define FOR_OB_PREPARE2(op_, field_, suffix_)
 
#define FOR_OB_FINISH()
 

Detailed Description

Macros used for looping through objects in various locations.

Author
Andreas Kirschbaum

Macro Definition Documentation

#define FOR_ABOVE_FINISH ( )
Value:
} while(0)
#define FOR_OB_AND_ABOVE_FINISH()
Definition: define.h:1773

Finishes FOR_ABOVE_PREPARE().

Definition at line 1717 of file define.h.

#define FOR_ABOVE_PREPARE (   op_,
  it_ 
)
Value:
do { \
object *it_ = (op_)->above; \
#define FOR_OB_AND_ABOVE_PREPARE(op_)
Definition: define.h:1769

Constructs a loop iterating over all objects above an object.

Parameters
op_the object to iterate over
it_a variable name that holds the inventory objects; a new variable will be declared; modifications do not affect the loop

Definition at line 1710 of file define.h.

#define FOR_BELOW_FINISH ( )
Value:
} while(0)
#define FOR_OB_AND_BELOW_FINISH()
Definition: define.h:1785

Finishes FOR_BELOW_PREPARE().

Definition at line 1736 of file define.h.

#define FOR_BELOW_PREPARE (   op_,
  it_ 
)
Value:
do { \
object *it_ = (op_)->below; \
#define FOR_OB_AND_BELOW_PREPARE(op_)
Definition: define.h:1781

Constructs a loop iterating over all objects below an object.

Parameters
op_the object to iterate over
it_a variable name that holds the inventory objects; a new variable will be declared; modifications do not affect the loop

Definition at line 1729 of file define.h.

#define FOR_INV_FINISH ( )
Value:
} while(0)
#define FOR_OB_AND_BELOW_FINISH()
Definition: define.h:1785

Finishes FOR_INV_PREPARE().

Definition at line 1698 of file define.h.

#define FOR_INV_PREPARE (   op_,
  it_ 
)
Value:
do { \
object *it_ = (op_)->inv; \
#define FOR_OB_AND_BELOW_PREPARE(op_)
Definition: define.h:1781

Constructs a loop iterating over the inventory of an object. Example:

FOR_INV_PREPARE(op, inv)
    LOG(INFO, "%s\n", inv->name);
FOR_INV_FINISH();

or

FOR_INV_PREPARE(op, inv) {
    LOG(INFO, "%s\n", inv->name);
} FOR_INV_FINISH();
Parameters
op_the object to iterate over
it_a variable name that holds the inventory objects; a new variable will be declared; modifications do not affect the loop

Definition at line 1691 of file define.h.

#define FOR_MAP_FINISH ( )
Value:
} while(0)
#define FOR_OB_AND_ABOVE_FINISH()
Definition: define.h:1773

Finishes FOR_MAP_PREPARE().

Definition at line 1759 of file define.h.

#define FOR_MAP_PREPARE (   map_,
  mx_,
  my_,
  it_ 
)
Value:
do { \
object *it_ = GET_MAP_OB((map_), (mx_), (my_)); \
#define FOR_OB_AND_ABOVE_PREPARE(op_)
Definition: define.h:1769

Constructs a loop iterating over all objects of a map tile.

Parameters
map_the map to iterate over
mx_the map's x-coordinate to iterate over
my_the map's y-coordinate to iterate over
it_a variable name that holds the inventory objects; a new variable will be declared; modifications do not affect the loop

Definition at line 1752 of file define.h.

#define FOR_OB_AND_ABOVE_FINISH ( )    FOR_OB_FINISH()

Finishes FOR_OB_AND_ABOVE_PREPARE().

Definition at line 1773 of file define.h.

#define FOR_OB_AND_ABOVE_PREPARE (   op_)    FOR_OB_PREPARE(op_, above, __LINE__)

Constructs a loop iterating over an object and all objects above it in the same pile.

Parameters
op_the object to start with

Definition at line 1769 of file define.h.

#define FOR_OB_AND_BELOW_FINISH ( )    FOR_OB_FINISH()

Finishes FOR_OB_AND_BELOW_PREPARE().

Definition at line 1785 of file define.h.

#define FOR_OB_AND_BELOW_PREPARE (   op_)    FOR_OB_PREPARE(op_, below, __LINE__)

Constructs a loop iterating over an object and all objects below it in the same pile.

Parameters
op_the object to start with

Definition at line 1781 of file define.h.

#define FOR_OB_FINISH ( )
Value:
} \
} while(0)

Finishes FOR_OB_PREPARE().

Definition at line 1821 of file define.h.

#define FOR_OB_PREPARE (   op_,
  field_,
  suffix_ 
)    FOR_OB_PREPARE2(op_, field_, suffix_)

Constructs a loop iterating over a set of objects. This function should not be used directly in client code.

Parameters
op_the object start start with
field_the field that holds the "next" pointer within op_
suffix_a suffix for constructing unique variable names

Definition at line 1797 of file define.h.

#define FOR_OB_PREPARE2 (   op_,
  field_,
  suffix_ 
)
Value:
do { \
object *next##suffix_ = (op_); \
tag_t next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;\
while (((op_) = next##suffix_) != NULL) { \
if (OBJECT_DESTROYED(next##suffix_, next_tag##suffix_)) {\
break; \
} \
next##suffix_ = next##suffix_->field_; \
next_tag##suffix_ = next##suffix_ == NULL ? 0 : next##suffix_->count;
struct sound_ambient_match * next
Next match rule in a linked list.
Definition: sound_ambient.c:39
#define OBJECT_DESTROYED(obj, tag)
Definition: object.h:716

Constructs a loop iterating over a set of objects. This function should not be used at all. Use FOR_OB_PREPARE() instead.

Parameters
op_the object to start with
field_the field that holds the "next" pointer within op_
suffix_a suffix for constructing unique variable names

Definition at line 1808 of file define.h.