Crossfire Server, Trunk  1.75.0
container.cpp File Reference
#include <global.h>
#include <ob_methods.h>
#include <ob_types.h>
#include <sounds.h>
#include <sproto.h>
+ Include dependency graph for container.cpp:

Go to the source code of this file.

Functions

int apply_container (object *op, object *sack, int aflags)
 Handle apply on containers. More...
 
method_ret close_container_apply (object *op, object *applier, int aflags)
 
method_ret container_apply (object *op, object *applier, int aflags)
 
void container_describe (const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
 
method_ret container_examine (const object *op, const object *, int, char *buf, size_t size)
 
static method_ret container_type_move_on (object *trap, object *victim, object *originator)
 Move on this Container object. More...
 
void init_type_container (void)
 Initializer for the CONTAINER object type. More...
 
int sack_can_hold (const object *pl, const object *sack, const object *op, uint32_t nrof)
 Check if an item op can be put into a sack. More...
 
bool sack_race_can_contain (const object *sack, const object *ob)
 
int set_object_face_main (object *op)
 Makes an object's face the main face, which is supposed to be the "closed" one. More...
 
static int set_object_face_other (object *op)
 Makes an object's face the other_arch face, supposed to be the "opened" one. More...
 

Detailed Description

The implementation of the Container class of objects.

Definition in file container.cpp.

Function Documentation

◆ apply_container()

int apply_container ( object op,
object sack,
int  aflags 
)

Handle apply on containers.

This is for containers that are applied by a player, whether in inventory or on the ground: eg, sacks, luggage, etc.

Moved to own function and added many features [Tero.Haatanen(at)lut.fi] This version is for client/server mode.

Reminder - there are three states for any container - closed (non applied), applied (not open, but objects that match get tossed into it), and open (applied flag set, and op->container points to the open container)

Parameters
opplayer.
sackcontainer the player is opening or closing.
aflagscombination of Flags for apply_special(). flags.
Returns
1 if an object is applied somehow or another, 0 if error/no apply
Author
Eneq(at)(csd.uu.se)

Definition at line 203 of file container.cpp.

References AP_APPLY, AP_NULL, AP_OPEN, AP_UNAPPLY, CLEAR_FLAG, CONTAINER, object::container, socket_struct::container_position, object::contr, object::count, draw_ext_info_format(), object::env, esrv_send_inventory(), esrv_send_item(), esrv_update_item(), EVENT_CLOSE, events_execute_object_event(), find_key(), FLAG_APPLIED, object::head, INS_NO_MERGE, llevError, LOG(), object::map, MAX_BUF, object::more, MOVE_ALL, object::move_off, MSG_TYPE_APPLY, MSG_TYPE_APPLY_ERROR, MSG_TYPE_APPLY_SUCCESS, MSG_TYPE_APPLY_UNAPPLY, object::name, NDI_UNIQUE, object::nrof, object_insert_in_map_at(), object_insert_in_ob(), object_split(), object_was_destroyed, PLAYER, QUERY_FLAG, query_name(), SCRIPT_FIX_ALL, SET_FLAG, set_object_face_main(), set_object_face_other(), object::slaying, player::socket, object::type, UPD_FACE, UPD_FLAGS, object::x, and object::y.

Referenced by close_container_apply(), container_apply(), container_type_move_on(), and loot_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ close_container_apply()

method_ret close_container_apply ( object op,
object applier,
int  aflags 
)

Definition at line 460 of file container.cpp.

References apply_container(), object::env, METHOD_OK, PLAYER, and object::type.

Referenced by init_type_container().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ container_apply()

method_ret container_apply ( object op,
object applier,
int  aflags 
)

Definition at line 454 of file container.cpp.

References apply_container(), METHOD_OK, PLAYER, and object::type.

Referenced by init_type_container().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ container_describe()

void container_describe ( const object op,
const object observer,
int  use_media_tags,
char *  buf,
size_t  size 
)

Definition at line 466 of file container.cpp.

References buf, object::container, object::env, FLAG_APPLIED, legacy_ob_describe(), and QUERY_FLAG.

Referenced by init_type_container().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ container_examine()

method_ret container_examine ( const object op,
const object ,
int  ,
char *  buf,
size_t  size 
)

Definition at line 472 of file container.cpp.

References buf, METHOD_OK, object::race, object::stats, living::Str, and object::weight_limit.

Referenced by init_type_container().

+ Here is the caller graph for this function:

◆ container_type_move_on()

static method_ret container_type_move_on ( object trap,
object victim,
object originator 
)
static

Move on this Container object.

Parameters
trapThe Container we're moving on
victimThe object moving over this one
originatorThe object that caused the move_on event
Returns
METHOD_OK

Definition at line 501 of file container.cpp.

References AP_NULL, apply_container(), common_post_ob_move_on(), common_pre_ob_move_on(), METHOD_ERROR, METHOD_OK, PLAYER, and object::type.

Referenced by init_type_container().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_type_container()

void init_type_container ( void  )

Initializer for the CONTAINER object type.

Definition at line 487 of file container.cpp.

References CLOSE_CON, close_container_apply(), CONTAINER, container_apply(), container_describe(), container_examine(), container_type_move_on(), register_apply(), register_describe(), register_examine(), and register_move_on().

Referenced by register_all_ob_types().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sack_can_hold()

int sack_can_hold ( const object pl,
const object sack,
const object op,
uint32_t  nrof 
)

Check if an item op can be put into a sack.

If pl exists then tell a player the reason of failure.

Parameters
plplayer.
sackcontainer to try to put into.
opwhat to put in the sack.
nrofnumber of objects (op) we want to put in. We specify it separately instead of using op->nrof because often times, a player may have specified a certain number of objects to drop, so we can pass that number, and not need to use split_ob() and stuff.
Returns
1 if it will fit, 0 if it will not.

Definition at line 66 of file container.cpp.

References object::carrying, CONTAINER, draw_ext_info_format(), FLAG_APPLIED, living::food, MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, name, NDI_UNIQUE, QUERY_FLAG, query_name(), object::race, sack_race_can_contain(), object::slaying, SPECIAL_KEY, object::stats, living::Str, object::type, object::weight, and object::weight_limit.

Referenced by esrv_move_object(), pick_up(), put_object_in_sack(), and sell_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sack_race_can_contain()

bool sack_race_can_contain ( const object sack,
const object ob 
)

Definition at line 36 of file container.cpp.

References csv_contains(), and object::race.

Referenced by sack_can_hold().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_object_face_main()

int set_object_face_main ( object op)

Makes an object's face the main face, which is supposed to be the "closed" one.

Sets an object's face to the 'face' in the archetype. Meant for showing containers opening and closing.

Parameters
opObject to set face on
Returns
TRUE if face changed

Definition at line 127 of file container.cpp.

References object::arch, archetype::clone, object::face, FALSE, object::more, object_get_value(), sstring, TRUE, and try_find_face().

Referenced by apply_container(), and put_object_in_sack().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_object_face_other()

static int set_object_face_other ( object op)
static

Makes an object's face the other_arch face, supposed to be the "opened" one.

Sets an object's face to the other_arch 'face'. Meant for showing containers opening and closing.

Parameters
opObject to set face on
Returns
TRUE if face changed

Definition at line 154 of file container.cpp.

References object::arch, archetype::clone, object::face, FALSE, object::head, object::more, Face::name, object_get_value(), object_set_value(), object::other_arch, sstring, TRUE, and try_find_face().

Referenced by apply_container().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: