Jelajahi Sumber

* Merged changes up to eAthena 15036.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15167 54d463be-8e91-2dee-dedb-b68131a5f0ec
eathenabot 13 tahun lalu
induk
melakukan
7b2c38fd24
9 mengubah file dengan 93 tambahan dan 44 penghapusan
  1. 5 0
      Changelog-Trunk.txt
  2. 4 0
      conf/Changelog.txt
  3. 31 12
      conf/log_athena.conf
  4. 1 2
      src/map/atcommand.c
  5. 3 6
      src/map/clif.c
  6. 1 2
      src/map/guild.c
  7. 32 19
      src/map/log.c
  8. 15 1
      src/map/log.h
  9. 1 2
      src/map/party.c

+ 5 - 0
Changelog-Trunk.txt

@@ -1,6 +1,11 @@
 Date (YYYY-MM-DD)
 	Added
 
+2011-12-19
+	* Changes to chat logging code. [Ai4rei]
+	- Moved log_config.chat checks into log_chat and replaced string chat types with an enumeration.
+	- Changed log_config.chat to only include chat types, old values 1 (all) and 64 (none during woe).
+	- Introduced setting 'log_chat_woe_disable' which replaces previous (log_config.chat&64) bit.
 2011-12-18
 	* Some preparation clean-ups in map log; no functional changes, yet. [Ai4rei]
 2011-12-17

+ 4 - 0
conf/Changelog.txt

@@ -1,5 +1,9 @@
 Date	Added
 
+2011/12/19
+	* Rev. 15036 Updates to log_athena.conf [Ai4rei]
+	- Changed meaning of 'log_chat' bits (shift to right by one, &64 bit removed, 1 no longer means 'all').
+	- Added option 'log_chat_woe_disable' which replaces &64 log_chat bit.
 2011/10/15
 	* Rev. 14972 Updated misleading comment in conf/mapflag/partylock.txt (bugreport:4930, since r14092). [Ai4rei]
 2011/08/21

+ 31 - 12
conf/log_athena.conf

@@ -1,4 +1,23 @@
-// eAthena - Log Configuration File
+//      ______  __    __                                 
+//     /\  _  \/\ \__/\ \                                
+//   __\ \ \L\ \ \ ,_\ \ \___      __    ___      __     
+// /'__`\ \  __ \ \ \/\ \  _ `\  /'__`\/' _ `\  /'__`\   
+///\  __/\ \ \/\ \ \ \_\ \ \ \ \/\  __//\ \/\ \/\ \L\.\_ 
+//\ \____\\ \_\ \_\ \__\\ \_\ \_\ \____\ \_\ \_\ \__/.\_\
+// \/____/ \/_/\/_/\/__/ \/_/\/_/\/____/\/_/\/_/\/__/\/_/
+//  _   _   _   _   _   _   _     _   _   _   _   _   _
+// / \ / \ / \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \ 
+//( e | n | g | l | i | s | h ) ( A | t | h | e | n | a )
+// \_/ \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/
+//
+//--------------------------------------------------------------
+// eAthena Log Configuration File
+//--------------------------------------------------------------
+// Note 1: Value is a config switch (on/off, yes/no or 1/0)
+// Note 2: Value is in percents (100 means 100%)
+// Note 3: Value is a bit field. If no description is given,
+//         assume unit types (1: Pc, 2: Mob, 4: Pet, 8: Homun)
+//--------------------------------------------------------------
 
 // Enable Logs?
 // 1 - Log all events.
@@ -83,20 +102,20 @@ log_npc: 0
 // LOGGING FILTERS
 // =============================================================
 // 0 = Don't log at all
-// 1 = Log EVERYTHING!
-// Advanced Filter Bits: ||
-// 02 - Log Global messages
-// 04 - Log Whisper messages
-// 08 - Log Party messages
-// 16 - Log Guild messages
-// 32 - Log Main chat messages
-// 64 - Don't log anything when WOE is on
+// 1 - Log Global messages
+// 2 - Log Whisper messages
+// 4 - Log Party messages
+// 8 - Log Guild messages
+// 16 - Log Main chat messages
 // Example:
-// log_chat: 12 = logs both Whisper & Party messages
-// log_chat: 16 = logs only Guild messages
-// log_chat: 68 = logs only Whisper, when WOE is off
+// log_chat: 5 = logs both Whisper & Party messages
+// log_chat: 8 = logs only Guild messages
+// log_chat: 31 = logs everything
 log_chat: 0
 
+// Disable chat logging when WoE is running? (Note 1)
+log_chat_woe_disable: no
+
 // Dead Branch Log Table
 log_branch_db: branchlog
 

+ 1 - 2
src/map/atcommand.c

@@ -8309,8 +8309,7 @@ ACMD_FUNC(main)
 			intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
 
 			// Chat logging type 'M' / Main Chat
