Go to the documentation of this file.
53 static void do_sql(
const char *sql, sqlite3 *base) {
60 err = sqlite3_exec(base, sql, NULL, NULL, &
msg);
61 if (err != SQLITE_OK) {
70 int nrow, ncolumn,
id;
75 sql = sqlite3_mprintf(
"select reg_id from region where reg_name='%q'", reg->
name);
79 id = atoi(
line[ncolumn]);
82 sql = sqlite3_mprintf(
"insert into region(reg_name) values( '%q' )", reg->
name);
87 sqlite3_free_table(
line);
106 const char *propname;
111 propname = va_arg(
args,
const char *);
113 if (!strcmp(propname,
"Identification")) {
115 size = va_arg(
args,
int);
121 if (!strcmp(propname,
"FullName")) {
123 size = va_arg(
args,
int);
143 event_code = va_arg(
args,
int);
145 switch (event_code) {
159 snprintf(
path, 500,
"%s/cflogger.db", dir);
168 snprintf(
path, 500,
"%s/cfnewspaper.db", dir);
208 static void news_cat(
char *buffer,
int size,
const char *format, ...) {
211 size -= strlen(buffer)-1;
212 buffer += strlen(buffer);
214 va_start(
args, format);
215 vsprintf(buffer, format,
args);
219 static void do_kills(
char *buffer,
int size, time_t start, time_t end,
const char *reg,
kill_format *format) {
226 const char *raw_players =
"select sum(1) as deaths from kill_event inner join living on liv_id = ke_victim_id where liv_is_player = %d and ke_time >= %d and ke_time < %d %s";
227 const char *raw_monsters =
"select sum(1) as deaths from kill_event inner join living on liv_id = ke_victim_id where liv_is_player = %d and ke_time >= %d and ke_time < %d";
229 sql = sqlite3_mprintf(raw_players, 1, start, end, reg);
232 if (err != SQLITE_OK) {
236 if (nrow > 0 &&
results[ncolumn] != NULL)
237 deaths = atoi(
results[ncolumn]);
242 else if (deaths == 1)
248 sql = sqlite3_mprintf(raw_monsters, 0, start, end);
251 if (err != SQLITE_OK) {
255 if (nrow > 0 &&
results[ncolumn] != NULL)
256 deaths = atoi(
results[ncolumn]);
261 else if (deaths == 1)
276 f.
no_monster_death =
"No monster was killed, players were lazy around here.";
281 snprintf(
where, 50,
"and map_reg_id = %d", region_id);
286 static void do_region(
region *reg,
char *buffer,
int size, time_t start, time_t end) {
287 news_cat(buffer, size,
"--- local %s news ---\n", reg->
name);
296 f.
one_player_death =
"Only one player died in the whole world, May Fido(tm) Have Mercy.";
297 f.
many_player_death =
"Monsters all around the world were busy, %d players died.";
298 f.
no_monster_death =
"No monster was killed at all, players must be tired!";
299 f.
one_monster_death =
"One poor monster was killed in the whole world, too bad for it.";
301 do_kills(buffer, size, start, end,
"", &f);
304 static void do_world(
char *buffer,
int size, time_t start, time_t end) {
305 news_cat(buffer, size,
"--- worldnews section ---\n");
327 sql = sqlite3_mprintf(
"select * from time where time_ingame < '%q' order by time_ingame desc",
date);
330 if (err != SQLITE_OK) {
334 if (nrow > 1 &&
results[ncolumn+1] != NULL) {
335 end = atol(
results[ncolumn+1]);
336 if (nrow > 1 &&
results[ncolumn+2] != NULL)
337 start = atol(
results[ncolumn+2]);
369 va_arg(
args,
object *);
370 va_arg(
args,
char *);
373 event = va_arg(
args,
object *);
374 event_code =
event->subtype;
region * cf_map_get_region_property(mapstruct *map, int propcode)
void cf_log(LogLevel logLevel, const char *format,...)
CF_PLUGIN int initPlugin(const char *iversion, f_plug_api gethooksptr)
const char * cf_get_directory(int id)
static sqlite3 * logger_database
object * cf_create_object_by_name(const char *name)
static void do_world(char *buffer, int size, time_t start, time_t end)
void cf_object_set_string_property(object *op, int propcode, const char *value)
static void do_region_kills(region *reg, char *buffer, int size, time_t start, time_t end)
static void format_time(timeofday_t *tod, char *buffer, int size)
CF_PLUGIN char SvnRevPlugin[]
CF_PLUGIN int cfnewspaper_globalEventListener(int *type,...)
static paper_properties default_properties
#define CFAPI_MAP_PROP_REGION
static int get_region_id(region *reg)
f_plug_api registerGlobalEvent
void(* f_plug_api)(int *type,...)
int cf_init_plugin(f_plug_api getHooks)
CF_PLUGIN int postInitPlugin(void)
struct kill_format kill_format
static sqlite3 * newspaper_database
static void do_world_kills(char *buffer, int size, time_t start, time_t end)
CF_PLUGIN int eventListener(int *type,...)
#define CFAPI_OBJECT_PROP_NAME_PLURAL
f_plug_api unregisterGlobalEvent
static void do_region(region *reg, char *buffer, int size, time_t start, time_t end)
static void news_cat(char *buffer, int size, const char *format,...)
CF_PLUGIN int closePlugin(void)
static void do_sql(const char *sql, sqlite3 *base)
#define CFAPI_OBJECT_PROP_NAME
CF_PLUGIN void * getPluginProperty(int *type,...)
CF_PLUGIN int cfnewspaper_runPluginCommand(object *op, char *params)
bool contents
DIALOGCHECK MINARGS 1 MAXARGS 1
event
DIALOGCHECK MINARGS 1 MAXARGS 2
static void get_newspaper_content(object *paper, paper_properties *properties, region *reg)
object * cf_object_insert_object(object *op, object *container)
static paper_properties * get_newspaper(const char *name)
static void do_kills(char *buffer, int size, time_t start, time_t end, const char *reg, kill_format *format)
#define CFAPI_OBJECT_PROP_MESSAGE
struct paper_properties paper_properties
static void read_parameters(void)
const char * properties[PROPERTY_COUNT]
void cf_get_time(timeofday_t *tod)