Atrinik Server  4.0
Data Structures | Macros | Typedefs | Functions | Variables
object.h File Reference
#include <decls.h>
#include <attack.h>

Go to the source code of this file.

Data Structures

struct  key_value
 
struct  obj
 
struct  oblnk
 
struct  magic_mirror_struct
 

Macros

#define WEIGHT(op)   (!op->nrof || op->type == CONTAINER ? op->weight + op->carrying : op->weight)
 
#define WEIGHT_NROF(op, nrof)   (MAX(1, nrof) * op->weight + op->carrying)
 
#define MOVE_APPLY_DEFAULT   0
 
#define MOVE_APPLY_WALK_ON   1
 
#define MOVE_APPLY_FLY_ON   2
 
#define MOVE_APPLY_WALK_OFF   4
 
#define MOVE_APPLY_FLY_OFF   8
 
#define MOVE_APPLY_MOVE   16
 
#define MOVE_APPLY_VANISHED   32
 
#define MOVE_APPLY_SAVING   64
 
#define CHECK_WALK_OK   0
 
#define CHECK_WALK_DESTROYED   1
 
#define CHECK_WALK_MOVED   2
 
#define free_objectlink_simple(_chunk_)   mempool_return(pool_objectlink, (_chunk_));
 
#define CONTR(ob)   ((player *) ((ob)->custom_attrset))
 
#define LOOK_OBJ(_ob)   (!IS_SYS_INVISIBLE(_ob) && _ob->type != PLAYER)
 
#define UP_OBJ_INSERT   1
 
#define UP_OBJ_REMOVE   2
 
#define UP_OBJ_FLAGS   3
 
#define UP_OBJ_FACE   4
 
#define UP_OBJ_FLAGFACE   5
 
#define UP_OBJ_ALL   6
 
#define OBJECT_VALID(_ob_, _count_)   ((_ob_) && (_ob_)->count == ((tag_t) _count_) && !QUERY_FLAG((_ob_), FLAG_REMOVED) && !OBJECT_FREE(_ob_))
 
#define OBJECT_ACTIVE(_ob_)   (!QUERY_FLAG((_ob_), FLAG_REMOVED) && !OBJECT_FREE(_ob_))
 
#define OBJECT_FREE(_ob_)   ((_ob_)->count == 0)
 
#define INS_NO_MERGE   1
 
#define INS_NO_WALK_ON   2
 
#define INS_FALL_THROUGH   4
 
#define REMOVE_NO_WEIGHT   1
 
#define REMOVE_NO_WALK_OFF   2
 
#define BEHAVIOR_SPELL_FRIENDLY   0x01
 
#define BEHAVIOR_OPEN_DOORS   0x02
 
#define BEHAVIOR_STEALTH   0x04
 
#define BEHAVIOR_EXITS   0x08
 
#define BEHAVIOR_SECRET_PASSAGES   0x10
 
#define BEHAVIOR_GUARD   0x20
 
#define decrease_ob(xyz)   object_decrease(xyz, 1)
 
#define GENDER_NEUTER   0
 
#define GENDER_MALE   1
 
#define GENDER_FEMALE   2
 
#define GENDER_HERMAPHRODITE   3
 
#define GENDER_MAX   4
 
#define CORPSE_INFRAVISION_PERCENT   75
 
#define HEAD(op)   ((op)->head ? (op)->head : (op))
 
#define MMIRROR(ob)   ((magic_mirror_struct *) ((ob)->custom_attrset))
 
#define OBJECT_CAN_TALK(ob)
 
#define OBJECT_CURSED(ob)   (QUERY_FLAG((ob), FLAG_CURSED) || QUERY_FLAG((ob), FLAG_DAMNED))
 
#define OBJ_DESTROYED_BEGIN(_op)
 
#define OBJ_DESTROYED(_op)   (!OBJECT_VALID((_op), __tag_ ## _op))
 
#define OBJ_DESTROYED_END()   } while (0)
 
