From ec0e6921392ad1ec8a3086413d01591d049217f1 Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 15 Apr 2019 12:28:49 -0400 Subject: add a built-in gm log delay option --- src/map/atcommand.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index a21848b..f19b6c9 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -208,19 +208,24 @@ bool asplit(ZString raw, F *first_arg, R *... rest_args) static io::AppendFile *get_gm_log(); -void log_atcommand(dumb_ptr sd, ZString cmd) +static +void real_log_atcommand(TimerData *, tick_t, AString cmd) { io::AppendFile *fp = get_gm_log(); if (!fp) return; + FPRINTF(*fp, "%s\n"_fmt, cmd); +} + +void log_atcommand(dumb_ptr sd, ZString cmd) +{ timestamp_seconds_buffer tmpstr; stamp_time(tmpstr); MapName map = (sd->bl_m->name_); - FPRINTF(*fp, "[%s] %s(%d,%d) %s(%d) : %s\n"_fmt, - tmpstr, - map, sd->bl_x, sd->bl_y, - sd->status_key.name, sd->status_key.account_id, - cmd); + AString str = STRPRINTF("[%s] %s(%d,%d) %s(%d) : %s"_fmt, tmpstr, + map, sd->bl_x, sd->bl_y, sd->status_key.name, + sd->status_key.account_id, cmd); + Timer(gettick() + battle_config.gm_log_delay, std::bind(real_log_atcommand, ph::_1, ph::_2, str)).detach(); } io::AppendFile *get_gm_log() -- cgit v1.2.3-60-g2f50