-			if( log_config.chat&1 || (log_config.chat&32 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
-				log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+			log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
 		}
 		
 	} else {

+ 3 - 6
src/map/clif.c

@@ -9135,8 +9135,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
 #endif
 
 	// Chat logging type 'O' / Global Chat
-	if( log_config.chat&1 || (log_config.chat&2 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
-		log_chat("O", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+	log_chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
 
 	return;
 }
@@ -9397,8 +9396,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
 	}
 
 	// Chat logging type 'W' / Whisper
-	if( log_config.chat&1 || (log_config.chat&4 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
-		log_chat("W", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);
+	log_chat(LOG_CHAT_WHISPER, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, target, message);
 
 	//-------------------------------------------------------//
 	//   Lordalfa - Paperboy - To whisper NPC commands       //
@@ -9457,8 +9455,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
 		}
 
 		// Chat logging type 'M' / Main Chat
-		if( log_config.chat&1 || (log_config.chat&32 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
-			log_chat("M", 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+		log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
 
 		return;
 	}

+ 1 - 2
src/map/guild.c

@@ -953,8 +953,7 @@ int guild_send_message(struct map_session_data *sd,const char *mes,int len)
 	guild_recv_message(sd->status.guild_id,sd->status.account_id,mes,len);
 
 	// Chat logging type 'G' / Guild Chat
-	if( log_config.chat&1 || (log_config.chat&16 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
-		log_chat("G", sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
+	log_chat(LOG_CHAT_GUILD, sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
 
 	return 0;
 }

+ 32 - 19
src/map/log.c

@@ -29,6 +29,24 @@ struct Log_Config log_config;
 #endif
 
 
+/// obtain log type character for chat logs
+static char log_chattype2char(e_log_chat_type type)
+{
+	switch( type )
+	{
+		case LOG_CHAT_GLOBAL:   return 'O';  // Gl(O)bal
+		case LOG_CHAT_WHISPER:  return 'W';  // (W)hisper
+		case LOG_CHAT_PARTY:    return 'P';  // (P)arty
+		case LOG_CHAT_GUILD:    return 'G';  // (G)uild
+		case LOG_CHAT_MAINCHAT: return 'M';  // (M)ain chat
+	}
+
+	// should not get here, fallback
+	ShowError("log_chattype2char: Unknown chat type %d.\n", type);
+	return 'O';
+}
+
+
 //FILTER OPTIONS
 //0 = Don't log
 //1 = Log any item
@@ -359,24 +377,17 @@ void log_npc(struct map_session_data* sd, const char* message)
 }
 
 
-void log_chat(const char* type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message)
+void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message)
 {
-	// Log CHAT (Global, Whisper, Party, Guild, Main chat)
-	// LOGGING FILTERS [Lupus]
-	// =============================================================
-	// 0 = Don't log at all
-	// 1 = Log EVERYTHING!
-	// Advanced Filter Bits: ||
-	// 02 - Log Global messages
-	// 04 - Log Whisper messages
-	// 08 - Log Party messages
-	// 16 - Log Guild messages
-	// 32 - Log Main chat messages
-	// 64 - Don't log anything when WOE is on
-
-	//Check ON/OFF
-	if(log_config.chat <= 0)
-		return; //Deactivated
+	if( (log_config.chat&type) == 0 )
+	{// disabled
+		return;
+	}
+
+	if( log_config.log_chat_woe_disable && ( agit_flag || agit2_flag ) )
+	{// no chat logging during woe
+		return;
+	}
 
 #ifndef TXT_ONLY
 	if( log_config.sql_logs )
@@ -384,7 +395,7 @@ void log_chat(const char* type, int type_id, int src_charid, int src_accid, cons
 		SqlStmt* stmt;
 
 		stmt = SqlStmt_Malloc(logmysql_handle);
-		if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y)
+		if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", log_config.log_chat_db, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
 		||  SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
 		||  SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
 		||  SQL_SUCCESS != SqlStmt_Execute(stmt) )
@@ -406,7 +417,7 @@ void log_chat(const char* type, int type_id, int src_charid, int src_accid, cons
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
-		fprintf(logfp, "%s - %s,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, type, type_id, src_charid, src_accid, map, x, y, dst_charname, message);
+		fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y, dst_charname, message);
 		fclose(logfp);
 	}
 }
@@ -476,6 +487,8 @@ int log_config_read(char *cfgName)
 				log_config.chat = (atoi(w2));
 			} else if(strcmpi(w1,"log_mvpdrop") == 0) {
 				log_config.mvpdrop = (atoi(w2));
+			} else if(strcmpi(w1,"log_chat_woe_disable") == 0) {
+				log_config.log_chat_woe_disable = (bool)config_switch(w2);
 			}
 
 #ifndef TXT_ONLY

+ 15 - 1
src/map/log.h

@@ -9,13 +9,25 @@ struct map_session_data;
 struct mob_data;
 struct item;
 
+
+typedef enum e_log_chat_type
+{
+	LOG_CHAT_GLOBAL      = 0x01,
+	LOG_CHAT_WHISPER     = 0x02,
+	LOG_CHAT_PARTY       = 0x04,
+	LOG_CHAT_GUILD       = 0x08,
+	LOG_CHAT_MAINCHAT    = 0x10,
+}
+e_log_chat_type;
+
+
 //New logs
 void log_pick_pc(struct map_session_data *sd, const char *type, int nameid, int amount, struct item *itm);
 void log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount, struct item *itm);
 void log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount);
 
 void log_npc(struct map_session_data *sd, const char *message);
-void log_chat(const char* type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message);
+void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message);
 void log_atcommand(struct map_session_data *sd, const char *message);
 
 //Old, but useful logs
@@ -44,11 +56,13 @@ typedef enum log_what
 }
 log_what;
 
+
 extern struct Log_Config
 {
 	enum log_what enable_logs;
 	int filter;
 	bool sql_logs;
+	bool log_chat_woe_disable;
 	int rare_items_log,refine_items_log,price_items_log,amount_items_log; //for filter
 	int branch, drop, mvpdrop, zeny, gm, npc, chat;
 	char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64];

+ 1 - 2
src/map/party.c

@@ -798,8 +798,7 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len)
 	party_recv_message(sd->status.party_id,sd->status.account_id,mes,len);
 
 	// Chat logging type 'P' / Party Chat
-	if( log_config.chat&1 || (log_config.chat&8 && !((agit_flag || agit2_flag) && log_config.chat&64)) )
-		log_chat("P", sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
+	log_chat(LOG_CHAT_PARTY, sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
 
 	return 0;
 }