summaryrefslogtreecommitdiff
path: root/src/map/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/log.c')
-rw-r--r--src/map/log.c109
1 files changed, 87 insertions, 22 deletions
diff --git a/src/map/log.c b/src/map/log.c
index e37aeae6b..df939488f 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -3,12 +3,57 @@
#include <stdio.h>
#include <string.h>
+#include "itemdb.h"
#include "map.h"
+
#include "nullpo.h"
#include "log.h"
struct Log_Config log_config;
+char timestring[255];
+time_t curtime;
+
+//0 = none, 1024 = any
+//Bits |
+//1 - Healing items (Potions)
+//2 - Usable Items
+//4 - Etc Items
+//8 - Weapon
+//16 - Shields,Armor,Headgears,Accessories,etc
+//32 - Cards
+//64 - Pet Accessories
+//128 - Eggs (well, monsters don't drop 'em but we'll use the same system for ALL logs)
+//256 - Log expensive items ( >= price_log)
+//512 - Log big amount of items ( >= amount_log)
+int slog_healing = 0;
+int slog_usable = 0;
+int slog_etc = 0;
+int slog_weapon = 0;
+int slog_armor = 0;
+int slog_card = 0;
+int slog_petacc = 0;
+int slog_egg = 0;
+int slog_expensive = 0;
+int slog_amount = 0;
+
+//check if this item should be logger according the settings
+int should_log_item(int nameid) {
+ struct item_data *item_data;
+
+ if (nameid<512 || (item_data= itemdb_search(nameid)) == NULL) return 0;
+
+ if (slog_expensive && item_data->value_buy >= log_config.price_items_log ) return item_data->nameid;
+ if (slog_healing && item_data->type == 0 ) return item_data->nameid;
+ if (slog_etc && item_data->type == 3 ) return item_data->nameid;
+ if (slog_weapon && item_data->type == 4 ) return item_data->nameid;
+ if (slog_armor && item_data->type == 5 ) return item_data->nameid;
+ if (slog_card && item_data->type == 6 ) return item_data->nameid;
+ if (slog_petacc && item_data->type == 8 ) return item_data->nameid;
+ if (slog_egg && item_data->type == 7 ) return item_data->nameid;
+ return 0;
+}
+
int log_branch(struct map_session_data *sd)
{
FILE *logfp;
@@ -25,8 +70,6 @@ int log_branch(struct map_session_data *sd)
} else {
#endif
if((logfp=fopen(log_config.log_branch,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -41,10 +84,16 @@ int log_branch(struct map_session_data *sd)
int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
{
FILE *logfp;
+ int i,flag = 0;
if(log_config.enable_logs <= 0)
return 0;
nullpo_retr(0, sd);
+ for (i = 0; i<10; i++) { //Should we log these items? [Lupus]
+ flag += should_log_item(log_drop[i]);
+ }
+ if (flag==0) return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
+
#ifndef TXT_ONLY
if(log_config.sql_logs > 0)
{
@@ -54,7 +103,7 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
} else {
#endif
if((logfp=fopen(log_config.log_drop,"a+")) != NULL) {
- char timestring[255];
+
time_t curtime;
time(&curtime);
@@ -65,7 +114,7 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
#ifndef TXT_ONLY
}
#endif
- return 0;
+ return 1; //Logged
}
int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
@@ -84,8 +133,6 @@ int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
} else {
#endif
if((logfp=fopen(log_config.log_mvpdrop,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -112,8 +159,6 @@ int log_present(struct map_session_data *sd, int source_type, int nameid)
} else {
#endif
if((logfp=fopen(log_config.log_present,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -140,8 +185,6 @@ int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, i
} else {
#endif
if((logfp=fopen(log_config.log_produce,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -182,8 +225,6 @@ int log_refine(struct map_session_data *sd, int n, int success)
} else {
#endif
if((logfp=fopen(log_config.log_refine,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -228,8 +269,6 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i
} else {
#endif
if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -271,8 +310,6 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int
} else {
#endif
if((logfp=fopen(log_config.log_vend,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -299,8 +336,6 @@ int log_zeny(struct map_session_data *sd, struct map_session_data *target_sd,int
} else {
#endif
if((logfp=fopen(log_config.log_trade,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -327,8 +362,6 @@ int log_atcommand(struct map_session_data *sd, const char *message)
} else {
#endif
if((logfp=fopen(log_config.log_gm,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -355,8 +388,6 @@ int log_npc(struct map_session_data *sd, const char *message)
} else {
#endif
if((logfp=fopen(log_config.log_npc,"a+")) != NULL) {
- char timestring[255];
- time_t curtime;
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);
@@ -379,6 +410,11 @@ int log_config_read(char *cfgName)
return 1;
}
+ //Default values
+ log_config.what_items_log = 1023; //log any items
+ log_config.price_items_log = 1000;
+ log_config.amount_items_log = 100;
+
while(fgets(line, sizeof(line) -1, fp))
{
if(line[0] == '/' && line[1] == '/')
@@ -390,6 +426,35 @@ int log_config_read(char *cfgName)
log_config.enable_logs = (atoi(w2));
} else if(strcmpi(w1,"sql_logs") == 0) {
log_config.sql_logs = (atoi(w2));
+ } else if(strcmpi(w1,"what_items_log") == 0) {
+ log_config.what_items_log = (atoi(w2));
+
+//Bits |
+//1 - Healing items (Potions)
+//2 - Usable Items
+//4 - Etc Items
+//8 - Weapon
+//16 - Shields,Armor,Headgears,Accessories,etc
+//32 - Cards
+//64 - Pet Accessories
+//128 - Eggs (well, monsters don't drop 'em but we'll use the same system for ALL logs)
+//256 - Log expensive items ( >= price_log)
+//512 - Log big amount of items ( >= amount_log)
+ slog_healing = log_config.what_items_log&1;
+ slog_usable = log_config.what_items_log&2;
+ slog_etc = log_config.what_items_log&4;
+ slog_weapon = log_config.what_items_log&8;
+ slog_armor = log_config.what_items_log&16;
+ slog_card = log_config.what_items_log&32;
+ slog_petacc = log_config.what_items_log&64;
+ slog_egg = log_config.what_items_log&128;
+ slog_expensive = log_config.what_items_log&256;
+ slog_amount = log_config.what_items_log&512;
+
+ } else if(strcmpi(w1,"price_items_log") == 0) {
+ log_config.price_items_log = (atoi(w2));
+ } else if(strcmpi(w1,"amount_items_log") == 0) {
+ log_config.amount_items_log = (atoi(w2));
} else if(strcmpi(w1,"log_branch") == 0) {
log_config.branch = (atoi(w2));
} else if(strcmpi(w1,"log_drop") == 0) {