Crossfire Server, Branches 1.12  R18729
cfnewspaper.c File Reference
#include <cfnewspaper.h>
#include <stdarg.h>
#include <cfnewspaper_proto.h>
#include <sqlite3.h>
+ Include dependency graph for cfnewspaper.c:

Go to the source code of this file.

Data Structures

struct  kill_format
 
struct  paper_properties
 

Typedefs

typedef struct kill_format kill_format
 
typedef struct paper_properties paper_properties
 

Functions

CF_PLUGIN void * cfnewspaper_globalEventListener (int *type,...)
 
CF_PLUGIN int cfnewspaper_runPluginCommand (object *op, char *params)
 
CF_PLUGIN int closePlugin (void)
 
static void do_kills (char *buffer, int size, time_t start, time_t end, const char *reg, kill_format *format)
 
static void do_region (region *reg, char *buffer, int size, time_t start, time_t end)
 
static void do_region_kills (region *reg, char *buffer, int size, time_t start, time_t end)
 
static void do_sql (const char *sql, sqlite3 *base)
 
static void do_world (char *buffer, int size, time_t start, time_t end)
 
static void do_world_kills (char *buffer, int size, time_t start, time_t end)
 
CF_PLUGIN void * eventListener (int *type,...)
 
static void format_time (timeofday_t *tod, char *buffer, int size)
 
static int get_living_id (object *living)
 
static paper_propertiesget_newspaper (const char *name)
 
static void get_newspaper_content (object *paper, paper_properties *properties, region *reg)
 
static int get_region_id (region *reg)
 
static int get_time_id (timeofday_t *tod, int create)
 
CF_PLUGIN void * getPluginProperty (int *type,...)
 
CF_PLUGIN int initPlugin (const char *iversion, f_plug_api gethooksptr)
 
static void news_cat (char *buffer, int size, const char *format,...)
 
CF_PLUGIN int postInitPlugin (void)
 
static void read_parameters (void)
 

Variables

static paper_properties default_properties
 
f_plug_api gethook
 
static sqlite3 * logger_database
 
static sqlite3 * newspaper_database
 
f_plug_api reCmp
 
f_plug_api registerGlobalEvent
 
f_plug_api unregisterGlobalEvent
 

Typedef Documentation

typedef struct kill_format kill_format

Function Documentation

CF_PLUGIN void* cfnewspaper_globalEventListener ( int *  type,
  ... 
)

Definition at line 181 of file cfnewspaper.c.

CF_PLUGIN int cfnewspaper_runPluginCommand ( object op,
char *  params 
)

Definition at line 177 of file cfnewspaper.c.

CF_PLUGIN int closePlugin ( void  )

Close the plugin.

Closes the sqlite database.

Returns
0.

Definition at line 440 of file cfnewspaper.c.

References cf_log(), llevInfo, logger_database, newspaper_database, and PLUGIN_VERSION.

+ Here is the call graph for this function:

static void do_kills ( char *  buffer,
int  size,
time_t  start,
time_t  end,
const char *  reg,
kill_format format 
)
static
static void do_region ( region reg,
char *  buffer,
int  size,
time_t  start,
time_t  end 
)
static

Definition at line 327 of file cfnewspaper.c.

References do_region_kills(), regiondef::name, and news_cat().

Referenced by get_newspaper_content().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void do_region_kills ( region reg,
char *  buffer,
int  size,
time_t  start,
time_t  end 
)
static

Definition at line 309 of file cfnewspaper.c.

References do_kills(), get_region_id(), kill_format::many_monster_death, kill_format::many_player_death, kill_format::no_monster_death, kill_format::no_player_death, kill_format::one_monster_death, kill_format::one_player_death, and snprintf().

Referenced by do_region().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void do_sql ( const char *  sql,
sqlite3 *  base 
)
static

Definition at line 50 of file cfnewspaper.c.

References cf_log(), llevError, and PLUGIN_NAME.

Referenced by get_living_id(), get_region_id(), and get_time_id().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void do_world ( char *  buffer,
int  size,
time_t  start,
time_t  end 
)
static

Definition at line 345 of file cfnewspaper.c.

References do_world_kills(), and news_cat().

Referenced by get_newspaper_content().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void do_world_kills ( char *  buffer,
int  size,
time_t  start,
time_t  end 
)
static

Definition at line 333 of file cfnewspaper.c.

References do_kills(), kill_format::many_monster_death, kill_format::many_player_death, kill_format::no_monster_death, kill_format::no_player_death, kill_format::one_monster_death, and kill_format::one_player_death.

Referenced by do_world().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CF_PLUGIN void* eventListener ( int *  type,
  ... 
)

