summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/GNUmakefile6
-rw-r--r--src/map/Makefile4
-rw-r--r--src/map/Makefile.win324
-rw-r--r--src/map/atcommand.c10
-rw-r--r--src/map/log.c336
-rw-r--r--src/map/log.h10
6 files changed, 305 insertions, 65 deletions
diff --git a/src/map/GNUmakefile b/src/map/GNUmakefile
index a1a68d107..c1938a40f 100644
--- a/src/map/GNUmakefile
+++ b/src/map/GNUmakefile
@@ -13,7 +13,7 @@ sqlobj:
COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/grfio.o ../common/db.o ../common/lock.o ../common/nullpo.o ../common/malloc.o ../common/showmsg.o
LIBS = -lz -lm
-map-server: txtobj/map.o txtobj/chrif.o txtobj/clif.o txtobj/pc.o txtobj/npc.o txtobj/chat.o txtobj/path.o txtobj/itemdb.o txtobj/mob.o txtobj/script.o txtobj/storage.o txtobj/skill.o txtobj/atcommand.o txtobj/battle.o txtobj/intif.o txtobj/trade.o txtobj/party.o txtobj/vending.o txtobj/guild.o txtobj/pet.o $(COMMON_OBJ)
+map-server: txtobj/map.o txtobj/chrif.o txtobj/clif.o txtobj/pc.o txtobj/npc.o txtobj/chat.o txtobj/path.o txtobj/itemdb.o txtobj/mob.o txtobj/script.o txtobj/storage.o txtobj/skill.o txtobj/atcommand.o txtobj/battle.o txtobj/intif.o txtobj/trade.o txtobj/party.o txtobj/vending.o txtobj/guild.o txtobj/pet.o txtobj/log.o $(COMMON_OBJ)
$(CC) -o ../../$@ $^ $(LIBS)
map-server_sql: sqlobj/map.o sqlobj/chrif.o sqlobj/clif.o sqlobj/pc.o sqlobj/npc.o sqlobj/chat.o sqlobj/path.o sqlobj/itemdb.o sqlobj/mob.o sqlobj/script.o sqlobj/storage.o sqlobj/skill.o sqlobj/atcommand.o sqlobj/battle.o sqlobj/intif.o sqlobj/trade.o sqlobj/party.o sqlobj/vending.o sqlobj/guild.o sqlobj/pet.o sqlobj/mail.o sqlobj/log.o $(COMMON_OBJ)
@@ -37,7 +37,7 @@ txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemd
txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h
txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h
txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
+txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h
txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h ../common/mmo.h ../common/showmsg.h
@@ -58,7 +58,7 @@ sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemd
sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h
sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h
sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
+sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h
sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h ../common/mmo.h ../common/showmsg.h
diff --git a/src/map/Makefile b/src/map/Makefile
index 3f1bab6c1..bd4700fd2 100644
--- a/src/map/Makefile
+++ b/src/map/Makefile
@@ -37,7 +37,7 @@ txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemd
txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h
txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h
txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
+txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h
txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h ../common/mmo.h ../common/showmsg.h
@@ -58,7 +58,7 @@ sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemd
sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h
sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h
sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
+sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h
sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h ../common/mmo.h ../common/showmsg.h
diff --git a/src/map/Makefile.win32 b/src/map/Makefile.win32
index 8614d8df0..384554008 100644
--- a/src/map/Makefile.win32
+++ b/src/map/Makefile.win32
@@ -57,7 +57,7 @@ txtobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemd
txtobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h
txtobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h
txtobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
+txtobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
txtobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
txtobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h
txtobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h ../common/mmo.h ../common/showmsg.h
@@ -78,7 +78,7 @@ sqlobj/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemd
sqlobj/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h ../common/timer.h ../common/socket.h ../common/db.h ../common/mmo.h ../common/lock.h ../common/showmsg.h
sqlobj/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h ../common/mmo.h ../common/db.h ../common/showmsg.h
sqlobj/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
-sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
+sqlobj/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h ../common/timer.h ../common/mmo.h ../common/showmsg.h
sqlobj/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h ../common/socket.h ../common/mmo.h ../common/showmsg.h
sqlobj/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h ../common/mmo.h ../common/showmsg.h
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 1ca2b9be5..606f63f8b 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5,10 +5,11 @@
#include <ctype.h>
#include <math.h>
-#include "socket.h"
-#include "timer.h"
-#include "nullpo.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/nullpo.h"
+#include "log.h"
#include "clif.h"
#include "chrif.h"
#include "intif.h"
@@ -673,6 +674,9 @@ is_atcommand(const int fd, struct map_session_data* sd, const char* message, int
}
}
+ if((log_config.gm) && (info.level >= log_config.gm))
+ log_atcommand(sd, message);
+
return info.type;
}
diff --git a/src/map/log.c b/src/map/log.c
index 6c0b01905..1f6968eab 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -11,67 +11,154 @@ struct Log_Config log_config;
int log_branch(struct map_session_data *sd)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
- sprintf(tmp_sql, "INSERT INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')", log_config.log_branch_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->mapname);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')", log_config.log_branch_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->mapname);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_drop,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%s%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, sd->mapname, RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
- sprintf(tmp_sql, "INSERT INTO `%s` (`drop_date`, `kill_char_id`, `monster_id`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s') ", log_config.log_drop_db, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], sd->mapname);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`drop_date`, `kill_char_id`, `monster_id`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s') ", log_config.log_drop_db, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], sd->mapname);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_drop,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%d,%d,%d,%d,%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_drop[0], log_drop[1], log_drop[2], log_drop[3], log_drop[4], log_drop[5], log_drop[6], log_drop[7], RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
- sprintf(tmp_sql, "INSERT INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], sd->mapname);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], sd->mapname);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_mvpdrop,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
int log_present(struct map_session_data *sd, int source_type, int nameid)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
- sprintf(tmp_sql, "INSERT INTO `%s` (`present_date`, `src_id`, `account_id`, `char_id`, `char_name`, `nameid`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%s', '%d', '%s') ", log_config.log_present_db, source_type, sd->status.account_id, sd->status.char_id, sd->status.name, nameid, sd->mapname);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`present_date`, `src_id`, `account_id`, `char_id`, `char_name`, `nameid`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%s', '%d', '%s') ", log_config.log_present_db, source_type, sd->status.account_id, sd->status.char_id, sd->status.name, nameid, sd->mapname);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_present,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, source_type, nameid, RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, int slot3, int success)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
- sprintf(tmp_sql, "INSERT INTO `%s` (`produce_date`, `account_id`, `char_id`, `char_name`, `nameid`, `slot1`, `slot2`, `slot3`, `map`, `success`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%s', '%d') ", log_config.log_produce_db, sd->status.account_id, sd->status.char_id, sd->status.name, nameid, slot1, slot2, slot3, sd->mapname, success);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`produce_date`, `account_id`, `char_id`, `char_name`, `nameid`, `slot1`, `slot2`, `slot3`, `map`, `success`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%s', '%d') ", log_config.log_produce_db, sd->status.account_id, sd->status.char_id, sd->status.name, nameid, slot1, slot2, slot3, sd->mapname, success);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_produce,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, nameid, slot1, slot2, slot3, success, RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
int log_refine(struct map_session_data *sd, int n, int success)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
+ nullpo_retr(0, sd);
+ FILE *logfp;
int log_card[4];
int item_level;
int i;
- nullpo_retr(0, sd);
if(success == 0)
item_level = 0;
@@ -81,36 +168,68 @@ int log_refine(struct map_session_data *sd, int n, int success)
for(i=0;i<4;i++)
log_card[i] = sd->status.inventory[n].card[i];
- sprintf(tmp_sql, "INSERT INTO `%s` (`refine_date`, `account_id`, `char_id`, `char_name`, `nameid`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `success`, `item_level`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d')", log_config.log_refine_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->status.inventory[n].nameid, sd->status.inventory[n].refine, log_card[0], log_card[1], log_card[2], log_card[3], sd->mapname, success, item_level);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`refine_date`, `account_id`, `char_id`, `char_name`, `nameid`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `success`, `item_level`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d', '%d')", log_config.log_refine_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->status.inventory[n].nameid, sd->status.inventory[n].refine, log_card[0], log_card[1], log_card[2], log_card[3], sd->mapname, success, item_level);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_refine,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%d,%d\t%d%d%d%d\t%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, sd->status.inventory[n].nameid, sd->status.inventory[n].refine, log_card[0], log_card[1], log_card[2], log_card[3], success, item_level, RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, int n,int amount)
{
- #ifndef TXT_ONLY
- int log_nameid, log_amount, log_refine, log_card[4];
- int i;
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
+ FILE *logfp;
+ int log_nameid, log_amount, log_refine, log_card[4];
+ int i;
if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
return 1;
- if(sd->status.inventory[n].amount>=0)
- {
- log_nameid = sd->status.inventory[n].nameid;
- log_amount = sd->status.inventory[n].amount;
- log_refine = sd->status.inventory[n].refine;
+ if(sd->status.inventory[n].amount < 0)
+ return 1;
- for(i=0;i<4;i++)
- log_card[i] = sd->status.inventory[n].card[i];
+ log_nameid = sd->status.inventory[n].nameid;
+ log_amount = sd->status.inventory[n].amount;
+ log_refine = sd->status.inventory[n].refine;
+
+ for(i=0;i<4;i++)
+ log_card[i] = sd->status.inventory[n].card[i];
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
sprintf(tmp_sql, "INSERT INTO `%s` (`trade_date`, `src_account_id`, `src_char_id`, `src_char_name`, `des_account_id`, `des_char_id`, `des_char_name`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')", log_config.log_trade_db, sd->status.account_id, sd->status.char_id, sd->status.name, target_sd->status.account_id, target_sd->status.char_id, target_sd->status.name, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], sd->mapname);
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, target_sd->status.name, target_sd->status.account_id, target_sd->status.char_id, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
}
#endif
return 0;
@@ -118,40 +237,98 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i
int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int amount, int zeny)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
+ FILE *logfp;
+ nullpo_retr(0, sd);
int log_nameid, log_amount, log_refine, log_card[4];
int i;
- nullpo_retr(0, sd);
-
if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL)
return 1;
+ if(sd->status.inventory[n].amount< 0)
+ return 1;
- if(sd->status.inventory[n].amount>=0)
- {
- log_nameid = sd->status.inventory[n].nameid;
- log_amount = sd->status.inventory[n].amount;
- log_refine = sd->status.inventory[n].refine;
+ log_nameid = sd->status.inventory[n].nameid;
+ log_amount = sd->status.inventory[n].amount;
+ log_refine = sd->status.inventory[n].refine;
+ for(i=0;i<4;i++)
+ log_card[i] = sd->status.inventory[n].card[i];
- for(i=0;i<4;i++)
- log_card[i] = sd->status.inventory[n].card[i];
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`vend_date`, `vend_account_id`, `vend_char_id`, `vend_char_name`, `buy_account_id`, `buy_char_id`, `buy_char_name`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `zeny`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d')", log_config.log_vend_db, sd->status.account_id, sd->status.char_id, sd->status.name, vsd->status.account_id, vsd->status.char_id, vsd->status.name, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], sd->mapname, zeny);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_vend,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d:%d]\t%s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d\t%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, vsd->status.name, vsd->status.account_id, vsd->status.char_id, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], zeny, RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
+ #endif
+ return 0;
+}
- sprintf(tmp_sql, "INSERT INTO `%s` (`vend_date`, `vend_account_id`, `vend_char_id`, `vend_char_name`, `buy_account_id`, `buy_char_id`, `buy_char_name`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`, `zeny`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%d')", log_config.log_vend_db, sd->status.account_id, sd->status.char_id, sd->status.name, vsd->status.account_id, vsd->status.char_id, vsd->status.name, log_nameid, log_amount, log_refine, log_card[0], log_card[1], log_card[2], log_card[3], sd->mapname, zeny);
+int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount)
+{
+ if(log_config.enable_logs <= 0)
+ return 0;
+ nullpo_retr(0, sd);
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql,"INSERT INTO `%s` (`trade_date`, `src_account_id`, `src_char_id`, `src_char_name`, `des_account_id`, `des_char_id`, `des_char_name`, `map`, `zeny`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%s', '%d')", log_config.log_trade_db, sd->status.account_id, sd->status.char_id, sd->status.name, target_sd->status.account_id, target_sd->status.char_id, target_sd->status.name, sd->mapname, sd->deal_zeny);
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d]\t%s[%d]\t%d\t%s", timestring, sd->status.name, sd->status.account_id, target_sd->status.name, target_sd->status.account_id, sd->deal_zeny, RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
}
#endif
return 0;
}
-int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount)
+int log_atcommand(struct map_session_data *sd, const char *message)
{
- #ifndef TXT_ONLY
+ if(log_config.enable_logs <= 0)
+ return 0;
nullpo_retr(0, sd);
-
- sprintf(tmp_sql,"INSERT INTO `%s` (`trade_date`, `src_account_id`, `src_char_id`, `src_char_name`, `des_account_id`, `des_char_id`, `des_char_name`, `map`, `zeny`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%d', '%s', '%s', '%d')", log_config.log_trade_db, sd->status.account_id, sd->status.char_id, sd->status.name, target_sd->status.account_id, target_sd->status.char_id, target_sd->status.name, sd->mapname, sd->deal_zeny);
- if(mysql_query(&mmysql_handle, tmp_sql))
- printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ FILE *logfp;
+ #ifndef TXT_ONLY
+ if(log_config.sql_logs > 0)
+ {
+ sprintf(tmp_sql, "INSERT INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ", log_config.log_gm_db, sd->status.account_id, sd->status.char_id, sd->status.name, sd->mapname, message);
+ if(mysql_query(&mmysql_handle, tmp_sql))
+ printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
+ } else {
+ #endif
+ if((logfp=fopen(log_config.log_gm,"a+")) != NULL) {
+ time_t curtime;
+ time(&curtime);
+ char timestring[255];
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
+ fclose(logfp);
+ }
+ #ifndef TXT_ONLY
+ }
#endif
return 0;
}
@@ -174,7 +351,11 @@ int log_config_read(char *cfgName)
if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
{
- if(strcmpi(w1,"log_branch") == 0) {
+ if(strcmpi(w1,"enable_logs") == 0) {
+ log_config.enable_logs = (atoi(w2));
+ } else if(strcmpi(w1,"sql_logs") == 0) {
+ log_config.sql_logs = (atoi(w2));
+ } else if(strcmpi(w1,"log_branch") == 0) {
log_config.branch = (atoi(w2));
} else if(strcmpi(w1,"log_drop") == 0) {
log_config.drop = (atoi(w2));
@@ -195,6 +376,8 @@ int log_config_read(char *cfgName)
log_config.zeny = 0;
else
log_config.zeny = (atoi(w2));
+ } else if(strcmpi(w1,"log_gm") == 0) {
+ log_config.gm = (atoi(w2));
}
else if(strcmpi(w1, "log_branch_db") == 0) {
@@ -234,6 +417,53 @@ int log_config_read(char *cfgName)
strcpy(log_config.log_vend_db, w2);
if(log_config.vend == 1)
printf("Logging Vending to table `%s`\n", w2);
+ } else if(strcmpi(w1, "log_gm_db") == 0) {
+ strcpy(log_config.log_gm_db, w2);
+ if(log_config.gm > 0)
+ printf("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
+ }
+
+ else if(strcmpi(w1, "log_branch") == 0) {
+ strcpy(log_config.log_branch, w2);
+ if(log_config.branch == 1)
+ printf("Logging Dead Branch Usage to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_drop") == 0) {
+ strcpy(log_config.log_drop, w2);
+ if(log_config.drop == 1)
+ printf("Logging Item Drops to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_mvpdrop") == 0) {
+ strcpy(log_config.log_mvpdrop, w2);
+ if(log_config.mvpdrop == 1)
+ printf("Logging MVP Drops to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_present") == 0) {
+ strcpy(log_config.log_present, w2);
+ if(log_config.present == 1)
+ printf("Logging Present Usage & Results to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_produce") == 0) {
+ strcpy(log_config.log_produce, w2);
+ if(log_config.produce == 1)
+ printf("Logging Producing to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_refine") == 0) {
+ strcpy(log_config.log_refine, w2);
+ if(log_config.refine == 1)
+ printf("Logging Refining to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_trade") == 0) {
+ strcpy(log_config.log_trade, w2);
+ if(log_config.trade == 1)
+ {
+ printf("Logging Item Trades");
+ if(log_config.zeny == 1)
+ printf("and Zeny Trades");
+ printf(" to file `%s`.txt\n", w2);
+ }
+ } else if(strcmpi(w1, "log_vend") == 0) {
+ strcpy(log_config.log_vend, w2);
+ if(log_config.vend == 1)
+ printf("Logging Vending to file `%s`.txt\n", w2);
+ } else if(strcmpi(w1, "log_gm") == 0) {
+ strcpy(log_config.log_gm, w2);
+ if(log_config.gm > 0)
+ printf("Logging GM Level %d Commands to file `%s`.txt\n", log_config.gm, w2);
}
}
}
diff --git a/src/map/log.h b/src/map/log.h
index 4e34ef0cc..d4ad0bd66 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -1,6 +1,8 @@
#ifndef _LOG_H_
#define _LOG_H_
+#include "map.h"
+
#ifndef TXT_ONLY
extern char db_server_logdb[32];
@@ -16,12 +18,16 @@ int log_refine(struct map_session_data *sd, int n, int success);
int log_trade(struct map_session_data *sd,struct map_session_data *target_sd,int n,int amount);
int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int amount,int zeny);
int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount);
+int log_atcommand(struct map_session_data *sd, const char *message);
int log_config_read(char *cfgName);
extern struct Log_Config {
- int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny;
- char log_branch_db[32], log_drop_db[32], log_mvpdrop_db[32], log_present_db[32], log_produce_db[32], log_refine_db[32], log_trade_db[32], log_vend_db[32];
+ int enable_logs;
+ int sql_logs;
+ int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm;
+ char log_branch[32], log_drop[32], log_mvpdrop[32], log_present[32], log_produce[32], log_refine[32], log_trade[32], log_vend[32], log_gm[32];
+ char log_branch_db[32], log_drop_db[32], log_mvpdrop_db[32], log_present_db[32], log_produce_db[32], log_refine_db[32], log_trade_db[32], log_vend_db[32], log_gm_db[32];
} log_config;
#endif