summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-04 19:32:34 +0000
committeramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-04 19:32:34 +0000
commit6acbd82fb5b77315853f42a9a31b7439a7e58bb9 (patch)
tree343173d795a6a7acfe990a8c0fe91b9fa3492296 /src
parent26bf6b6dacd8029a1ed48255518a78dfb11b4ce4 (diff)
downloadhercules-6acbd82fb5b77315853f42a9a31b7439a7e58bb9.tar.gz
hercules-6acbd82fb5b77315853f42a9a31b7439a7e58bb9.tar.bz2
hercules-6acbd82fb5b77315853f42a9a31b7439a7e58bb9.tar.xz
hercules-6acbd82fb5b77315853f42a9a31b7439a7e58bb9.zip
Fixes for logging trades [MouseJstr]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1407 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/common/showmsg.h14
-rw-r--r--src/map/log.c204
-rw-r--r--src/map/log.h7
-rw-r--r--src/map/storage.c14
-rw-r--r--src/map/trade.c10
5 files changed, 177 insertions, 72 deletions
diff --git a/src/common/showmsg.h b/src/common/showmsg.h
index 5b169dc82..3461369c3 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -4,6 +4,19 @@
//davidsiaw, 'lookee' here!
#define SHOW_DEBUG_MSG 1
+#ifdef _WIN32
+#define CL_RESET ""
+#define CL_NORMAL CL_RESET
+#define CL_NONE CL_RESET
+#define CL_WHITE ""
+#define CL_GRAY ""
+#define CL_RED ""
+#define CL_GREEN ""
+#define CL_YELLOW ""
+#define CL_BLUE ""
+#define CL_MAGENTA ""
+#define CL_CYAN ""
+#else
#define CL_RESET "\033[0;0m"
#define CL_NORMAL CL_RESET
#define CL_NONE CL_RESET
@@ -15,6 +28,7 @@
#define CL_BLUE "\033[1;34m"
#define CL_MAGENTA "\033[1;35m"
#define CL_CYAN "\033[1;36m"
+#endif
extern char tmp_output[1024];
diff --git a/src/map/log.c b/src/map/log.c
index 417d2dcbc..833fb8b16 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -56,15 +56,15 @@ int should_log_item(int nameid) {
int log_branch(struct map_session_data *sd)
{
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100];
- #endif
+#endif
FILE *logfp;
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')",
@@ -72,16 +72,16 @@ int log_branch(struct map_session_data *sd)
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_branch,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
@@ -98,14 +98,14 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
}
if (flag==0) return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`drop_date`, `kill_char_id`, `monster_id`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `itemCard`, `map`) VALUES (NOW(), '%d', '%d', '%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], log_drop[8], log_drop[9], sd->mapname);
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_drop,"a+")) != NULL) {
@@ -115,9 +115,9 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d,%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], log_drop[8], log_drop[9], RETCODE);
fclose(logfp);
}
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 1; //Logged
}
@@ -128,37 +128,37 @@ int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED 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
+#endif
if((logfp=fopen(log_config.log_mvpdrop,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
int log_present(struct map_session_data *sd, int source_type, int nameid)
{
FILE *logfp;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`present_date`, `src_id`, `account_id`, `char_id`, `char_name`, `nameid`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%s', '%d', '%s') ",
@@ -166,30 +166,30 @@ int log_present(struct map_session_data *sd, int source_type, int nameid)
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_present,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, int slot3, int success)
{
FILE *logfp;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED 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') ",
@@ -197,16 +197,16 @@ int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, i
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_produce,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
@@ -216,9 +216,9 @@ int log_refine(struct map_session_data *sd, int n, int success)
int log_card[4];
int item_level;
int i;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
@@ -233,7 +233,7 @@ 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];
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED 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')",
@@ -241,27 +241,89 @@ int log_refine(struct map_session_data *sd, int n, int success)
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_refine,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
+int log_tostorage(struct map_session_data *sd,int n, int guild)
+{
+ FILE *logfp;
+
+ if(log_config.enable_logs <= 0 || log_config.storage == 0 || log_config.log_storage[0] == '\0')
+ return 0;
+
+ nullpo_retr(0, sd);
+
+ if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL)
+ return 1;
+
+ if(sd->status.inventory[n].amount < 0)
+ return 1;
+
+ if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
+ time(&curtime);
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - to %s: %s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d%s", timestring, guild ? "guild_storage": "storage", sd->status.name, sd->status.account_id, sd->status.char_id,
+ sd->status.inventory[n].nameid,
+ sd->status.inventory[n].amount,
+ sd->status.inventory[n].refine,
+ sd->status.inventory[n].card[0],
+ sd->status.inventory[n].card[1],
+ sd->status.inventory[n].card[2],
+ sd->status.inventory[n].card[3], RETCODE);
+ fclose(logfp);
+ }
+ return 0;
+}
+
+int log_fromstorage(struct map_session_data *sd,int n, int guild)
+{
+ FILE *logfp;
+
+ if(log_config.enable_logs <= 0 || log_config.storage == 0 || log_config.log_storage[0] == '\0')
+ return 0;
+
+ nullpo_retr(0, sd);
+
+ if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL)
+ return 1;
+
+ if(sd->status.inventory[n].amount < 0)
+ return 1;
+
+ if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
+ time(&curtime);
+ strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
+ fprintf(logfp,"%s - from %s: %s[%d:%d]\t%d\t%d\t%d\t%d,%d,%d,%d%s", timestring, guild ? "guild_storage": "storage", sd->status.name, sd->status.account_id, sd->status.char_id,
+ sd->status.inventory[n].nameid,
+ sd->status.inventory[n].amount,
+ sd->status.inventory[n].refine,
+ sd->status.inventory[n].card[0],
+ sd->status.inventory[n].card[1],
+ sd->status.inventory[n].card[2],
+ sd->status.inventory[n].card[3], RETCODE);
+ fclose(logfp);
+ }
+ return 0;
+}
+
int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, int n,int amount)
{
FILE *logfp;
int log_nameid, log_amount, log_refine, log_card[4];
int i;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100],t_name2[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
@@ -281,7 +343,7 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i
for(i=0;i<4;i++)
log_card[i] = sd->status.inventory[n].card[i];
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED 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')",
@@ -289,16 +351,16 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
@@ -307,9 +369,9 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int
FILE *logfp;
int log_nameid, log_amount, log_refine, log_card[4];
int i;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100],t_name2[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
@@ -326,7 +388,7 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int
for(i=0;i<4;i++)
log_card[i] = sd->status.inventory[n].card[i];
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED 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')",
@@ -334,30 +396,30 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_vend,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int amount)
{
FILE *logfp;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100],t_name2[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql,"INSERT DELAYED 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')",
@@ -365,30 +427,30 @@ int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
int log_atcommand(struct map_session_data *sd, const char *message)
{
FILE *logfp;
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
char t_name[100];
- #endif
+#endif
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ",
@@ -396,16 +458,16 @@ int log_atcommand(struct map_session_data *sd, const char *message)
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_gm,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
@@ -419,7 +481,7 @@ int log_npc(struct map_session_data *sd, const char *message)
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ",
@@ -427,16 +489,16 @@ int log_npc(struct map_session_data *sd, const char *message)
if(mysql_query(&mmysql_handle, tmp_sql))
printf("DB server Error - %s\n",mysql_error(&mmysql_handle));
} else {
- #endif
+#endif
if((logfp=fopen(log_config.log_npc,"a+")) != NULL) {
time(&curtime);
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
+#ifndef TXT_ONLY
}
- #endif
+#endif
return 0;
}
@@ -445,6 +507,8 @@ int log_config_read(char *cfgName)
char line[1024], w1[1024], w2[1024];
FILE *fp;
+ memset(&log_config, 0, sizeof(log_config));
+
if((fp = fopen(cfgName, "r")) == NULL)
{
printf("Log configuration file not found at: %s\n", cfgName);
@@ -510,6 +574,8 @@ int log_config_read(char *cfgName)
log_config.refine = (atoi(w2));
} else if(strcmpi(w1,"log_trade") == 0) {
log_config.trade = (atoi(w2));
+ } else if(strcmpi(w1,"log_storage") == 0) {
+ log_config.storage = (atoi(w2));
} else if(strcmpi(w1,"log_vend") == 0) {
log_config.vend = (atoi(w2));
} else if(strcmpi(w1,"log_zeny") == 0) {
@@ -523,7 +589,7 @@ int log_config_read(char *cfgName)
log_config.npc = (atoi(w2));
}
- #ifndef TXT_ONLY
+#ifndef TXT_ONLY
else if(strcmpi(w1, "log_branch_db") == 0) {
strcpy(log_config.log_branch_db, w2);
if(log_config.branch == 1)
@@ -557,6 +623,13 @@ int log_config_read(char *cfgName)
printf("and Zeny Trades");
printf(" to table `%s`\n", w2);
}
+// } else if(strcmpi(w1, "log_storage_db") == 0) {
+// strcpy(log_config.log_storage_db, w2);
+// if(log_config.storage == 1)
+// {
+// printf("Logging Item Storages");
+// printf(" to table `%s`\n", w2);
+// }
} else if(strcmpi(w1, "log_vend_db") == 0) {
strcpy(log_config.log_vend_db, w2);
if(log_config.vend == 1)
@@ -570,7 +643,7 @@ int log_config_read(char *cfgName)
if(log_config.npc > 0)
printf("Logging NPC 'logmes' to table `%s`\n", w2);
}
- #endif
+#endif
else if(strcmpi(w1, "log_branch_file") == 0) {
strcpy(log_config.log_branch, w2);
@@ -605,6 +678,13 @@ int log_config_read(char *cfgName)
printf("and Zeny Trades");
printf(" to file `%s`.txt\n", w2);
}
+ } else if(strcmpi(w1, "log_storage_file") == 0) {
+ strcpy(log_config.log_storage, w2);
+ if(log_config.storage > 0 && log_config.sql_logs < 1)
+ {
+ printf("Logging Item Storages");
+ printf(" to file `%s`.txt\n", w2);
+ }
} else if(strcmpi(w1, "log_vend_file") == 0) {
strcpy(log_config.log_vend, w2);
if(log_config.vend > 0 && log_config.sql_logs < 1)
diff --git a/src/map/log.h b/src/map/log.h
index 1c72d3f96..f0635b826 100644
--- a/src/map/log.h
+++ b/src/map/log.h
@@ -16,6 +16,9 @@ int log_present(struct map_session_data *sd, int source_type, int nameid);
int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, int slot3, int success);
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_tostorage(struct map_session_data *sd,int n, int guild);
+int log_fromstorage(struct map_session_data *sd,int n, int guild);
+
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);
@@ -27,8 +30,8 @@ extern struct Log_Config {
int enable_logs;
int sql_logs;
int what_items_log,price_items_log,amount_items_log;
- int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm, npc;
- 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], log_npc[32];
+ int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm, npc, storage;
+ 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], log_npc[32], log_storage[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_npc_db[32];
int uptime;
char log_uptime[32];
diff --git a/src/map/storage.c b/src/map/storage.c
index 6c4d6bea7..82ecd9321 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -233,11 +233,12 @@ int storage_storageadd(struct map_session_data *sd,int index,int amount)
if( (stor->storage_amount <= MAX_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open
if(index>=0 && index<MAX_INVENTORY) { // valid index
- if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount
- if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
- // remove item from inventory
- pc_delitem(sd,index,amount,0);
- } // valid amount
+ if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount
+// log_tostorage(sd, index, 0);
+ if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
+ // remove item from inventory
+ pc_delitem(sd,index,amount,0);
+ } // valid amount
}// valid index
}// storage not full & storage open
@@ -263,6 +264,7 @@ int storage_storageget(struct map_session_data *sd,int index,int amount)
storage_delitem(sd,stor,index,amount);
else
clif_additem(sd,0,0,flag);
+// log_fromstorage(sd, index, 0);
} // valid amount
}// valid index
}// storage open
@@ -510,6 +512,7 @@ int storage_guild_storageadd(struct map_session_data *sd,int index,int amount)
if( (stor->storage_amount <= MAX_GUILD_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open
if(index>=0 && index<MAX_INVENTORY) { // valid index
if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount
+// log_tostorage(sd, index, 1);
if(guild_storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
// remove item from inventory
pc_delitem(sd,index,amount,0);
@@ -536,6 +539,7 @@ int storage_guild_storageget(struct map_session_data *sd,int index,int amount)
guild_storage_delitem(sd,stor,index,amount);
else
clif_additem(sd,0,0,flag);
+// log_fromstorage(sd, index, 1);
} // valid amount
}// valid index
}// storage open
diff --git a/src/map/trade.c b/src/map/trade.c
index d98eed2a0..eb1d45ba2 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -16,6 +16,7 @@
#include "storage.h"
#include "intif.h"
#include "atcommand.h"
+#include "log.h"
/*==========================================
* 取引要請を相手に送る
@@ -33,15 +34,15 @@ void trade_traderequest(struct map_session_data *sd, int target_id) {
return;
}
}
- if(pc_isGM(sd) && pc_isGM(sd) < battle_config.gm_can_drop_lv) {
+ if(pc_isGM(sd) && pc_isGM(target_sd) < battle_config.gm_can_drop_lv) {
clif_displaymessage(sd->fd, msg_txt(246));
trade_tradecancel(sd); // GM is not allowed to trade
} else if ((target_sd->trade_partner != 0) || (sd->trade_partner != 0)) {
trade_tradecancel(sd); // person is in another trade
} else {
- if (sd->bl.m != target_sd->bl.m ||
+ if (!pc_isGM(sd) && (sd->bl.m != target_sd->bl.m ||
(sd->bl.x - target_sd->bl.x <= -5 || sd->bl.x - target_sd->bl.x >= 5) ||
- (sd->bl.y - target_sd->bl.y <= -5 || sd->bl.y - target_sd->bl.y >= 5)) {
+ (sd->bl.y - target_sd->bl.y <= -5 || sd->bl.y - target_sd->bl.y >= 5))) {
clif_tradestart(sd, 0); // too far
} else if (sd != target_sd) {
target_sd->trade_partner = sd->status.account_id;
@@ -328,6 +329,7 @@ void trade_tradecommit(struct map_session_data *sd) {
if (sd->status.inventory[n].amount < sd->deal_item_amount[trade_i])
sd->deal_item_amount[trade_i] = sd->status.inventory[n].amount;
+ log_trade(sd, target_sd, n, sd->deal_item_amount[trade_i]);
flag = pc_additem(target_sd, &sd->status.inventory[n], sd->deal_item_amount[trade_i]);
if (flag == 0)
@@ -336,6 +338,7 @@ void trade_tradecommit(struct map_session_data *sd) {
clif_additem(sd, n, sd->deal_item_amount[trade_i], 0);
sd->deal_item_index[trade_i] = 0;
sd->deal_item_amount[trade_i] = 0;
+
}
if (target_sd->deal_item_amount[trade_i] != 0) {
int n = target_sd->deal_item_index[trade_i] - 2;
@@ -343,6 +346,7 @@ void trade_tradecommit(struct map_session_data *sd) {
if (target_sd->status.inventory[n].amount < target_sd->deal_item_amount[trade_i])
target_sd->deal_item_amount[trade_i] = target_sd->status.inventory[n].amount;
+ log_trade(target_sd, sd, n, target_sd->deal_item_amount[trade_i]);
flag = pc_additem(sd, &target_sd->status.inventory[n], target_sd->deal_item_amount[trade_i]);
if (flag == 0)
pc_delitem(target_sd, n, target_sd->deal_item_amount[trade_i], 1);