diff options
-rw-r--r-- | src/map/atcommand.c | 73 | ||||
-rw-r--r-- | src/map/atcommand.h | 2 | ||||
-rw-r--r-- | src/map/clif.c | 19 |
3 files changed, 56 insertions, 38 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 7d706e1..f081aa4 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -547,48 +547,53 @@ int last_logfile_nr = 0; char *gm_logfile_name = NULL; static FILE *gm_logfile = NULL; -static void -log_atcommand(struct map_session_data *sd, const char *message) +void log_atcommand(struct map_session_data *sd, const char *fmt, ...) { - if (gm_logfile_name) { - time_t time_v; - struct tm ctime; - int month, year, logfile_nr; - time(&time_v); - gmtime_r(&time_v, &ctime); + time_t time_v; + struct tm ctime; + int month, year, logfile_nr; + char message[512]; + va_list ap; - year = ctime.tm_year + 1900; - month = ctime.tm_mon + 1; - logfile_nr = (year * 12) + month; + if (!gm_logfile_name) + return; - if (logfile_nr != last_logfile_nr) { - char *fullname = malloc(strlen(gm_logfile_name) + 10); - sprintf(fullname, "%s.%04d-%02d", gm_logfile_name, - year, month); + va_start(ap, fmt); + vsnprintf(message, 511, fmt, ap); + va_end(ap); - if (gm_logfile) - close(gm_logfile); + time(&time_v); + gmtime_r(&time_v, &ctime); - gm_logfile = fopen(fullname, "a"); - free(fullname); + year = ctime.tm_year + 1900; + month = ctime.tm_mon + 1; + logfile_nr = (year * 12) + month; - if (!gm_logfile) { - perror("GM log file"); - gm_logfile_name = NULL; - } + if (logfile_nr != last_logfile_nr) { + char *fullname = malloc(strlen(gm_logfile_name) + 10); + sprintf(fullname, "%s.%04d-%02d", gm_logfile_name, year, month); - last_logfile_nr = logfile_nr; - } + if (gm_logfile) + close(gm_logfile); + + gm_logfile = fopen(fullname, "a"); + free(fullname); + + if (!gm_logfile) { + perror("GM log file"); + gm_logfile_name = NULL; + } + last_logfile_nr = logfile_nr; + } - if (gm_logfile && pc_isGM(sd)) { - fprintf(gm_logfile, "[%04d-%02d-%02d %02d:%02d:%02d] %s(%d,%d) %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, - message); + 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); - } - } + } } /*========================================== @@ -642,7 +647,7 @@ is_atcommand(const int fd, struct map_session_data* sd, const char* message, int clif_displaymessage(fd, output); } else { if (get_atcommand_level(type) != 0) // Don't log level 0 commands - log_atcommand(sd, message); + log_atcommand(sd, "%s %s", command, p); } } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 575bad4..3f247bc 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -212,5 +212,7 @@ int atcommand_recall(const int fd, struct map_session_data* sd, const char* comm int atcommand_config_read(const char *cfgName); int msg_config_read(const char *cfgName); +void log_atcommand(struct map_session_data *sd, const char *fmt, ...); + #endif diff --git a/src/map/clif.c b/src/map/clif.c index 2b97e38..e053357 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6583,7 +6583,8 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) { (pc_isGM(sd) >= get_atcommand_level(AtCommand_MapMove))) { memcpy(map_name, RFIFOP(fd,2), 16); sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20)); - atcommand_warp(fd, sd, "@rura", output); + log_atcommand(sd, "@warp %s", output); + atcommand_warp(fd, sd, "@warp", output); } return; @@ -7510,10 +7511,12 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) { if (battle_config.atc_gmonly == 0 || pc_isGM(sd)) { switch(RFIFOW(fd,2)){ case 0: + log_atcommand(sd, "@charstreset %s", sd->status.name); if (pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState)) pc_resetstate(sd); break; case 1: + log_atcommand(sd, "@charskreset %s", sd->status.name); if (pc_isGM(sd) >= get_atcommand_level(AtCommand_ResetState)) pc_resetskill(sd); break; @@ -7728,11 +7731,15 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) { memcpy(monster_item_name, RFIFOP(fd,2), 24); if (mobdb_searchname(monster_item_name) != 0) { - if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Monster)) + if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Monster)) { + log_atcommand(sd, "@spawn %s", monster_item_name); atcommand_spawn(fd, sd, "@spawn", monster_item_name); // as @spawn + } } else if (itemdb_searchname(monster_item_name) != NULL) { - if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Item)) + if (pc_isGM(sd) >= get_atcommand_level(AtCommand_Item)) { + log_atcommand(sd, "@item %s", monster_item_name); atcommand_item(fd, sd, "@item", monster_item_name); // as @item + } } } @@ -7940,6 +7947,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) { if (target) { if (target->type == BL_PC) { struct map_session_data *tsd = (struct map_session_data *)target; + log_atcommand(sd, "@kick %s", tsd->status.name); if (pc_isGM(sd) > pc_isGM(tsd)) clif_GM_kick(sd, tsd, 1); else @@ -7969,7 +7977,8 @@ void clif_parse_Shift(int fd, struct map_session_data *sd) { // Rewriten by [Yor if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level(AtCommand_Goto))) { memcpy(player_name, RFIFOP(fd,2), 24); - atcommand_goto(fd, sd, "@jumpto", player_name); // as @jumpto + log_atcommand(sd, "@goto %s", player_name); + atcommand_goto(fd, sd, "@goto", player_name); // as @jumpto } return; @@ -7989,6 +7998,7 @@ void clif_parse_Recall(int fd, struct map_session_data *sd) { // Added by RoVeRT if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level(AtCommand_Recall))) { memcpy(player_name, RFIFOP(fd,2), 24); + log_atcommand(sd, "@recall %s", player_name); atcommand_recall(fd, sd, "@recall", player_name); // as @recall } @@ -8001,6 +8011,7 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) { // Modified by [Yo //printf("%2x %2x %2x\n", RFIFOW(fd,0), RFIFOW(fd,2), RFIFOW(fd,4)); // R 019d <Option_value>.2B <flag>.2B if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) { + log_atcommand(sd, "@hide"); if (sd->status.option & OPTION_HIDE) { // OPTION_HIDE = 0x40 sd->status.option &= ~OPTION_HIDE; // OPTION_HIDE = 0x40 clif_displaymessage(fd, "Invisible: Off."); |