Crossfire Server, Trunk
events.cpp File Reference
#include <stdarg.h>
#include "global.h"
#include "events.h"
#include <map>
#include <string>
Include dependency graph for events.cpp:

Go to the source code of this file.

Functions

static int do_execute_event (object *op, int eventcode, object *activator, object *third, const char *message, int fix, talk_info *talk)
 
static void ensure_bitmask (object *op)
 
void events_execute_global_event (int eventcode,...)
 
int events_execute_object_event (object *op, int eventcode, object *activator, object *third, const char *message, int fix)
 
int events_execute_object_say (object *npc, talk_info *talk)
 
int events_execute_object_user (object *op, object *activator, object *third, const char *message, int fix)
 
event_registration events_register_global_handler (int eventcode, f_plug_event hook)
 
void events_register_object_handler (const char *id, f_plug_event handler)
 
void events_unregister_global_handler (int eventcode, event_registration id)
 
void events_unregister_object_handler (const char *id)
 

Variables

static std::map< event_registration, f_plug_eventglobal_handlers [NR_EVENTS]
 
static event_registration next_event_registration = 1
 
static std::map< std::string, f_plug_eventobject_handlers
 

Function Documentation

◆ do_execute_event()

static int do_execute_event ( object op,
int  eventcode,
object activator,
object third,
const char *  message,
int  fix,
talk_info talk 
)
static

◆ ensure_bitmask()

static void ensure_bitmask ( object op)
static

Definition at line 195 of file events.cpp.

References BITMASK_EVENT, BITMASK_VALID, EVENT_CONNECTOR, commongive::inv, and give::op.

Referenced by do_execute_event().

Here is the caller graph for this function:

◆ events_execute_global_event()

◆ events_execute_object_event()

int events_execute_object_event ( object op,
int  eventcode,
object activator,
object third,
const char *  message,
int  fix 
)

Execute an event on the specified object.

Parameters
opobject to execute the event on.
eventcodeevent code to execute.
activatorobject which caused the event to be triggered.
thirdadditional object.
messagewhat the object said to trigger.
fixwhether to fix op or not.
Returns
value to return to the caller.

Definition at line 292 of file events.cpp.

References diamondslots::activator, do_execute_event(), message, and give::op.

Referenced by apply_container(), attack_ob_simple(), cftimer_process_event(), common_pre_ob_move_on(), do_throw(), drop_object(), events_execute_object_user(), hit_player(), hit_with_arrow(), kill_object(), kill_player(), move_teleporter(), ob_apply(), object_free(), pick_lock(), pick_up_object(), player_changer_type_process(), pray_at_altar(), process_object(), sell_item(), shop_pay_unpaid_callback(), stop_projectile(), trigger_connected(), write_note(), and write_scroll().

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

◆ events_execute_object_say()

int events_execute_object_say ( object npc,
talk_info talk 
)

Execute an EVENT_SAY on the specified object.

Parameters
npcobject to execute the event on.
talkdialog information, which may be altered to add replies or questions.
Returns
value to return to the caller.

Definition at line 296 of file events.cpp.

References do_execute_event(), EVENT_SAY, npc_dialog::npc, SCRIPT_FIX_ALL, talk_info::text, and talk_info::who.

Referenced by monster_talk_to_npc().

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

◆ events_execute_object_user()

int events_execute_object_user ( object op,
object activator,
object third,
const char *  message,
int  fix 
)

Execute an EVENT_USER on the specified object.

Parameters
opobject to execute the event on.
activatorobject which caused the event to be triggered.
thirdadditional object.
messagewhat the object said to trigger.
fixwhether to fix op or not.
Returns
value to return to the caller.

Definition at line 300 of file events.cpp.

References diamondslots::activator, EVENT_USER, events_execute_object_event(), message, and give::op.

Referenced by cfapi_object_user_event().

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

◆ events_register_global_handler()

event_registration events_register_global_handler ( int  eventcode,
f_plug_event  hook 
)

Register a global event handler.

Parameters
eventcodeevent code to register the handler for.
hookfunction to call for the event.
Returns
registration identifier, used with events_unregister_global_handler().

Definition at line 16 of file events.cpp.

References eg, global_handlers, and next_event_registration.

Referenced by cfapi_system_register_global_event(), cfcitybell_init(), citylife_init(), and random_house_generator_init().

Here is the caller graph for this function:

◆ events_register_object_handler()

void events_register_object_handler ( const char *  id,
f_plug_event  handler 
)

Register an object event handler.

Parameters
idhandler identifier, must be unique and match the "title" field of the event connector.
handlerfunction to call for the event.

Definition at line 282 of file events.cpp.

References diamondslots::id, llevDebug, LOG(), and object_handlers.

Referenced by citylife_init(), and plugins_init_plugin().

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

◆ events_unregister_global_handler()

void events_unregister_global_handler ( int  eventcode,
event_registration  id 
)

Remove a global event handler.

Parameters
eventcodeevent code to unregister the handler of.
idregistration identifier as returned by events_register_global_handler().

Definition at line 23 of file events.cpp.

References global_handlers.

Referenced by cfapi_system_unregister_global_event(), cfcitybell_close(), citylife_close(), plugins_remove_plugin(), and random_house_generator_close().

Here is the caller graph for this function:

◆ events_unregister_object_handler()

void events_unregister_object_handler ( const char *  id)

Remove an object event handler.

Parameters
idhandler identifier.

Definition at line 287 of file events.cpp.

References llevDebug, LOG(), and object_handlers.

Referenced by citylife_close(), and plugins_remove_plugin().

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

Variable Documentation

◆ global_handlers

To turn on verbose messages about events in the debug log, set the CF_DEBUG_EVENTS environment variable.

Definition at line 12 of file events.cpp.

Referenced by events_execute_global_event(), events_register_global_handler(), and events_unregister_global_handler().

◆ next_event_registration

event_registration next_event_registration = 1
static

Definition at line 13 of file events.cpp.

Referenced by events_register_global_handler().

◆ object_handlers

std::map<std::string, f_plug_event> object_handlers
static