/* * SWServ Plugins Context * * Defines the plugins context that is used to pass between plugins * and the server. * * Both the server and the plugins need to #include this. * * Members of this context may change from version to version so * a recompile of all plugins may be needed upon each server * upgrade. */ #ifndef SWSERV_PLUGINS_CONTEXT_H #define SWSERV_PLUGINS_CONTEXT_H #include "reality.h" #include "objects.h" /* * Plugin ID: * * This is basically the plugin's index number when it is loaded * to SWServ's list of plugins. */ #define plugin_id_t int typedef struct _SWServContext SWServContext; /* 1.34.x compatability for plugin_data_ref_struct */ #define plugin_data_ref_struct SWServContext; /* * Plugin Function Names & Prototypes: * * Definitions ending with FUNC are the names of the functions * themselves. * * Definitions ending with FUNCNAME are the names of the functions * as strings. * * Definitions ending with FUNCPROTO are the prototypes for inputs * of that function but without the variable declarations. * * Definitions ending with FUNCINPUT are the prototypes for inputs * of that function (with variable declarations). * * Definitions ending with FUNCRTN are the return types for the * functions. */ /* Initialize Callback Function Name & Prototypes */ #define SWPLUGIN_INIT_FUNC swplugin_init #define SWPLUGIN_INIT_FUNCNAME "swplugin_init" #define SWPLUGIN_INIT_FUNCINPUT int argc, \ char **argv, \ int condescriptor, \ SWServContext *in #define SWPLUGIN_INIT_FUNCPROTO int, \ char **, \ int, \ SWServContext * #define SWPLUGIN_INIT_FUNCRTN int /* Manage Callback Function Name & Prototypes */ #define SWPLUGIN_MANAGE_FUNC swplugin_manage #define SWPLUGIN_MANAGE_FUNCNAME "swplugin_manage" #define SWPLUGIN_MANAGE_FUNCINPUT SWServContext *in #define SWPLUGIN_MANAGE_FUNCPROTO SWServContext * #define SWPLUGIN_MANAGE_FUNCRTN int /* Shutdown Callback Function Name & Prototypes */ #define SWPLUGIN_SHUTDOWN_FUNC swplugin_shutdown #define SWPLUGIN_SHUTDOWN_FUNCNAME "swplugin_shutdown" #define SWPLUGIN_SHUTDOWN_FUNCINPUT SWServContext *in #define SWPLUGIN_SHUTDOWN_FUNCPROTO SWServContext * #define SWPLUGIN_SHUTDOWN_FUNCRTN void /* Help Commands List Callback Function Name & Prototypes */ #define SWPLUGIN_HELP_COMMANDS_LIST_FUNC swplugin_help_commands_list #define SWPLUGIN_HELP_COMMANDS_LIST_FUNCNAME "swplugin_help_commands_list" #define SWPLUGIN_HELP_COMMANDS_LIST_FUNCINPUT int *ncommands, \ SWServContext *in #define SWPLUGIN_HELP_COMMANDS_LIST_FUNCPROTO int *, \ SWServContext * #define SWPLUGIN_HELP_COMMANDS_LIST_FUNCRTN char ** /* Command Callback Function Name & Prototypes */ #define SWPLUGIN_COMMAND_FUNC swplugin_command #define SWPLUGIN_COMMAND_FUNCNAME "swplugin_command" #define SWPLUGIN_COMMAND_FUNCINPUT const char *cmd, \ const char *arg, \ int con_num, \ int obj_num, \ int uid, \ int gid, \ SWServContext *in #define SWPLUGIN_COMMAND_FUNCPROTO const char *, \ const char *, \ int, \ int, \ int, \ int, \ SWServContext * #define SWPLUGIN_COMMAND_FUNCRTN int /* Hail Notify Callback Function Name & Prototypes */ #define SWPLUGIN_HAIL_NOTIFY_FUNC swplugin_hail_notify #define SWPLUGIN_HAIL_NOTIFY_FUNCNAME "swplugin_hail_notify" #define SWPLUGIN_HAIL_NOTIFY_FUNCINPUT int con_num, \ int obj_num, \ int tar_obj_num, \ int channel, \ const char *message, \ SWServContext *in #define SWPLUGIN_HAIL_NOTIFY_FUNCPROTO int, \ int, \ int, \ int, \ const char *, \ SWServContext * #define SWPLUGIN_HAIL_NOTIFY_FUNCRTN void /* Hit Notify Callback Function Name & Prototypes */ #define SWPLUGIN_HIT_NOTIFY_FUNC swplugin_hit_notify #define SWPLUGIN_HIT_NOTIFY_FUNCNAME "swplugin_hit_notify" #define SWPLUGIN_HIT_NOTIFY_FUNCINPUT int wobj_num, \ int tobj_num, \ float dmg_total, \ float bearing, \ float dmg_hull, \ float dmg_shield, \ SWServContext *in #define SWPLUGIN_HIT_NOTIFY_FUNCPROTO int, \ int, \ float, \ float, \ float, \ float, \ SWServContext * #define SWPLUGIN_HIT_NOTIFY_FUNCRTN void /* Destroy Notify Callback Function Name & Prototypes */ #define SWPLUGIN_DESTROY_NOTIFY_FUNC swplugin_destroy_notify #define SWPLUGIN_DESTROY_NOTIFY_FUNCNAME "swplugin_destroy_notify" #define SWPLUGIN_DESTROY_NOTIFY_FUNCINPUT int reason, \ int destroyed_obj_num, \ int destroyer_obj_num, \ int destroyer_obj_owner_num, \ SWServContext *in #define SWPLUGIN_DESTROY_NOTIFY_FUNCPROTO int, \ int, \ int, \ int, \ SWServContext * #define SWPLUGIN_DESTROY_NOTIFY_FUNCRTN void /* * Plugin Context: * * Contains pointers to values on SWServ. * * Plugins will recieve this structure passed in the functions: * * SWPLUGIN_INIT_FUNCNAME() * SWPLUGIN_MANGE_FUNCNAME() * SWPLUGIN_SHUTDOWN_FUNCNAME() */ struct _SWServContext { void *data; /* User data */ time_t *cur_millitime, *cur_systime, *lapsed_millitime; float *time_compensation; xsw_object_struct ***xsw_object; int *total_objects; sw_legend_struct *legend; xsw_object_struct ***opm; int *total_opms; void ***ocs; int *total_ocss; void ***connection; /* connection_struct *** */ int *total_connections; /* SWServ Function Pointers */ /* Set user data */ void (*set_data)( SWServContext *, /* Context */ void * /* Data */ ); /* Get user data */ void *(*get_data)( SWServContext * /* Context */ ); /* Checks if a connection is connected */ int (*con_is_connected)( int /* Connection */ ); /* Checks if a connection is logged in */ int (*con_is_logged_in)( int /* Connection */ ); /* Gets the connection's object */ int (*con_get_obj_num)( int /* Connection */ ); /* Prints the message to the connection */ void (*con_print)( int, /* Connection (can be -1 for all) */ const char * /* Message */ ); /* PRints the message to the connection as a dialog */ void (*con_print_dialog)( int, /* Connection (can be -1 for all) */ int, /* Code, one of CS_SYSMESG_CODE_* */ const char * /* Message */ ); /* Gets the sysparm value as an int */ int (*sysparm_get_i)( const char * /* Parm */ ); /* Gets the sysparm value as a float */ float (*sysparm_get_f)( const char * /* Parm */ ); /* Gets the sysparm value as a string */ const char *(*sysparm_get_s)( const char * /* Parm */ ); /* Checks if the object is garbage */ char (*obj_is_garbage)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int /* Object Number */ ); /* Returns the pointer to the object */ xsw_object_struct *(*obj_get_pointer)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int /* Object Number */ ); /* Creates a new object in the specified list of objects * and returns the new object's number or -1 on error */ int (*obj_create)( xsw_object_struct ***, /* Objects List Pointer */ int *, /* Total Objects Pointer */ int /* One of XSW_OBJ_TYPE_* */ ); /* Recycles the object in the specified list of objects */ void (*obj_recycle)( xsw_object_struct ***, /* Objects List Pointer */ int *, /* Total Objects Pointer */ int /* Object Number */ ); /* Gets the player object that owns the specified object (not * just the immediate owner). */ int (*obj_get_player_owner)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int /* Object Number */ ); /* Checks if the object is a player that is currently * connected */ int (*obj_is_connected)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int /* Object Number */ ); /* Checks if the object is marked hidden by the server */ int (*obj_is_hidden)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int /* Object Number */ ); /* Gets the weapon object's flags */ unsigned int (*wep_get_flags)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int ); /* Sets the weapon object's flags */ void (*wep_set_flags)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object Number */ unsigned int /* Flags */ ); /* Unsets the weapon object's flag */ void (*wep_unset_flags)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object Number */ unsigned int /* Flags */ ); /* Checks if the two objects are valid and in the same sector */ int (*obj_in_same_sector)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object 1 Number */ int /* Object 2 Number */ ); /* Checks if the two objects are valid, in the same sector, * and in contact with each other */ int (*obj_in_contact)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object 1 Number */ int /* Object 2 Number */ ); /* Checks if the two objects are valid, in the same sector, * and within the specified distance (in real units) */ int (*obj_in_range)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object 1 Number */ int, /* Object 2 Number */ float /* Distance in real units */ ); /* Checks if the two objects are valid, in the same sector, * within the specified distance (in screen units), and if the * first object is at the specified bearing to the second * object and within the specified variance (in radians) */ int (*obj_in_vector_range)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object 1 Number */ int, /* Object 2 Number */ float, /* Distance in screen units */ float, /* Bearing in radians */ float /* Variance in radians */ ); /* Instructs the object to fire its selected weapon */ void (*obj_fire_weapon)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object Number */ float freq, /* Weapon requency */ float yield /* Weapon Yield [0.0 to 1.0] */ ); /* Instructs the object to send a message on the specified * com channel. If msg is NULL then a hail is sent */ void (*obj_send_message)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object Number */ int, /* Target Object Number (or -1 for all) */ int, /* Com channel */ const char * /* Msg */ ); /* Sends out values to all connections interested about the * specified object */ void (*obj_sync_connections)( xsw_object_struct **, /* Objects List */ int, /* Total Objects */ int, /* Object Number */ char /* Treat as a ew object if true */ ); /* Returns the pointer to the OPM */ xsw_object_struct *(*opm_get_pointer)( xsw_object_struct **, /* OPMs List */ int, /* Total OPMs */ int /* OPM Number */ ); /* Gets the OPM that matches the specified name */ int (*opm_get_by_name)( xsw_object_struct **, /* OPMs List */ int, /* Total OPMs */ const char * /* Name */ ); /* Models the object with the specified OPM */ int (*opm_model_object)( xsw_object_struct **, /* OPMs List */ int, /* Total OPMs */ int, /* OPM */ int /* Object */ ); /* Returns the version number */ void (*get_version)( int *, /* Major */ int *, /* Minor */ int * /* Release */ ); /* Prints the specified message to stdout */ void (*print)( const char *s ); /* Prints the specified message to stderr */ void (*print_err)( const char *s ); }; #define SWSERV_CONTEXT(p) ((SWServContext *)(p)) #endif /* SWSERV_PLUGINS_CONTEXT_H */