#define OBJECT_DESTROYED(obj, tag)   (OBJECT_FREE(obj) || (obj)->count != (tag))
 
#define _OBJECTS_DESTROYED_DEFINE(obj)
 
#define _OBJECTS_DESTROYED(obj)   (OBJECT_DESTROYED(obj, __tag_##obj))
 
#define _OBJECTS_DESTROYED_ANY(obj)   _OBJECTS_DESTROYED(obj) ||
 
#define _OBJECTS_DESTROYED_ALL(obj)   _OBJECTS_DESTROYED(obj) &&
 
#define OBJECTS_DESTROYED_BEGIN(...)
 
#define OBJECTS_DESTROYED_ANY(...)   (FOR_EACH(_OBJECTS_DESTROYED_ANY, __VA_ARGS__) 0)
 
#define OBJECTS_DESTROYED_ALL(...)   (FOR_EACH(_OBJECTS_DESTROYED_ALL, __VA_ARGS__) 1)
 
#define OBJECTS_DESTROYED(obj)   (_OBJECTS_DESTROYED(obj))
 
#define OBJECTS_DESTROYED_END()   } while (0)
 
#define OBJECT_IS_PROJECTILE(ob)   (QUERY_FLAG((ob), FLAG_FLYING) && (QUERY_FLAG((ob), FLAG_IS_MISSILE) || QUERY_FLAG((ob), FLAG_IS_SPELL)))
 
#define OBJECT_IS_RANGED(_ob)   ((_ob)->type == WAND || (_ob)->type == ROD || (_ob)->type == BOW || (_ob)->type == SPELL || (_ob)->type == SKILL || ((_ob)->type == ARROW && QUERY_FLAG((_ob), FLAG_IS_THROWN)))
 
#define OBJECT_IS_AMMO(_ob)
 
#define OBJECT_IS_SPELL_TOOL(ob)
 

Typedefs

typedef struct key_value key_value_t
 
typedef struct magic_mirror_struct magic_mirror_struct
 

Functions

bool object_can_merge (object *ob1, object *ob2)
 
objectobject_merge (object *op)
 
uint32_t object_weight_sum (object *op)
 
void object_weight_add (object *op, uint32_t weight)
 
void object_weight_sub (object *op, uint32_t weight)
 
objectobject_get_env (object *op)
 
bool object_is_in_inventory (const object *op, const object *inv)
 
void object_dump (const object *op, StringBuffer *sb)
 
void object_dump_rec (const object *op, StringBuffer *sb)
 
void object_owner_clear (object *op)
 
void object_owner_set (object *op, object *owner)
 
void object_owner_copy (object *op, object *clone_ob)
 
objectobject_owner (object *op)
 
void object_copy (object *op, const object *src, bool no_speed)
 
void object_copy_full (object *op, const object *src)
 
void object_init (void)
 
void object_deinit (void)
 
objectobject_get (void)
 
void object_update_turnable (object *op)
 
void object_update_speed (object *op)
 
void object_update (object *op, int action)
 
void object_drop_inventory (object *op)
 
void object_destroy_inv (object *ob)
 
void object_destroy (object *ob)
 
void object_destruct (object *op)
 
void object_remove (object *op, int flags)
 
objectobject_insert_map (object *op, mapstruct *m, object *originator, int flag)
 
objectobject_stack_get (object *op, uint32_t nrof)
 
objectobject_stack_get_reinsert (object *op, uint32_t nrof)
 
objectobject_stack_get_removed (object *op, uint32_t nrof)
 
objectobject_decrease (object *op, uint32_t i)
 
objectobject_insert_into (object *op, object *where, int flag)
 
objectobject_find_arch (object *op, archetype_t *at)
 
objectobject_find_type (object *op, uint8_t type)
 
int object_dir_to_target (object *op, object *target)
 
bool object_can_pick (const object *op, const object *item)
 
objectobject_clone (const object *op)
 
objectobject_load_str (const char *obstr)
 
void object_free_key_values (object *op)
 
key_value_tobject_get_key_link (const object *op, shstr *key)
 
shstr * object_get_value (const object *op, const char *const key)
 
bool object_set_value (object *op, const char *key, const char *value, bool add_key)
 
int object_matches_string (object *op, object *caller, const char *str)
 
int object_get_gender (const object *op)
 
void object_reverse_inventory (object *op)
 
bool object_enter_map (object *op, object *exit, mapstruct *m, int x, int y, bool fixed_pos)
 
const char * object_get_str (const object *op)
 
char * object_get_str_r (const object *op, char *buf, size_t bufsize)
 
int object_blocked (object *op, mapstruct *m, int x, int y)
 
objectobject_create_singularity (const char *name)
 
void object_save (const object *op, FILE *fp)
 
static objectOWNER (object *op)
 

Variables

objectactive_objects
 
const char * gender_noun [GENDER_MAX]
 
const char * gender_subjective [GENDER_MAX]
 
const char * gender_subjective_upper [GENDER_MAX]
 
const char * gender_objective [GENDER_MAX]
 
const char * gender_possessive [GENDER_MAX]
 
const char * gender_reflexive [GENDER_MAX]
 
int freearr_x [SIZEOFFREE]
 
int freearr_y [SIZEOFFREE]
 
int maxfree [SIZEOFFREE]
 
int freedir [SIZEOFFREE]
 
const char * object_flag_names [NUM_FLAGS+1]
 

Detailed Description

Object related structures, core of Atrinik

Definition in file object.h.

Macro Definition Documentation

#define CORPSE_INFRAVISION_PERCENT   75

Value in percent of time above which the corpse will be highlighted in infravision mode.

Definition at line 646 of file object.h.

#define decrease_ob (   xyz)    object_decrease(xyz, 1)

Decrease an object by one.

Definition at line 624 of file object.h.

#define HEAD (   op)    ((op)->head ? (op)->head : (op))

Returns the head part of an object. For single-tile objects returns the object itself.

Parameters
opThe object.
Returns
The head object.

Definition at line 657 of file object.h.

#define MMIRROR (   ob)    ((magic_mirror_struct *) ((ob)->custom_attrset))

Returns the magic_mirror_struct that holds the magic mirror's map, x and y. Can be NULL in case of a magic mirror that is only used for zooming or similar effect, and not mirroring.

Definition at line 678 of file object.h.

#define OBJ_DESTROYED (   _op)    (!OBJECT_VALID((_op), __tag_ ## _op))
Deprecated:

Definition at line 701 of file object.h.

#define OBJ_DESTROYED_BEGIN (   _op)
Value:
do { \
tag_t __tag_ ## _op = (_op)->count;
Deprecated:

Definition at line 695 of file object.h.

#define OBJ_DESTROYED_END ( )    } while (0)
Deprecated:

Definition at line 705 of file object.h.

#define OBJECT_ACTIVE (   _ob_)    (!QUERY_FLAG((_ob_), FLAG_REMOVED) && !OBJECT_FREE(_ob_))

Test the object is not removed nor freed - but no count test

Definition at line 551 of file object.h.

#define OBJECT_CAN_TALK (   ob)
Value:
((ob)->type == MONSTER && ((ob)->msg || \
HAS_EVENT((ob), EVENT_SAY)) && !OBJECT_VALID((ob)->enemy, \
(ob)->enemy_count))
#define MONSTER
Definition: define.h:353
uint8_t type
One of operation types.
Definition: sound_ambient.c:45
#define HAS_EVENT(ob, event)
Definition: plugin.h:179
#define EVENT_SAY
Definition: plugin.h:85
#define OBJECT_VALID(_ob_, _count_)
Definition: object.h:548

Check whether the specified object can talk.

Definition at line 683 of file object.h.

#define OBJECT_CURSED (   ob)    (QUERY_FLAG((ob), FLAG_CURSED) || QUERY_FLAG((ob), FLAG_DAMNED))

Check whether an object is cursed/damned.

Definition at line 690 of file object.h.

#define OBJECT_DESTROYED (   obj,
  tag 
)    (OBJECT_FREE(obj) || (obj)->count != (tag))

