ソースを参照

added logging filters. optimized ATCommands temp strings usage

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1302 54d463be-8e91-2dee-dedb-b68131a5f0ec
Lupus 20 年 前
コミット
4a8a574f14
6 ファイル変更281 行追加210 行削除
  1. 4 0
      Changelog-SVN.txt
  2. 26 0
      conf-tmpl/log_athena.conf
  3. 160 188
      src/map/atcommand.c
  4. 87 22
      src/map/log.c
  5. 1 0
      src/map/log.h
  6. 3 0
      src/map/mob.c

+ 4 - 0
Changelog-SVN.txt

@@ -1,6 +1,10 @@
 Date	Added
 
 03/27
+	* Added flexible Filter to the Monster Drops logging [Lupus]
+	   - Now you can choose what types of items either to log or not.
+	   - You can also log expensive items (you can set the min logging price)
+	* Optimized a bit ATCommands.c functions (inspired by Freya) [Lupus]
 	* Added missing parenthesis in my Improve Dodge code, not giving +4/lv to proper jobs [DracoRPG]
 	* Added all released cards into monsters drops and Old Card Album [Lupus]
 03/25

+ 26 - 0
conf-tmpl/log_athena.conf

@@ -6,6 +6,32 @@ enable_logs: 1
 // Use MySQL Logs? (SQL Version Only)
 sql_logs: 0
 
+// LOGGING FILTERS by Lupus
+//========== It works for Monster Drops yet ========
+what_items_log: 1023
+//0 = none, 1023 = 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) Note: Amount is ignored in Monster Drops Log
+//1024 - Log items which have scripts (not implemented yet)
+
+//For example:  258 -> log all USABLE and all items which price is >= price_items_log
+//For example:  568 -> log all CARDS,WEAPON,ARMOR and all items which amount >= amount_items_log
+
+//don't log it if the current item price < price_items_log
+price_items_log: 1000
+
+//don't log it if the current item amount < amount_items_log
+amount_items_log: 100
+//==================================================
 
 // Log Dead Branch Usage
 log_branch: 0

ファイルの差分が大きいため隠しています
+ 160 - 188
src/map/atcommand.c


+ 87 - 22
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) {

+ 1 - 0
src/map/log.h

@@ -26,6 +26,7 @@ int log_config_read(char *cfgName);
 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];
 	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];

+ 3 - 0
src/map/mob.c

@@ -2139,6 +2139,9 @@ int mob_timer_delete(int tid, unsigned int tick, int id, int data)
 	nullpo_retr(0, bl);
 
 	md = (struct mob_data *)bl;
+//for Alchemist CANNIBALIZE [Lupus]
+
+
 	mob_catch_delete(md,3);
 	return 0;
 }

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません