Crossfire Server  1.75.0
friend.cpp File Reference

Functions related to relationship management. More...

#include "global.h"
#include <stdlib.h>

Go to the source code of this file.

Functions

void add_friendly_object (object *op)
 Add a new friendly object to the list of friendly objects. More...
 
void clean_friendly_list (void)
 It traverses the friendly list removing objects that should not be here (ie, do not have friendly flag set, freed, etc) More...
 
void clear_friendly_list (void)
 Totally clear the friendly list. More...
 
void dump_friendly_objects (void)
 Dumps all friendly objects. More...
 
objectlinkget_friends_of (const object *owner)
 Get a list of friendly objects for the specified owner. More...
 
objectget_next_friend (object *current)
 Get the next object on the friendly list. More...
 
int is_friendly (const object *op)
 Checks if the given object is already in the friendly list or not. More...
 
void remove_friendly_object (object *op)
 Removes the specified object from the linked list of friendly objects. More...
 

Variables

static std::vector< std::pair< object *, tag_t > > friends
 List of all friendly objects, object and its count. More...
 

Detailed Description

Functions related to relationship management.

Definition in file friend.cpp.

Function Documentation

◆ add_friendly_object()

void add_friendly_object ( object op)

Add a new friendly object to the list of friendly objects.

Will log an error if the object is already on that list.

Parameters
opobject to add to the list.

Definition at line 32 of file friend.cpp.

References object::count, friends, is_friendly(), llevError, LOG(), and object::name.

Referenced by add_player(), animate_weapon(), cfapi_object_set_property(), change_object(), do_mood_floor(), fix_summon_pet(), mood_change(), pets_summon_golem(), pets_summon_object(), polymorph_living(), receive_play_again(), and use_oratory().

◆ clean_friendly_list()

void clean_friendly_list ( void  )

It traverses the friendly list removing objects that should not be here (ie, do not have friendly flag set, freed, etc)

Definition at line 80 of file friend.cpp.

References FLAG_FREED, FLAG_FRIENDLY, friends, llevDebug, LOG(), and QUERY_FLAG.

Referenced by do_specials().

◆ clear_friendly_list()

void clear_friendly_list ( void  )

Totally clear the friendly list.

Definition at line 134 of file friend.cpp.

References friends.

Referenced by free_globals().

◆ dump_friendly_objects()

void dump_friendly_objects ( void  )

Dumps all friendly objects.

Invoked in DM-mode with dumpfriendlyobjects command.

Note
logs at the error level.

Definition at line 70 of file friend.cpp.

References friends, llevError, and LOG().

Referenced by command_dumpfriendlyobjects().

◆ get_friends_of()

objectlink* get_friends_of ( const object owner)

Get a list of friendly objects for the specified owner.

Parameters
ownerwho to get objects of, may be NULL to get all friendly objects.
Returns
list of objects that must be freed with free_objectlink(), may be NULL.

Definition at line 117 of file friend.cpp.

References friends, get_objectlink(), objectlink::id, objectlink::next, objectlink::ob, and object_get_owner().

Referenced by command_kill_pets(), command_showpets(), get_nearest_player(), pets_attempt_follow(), and pets_terminate_all().

◆ get_next_friend()

object* get_next_friend ( object current)

Get the next object on the friendly list.

Parameters
currentcurrent object, NULL to get the first item on the list.
Returns
next item, NULL if no more items or current isn't on the list.

Definition at line 143 of file friend.cpp.

References friends.

Referenced by cfapi_friendlylist_get_next(), and cfapi_system_get_object_vector().

◆ is_friendly()

int is_friendly ( const object op)

Checks if the given object is already in the friendly list or not.

Parameters
opitem to check
Returns
1 if on friendly list, 0 else

Definition at line 108 of file friend.cpp.

References friends.

Referenced by add_friendly_object(), cfapi_object_get_property(), and cfapi_object_set_property().

◆ remove_friendly_object()

Variable Documentation

◆ friends

std::vector<std::pair<object *, tag_t> > friends
static