Check if the specified object has been destroyed.

Parameters
objThe object to check.
tagTag to check against.

Definition at line 716 of file object.h.

#define OBJECT_FREE (   _ob_)    ((_ob_)->count == 0)

Test if an object

Definition at line 554 of file object.h.

#define OBJECT_IS_AMMO (   _ob)
Value:
(((_ob)->type == CONTAINER && \
(_ob)->race != NULL && (_ob)->sub_type == ST1_CONTAINER_QUIVER) || \
((_ob)->type == ARROW && !QUERY_FLAG((_ob), FLAG_IS_THROWN)))
uint8_t type
One of operation types.
Definition: sound_ambient.c:45
#define FLAG_IS_THROWN
Definition: define.h:1170
#define ST1_CONTAINER_QUIVER
Definition: define.h:572
#define QUERY_FLAG(xyz, p)
Definition: define.h:761
#define CONTAINER
Definition: define.h:493
#define ARROW
Definition: define.h:170

Check whether the object is ammunition (quiver, arrow, bolt, etc).

Definition at line 833 of file object.h.

#define OBJECT_IS_PROJECTILE (   ob)    (QUERY_FLAG((ob), FLAG_FLYING) && (QUERY_FLAG((ob), FLAG_IS_MISSILE) || QUERY_FLAG((ob), FLAG_IS_SPELL)))

Check whether the object is a flying projectile.

Definition at line 823 of file object.h.

#define OBJECT_IS_RANGED (   _ob)    ((_ob)->type == WAND || (_ob)->type == ROD || (_ob)->type == BOW || (_ob)->type == SPELL || (_ob)->type == SKILL || ((_ob)->type == ARROW && QUERY_FLAG((_ob), FLAG_IS_THROWN)))

Check whether the object is a ranged weapon.

Definition at line 828 of file object.h.

#define OBJECT_IS_SPELL_TOOL (   ob)
Value:
((ob)->type == WAND || \
(ob)->type == ROD || \
(ob)->type == POTION || \
(ob)->type == SCROLL || \
(ob)->type == BOOK_SPELL)
#define SCROLL
Definition: define.h:453
uint8_t type
One of operation types.
Definition: sound_ambient.c:45
#define WAND
Definition: define.h:445
#define BOOK_SPELL
Definition: define.h:373
#define ROD
Definition: define.h:130
#define POTION
Definition: define.h:138

Check whether the object is spell-related tool, eg, a wand, a potion, etc.

Definition at line 840 of file object.h.

#define OBJECT_VALID (   _ob_,
  _count_ 
)    ((_ob_) && (_ob_)->count == ((tag_t) _count_) && !QUERY_FLAG((_ob_), FLAG_REMOVED) && !OBJECT_FREE(_ob_))

Macro for the often used object validity test (verify a pointer/count pair)

Definition at line 548 of file object.h.

#define WEIGHT (   op)    (!op->nrof || op->type == CONTAINER ? op->weight + op->carrying : op->weight)

Get the weight of an object. If the object is a container or doesn't have nrof, include the weight it is carrying.

Definition at line 40 of file object.h.

Typedef Documentation

typedef struct key_value key_value_t

This structure allows any object to have extra fields the Flex loader does not know about.

Structure used for object::custom_attrset of magic mirrors.

Function Documentation

int object_blocked ( object op,
mapstruct m,
int  x,
int  y 
)

Checks if the specified coordinates are blocked for the specified object.

Takes multi-part objects into account.

Parameters
opObject to check.
mMap.
xX coordinate.
yY coordinate.
Returns
0 if the tile is not blocked, a combination of Map look flags otherwise.

Definition at line 3224 of file object.c.

bool object_can_merge ( object ob1,
object ob2 
)

Examines two objects, and returns true if they can be merged together.

Parameters
ob1The first object.
ob2The second object.
Returns
True if the two object can merge, false otherwise.

Definition at line 299 of file object.c.

bool object_can_pick ( const object op,
const object item 
)

Finds out if an object can be picked up.

Note
This introduces a weight limitation for monsters.
Parameters
whoWho is trying to pick up. Can be a monster or a player.
itemItem we're trying to pick up.
Returns
True if it can be picked up, false otherwise.

Definition at line 2335 of file object.c.

object* object_clone ( const object op)

Create clone from one object to another.

Parameters
opObject to clone.
Returns
Clone of op, including inventory and 'more' body parts.

Definition at line 2385 of file object.c.

void object_copy ( object op,
const object src,
bool  no_speed 
)

Copy object first frees everything allocated by the second object, and then copies the contents of the first object into the second object, allocating what needs to be allocated.

Parameters
opObject to copy to.
srcObject to copy from.
no_speedIf set, do not touch the active list.

Definition at line 886 of file object.c.

void object_copy_full ( object op,
const object src 
)

Completely copy an object, duplicating the inventory too.

Parameters
opWhere to copy.
srcObject to copy.

Definition at line 970 of file object.c.

object* object_create_singularity ( const char *  name)

Creates a dummy object.

Parameters
nameName to give the dummy object. Can be NULL.
Returns
Object of specified name. It fill have the FLAG_NO_PICK flag set.

Definition at line 3281 of file object.c.

object* object_decrease ( object op,
uint32_t  nrof 
)

Decreases a specified number from the amount of an object. If the amount reaches 0, the object is subsequently removed and freed.

This function will send an update to client if op is in a player inventory.

Parameters
opObject to decrease.
nrofNumber to remove.
Returns
'op' if something is left, NULL if the amount reached 0.

Definition at line 2105 of file object.c.

void object_deinit ( void  )

Deinitialize the object API.

Definition at line 229 of file object.c.

void object_destroy ( object op)

Cleanups and frees everything allocated by an object and gives the memory back to the object mempool.

Note
The object must have been removed by object_remove() first.
Parameters
opThe object to destroy (free).

Definition at line 1441 of file object.c.

void object_destroy_inv ( object op)

Destroy (free) inventory of an object. Used internally by object_destroy() to recursively free the object's inventory.

Parameters
opObject to free the inventory of.

Definition at line 1414 of file object.c.

void object_destruct ( object op)

Drop op's inventory on the floor and remove op from the map.

Used mainly for physical destruction of normal objects and monsters.

Parameters
opObject to destruct.

Definition at line 1521 of file object.c.

int object_dir_to_target ( object op,
object target 
)

Get direction from one object to another.

Parameters
opThe first object.
targetThe target object.
range_vectorRange vector pointer to use.
Returns
The direction; zero if no direction can be computed.

Definition at line 2310 of file object.c.

void object_drop_inventory ( object op)

Drops the inventory of the specified object into its current environment.

Makes some decisions whether to actually drop or not, and/or to create a corpse for the stuff.

Parameters
opThe object to drop the inventory for.

Definition at line 1282 of file object.c.

void object_dump ( const object op,
StringBuffer *  sb 
)

Dumps an object.

Parameters
opObject to dump. Can be NULL.
sbBuffer that will contain object information. Must not be NULL.

Definition at line 680 of file object.c.

void object_dump_rec ( const object op,
StringBuffer *  sb 
)

Dump an object, complete with its inventory.

Parameters
opObject to dump.
sbBuffer that will contain object information.

Definition at line 711 of file object.c.

bool object_enter_map ( object op,
object exit,
mapstruct m,
int  x,
int  y,
bool  fixed_pos 
)

Make the specified object enter a map, using either an absolute position with a map pointer and coordinates, or using an exit object.

If neither 'm' nor 'exit' is specified, the object enters the emergency map.

Parameters
opObject entering a map.
exitExit object to use in order to ender the map.
mMap to enter.
xX coordinate.
yY coordinate.
fixed_posIf true, will not attempt to find an adjacency square if the original destination is blocked.
Returns
True on success, false on failure.

