From 79874123b9e62276c67bc2f8e300d6b88d43e151 Mon Sep 17 00:00:00 2001 From: MadCamel Date: Wed, 26 Aug 2009 18:32:32 -0400 Subject: Autobans are now logged, more chat spam improvements Added a timeout to the total repeat counter. 5 minutes by default. --- src/map/atcommand.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 39e62da..de44d77 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -544,13 +544,27 @@ int get_atcommand_level(const AtCommandType type) { /*======================================== * At-command logging */ +void log_atcommand(struct map_session_data *sd, const char *fmt, ...) { + char message[512]; + va_list ap; -int last_logfile_nr = 0; -char *gm_logfile_name = NULL; -static FILE *gm_logfile = NULL; + va_start(ap, fmt); + vsnprintf(message, 511, fmt, ap); + va_end(ap); -void log_atcommand(struct map_session_data *sd, const char *fmt, ...) -{ + if (pc_isGM(sd)) + gm_log("%s(%d,%d) %s : %s", map[sd->bl.m].name, sd->bl.x, + sd->bl.y, sd->status.name, message); +} + +char *gm_logfile_name = NULL; +/*========================================== + * Log a timestamped line to GM log file + *------------------------------------------ + */ +void gm_log(const char *fmt, ...) { + static int last_logfile_nr = 0; + static FILE *gm_logfile = NULL; time_t time_v; struct tm ctime; int month, year, logfile_nr; @@ -588,16 +602,14 @@ void log_atcommand(struct map_session_data *sd, const char *fmt, ...) last_logfile_nr = logfile_nr; } - if (gm_logfile && pc_isGM(sd)) { - fprintf(gm_logfile, "[%04d-%02d-%02d %02d:%02d:%02d] %s(%d,%d) %s : %s\n", - year, month, ctime.tm_mday, - ctime.tm_hour, ctime.tm_min, ctime.tm_sec, - map[sd->bl.m].name, sd->bl.x, sd->bl.y, sd->status.name, - message); - fflush(gm_logfile); - } + fprintf(gm_logfile, "[%04d-%02d-%02d %02d:%02d:%02d] %s\n", + year, month, ctime.tm_mday, ctime.tm_hour, + ctime.tm_min, ctime.tm_sec, message); + + fflush(gm_logfile); } + /*========================================== *is_atcommand @コマンドに存在するかどうか確認する *------------------------------------------ -- cgit v1.2.3-60-g2f50