From 59c5b131644b8caedae22f6e716cddab90512dae Mon Sep 17 00:00:00 2001 From: eathenabot Date: Mon, 19 Dec 2011 21:47:34 +0000 Subject: * Merged changes up to eAthena 15036. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15167 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 +++++ conf/Changelog.txt | 4 ++++ conf/log_athena.conf | 43 +++++++++++++++++++++++++++++++------------ src/map/atcommand.c | 3 +-- src/map/clif.c | 9 +++------ src/map/guild.c | 3 +-- src/map/log.c | 51 ++++++++++++++++++++++++++++++++------------------- src/map/log.h | 16 +++++++++++++++- src/map/party.c | 3 +-- 9 files changed, 93 insertions(+), 44 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 3615d82e5..19defb83e 100644 --- a/Changelog-Trunk.txt +++ b/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 diff --git a/conf/Changelog.txt b/conf/Changelog.txt index 8a32c7f47..4b8a7844a 100644 --- a/conf/Changelog.txt +++ b/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 diff --git a/conf/log_athena.conf b/conf/log_athena.conf index 0d5378a8f..c3bc2009a 100644 --- a/conf/log_athena.conf +++ b/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 diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 2b2f44278..00d7deb5f 100644 --- a/src/map/atcommand.c +++ b/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 { diff --git a/src/map/clif.c b/src/map/clif.c index 576aaa4d1..b8feb6746 100644 --- a/src/map/clif.c +++ b/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; } diff --git a/src/map/guild.c b/src/map/guild.c index 49d92914e..ec15d8cfb 100644 --- a/src/map/guild.c +++ b/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; } diff --git a/src/map/log.c b/src/map/log.c index cf10fdfd7..20ef57c34 100644 --- a/src/map/log.c +++ b/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 diff --git a/src/map/log.h b/src/map/log.h index 66375ea4a..72804009e 100644 --- a/src/map/log.h +++ b/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]; diff --git a/src/map/party.c b/src/map/party.c index d85221e47..15f1e4794 100644 --- a/src/map/party.c +++ b/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; } -- cgit v1.2.3-70-g09d2