Handles an object-related event. Doesn't do anything.

Parameters
typeignored.
Returns
pointer to an int containing 0.
Todo:
build from current map's path, probably

Definition at line 391 of file cfnewspaper.c.

References cf_create_object_by_name(), cf_map_get_region_property(), cf_object_insert_object(), cf_object_set_string_property(), CFAPI_MAP_PROP_REGION, CFAPI_OBJECT_PROP_NAME, CFAPI_OBJECT_PROP_NAME_PLURAL, EVENT_APPLY, get_newspaper(), get_newspaper_content(), obj::map, paper_properties::name, and obj::slaying.

+ Here is the call graph for this function:

static void format_time ( timeofday_t tod,
char *  buffer,
int  size 
)
static

Definition at line 112 of file cfnewspaper.c.

References _timeofday::day, _timeofday::hour, _timeofday::minute, _timeofday::month, snprintf(), and _timeofday::year.

Referenced by get_newspaper_content(), and get_time_id().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int get_living_id ( object living)
static

Definition at line 64 of file cfnewspaper.c.

References do_sql(), obj::level, logger_database, obj::name, PLAYER, and obj::type.

+ Here is the call graph for this function:

static paper_properties* get_newspaper ( const char *  name)
static

Definition at line 248 of file cfnewspaper.c.

References default_properties.

Referenced by eventListener().

+ Here is the caller graph for this function:

static void get_newspaper_content ( object paper,
paper_properties properties,
region reg 
)
static

Definition at line 351 of file cfnewspaper.c.

References cf_get_time(), cf_log(), cf_object_set_string_property(), CFAPI_OBJECT_PROP_MESSAGE, do_region(), do_world(), format_time(), paper_properties::info_region, paper_properties::info_world, llevError, logger_database, and PLUGIN_NAME.

Referenced by eventListener().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int get_region_id ( region reg)
static

Definition at line 88 of file cfnewspaper.c.

References do_sql(), logger_database, and regiondef::name.

Referenced by do_region_kills().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int get_time_id ( timeofday_t tod,
int  create 
)
static

Definition at line 116 of file cfnewspaper.c.

References do_sql(), format_time(), and logger_database.

+ Here is the call graph for this function:

CF_PLUGIN void* getPluginProperty ( int *  type,
  ... 
)

Gets a plugin property.

Parameters
typeignored.
Returns
  • the name, if asked for 'Identification'.
  • the version, if asked for 'FullName'.
  • NULL else.

Definition at line 148 of file cfnewspaper.c.

References PLUGIN_NAME, PLUGIN_VERSION, and snprintf().

+ Here is the call graph for this function:

CF_PLUGIN int initPlugin ( const char *  iversion,
f_plug_api  gethooksptr 
)

Plugin initialisation function.

Parameters
iversionserver version.
gethooksptrfunction to get the hooks.
Returns
0

Main plugin entry point.

Parameters
iversionserver version.
gethooksptrfunction to get hooks from.
Returns
always 0.

Definition at line 142 of file cfnewspaper.c.

References cf_init_plugin(), cf_log(), llevInfo, and PLUGIN_VERSION.

+ Here is the call graph for this function:

static void news_cat ( char *  buffer,
int  size,
const char *  format,
  ... 
)
static

Definition at line 252 of file cfnewspaper.c.

Referenced by do_kills(), do_region(), and do_world().

+ Here is the caller graph for this function:

CF_PLUGIN int postInitPlugin ( void  )

Plugin was initialized, now to finish.

Registers events, initializes the database.

Returns
0.

Definition at line 196 of file cfnewspaper.c.

References cf_get_directory(), cf_log(), llevError, llevInfo, logger_database, newspaper_database, PLUGIN_NAME, PLUGIN_VERSION, read_parameters(), and snprintf().

+ Here is the call graph for this function:

static void read_parameters ( void  )
static

Definition at line 139 of file cfnewspaper.c.

Referenced by postInitPlugin().

+ Here is the caller graph for this function:

Variable Documentation

paper_properties default_properties
static
Initial value:
= {
"world newspaper",
0,
1
}

Definition at line 233 of file cfnewspaper.c.

Referenced by get_newspaper().

f_plug_api gethook

Definition at line 38 of file cfnewspaper.c.

sqlite3* logger_database
static
sqlite3* newspaper_database
static

Definition at line 48 of file cfnewspaper.c.

Referenced by closePlugin(), and postInitPlugin().

f_plug_api reCmp

Definition at line 44 of file cfnewspaper.c.

f_plug_api registerGlobalEvent

Definition at line 40 of file cfnewspaper.c.

f_plug_api unregisterGlobalEvent

Definition at line 42 of file cfnewspaper.c.