log.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/strlib.h"
  4. #include "../common/nullpo.h"
  5. #include "../common/showmsg.h"
  6. #include "itemdb.h"
  7. #include "map.h"
  8. #include "log.h"
  9. #include "battle.h"
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. struct Log_Config log_config;
  14. char timestring[255];
  15. time_t curtime;
  16. static int should_log_item(int filter, int nameid, int amount); //log filter check
  17. //FILTER OPTIONS
  18. //0 = Don't log
  19. //1 = Log any item
  20. //Bits: ||
  21. //2 - Healing items (0)
  22. //3 - Etc Items(3) + Arrows (10)
  23. //4 - Usable Items(2) + Scrolls,Lures(11)
  24. //5 - Weapon(4)
  25. //6 - Shields,Armor,Headgears,Accessories,etc(5)
  26. //7 - Cards(6)
  27. //8 - Pet Accessories(8) + Eggs(7) (well, monsters don't drop 'em but we'll use the same system for ALL logs)
  28. //9 - Log expensive items ( >= price_log)
  29. //10 - Log big amount of items ( >= amount_log)
  30. //11 - Log refined items (if their refine >= refine_log )
  31. //12 - Log rare items (if their drop chance <= rare_log )
  32. //check if this item should be logged according the settings
  33. int should_log_item(int filter, int nameid, int amount)
  34. {
  35. struct item_data *item_data;
  36. if ((item_data= itemdb_exists(nameid)) == NULL) return 0;
  37. if ((filter&1) || // Filter = 1, we log any item
  38. (filter&2 && item_data->type == IT_HEALING ) ||
  39. (filter&4 && (item_data->type == IT_ETC || item_data->type == IT_AMMO) ) ||
  40. (filter&8 && item_data->type == IT_USABLE ) ||
  41. (filter&16 && item_data->type == IT_WEAPON ) ||
  42. (filter&32 && item_data->type == IT_ARMOR ) ||
  43. (filter&64 && item_data->type == IT_CARD ) ||
  44. (filter&128 && (item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) ) ||
  45. (filter&256 && item_data->value_buy >= log_config.price_items_log ) || //expensive items
  46. (filter&512 && abs(amount) >= log_config.amount_items_log ) || //big amount of items
  47. (filter&2048 && ((item_data->maxchance <= log_config.rare_items_log) || item_data->nameid == 714) ) //Rare items or Emperium
  48. ) return item_data->nameid;
  49. return 0;
  50. }
  51. int log_branch(struct map_session_data *sd)
  52. {
  53. if(!log_config.enable_logs)
  54. return 0;
  55. nullpo_retr(0, sd);
  56. #ifndef TXT_ONLY
  57. if(log_config.sql_logs > 0)
  58. {
  59. SqlStmt* stmt;
  60. stmt = SqlStmt_Malloc(logmysql_handle);
  61. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", log_config.log_branch_db, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex))
  62. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
  63. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  64. {
  65. SqlStmt_ShowDebug(stmt);
  66. SqlStmt_Free(stmt);
  67. return 0;
  68. }
  69. SqlStmt_Free(stmt);
  70. }
  71. else
  72. #endif
  73. {
  74. FILE* logfp;
  75. if((logfp = fopen(log_config.log_branch, "a+")) == NULL)
  76. return 0;
  77. time(&curtime);
  78. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  79. 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));
  80. fclose(logfp);
  81. }
  82. return 1;
  83. }
  84. int log_pick_pc(struct map_session_data *sd, const char *type, int nameid, int amount, struct item *itm)
  85. {
  86. nullpo_retr(0, sd);
  87. if (!should_log_item(log_config.filter, nameid, amount))
  88. return 0; //we skip logging this item set - it doesn't meet our logging conditions [Lupus]
  89. #ifndef TXT_ONLY
  90. if(log_config.sql_logs > 0)
  91. {
  92. if (itm == NULL) {
  93. //We log common item
  94. if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')",
  95. log_config.log_pick_db, sd->status.char_id, type, nameid, amount, mapindex_id2name(sd->mapindex)) )
  96. {
  97. Sql_ShowDebug(logmysql_handle);
  98. return 0;
  99. }
  100. } else {
  101. //We log Extended item
  102. if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
  103. log_config.log_pick_db, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapindex_id2name(sd->mapindex)) )
  104. {
  105. Sql_ShowDebug(logmysql_handle);
  106. return 0;
  107. }
  108. }
  109. }
  110. else
  111. #endif
  112. {
  113. FILE* logfp;
  114. if((logfp = fopen(log_config.log_pick, "a+")) == NULL)
  115. return 0;
  116. time(&curtime);
  117. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  118. if (itm == NULL) {
  119. //We log common item
  120. fprintf(logfp,"%s - %d\t%s\t%d,%d,%s\n",
  121. timestring, sd->status.char_id, type, nameid, amount, mapindex_id2name(sd->mapindex));
  122. } else {
  123. //We log Extended item
  124. fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s\n",
  125. timestring, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapindex_id2name(sd->mapindex));
  126. }
  127. fclose(logfp);
  128. }
  129. return 1; //Logged
  130. }
  131. //Mob picked item
  132. int log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount, struct item *itm)
  133. {
  134. char* mapname;
  135. nullpo_retr(0, md);
  136. if (!should_log_item(log_config.filter, nameid, amount))
  137. return 0; //we skip logging this item set - it doesn't meet our logging conditions [Lupus]
  138. //either PLAYER or MOB (here we get map name and objects ID)
  139. mapname = map[md->bl.m].name;
  140. if(mapname==NULL)
  141. mapname="";
  142. #ifndef TXT_ONLY
  143. if(log_config.sql_logs > 0)
  144. {
  145. if (itm==NULL) {
  146. //We log common item
  147. if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')",
  148. log_config.log_pick_db, md->class_, type, nameid, amount, mapname) )
  149. {
  150. Sql_ShowDebug(logmysql_handle);
  151. return 0;
  152. }
  153. } else {
  154. //We log Extended item
  155. if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
  156. log_config.log_pick_db, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname) )
  157. {
  158. Sql_ShowDebug(logmysql_handle);
  159. return 0;
  160. }
  161. }
  162. }
  163. else
  164. #endif
  165. {
  166. FILE *logfp;
  167. if((logfp=fopen(log_config.log_pick,"a+")) == NULL)
  168. return 0;
  169. time(&curtime);
  170. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  171. if (itm==NULL) {
  172. //We log common item
  173. fprintf(logfp,"%s - %d\t%s\t%d,%d,%s\n",
  174. timestring, md->class_, type, nameid, amount, mapname);
  175. } else {
  176. //We log Extended item
  177. fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s\n",
  178. timestring, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname);
  179. }
  180. fclose(logfp);
  181. }
  182. return 1; //Logged
  183. }
  184. int log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount)
  185. {
  186. if(!log_config.enable_logs || (log_config.zeny != 1 && abs(amount) < log_config.zeny))
  187. return 0;
  188. nullpo_retr(0, sd);
  189. #ifndef TXT_ONLY
  190. if(log_config.sql_logs > 0)
  191. {
  192. if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%s')",
  193. log_config.log_zeny_db, sd->status.char_id, src_sd->status.char_id, type, amount, mapindex_id2name(sd->mapindex)) )
  194. {
  195. Sql_ShowDebug(logmysql_handle);
  196. return 0;
  197. }
  198. }
  199. else
  200. #endif
  201. {
  202. FILE* logfp;
  203. if((logfp=fopen(log_config.log_zeny,"a+")) == NULL)
  204. return 0;
  205. time(&curtime);
  206. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  207. 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);
  208. fclose(logfp);
  209. }
  210. return 1;
  211. }
  212. int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
  213. {
  214. if(!log_config.enable_logs)
  215. return 0;
  216. nullpo_retr(0, sd);
  217. #ifndef TXT_ONLY
  218. if(log_config.sql_logs > 0)
  219. {
  220. if (SQL_ERROR == Sql_Query(logmysql_handle, "INSERT DELAYED INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
  221. log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex)) )
  222. {
  223. Sql_ShowDebug(logmysql_handle);
  224. return 0;
  225. }
  226. }
  227. else
  228. #endif
  229. {
  230. FILE* logfp;
  231. if((logfp=fopen(log_config.log_mvpdrop,"a+")) == NULL)
  232. return 0;
  233. time(&curtime);
  234. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  235. 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]);
  236. fclose(logfp);
  237. }
  238. return 1;
  239. }
  240. int log_atcommand(struct map_session_data* sd, const char* message)
  241. {
  242. if(!log_config.enable_logs)
  243. return 0;
  244. nullpo_retr(0, sd);
  245. #ifndef TXT_ONLY
  246. if(log_config.sql_logs > 0)
  247. {
  248. SqlStmt* stmt;
  249. if (strlen(message) > CHAT_SIZE) {
  250. if (battle_config.error_log)
  251. ShowError("log atcommand: Received message too long from player %s (%d:%d)!\n", sd->status.name, sd->status.account_id, sd->status.char_id);
  252. return 0;
  253. }
  254. stmt = SqlStmt_Malloc(logmysql_handle);
  255. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_gm_db, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex), message)
  256. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
  257. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
  258. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  259. {
  260. SqlStmt_ShowDebug(stmt);
  261. SqlStmt_Free(stmt);
  262. return 0;
  263. }
  264. SqlStmt_Free(stmt);
  265. }
  266. else
  267. #endif
  268. {
  269. FILE* logfp;
  270. if((logfp = fopen(log_config.log_gm, "a+")) == NULL)
  271. return 0;
  272. time(&curtime);
  273. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  274. fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
  275. fclose(logfp);
  276. }
  277. return 1;
  278. }
  279. int log_npc(struct map_session_data* sd, const char* message)
  280. {
  281. if(!log_config.enable_logs)
  282. return 0;
  283. nullpo_retr(0, sd);
  284. #ifndef TXT_ONLY
  285. if(log_config.sql_logs > 0)
  286. {
  287. SqlStmt* stmt;
  288. stmt = SqlStmt_Malloc(logmysql_handle);
  289. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", log_config.log_npc_db, sd->status.account_id, sd->status.char_id, sd->status.name, mapindex_id2name(sd->mapindex), message)
  290. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
  291. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
  292. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  293. {
  294. SqlStmt_ShowDebug(stmt);
  295. SqlStmt_Free(stmt);
  296. return 0;
  297. }
  298. SqlStmt_Free(stmt);
  299. }
  300. else
  301. #endif
  302. {
  303. FILE* logfp;
  304. if((logfp = fopen(log_config.log_npc, "a+")) == NULL)
  305. return 0;
  306. time(&curtime);
  307. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  308. fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
  309. fclose(logfp);
  310. }
  311. return 1;
  312. }
  313. int 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)
  314. {
  315. // Log CHAT (Global, Whisper, Party, Guild, Main chat)
  316. // LOGGING FILTERS [Lupus]
  317. // =============================================================
  318. // 0 = Don't log at all
  319. // 1 = Log EVERYTHING!
  320. // Advanced Filter Bits: ||
  321. // 02 - Log Global messages
  322. // 04 - Log Whisper messages
  323. // 08 - Log Party messages
  324. // 16 - Log Guild messages
  325. // 32 - Log Main chat messages
  326. // 64 - Don't log anything when WOE is on
  327. //Check ON/OFF
  328. if(log_config.chat <= 0)
  329. return 0; //Deactivated
  330. #ifndef TXT_ONLY
  331. if(log_config.sql_logs > 0)
  332. {
  333. SqlStmt* stmt;
  334. if (strlen(message) > CHAT_SIZE) {
  335. if (battle_config.error_log)
  336. ShowError("log chat: Received message too long from type %d (%d:%d)!\n", type_id, src_accid, src_charid);
  337. return 0;
  338. }
  339. stmt = SqlStmt_Malloc(logmysql_handle);
  340. if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT DELAYED 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)
  341. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
  342. || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE))
  343. || SQL_SUCCESS != SqlStmt_Execute(stmt) )
  344. {
  345. SqlStmt_ShowDebug(stmt);
  346. SqlStmt_Free(stmt);
  347. return 0;
  348. }
  349. SqlStmt_Free(stmt);
  350. }
  351. else
  352. #endif
  353. {
  354. FILE* logfp;
  355. if((logfp = fopen(log_config.log_chat, "a+")) == NULL)
  356. return 0;
  357. time(&curtime);
  358. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  359. 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);
  360. fclose(logfp);
  361. }
  362. return 1;
  363. }
  364. void log_set_defaults(void)
  365. {
  366. memset(&log_config, 0, sizeof(log_config));
  367. //LOG FILTER Default values
  368. log_config.refine_items_log = 5; //log refined items, with refine >= +7
  369. log_config.rare_items_log = 100; //log rare items. drop chance <= 1%
  370. log_config.price_items_log = 1000; //1000z
  371. log_config.amount_items_log = 100;
  372. }
  373. int log_config_read(char *cfgName)
  374. {
  375. static int count = 0;
  376. char line[1024], w1[1024], w2[1024];
  377. FILE *fp;
  378. if ((count++) == 0)
  379. log_set_defaults();
  380. if((fp = fopen(cfgName, "r")) == NULL)
  381. {
  382. ShowError("Log configuration file not found at: %s\n", cfgName);
  383. return 1;
  384. }
  385. while(fgets(line, sizeof(line), fp))
  386. {
  387. if(line[0] == '/' && line[1] == '/')
  388. continue;
  389. if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
  390. {
  391. if(strcmpi(w1,"enable_logs") == 0) {
  392. log_config.enable_logs = (atoi(w2));
  393. if (log_config.enable_logs&1) //Log everything.
  394. log_config.enable_logs=0xFFFFFFFF;
  395. } else if(strcmpi(w1,"sql_logs") == 0) {
  396. log_config.sql_logs = (atoi(w2));
  397. //start of common filter settings
  398. } else if(strcmpi(w1,"rare_items_log") == 0) {
  399. log_config.rare_items_log = (atoi(w2));
  400. } else if(strcmpi(w1,"refine_items_log") == 0) {
  401. log_config.refine_items_log = (atoi(w2));
  402. } else if(strcmpi(w1,"price_items_log") == 0) {
  403. log_config.price_items_log = (atoi(w2));
  404. } else if(strcmpi(w1,"amount_items_log") == 0) {
  405. log_config.amount_items_log = (atoi(w2));
  406. //end of common filter settings
  407. } else if(strcmpi(w1,"log_branch") == 0) {
  408. log_config.branch = (atoi(w2));
  409. } else if(strcmpi(w1,"log_filter") == 0) {
  410. log_config.filter = (atoi(w2));
  411. } else if(strcmpi(w1,"log_zeny") == 0) {
  412. log_config.zeny = (atoi(w2));
  413. } else if(strcmpi(w1,"log_gm") == 0) {
  414. log_config.gm = (atoi(w2));
  415. } else if(strcmpi(w1,"log_npc") == 0) {
  416. log_config.npc = (atoi(w2));
  417. } else if(strcmpi(w1, "log_chat") == 0) {
  418. log_config.chat = (atoi(w2));
  419. } else if(strcmpi(w1,"log_mvpdrop") == 0) {
  420. log_config.mvpdrop = (atoi(w2));
  421. }
  422. #ifndef TXT_ONLY
  423. else if(strcmpi(w1, "log_branch_db") == 0) {
  424. strcpy(log_config.log_branch_db, w2);
  425. if(log_config.branch == 1)
  426. ShowNotice("Logging Dead Branch Usage to table `%s`\n", w2);
  427. } else if(strcmpi(w1, "log_pick_db") == 0) {
  428. strcpy(log_config.log_pick_db, w2);
  429. if(log_config.filter)
  430. ShowNotice("Logging Item Picks to table `%s`\n", w2);
  431. } else if(strcmpi(w1, "log_zeny_db") == 0) {
  432. strcpy(log_config.log_zeny_db, w2);
  433. if(log_config.zeny == 1)
  434. ShowNotice("Logging Zeny to table `%s`\n", w2);
  435. } else if(strcmpi(w1, "log_mvpdrop_db") == 0) {
  436. strcpy(log_config.log_mvpdrop_db, w2);
  437. if(log_config.mvpdrop == 1)
  438. ShowNotice("Logging MVP Drops to table `%s`\n", w2);
  439. } else if(strcmpi(w1, "log_gm_db") == 0) {
  440. strcpy(log_config.log_gm_db, w2);
  441. if(log_config.gm > 0)
  442. ShowNotice("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
  443. } else if(strcmpi(w1, "log_npc_db") == 0) {
  444. strcpy(log_config.log_npc_db, w2);
  445. if(log_config.npc > 0)
  446. ShowNotice("Logging NPC 'logmes' to table `%s`\n", w2);
  447. } else if(strcmpi(w1, "log_chat_db") == 0) {
  448. strcpy(log_config.log_chat_db, w2);
  449. if(log_config.chat > 0)
  450. ShowNotice("Logging CHAT to table `%s`\n", w2);
  451. }
  452. #endif
  453. else if(strcmpi(w1, "log_branch_file") == 0) {
  454. strcpy(log_config.log_branch, w2);
  455. if(log_config.branch > 0 && log_config.sql_logs < 1)
  456. ShowNotice("Logging Dead Branch Usage to file `%s`.txt\n", w2);
  457. } else if(strcmpi(w1, "log_pick_file") == 0) {
  458. strcpy(log_config.log_pick, w2);
  459. if(log_config.filter > 0 && log_config.sql_logs < 1)
  460. ShowNotice("Logging Item Picks to file `%s`.txt\n", w2);
  461. } else if(strcmpi(w1, "log_zeny_file") == 0) {
  462. strcpy(log_config.log_zeny, w2);
  463. if(log_config.zeny > 0 && log_config.sql_logs < 1)
  464. ShowNotice("Logging Zeny to file `%s`.txt\n", w2);
  465. } else if(strcmpi(w1, "log_mvpdrop_file") == 0) {
  466. strcpy(log_config.log_mvpdrop, w2);
  467. if(log_config.mvpdrop > 0 && log_config.sql_logs < 1)
  468. ShowNotice("Logging MVP Drops to file `%s`.txt\n", w2);
  469. } else if(strcmpi(w1, "log_gm_file") == 0) {
  470. strcpy(log_config.log_gm, w2);
  471. if(log_config.gm > 0 && log_config.sql_logs < 1)
  472. ShowNotice("Logging GM Level %d Commands to file `%s`.txt\n", log_config.gm, w2);
  473. } else if(strcmpi(w1, "log_npc_file") == 0) {
  474. strcpy(log_config.log_npc, w2);
  475. if(log_config.npc > 0 && log_config.sql_logs < 1)
  476. ShowNotice("Logging NPC 'logmes' to file `%s`.txt\n", w2);
  477. } else if(strcmpi(w1, "log_chat_file") == 0) {
  478. strcpy(log_config.log_chat, w2);
  479. if(log_config.chat > 0 && log_config.sql_logs < 1)
  480. ShowNotice("Logging CHAT to file `%s`.txt\n", w2);
  481. //support the import command, just like any other config
  482. } else if(strcmpi(w1,"import") == 0) {
  483. log_config_read(w2);
  484. }
  485. }
  486. }
  487. fclose(fp);
  488. return 0;
  489. }