log.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/sql.h" // SQL_INNODB
  5. #include "../common/strlib.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/showmsg.h"
  8. #include "battle.h"
  9. #include "itemdb.h"
  10. #include "log.h"
  11. #include "map.h"
  12. #include "mob.h"
  13. #include "pc.h"
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. /// filters for item logging
  18. typedef enum e_log_filter
  19. {
  20. LOG_FILTER_NONE = 0x000,
  21. LOG_FILTER_ALL = 0x001,
  22. // bits
  23. LOG_FILTER_HEALING = 0x002, // Healing items (0)
  24. LOG_FILTER_ETC_AMMO = 0x004, // Etc Items(3) + Arrows (10)
  25. LOG_FILTER_USABLE = 0x008, // Usable Items(2) + Scrolls, Lures(11) + Usable Cash Items(18)
  26. LOG_FILTER_WEAPON = 0x010, // Weapons(4)
  27. LOG_FILTER_ARMOR = 0x020, // Shields, Armors, Headgears, Accessories, Garments and Shoes(5)
  28. LOG_FILTER_CARD = 0x040, // Cards(6)
  29. LOG_FILTER_PETITEM = 0x080, // Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs)
  30. LOG_FILTER_PRICE = 0x100, // Log expensive items ( >= price_log )
  31. LOG_FILTER_AMOUNT = 0x200, // Log large amount of items ( >= amount_log )
  32. LOG_FILTER_REFINE = 0x400, // Log refined items ( refine >= refine_log ) [not implemented]
  33. LOG_FILTER_CHANCE = 0x800, // Log rare items and Emperium ( drop chance <= rare_log )
  34. }
  35. e_log_filter;
  36. struct Log_Config log_config;
  37. #ifdef SQL_INNODB
  38. // database is using an InnoDB engine so do not use DELAYED
  39. #define LOG_QUERY "INSERT"
  40. #else
  41. // database is using a MyISAM engine so use DELAYED
  42. #define LOG_QUERY "INSERT DELAYED"
  43. #endif
  44. /// obtain log type character for item/zeny logs
  45. static char log_picktype2char(e_log_pick_type type)
  46. {
  47. switch( type )
  48. {
  49. case LOG_TYPE_TRADE: return 'T'; // (T)rade
  50. case LOG_TYPE_VENDING: return 'V'; // (V)ending
  51. case LOG_TYPE_PICKDROP_PLAYER: return 'P'; // (P)player
  52. case LOG_TYPE_PICKDROP_MONSTER: return 'M'; // (M)onster
  53. case LOG_TYPE_NPC: return 'S'; // NPC (S)hop
  54. case LOG_TYPE_SCRIPT: return 'N'; // (N)PC Script
  55. //case LOG_TYPE_STEAL: return 'D'; // Steal/Snatcher
  56. case LOG_TYPE_CONSUME: return 'C'; // (C)onsumed
  57. case LOG_TYPE_PRODUCE: return 'O'; // Pr(O)duced/Ingredients
  58. //case LOG_TYPE_MVP: return 'U'; // MVP Rewards
  59. case LOG_TYPE_COMMAND: return 'A'; // (A)dmin command
  60. case LOG_TYPE_STORAGE: return 'R'; // Sto(R)age
  61. case LOG_TYPE_GSTORAGE: return 'G'; // (G)uild storage
  62. case LOG_TYPE_MAIL: return 'E'; // (E)mail attachment
  63. case LOG_TYPE_AUCTION: return 'I'; // Auct(I)on
  64. case LOG_TYPE_BUYING_STORE: return 'B'; // (B)uying Store
  65. case LOG_TYPE_LOOT: return 'L'; // (L)oot (consumed monster pick/drop)
  66. case LOG_TYPE_OTHER: return 'X'; // Other
  67. }
  68. // should not get here, fallback
  69. ShowDebug("log_picktype2char: Unknown pick type %d.\n", type);
  70. return 'X';
  71. }
  72. /// obtain log type character for chat logs
  73. static char log_chattype2char(e_log_chat_type type)
  74. {
  75. switch( type )
  76. {
  77. case LOG_CHAT_GLOBAL: return 'O'; // Gl(O)bal
  78. case LOG_CHAT_WHISPER: return 'W'; // (W)hisper
  79. case LOG_CHAT_PARTY: return 'P'; // (P)arty
  80. case LOG_CHAT_GUILD: return 'G'; // (G)uild
  81. case LOG_CHAT_MAINCHAT: return 'M'; // (M)ain chat
  82. }
  83. // should not get here, fallback
  84. ShowDebug("log_chattype2char: Unknown chat type %d.\n", type);
  85. return 'O';
  86. }
  87. /// check if this item should be logged according the settings
  88. static bool should_log_item(int nameid, int amount, int refine)
  89. {
  90. int filter = log_config.filter;
  91. struct item_data* id;
  92. if( ( id = itemdb_exists(nameid) ) == NULL )
  93. return false;
  94. if( ( filter&LOG_FILTER_ALL ) ||
  95. ( filter&LOG_FILTER_HEALING && id->type == IT_HEALING ) ||
  96. ( filter&LOG_FILTER_ETC_AMMO && ( id->type == IT_ETC || id->type == IT_AMMO ) ) ||
  97. ( filter&LOG_FILTER_USABLE && ( id->type == IT_USABLE || id->type == IT_CASH ) ) ||
  98. ( filter&LOG_FILTER_WEAPON && id->type == IT_WEAPON ) ||
  99. ( filter&LOG_FILTER_ARMOR && id->type == IT_ARMOR ) ||
  100. ( filter&LOG_FILTER_CARD && id->type == IT_CARD ) ||
  101. ( filter&LOG_FILTER_PETITEM && ( id->type == IT_PETEGG || id->type == IT_PETARMOR ) ) ||
  102. ( filter&LOG_FILTER_PRICE && id->value_buy >= log_config.price_items_log ) ||
  103. ( filter&LOG_FILTER_AMOUNT && abs(amount) >= log_config.amount_items_log ) ||
  104. ( filter&LOG_FILTER_REFINE && refine >= log_config.refine_items_log ) ||
  105. ( filter&LOG_FILTER_CHANCE && ( ( id->maxchance != -1 && id->maxchance <= log_config.rare_items_log ) || id->nameid == ITEMID_EMPERIUM ) )
  106. )
  107. return true;
  108. return false;
  109. }
  110. /// logs items, that summon monsters
  111. void log_branch(struct map_session_data* sd)
  112. {
  113. nullpo_retv(sd);
  114. if( !log_config.branch )
  115. return;
  116. if( log_config.sql_logs )
  117. {
  118. SqlStmt* stmt;
  119. stmt = SqlStmt_Malloc(logmysql_handle);
  120. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
  121. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
  122. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  123. {
  124. SqlStmt_ShowDebug(stmt);
  125. SqlStmt_Free(stmt);
  126. return;
  127. }
  128. SqlStmt_Free(stmt);
  129. }
  130. else
  131. {
  132. char timestring[255];
  133. time_t curtime;
  134. FILE* logfp;
  135. if( ( logfp = fopen(log_config.log_branch, "a") ) == NULL )
  136. return;
  137. time(&curtime);
  138. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  139. fprintf(logfp,"%s - %s[%d:%d]\t%s\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex));
  140. fclose(logfp);
  141. }
  142. }
  143. /// logs item transactions (generic)
  144. void log_pick(int id, int m, e_log_pick_type type, int amount, struct item* itm)
  145. {
  146. nullpo_retv(itm);
  147. if( ( log_config.enable_logs&type ) == 0 )
  148. {// disabled
  149. return;
  150. }
  151. if( !should_log_item(itm->nameid, amount, itm->refine) )
  152. return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus]
  153. if( log_config.sql_logs )
  154. {
  155. if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
  156. log_config.log_pick, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"") )
  157. {
  158. Sql_ShowDebug(logmysql_handle);
  159. return;
  160. }
  161. }
  162. else
  163. {
  164. char timestring[255];
  165. time_t curtime;
  166. FILE* logfp;
  167. if( ( logfp = fopen(log_config.log_pick, "a") ) == NULL )
  168. return;
  169. time(&curtime);
  170. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  171. fprintf(logfp,"%s - %d\t%c\t%d,%d,%d,%d,%d,%d,%d,%s\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"");
  172. fclose(logfp);
  173. }
  174. }
  175. /// logs item transactions (players)
  176. void log_pick_pc(struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm)
  177. {
  178. nullpo_retv(sd);
  179. log_pick(sd->status.char_id, sd->bl.m, type, amount, itm);
  180. }
  181. /// logs item transactions (monsters)
  182. void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm)
  183. {
  184. nullpo_retv(md);
  185. log_pick(md->class_, md->bl.m, type, amount, itm);
  186. }
  187. /// logs zeny transactions
  188. void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount)
  189. {
  190. nullpo_retv(sd);
  191. if( !log_config.zeny || ( log_config.zeny != 1 && abs(amount) < log_config.zeny ) )
  192. return;
  193. if( log_config.sql_logs )
  194. {
  195. if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
  196. log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) )
  197. {
  198. Sql_ShowDebug(logmysql_handle);
  199. return;
  200. }
  201. }
  202. else
  203. {
  204. char timestring[255];
  205. time_t curtime;
  206. FILE* logfp;
  207. if( ( logfp = fopen(log_config.log_zeny, "a") ) == NULL )
  208. return;
  209. time(&curtime);
  210. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  211. fprintf(logfp, "%s - %s[%d]\t%s[%d]\t%d\t\n", timestring, src_sd->status.name, src_sd->status.account_id, sd->status.name, sd->status.account_id, amount);
  212. fclose(logfp);
  213. }
  214. }
  215. /// logs MVP monster rewards
  216. void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp)
  217. {
  218. nullpo_retv(sd);
  219. if( !log_config.mvpdrop )
  220. return;
  221. if( log_config.sql_logs )
  222. {
  223. if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
  224. log_config.log_mvpdrop, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
  225. {
  226. Sql_ShowDebug(logmysql_handle);
  227. return;
  228. }
  229. }
  230. else
  231. {
  232. char timestring[255];
  233. time_t curtime;
  234. FILE* logfp;
  235. if( ( logfp = fopen(log_config.log_mvpdrop,"a") ) == NULL )
  236. return;
  237. time(&curtime);
  238. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  239. fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1]);
  240. fclose(logfp);
  241. }
  242. }
  243. /// logs used GM commands
  244. void log_atcommand(struct map_session_data* sd, int cmdlvl, const char* message)
  245. {
  246. nullpo_retv(sd);
  247. if( cmdlvl < log_config.gm )
  248. return;
  249. if( log_config.sql_logs )
  250. {
  251. SqlStmt* stmt;
  252. stmt = SqlStmt_Malloc(logmysql_handle);
  253. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
  254. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
  255. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
  256. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  257. {
  258. SqlStmt_ShowDebug(stmt);
  259. SqlStmt_Free(stmt);
  260. return;
  261. }
  262. SqlStmt_Free(stmt);
  263. }
  264. else
  265. {
  266. char timestring[255];
  267. time_t curtime;
  268. FILE* logfp;
  269. if( ( logfp = fopen(log_config.log_gm, "a") ) == NULL )
  270. return;
  271. time(&curtime);
  272. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  273. fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
  274. fclose(logfp);
  275. }
  276. }
  277. /// logs messages passed to script command 'logmes'
  278. void log_npc(struct map_session_data* sd, const char* message)
  279. {
  280. nullpo_retv(sd);
  281. if( !log_config.npc )
  282. return;
  283. if( log_config.sql_logs )
  284. {
  285. SqlStmt* stmt;
  286. stmt = SqlStmt_Malloc(logmysql_handle);
  287. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
  288. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
  289. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
  290. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  291. {
  292. SqlStmt_ShowDebug(stmt);
  293. SqlStmt_Free(stmt);
  294. return;
  295. }
  296. SqlStmt_Free(stmt);
  297. }
  298. else
  299. {
  300. char timestring[255];
  301. time_t curtime;
  302. FILE* logfp;
  303. if( ( logfp = fopen(log_config.log_npc, "a") ) == NULL )
  304. return;
  305. time(&curtime);
  306. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  307. fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
  308. fclose(logfp);
  309. }
  310. }
  311. /// logs chat
  312. 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)
  313. {
  314. if( ( log_config.chat&type ) == 0 )
  315. {// disabled
  316. return;
  317. }
  318. if( log_config.log_chat_woe_disable && ( agit_flag || agit2_flag ) )
  319. {// no chat logging during woe
  320. return;
  321. }
  322. if( log_config.sql_logs )
  323. {
  324. SqlStmt* stmt;
  325. stmt = SqlStmt_Malloc(logmysql_handle);
  326. 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, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
  327. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
  328. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
  329. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  330. {
  331. SqlStmt_ShowDebug(stmt);
  332. SqlStmt_Free(stmt);
  333. return;
  334. }
  335. SqlStmt_Free(stmt);
  336. }
  337. else
  338. {
  339. char timestring[255];
  340. time_t curtime;
  341. FILE* logfp;
  342. if( ( logfp = fopen(log_config.log_chat, "a") ) == NULL )
  343. return;
  344. time(&curtime);
  345. strftime(timestring, sizeof(timestring), "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  346. 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);
  347. fclose(logfp);
  348. }
  349. }
  350. void log_set_defaults(void)
  351. {
  352. memset(&log_config, 0, sizeof(log_config));
  353. //LOG FILTER Default values
  354. log_config.refine_items_log = 5; // log refined items, with refine >= +5
  355. log_config.rare_items_log = 100; // log rare items. drop chance <= 1%
  356. log_config.price_items_log = 1000; // 1000z
  357. log_config.amount_items_log = 100;
  358. }
  359. int log_config_read(const char* cfgName)
  360. {
  361. static int count = 0;
  362. char line[1024], w1[1024], w2[1024];
  363. FILE *fp;
  364. if( count++ == 0 )
  365. log_set_defaults();
  366. if( ( fp = fopen(cfgName, "r") ) == NULL )
  367. {
  368. ShowError("Log configuration file not found at: %s\n", cfgName);
  369. return 1;
  370. }
  371. while( fgets(line, sizeof(line), fp) )
  372. {
  373. if( line[0] == '/' && line[1] == '/' )
  374. continue;
  375. if( sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 )
  376. {
  377. if( strcmpi(w1, "enable_logs") == 0 )
  378. log_config.enable_logs = (e_log_pick_type)config_switch(w2);
  379. else if( strcmpi(w1, "sql_logs") == 0 )
  380. log_config.sql_logs = (bool)config_switch(w2);
  381. //start of common filter settings
  382. else if( strcmpi(w1, "rare_items_log") == 0 )
  383. log_config.rare_items_log = atoi(w2);
  384. else if( strcmpi(w1, "refine_items_log") == 0 )
  385. log_config.refine_items_log = atoi(w2);
  386. else if( strcmpi(w1, "price_items_log") == 0 )
  387. log_config.price_items_log = atoi(w2);
  388. else if( strcmpi(w1, "amount_items_log") == 0 )
  389. log_config.amount_items_log = atoi(w2);
  390. //end of common filter settings
  391. else if( strcmpi(w1, "log_branch") == 0 )
  392. log_config.branch = config_switch(w2);
  393. else if( strcmpi(w1, "log_filter") == 0 )
  394. log_config.filter = config_switch(w2);
  395. else if( strcmpi(w1, "log_zeny") == 0 )
  396. log_config.zeny = config_switch(w2);
  397. else if( strcmpi(w1, "log_gm") == 0 )
  398. log_config.gm = config_switch(w2);
  399. else if( strcmpi(w1, "log_npc") == 0 )
  400. log_config.npc = config_switch(w2);
  401. else if( strcmpi(w1, "log_chat") == 0 )
  402. log_config.chat = config_switch(w2);
  403. else if( strcmpi(w1, "log_mvpdrop") == 0 )
  404. log_config.mvpdrop = config_switch(w2);
  405. else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
  406. log_config.log_chat_woe_disable = (bool)config_switch(w2);
  407. else if( strcmpi(w1, "log_branch_db") == 0 )
  408. safestrncpy(log_config.log_branch, w2, sizeof(log_config.log_branch));
  409. else if( strcmpi(w1, "log_pick_db") == 0 )
  410. safestrncpy(log_config.log_pick, w2, sizeof(log_config.log_pick));
  411. else if( strcmpi(w1, "log_zeny_db") == 0 )
  412. safestrncpy(log_config.log_zeny, w2, sizeof(log_config.log_zeny));
  413. else if( strcmpi(w1, "log_mvpdrop_db") == 0 )
  414. safestrncpy(log_config.log_mvpdrop, w2, sizeof(log_config.log_mvpdrop));
  415. else if( strcmpi(w1, "log_gm_db") == 0 )
  416. safestrncpy(log_config.log_gm, w2, sizeof(log_config.log_gm));
  417. else if( strcmpi(w1, "log_npc_db") == 0 )
  418. safestrncpy(log_config.log_npc, w2, sizeof(log_config.log_npc));
  419. else if( strcmpi(w1, "log_chat_db") == 0 )
  420. safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
  421. //support the import command, just like any other config
  422. else if( strcmpi(w1,"import") == 0 )
  423. log_config_read(w2);
  424. }
  425. }
  426. fclose(fp);
  427. if( --count == 0 )
  428. {// report final logging state
  429. const char* target = log_config.sql_logs ? "table" : "file";
  430. if( log_config.enable_logs && log_config.filter )
  431. {
  432. ShowInfo("Logging item transactions to %s '%s'.\n", target, log_config.log_pick);
  433. }
  434. if( log_config.branch )
  435. {
  436. ShowInfo("Logging monster summon item usage to %s '%s'.\n", target, log_config.log_pick);
  437. }
  438. if( log_config.chat )
  439. {
  440. ShowInfo("Logging chat to %s '%s'.\n", target, log_config.log_chat);
  441. }
  442. if( log_config.gm )
  443. {
  444. ShowInfo("Logging gm commands to %s '%s'.\n", target, log_config.log_gm);
  445. }
  446. if( log_config.mvpdrop )
  447. {
  448. ShowInfo("Logging MVP monster rewards to %s '%s'.\n", target, log_config.log_mvpdrop);
  449. }
  450. if( log_config.npc )
  451. {
  452. ShowInfo("Logging 'logmes' messages to %s '%s'.\n", target, log_config.log_npc);
  453. }
  454. if( log_config.zeny )
  455. {
  456. ShowInfo("Logging Zeny transactions to %s '%s'.\n", target, log_config.log_zeny);
  457. }
  458. }
  459. return 0;
  460. }