Definition at line 2956 of file object.c.

object* object_find_arch ( object op,
archetype_t at 
)

Searches for any object with a matching archetype in the inventory of the given object.

Parameters
opWhere to search.
atArchetype to search for.
Returns
First matching object, or NULL if none matches.

Definition at line 2258 of file object.c.

object* object_find_type ( object op,
uint8_t  type 
)

Searches for any object with a matching type variable in the inventory of the given object.

Parameters
opObject to search in.
typeType to search for.
Returns
First matching object, or NULL if none matches.

Definition at line 2284 of file object.c.

void object_free_key_values ( object op)

Zero the key_values on op, decrementing the shared-string refcounts and freeing the links.

Parameters
opObject to clear.

Definition at line 2456 of file object.c.

object* object_get ( void  )

Grabs an object from the list of unused objects, makes sure it is initialized, and returns it.

If there are no free objects, expand_objects() is called to get more.

Returns
The new object.

Definition at line 993 of file object.c.

object* object_get_env ( object op)

Acquire the outermost environment object for a given object.

Parameters
opObject we want the environment of.
Returns
The outermost environment object for a given object. Never NULL.

Definition at line 631 of file object.c.

int object_get_gender ( const object op)

Get object's gender ID, as defined in #GENDER_xxx.

Parameters
opObject to get gender ID of.
Returns
The gender ID.

Definition at line 2877 of file object.c.

key_value_t* object_get_key_link ( const object op,
shstr *  key 
)

Search for a field by key.

Parameters
opObject to search in.
keyKey to search. Must be a shared string.
Returns
The link from the list if pb has a field named key, NULL otherwise.

Definition at line 2487 of file object.c.

const char* object_get_str ( const object op)

Acquires a string representation of the object that is suitable for debugging purposes, as it includes the object's name, archname, map, environment, etc.

This function cycles through internal buffers to use as return values, and is safe to call up to ten times. After that, previously returned pointers will start getting overwritten.

Parameters
opObject. Can be NULL.
Returns
String representation of the object.

Definition at line 3151 of file object.c.

char* object_get_str_r ( const object op,
char *  buf,
size_t  bufsize 
)

Re-entrant version of object_get_str().

Parameters
opObject. Can be NULL.
bufBuffer to use.
bufsizeSize of 'buf'.
Returns
'buf'.

Definition at line 3175 of file object.c.

shstr* object_get_value ( const object op,
const char *const  key 
)

Get an extra value by key.

Parameters
opObject to search in.
keyKey of which to retrieve the value. Doesn't need to be a shared string.
Returns
The value if found, NULL otherwise.
Note
The returned string is shared.

Definition at line 2515 of file object.c.

void object_init ( void  )

Initialize the object API.

Definition at line 211 of file object.c.

object* object_insert_into ( object op,
object where,
int  flag 
)

This function inserts the object op in the linked list inside the object environment.

Parameters
opObject to insert. Must be removed. May become invalid after return, so use return value of the function.
whereObject to insert into.
flagCombination of INS_xxx values.
Returns
Pointer to inserted item, which will be different than op if object was merged.

Definition at line 2158 of file object.c.

object* object_insert_map ( object op,
mapstruct m,
object originator,
int  flag 
)

This function inserts the object in the two-way linked list which represents what is on a map.

Parameters
opObject to insert.
mMap to insert into.
originatorWhat caused op to be inserted.
flagCombination of INS_xxx values.
Returns
NULL if 'op' was destroyed, 'op' otherwise.

Definition at line 1741 of file object.c.

bool object_is_in_inventory ( const object op,
const object inv 
)

Check if the specified object is somewhere inside another object's inventory, regardless of the inventory nesting level.

Parameters
opThe object to check.
invInventory the object should be in.
Returns
True if the checked object is somewhere inside the specified inventory, false otherwise.

Definition at line 655 of file object.c.

object* object_load_str ( const char *  str)

Creates an object using a string representing its content.

