added better filters into logs
git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1416 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
cc757903b3
commit
d082b6aa4e
@ -1,6 +1,12 @@
|
|||||||
|
|
||||||
Date Added
|
Date Added
|
||||||
|
|
||||||
|
04/06
|
||||||
|
* Added logs filters in more logs [Lupus]
|
||||||
|
now you can set individual bit-mask filter for each log file
|
||||||
|
Example: (drops log)
|
||||||
|
log_drop: 1 = logs ANY items
|
||||||
|
log_drop: 332 = logs only Healing items, Cards and those items which price is >= price_items_log
|
||||||
04/05
|
04/05
|
||||||
* Fixed damage reflecting (silly typo xP) [celest]
|
* Fixed damage reflecting (silly typo xP) [celest]
|
||||||
* Fixed Backstab to not have a push back effect [celest]
|
* Fixed Backstab to not have a push back effect [celest]
|
||||||
|
@ -6,55 +6,64 @@ enable_logs: 1
|
|||||||
// Use MySQL Logs? (SQL Version Only)
|
// Use MySQL Logs? (SQL Version Only)
|
||||||
sql_logs: 0
|
sql_logs: 0
|
||||||
|
|
||||||
// LOGGING FILTERS by Lupus
|
// LOGGING FILTERS [Lupus]
|
||||||
//========== It works for Monster Drops yet ========
|
//=============================================================
|
||||||
what_items_log: 1023
|
//if any condition is true then the item will be logged
|
||||||
//0 = none, 1023 = any
|
//0 = Don't log at all
|
||||||
//Bits |
|
//1 = Log any item
|
||||||
//1 - Healing items (Potions)
|
//Advanced Filter Bits: ||
|
||||||
//2 - Usable Items
|
//2 - Healing items (0)
|
||||||
//4 - Etc Items
|
//3 - Etc Items(3) + Arrows (10)
|
||||||
//8 - Weapon
|
//4 - Usable Items(2)
|
||||||
//16 - Shields,Armor,Headgears,Accessories,etc
|
//5 - Weapon(4)
|
||||||
//32 - Cards
|
//6 - Shields,Armor,Headgears,Accessories,etc(5)
|
||||||
//64 - Pet Accessories
|
//7 - Cards(6)
|
||||||
//128 - Eggs (well, monsters don't drop 'em but we'll use the same system for ALL logs)
|
//8 - Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs)
|
||||||
//256 - Log expensive items ( >= price_log)
|
//9 - Log expensive items ( >= price_log)
|
||||||
//512 - Log big amount of items ( >= amount_log) Note: Amount is ignored in Monster Drops Log
|
//10 - Log big amount of items ( >= amount_log)
|
||||||
//1024 - Log items which have scripts (not implemented yet)
|
//11 - Log refined items (if their refine >= refine_log )
|
||||||
|
//12 - Log rare items (if their drop chance <= rare_log )
|
||||||
|
|
||||||
//For example: 258 -> log all USABLE and all items which price is >= price_items_log
|
//Example: (drops log)
|
||||||
//For example: 568 -> log all CARDS,WEAPON,ARMOR and all items which amount >= amount_items_log
|
//log_drop: 1 = logs ANY items
|
||||||
|
//log_drop: 2 = logs only HEALING items
|
||||||
|
//log_drop: 4 = logs only Etc Items and Arrows
|
||||||
|
//log_drop: 64 = logs only Cards
|
||||||
|
//log_drop: 332 = logs only Healing items, Cards and those items which price is >= price_items_log
|
||||||
|
//etc
|
||||||
|
|
||||||
|
//not implemented yet
|
||||||
|
refine_items_log: 7
|
||||||
|
//not implemented yet
|
||||||
|
rare_items_log: 100
|
||||||
//don't log it if the current item price < price_items_log
|
//don't log it if the current item price < price_items_log
|
||||||
price_items_log: 1000
|
price_items_log: 1000
|
||||||
|
|
||||||
//don't log it if the current item amount < amount_items_log
|
//don't log it if the current item amount < amount_items_log
|
||||||
amount_items_log: 100
|
amount_items_log: 100
|
||||||
//==================================================
|
//=============================================================
|
||||||
|
|
||||||
// Log Dead Branch Usage
|
// Log Dead Branch Usage
|
||||||
log_branch: 0
|
log_branch: 0
|
||||||
|
|
||||||
// Log Monster Drops
|
// Log Monster Drops (You can use a filter)
|
||||||
log_drop: 0
|
log_drop: 0
|
||||||
|
|
||||||
// Log MVP Monster Drops
|
// Log MVP Monster Drops
|
||||||
log_mvpdrop: 0
|
log_mvpdrop: 0
|
||||||
|
|
||||||
// Log Present Items (Old Blue Box, etc.)
|
// Log Present Items (Old Blue Box, etc.) (You can use a filter)
|
||||||
log_present: 0
|
log_present: 0
|
||||||
|
|
||||||
// Log Produced Items
|
// Log Produced Items (You can use a filter)
|
||||||
log_produce: 0
|
log_produce: 0
|
||||||
|
|
||||||
// Log Refining
|
// Log Refining (You can use a filter)
|
||||||
log_refine: 0
|
log_refine: 0
|
||||||
|
|
||||||
// Log Trading
|
// Log Trading (You can use a filter)
|
||||||
log_trade: 0
|
log_trade: 0
|
||||||
|
|
||||||
// Log Vending
|
// Log Vending (You can use a filter)
|
||||||
log_vend: 0
|
log_vend: 0
|
||||||
|
|
||||||
// Log Zeny Trades
|
// Log Zeny Trades
|
||||||
|
110
src/map/log.c
110
src/map/log.c
@ -14,43 +14,38 @@ struct Log_Config log_config;
|
|||||||
char timestring[255];
|
char timestring[255];
|
||||||
time_t curtime;
|
time_t curtime;
|
||||||
|
|
||||||
//0 = none, 1024 = any
|
//FILTER OPTIONS
|
||||||
//Bits |
|
//0 = Don't log
|
||||||
//1 - Healing items (Potions)
|
//1 = Log any item
|
||||||
//2 - Usable Items
|
//Bits: ||
|
||||||
//4 - Etc Items
|
//2 - Healing items (0)
|
||||||
//8 - Weapon
|
//3 - Etc Items(3) + Arrows (10)
|
||||||
//16 - Shields,Armor,Headgears,Accessories,etc
|
//4 - Usable Items(2)
|
||||||
//32 - Cards
|
//5 - Weapon(4)
|
||||||
//64 - Pet Accessories
|
//6 - Shields,Armor,Headgears,Accessories,etc(5)
|
||||||
//128 - Eggs (well, monsters don't drop 'em but we'll use the same system for ALL logs)
|
//7 - Cards(6)
|
||||||
//256 - Log expensive items ( >= price_log)
|
//8 - Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs)
|
||||||
//512 - Log big amount of items ( >= amount_log)
|
//9 - Log expensive items ( >= price_log)
|
||||||
int slog_healing = 0;
|
//10 - Log big amount of items ( >= amount_log)
|
||||||
int slog_usable = 0;
|
//11 - Log refined items (if their refine >= refine_log )
|
||||||
int slog_etc = 0;
|
//12 - Log rare items (if their drop chance <= rare_log )
|
||||||
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
|
//check if this item should be logger according the settings
|
||||||
int should_log_item(int nameid) {
|
int should_log_item(int filter, int nameid) {
|
||||||
struct item_data *item_data;
|
struct item_data *item_data;
|
||||||
|
|
||||||
if (nameid<512 || (item_data= itemdb_search(nameid)) == NULL) return 0;
|
if (nameid<512 || (item_data= itemdb_search(nameid)) == NULL) return 0;
|
||||||
|
if ( (filter&1) || // Filter = 1, we log any item
|
||||||
|
(filter&2 && item_data->type == 0 ) || //healing items
|
||||||
|
(filter&4 && (item_data->type == 3 || item_data->type == 10) ) || //etc+arrows
|
||||||
|
(filter&8 && item_data->type == 2 ) || //usable
|
||||||
|
(filter&16 && item_data->type == 4 ) || //weapon
|
||||||
|
(filter&32 && item_data->type == 5 ) || //armor
|
||||||
|
(filter&64 && item_data->type == 6 ) || //cards
|
||||||
|
(filter&128 && (item_data->type == 7 || item_data->type == 8) ) || //eggs+pet access
|
||||||
|
(filter&256 && item_data->value_buy >= log_config.price_items_log ) ||
|
||||||
|
(filter&512 && item_data->refine >= log_config.refine_items_log )
|
||||||
|
) return item_data->nameid;
|
||||||
|
|
||||||
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +89,7 @@ int log_drop(struct map_session_data *sd, int monster_id, int *log_drop)
|
|||||||
return 0;
|
return 0;
|
||||||
nullpo_retr(0, sd);
|
nullpo_retr(0, sd);
|
||||||
for (i = 0; i<10; i++) { //Should we log these items? [Lupus]
|
for (i = 0; i<10; i++) { //Should we log these items? [Lupus]
|
||||||
flag += should_log_item(log_drop[i]);
|
flag += should_log_item(log_config.drop,log_drop[i]);
|
||||||
}
|
}
|
||||||
if (flag==0) return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
|
if (flag==0) return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
|
||||||
|
|
||||||
@ -158,6 +153,7 @@ int log_present(struct map_session_data *sd, int source_type, int nameid)
|
|||||||
if(log_config.enable_logs <= 0)
|
if(log_config.enable_logs <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
nullpo_retr(0, sd);
|
nullpo_retr(0, sd);
|
||||||
|
if(!should_log_item(log_config.present,nameid)) return 0; //filter [Lupus]
|
||||||
#ifndef TXT_ONLY
|
#ifndef TXT_ONLY
|
||||||
if(log_config.sql_logs > 0)
|
if(log_config.sql_logs > 0)
|
||||||
{
|
{
|
||||||
@ -189,6 +185,7 @@ int log_produce(struct map_session_data *sd, int nameid, int slot1, int slot2, i
|
|||||||
if(log_config.enable_logs <= 0)
|
if(log_config.enable_logs <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
nullpo_retr(0, sd);
|
nullpo_retr(0, sd);
|
||||||
|
if(!should_log_item(log_config.produce,nameid)) return 0; //filter [Lupus]
|
||||||
#ifndef TXT_ONLY
|
#ifndef TXT_ONLY
|
||||||
if(log_config.sql_logs > 0)
|
if(log_config.sql_logs > 0)
|
||||||
{
|
{
|
||||||
@ -229,7 +226,7 @@ int log_refine(struct map_session_data *sd, int n, int success)
|
|||||||
item_level = 0;
|
item_level = 0;
|
||||||
else
|
else
|
||||||
item_level = sd->status.inventory[n].refine + 1;
|
item_level = sd->status.inventory[n].refine + 1;
|
||||||
|
if(!should_log_item(log_config.refine,sd->status.inventory[n].nameid)) return 0; //filter [Lupus]
|
||||||
for(i=0;i<4;i++)
|
for(i=0;i<4;i++)
|
||||||
log_card[i] = sd->status.inventory[n].card[i];
|
log_card[i] = sd->status.inventory[n].card[i];
|
||||||
|
|
||||||
@ -262,7 +259,6 @@ int log_tostorage(struct map_session_data *sd,int n, int guild)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
nullpo_retr(0, sd);
|
nullpo_retr(0, sd);
|
||||||
|
|
||||||
if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL)
|
if(sd->status.inventory[n].nameid==0 || sd->inventory_data[n] == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -335,7 +331,7 @@ int log_trade(struct map_session_data *sd, struct map_session_data *target_sd, i
|
|||||||
|
|
||||||
if(sd->status.inventory[n].amount < 0)
|
if(sd->status.inventory[n].amount < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
if(!should_log_item(log_config.trade,sd->status.inventory[n].nameid)) return 0; //filter [Lupus]
|
||||||
log_nameid = sd->status.inventory[n].nameid;
|
log_nameid = sd->status.inventory[n].nameid;
|
||||||
log_amount = sd->status.inventory[n].amount;
|
log_amount = sd->status.inventory[n].amount;
|
||||||
log_refine = sd->status.inventory[n].refine;
|
log_refine = sd->status.inventory[n].refine;
|
||||||
@ -381,7 +377,7 @@ int log_vend(struct map_session_data *sd,struct map_session_data *vsd,int n,int
|
|||||||
return 1;
|
return 1;
|
||||||
if(sd->status.inventory[n].amount< 0)
|
if(sd->status.inventory[n].amount< 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
if(!should_log_item(log_config.vend,sd->status.inventory[n].nameid)) return 0; //filter [Lupus]
|
||||||
log_nameid = sd->status.inventory[n].nameid;
|
log_nameid = sd->status.inventory[n].nameid;
|
||||||
log_amount = sd->status.inventory[n].amount;
|
log_amount = sd->status.inventory[n].amount;
|
||||||
log_refine = sd->status.inventory[n].refine;
|
log_refine = sd->status.inventory[n].refine;
|
||||||
@ -514,10 +510,11 @@ int log_config_read(char *cfgName)
|
|||||||
printf("Log configuration file not found at: %s\n", cfgName);
|
printf("Log configuration file not found at: %s\n", cfgName);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Default values
|
//LOG FILTER Default values
|
||||||
log_config.what_items_log = 1023; //log any items
|
log_config.refine_items_log = 7; //log refined items, with refine >= +7
|
||||||
log_config.price_items_log = 1000;
|
log_config.rare_items_log = 100; //log rare items. drop chance <= 1%
|
||||||
|
log_config.price_items_log = 1000; //1000z
|
||||||
log_config.amount_items_log = 100;
|
log_config.amount_items_log = 100;
|
||||||
|
|
||||||
while(fgets(line, sizeof(line) -1, fp))
|
while(fgets(line, sizeof(line) -1, fp))
|
||||||
@ -531,35 +528,16 @@ int log_config_read(char *cfgName)
|
|||||||
log_config.enable_logs = (atoi(w2));
|
log_config.enable_logs = (atoi(w2));
|
||||||
} else if(strcmpi(w1,"sql_logs") == 0) {
|
} else if(strcmpi(w1,"sql_logs") == 0) {
|
||||||
log_config.sql_logs = (atoi(w2));
|
log_config.sql_logs = (atoi(w2));
|
||||||
} else if(strcmpi(w1,"what_items_log") == 0) {
|
//start of common filter settings
|
||||||
log_config.what_items_log = (atoi(w2));
|
} else if(strcmpi(w1,"rare_items_log") == 0) {
|
||||||
|
log_config.rare_items_log = (atoi(w2));
|
||||||
//Bits |
|
} else if(strcmpi(w1,"refine_items_log") == 0) {
|
||||||
//1 - Healing items (Potions)
|
log_config.refine_items_log = (atoi(w2));
|
||||||
//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) {
|
} else if(strcmpi(w1,"price_items_log") == 0) {
|
||||||
log_config.price_items_log = (atoi(w2));
|
log_config.price_items_log = (atoi(w2));
|
||||||
} else if(strcmpi(w1,"amount_items_log") == 0) {
|
} else if(strcmpi(w1,"amount_items_log") == 0) {
|
||||||
log_config.amount_items_log = (atoi(w2));
|
log_config.amount_items_log = (atoi(w2));
|
||||||
|
//end of common filter settings
|
||||||
} else if(strcmpi(w1,"log_branch") == 0) {
|
} else if(strcmpi(w1,"log_branch") == 0) {
|
||||||
log_config.branch = (atoi(w2));
|
log_config.branch = (atoi(w2));
|
||||||
} else if(strcmpi(w1,"log_drop") == 0) {
|
} else if(strcmpi(w1,"log_drop") == 0) {
|
||||||
|
@ -29,7 +29,7 @@ int log_config_read(char *cfgName);
|
|||||||
extern struct Log_Config {
|
extern struct Log_Config {
|
||||||
int enable_logs;
|
int enable_logs;
|
||||||
int sql_logs;
|
int sql_logs;
|
||||||
int what_items_log,price_items_log,amount_items_log;
|
int rare_items_log,refine_items_log,price_items_log,amount_items_log;
|
||||||
int branch, drop, mvpdrop, present, produce, refine, trade, vend, zeny, gm, npc, storage;
|
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[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];
|
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];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user