Atrinik Server  4.0
Macros | Functions | Variables
plugins.c File Reference
#include <global.h>
#include <loader.h>
#include <toolkit/packet.h>
#include <toolkit/string.h>
#include <plugin.h>
#include <faction.h>
#include <arch.h>
#include <artifact.h>
#include <plugin_hooklist.h>
#include <plugin_hooks.h>

Go to the source code of this file.

Functions

static void register_global_event (const char *plugin_name, int event_nr)
 
static void unregister_global_event (const char *plugin_name, int event_nr)
 
static atrinik_pluginfind_plugin (const char *id)
 
objectget_event_object (object *op, int event_nr)
 
void display_plugins_list (object *op)
 
void init_plugins (void)
 
void init_plugin (const char *pluginfile)
 
void remove_plugin (const char *id)
 
void remove_plugins (void)
 
void map_event_obj_init (object *ob)
 
void map_event_free (map_event *tmp)
 
int trigger_map_event (int event_id, mapstruct *m, object *activator, object *other, object *other2, const char *text, int parm)
 
void trigger_global_event (int event_type, void *parm1, void *parm2)
 
void trigger_unit_event (object *const activator, object *const me)
 
int trigger_event (int event_type, object *const activator, object *const me, object *const other, const char *msg, int parm1, int parm2, int parm3, int flags)
 

Variables

static atrinik_pluginplugins_list = NULL
 

Detailed Description

Handles the plugins code.

Definition in file plugins.c.

Function Documentation

void display_plugins_list ( object op)

Display a list of loaded and loadable plugins in player's window.

Parameters
opThe player to print the plugins to.

Definition at line 139 of file plugins.c.

static atrinik_plugin* find_plugin ( const char *  id)
static

Find a plugin by its identification string.

Parameters
idPlugin's identification string.
Returns
Pointer to the found plugin, NULL if not found.

Definition at line 56 of file plugins.c.

object* get_event_object ( object op,
int  event_nr 
)

Browse through the inventory of an object to find first event that matches the event type of event_nr.

Parameters
opThe object to search in.
event_nrThe event number.
Returns
Script object matching the event type.

Definition at line 121 of file plugins.c.

void init_plugin ( const char *  pluginfile)

Initializes a plugin known by its filename.

Parameters
pluginfileThe plugin filename.

Definition at line 231 of file plugins.c.

void init_plugins ( void  )

Initializes plugins. Browses the plugins directory and calls init_plugin() for each plugin file found with the extension being PLUGIN_SUFFIX.

Definition at line 178 of file plugins.c.

void map_event_free ( map_event tmp)

Free a map_event.

Parameters
tmpWhat to free.

Definition at line 392 of file plugins.c.

void map_event_obj_init ( object ob)

Initialize map event object.

Parameters
obWhat to initialize.

Definition at line 370 of file plugins.c.

static void register_global_event ( const char *  plugin_name,
int  event_nr 
)
static

Register a global event.

Parameters
plugin_namePlugin's name.
event_nrEvent ID to register.

Definition at line 80 of file plugins.c.

void remove_plugin ( const char *  id)

Removes one plugin from memory. The plugin is identified by its keyname.

Parameters
idThe plugin keyname.

Definition at line 318 of file plugins.c.

void remove_plugins ( void  )

Deinitialize all plugins.

Definition at line 345 of file plugins.c.

int trigger_event ( int  event_type,
object *const  activator,
object *const  me,
object *const  other,
const char *  msg,
int  parm1,
int  parm2,
int  parm3,
int  flags 
)

Handles triggering normal events like EVENT_ATTACK, EVENT_STOP, etc.

Parameters
event_typeThe event type.
activatorActivator object.
meObject the event object is in.
otherOther object.
msgMessage.
parm1First parameter.
parm2Second parameter.
parm3Third parameter.
flagsEvent flags.
Returns
1 if the event returns an event value, 0 otherwise.

Definition at line 510 of file plugins.c.

void trigger_global_event ( int  event_type,
void *  parm1,
void *  parm2 
)

Handles triggering global events like EVENT_BORN, EVENT_MAPRESET, etc.

Parameters
event_typeThe event type.
parm1First data parameter.
parm2Second data parameter.

Definition at line 455 of file plugins.c.

int trigger_map_event ( int  event_id,
mapstruct m,
object activator,
object other,
object other2,
const char *  text,
int  parm 
)

Triggers a map-wide event.

Parameters
event_idEvent ID to trigger.
mMap we're working on.
activatorActivator.
otherSome other object related to this event.
other2Another object related to this event.
textString related to this event.
parmInteger related to this event.
Returns
1 if the event returns an event value, 0 otherwise.

Definition at line 416 of file plugins.c.

void trigger_unit_event ( object *const  activator,
object *const  me 
)

Triggers the unit tests event for all plugins.

Parameters
activatorPlayer object.
meAnother player object.

Definition at line 477 of file plugins.c.

static void unregister_global_event ( const char *  plugin_name,
int  event_nr 
)
static

Unregister a global event.

Parameters
plugin_namePlugin's name.
event_nrEvent ID to unregister.

Definition at line 99 of file plugins.c.

Variable Documentation

atrinik_plugin* plugins_list = NULL
static

The list of loaded plugins.

Definition at line 47 of file plugins.c.