Parameters
strString to load the object from.
Returns
The newly created object, NULL on failure.

Definition at line 2433 of file object.c.

int object_matches_string ( object op,
object caller,
const char *  str 
)

Checks if the specified object matches one of the keywords in the specified string. This is used for example by the /drop and /take commands, but also by the /apply command.

Calling function takes care of what action might need to be done and if it is valid (pickup, drop, etc).

Parameters
opThe item we're trying to match.
callerWho is trying to match the objects, for the purposes of functions like object_get_name_s().
strString we're searching.
Returns
Non-zero if we have a match. A higher value means a better match. Zero means no match.

Definition at line 2676 of file object.c.

object* object_merge ( object op)

Tries to merge 'op' with items above and below the object.

Parameters
opObject to merge.
Returns
'op', or the object 'op' was merged into.

Definition at line 479 of file object.c.

object* object_owner ( object op)

Returns the object which this object marks as being the owner.

An ID scheme is used to avoid pointing to objects which have been freed and are now reused. If this is detected, the owner is set to NULL, and NULL is returned.

Parameters
opThe object to get owner for.
Returns
Owner of the object if any, NULL if no owner.

Definition at line 857 of file object.c.

void object_owner_clear ( object op)

Clear pointer to owner of an object, including ownercount.

Parameters
opThe object to clear the owner for.

Definition at line 741 of file object.c.

void object_owner_copy ( object op,
object src 
)

Copies owner from a source object to the specified object.

Chosen skill object is set to that of the source object (typically the skill that was currently chosen at the time when the source object's owner was set and not the owner's current skill object).

Use this function if player created an object (e.g. fire bullet, swarm spell), and this object creates further objects whose kills should be accounted for the player's original skill, even if player has changed skills in the meanwhile.

Parameters
opThe object.
srcThe source object to copy the owner from.

Definition at line 824 of file object.c.

void object_owner_set ( object op,
object owner 
)

Sets the owner and sets the chosen skill pointer owner's current skill.

Parameters
opThe object.
ownerThe owner.

Definition at line 788 of file object.c.

void object_remove ( object op,
int  flags 
)

This function removes the object op from the linked list of objects which it is currently tied to. When this function is done, the object will have no environment. If the object previously had an environment, the map pointer and x/y coordinates will be updated to the previous environment.

Note
If you want to remove a lot of items in player's inventory, set FLAG_NO_FIX_PLAYER on the player first and then explicitly call living_update() on the player.
Parameters
opObject to remove.
flagsCombination of Object removal flags..

Definition at line 1623 of file object.c.

void object_reverse_inventory ( object op)

Reverses order of all the objects in the specified object's inventory.

Parameters
opObject to reverse the inventory of.

Definition at line 2901 of file object.c.

void object_save ( const object op,
FILE *  fp 
)

Dumps all variables in an object to a file.

Parameters
opObject to save.
fpWhere to save the object's text representation. Can be NULL, in which case this is a no-op.

Definition at line 3305 of file object.c.

bool object_set_value ( object op,
const char *  key,
const char *  value,
bool  add_key 
)

Updates the key in op to value.

Parameters
opObject to update.
keyKey to set or update. Doesn't need to be a shared string.
valueValue to set. Doesn't need to be a shared string. Can be NULL.
add_keyIf false, will not add the key if it doesn't exist in op.
Returns
True if key was updated or added, false otherwise.
Note
This function is merely a wrapper to object_set_value_s() to ensure the key is a shared string.

Definition at line 2635 of file object.c.

object* object_stack_get ( object op,
uint32_t  nrof 
)

Split a stack of objects into another object with the specified quantity.

If 'nrof' is more or equal to the nrof of the specified object, the original object is returned instead and no extra work is done.

Parameters
opObject to split.
nrofNumber of items to split from the stack.
Returns
Split part of the stack. Can be the original object; never NULL.

Definition at line 2010 of file object.c.

object* object_stack_get_reinsert ( object op,
uint32_t  nrof 
)

Like object_stack_get(), but if a new object is created due to the split, it is inserted in the same environment as the original object.

Parameters
opObject to split.
nrofNumber of items to split from the stack.
Returns
Split part of the stack. Can be the original object; never NULL.

Definition at line 2046 of file object.c.

object* object_stack_get_removed ( object op,
uint32_t  nrof 
)

Like object_stack_get(), but if the original object is returned (no new stack is created), it is also removed from its environment.

Parameters
opObject to split.
nrofNumber of items to split from the stack.
Returns
Split part of the stack. Can be the original object; never NULL.

Definition at line 2078 of file object.c.

void object_update ( object op,
int  action 
)

Updates the various map square flags and values depending on 'action'.

Parameters
opObject to update.
actionHint of what the caller believes need to be done. One of Object update flags values.

Definition at line 1117 of file object.c.

void object_update_speed ( object op)

Updates the speed of an object. If the speed changes from 0 to another value, or vice versa, then add/remove the object from the active list.

This function needs to be called whenever the speed of an object changes.

Parameters
opThe object.

Definition at line 1043 of file object.c.

void object_update_turnable ( object op)

If an object with the FLAG_IS_TURNABLE flag needs to be updated due to a direction change, this function can be called to update the face variable.

Parameters
opThe object to update.

Definition at line 1021 of file object.c.

void object_weight_add ( object op,
uint32_t  weight 
)

Adds the specified weight to an object, and also updates how much the environment(s) is/are carrying.

Parameters
opThe object.
weightThe weight to add.

Definition at line 568 of file object.c.

void object_weight_sub ( object op,
uint32_t  weight 
)

Recursively (outwards) subtracts a number from the weight of an object (and what is carried by its environment(s)).

Parameters
opThe object.
weightThe weight to subtract.

Definition at line 600 of file object.c.

uint32_t object_weight_sum ( object op)

Recursive function to calculate the weight an object is carrying.

It goes through in figures out how much containers are carrying, and sums it up.

Parameters
opThe object to calculate the weight for
Returns
The calculated weight

Definition at line 523 of file object.c.

static object* OWNER ( object op)
inlinestatic

Returns the owner of the specified object. If there is no object, the originally passed object pointer is returned instead.

Parameters
opThe object.
Returns
Owner of the object (may be the same object).

Definition at line 979 of file object.h.

Variable Documentation

object* active_objects

List of active objects that need to be processed

Definition at line 42 of file object.c.

int freearr_x[SIZEOFFREE]

X offset when searching around a spot.

Definition at line 84 of file object.c.

int freearr_y[SIZEOFFREE]

Y offset when searching around a spot.

Definition at line 99 of file object.c.

int freedir[SIZEOFFREE]

Direction we're pointing on this spot.

Definition at line 129 of file object.c.

const char* gender_noun[GENDER_MAX]

Gender nouns.

Definition at line 47 of file object.c.

const char* gender_objective[GENDER_MAX]

Objective pronouns.

Definition at line 65 of file object.c.

const char* gender_possessive[GENDER_MAX]

Possessive pronouns.

Definition at line 71 of file object.c.

const char* gender_reflexive[GENDER_MAX]

Reflexive pronouns.

Definition at line 77 of file object.c.

const char* gender_subjective[GENDER_MAX]

Subjective pronouns.

Definition at line 53 of file object.c.

const char* gender_subjective_upper[GENDER_MAX]

Subjective pronouns, with first letter in uppercase.

Definition at line 59 of file object.c.

int maxfree[SIZEOFFREE]

Number of spots around a location, including that location (except for 0).

Definition at line 114 of file object.c.

const char* object_flag_names[NUM_FLAGS+1]

This is a list of pointers that correspond to the FLAG_.. values. This is a simple 1:1 mapping - if FLAG_FRIENDLY is 15, then the 15'th element of this array should match that name.

If an entry is NULL, that is a flag not to be loaded/saved.

See Also
Flag defines

Definition at line 153 of file object.c.