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 --- 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 +-- 6 files changed, 53 insertions(+), 32 deletions(-) (limited to 'src') 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-60-g2f50