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)
static void do_world(char *buffer, int size, time_t start, time_t end)
f_plug_api unregisterGlobalEvent
void cf_log(LogLevel logLevel, const char *format,...)
static void read_parameters(void)
struct paper_properties paper_properties
static void do_sql(const char *sql, sqlite3 *base)
const char * cf_get_directory(int id)
static paper_properties * get_newspaper(const char *name)
int cfnewspaper_globalEventListener(int *type,...)
int eventListener(int *type,...)
object * cf_create_object_by_name(const char *name)
int cfnewspaper_runPluginCommand(object *op, char *params)
void cf_object_set_string_property(object *op, int propcode, const char *value)
static void do_kills(char *buffer, int size, time_t start, time_t end, const char *reg, kill_format *format)
static void format_time(timeofday_t *tod, char *buffer, int size)
#define CFAPI_MAP_PROP_REGION
static sqlite3 * logger_database
CF_PLUGIN char SvnRevPlugin[]
static void do_region_kills(region *reg, char *buffer, int size, time_t start, time_t end)
void(* f_plug_api)(int *type,...)
int cf_init_plugin(f_plug_api getHooks)
void * getPluginProperty(int *type,...)
int initPlugin(const char *iversion, f_plug_api gethooksptr)
static void do_region(region *reg, char *buffer, int size, time_t start, time_t end)
static sqlite3 * newspaper_database
#define CFAPI_OBJECT_PROP_NAME_PLURAL
static void get_newspaper_content(object *paper, paper_properties *properties, region *reg)
f_plug_api registerGlobalEvent
#define CFAPI_OBJECT_PROP_NAME
static void do_world_kills(char *buffer, int size, time_t start, time_t end)
static paper_properties default_properties
static void news_cat(char *buffer, int size, const char *format,...)
bool contents
DIALOGCHECK MINARGS 1 MAXARGS 1
event
DIALOGCHECK MINARGS 1 MAXARGS 2
static int get_region_id(region *reg)
object * cf_object_insert_object(object *op, object *container)
#define CFAPI_OBJECT_PROP_MESSAGE
struct kill_format kill_format
const char * properties[PROPERTY_COUNT]
void cf_get_time(timeofday_t *tod)