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. // Logging functions by Azndragon & Codemaster
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include "../common/strlib.h"
  8. #include "../common/nullpo.h"
  9. #include "../common/showmsg.h"
  10. #include "itemdb.h"
  11. #include "map.h"
  12. #include "log.h"
  13. #include "battle.h"
  14. struct Log_Config log_config;
  15. char timestring[255];
  16. time_t curtime;
  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. #ifndef TXT_ONLY
  54. char t_name[NAME_LENGTH*2];
  55. #endif
  56. FILE *logfp;
  57. if(!log_config.enable_logs)
  58. return 0;
  59. nullpo_retr(0, sd);
  60. #ifndef TXT_ONLY
  61. if(log_config.sql_logs > 0)
  62. {
  63. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%s')",
  64. log_config.log_branch_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex));
  65. if(mysql_query(&logmysql_handle, tmp_sql))
  66. {
  67. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  68. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  69. return 0;
  70. }
  71. return 1;
  72. }
  73. #endif
  74. if((logfp=fopen(log_config.log_branch,"a+")) == NULL)
  75. return 0;
  76. time(&curtime);
  77. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  78. fprintf(logfp,"%s - %s[%d:%d]\t%s%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex), RETCODE);
  79. fclose(logfp);
  80. return 1;
  81. }
  82. int log_pick_pc(struct map_session_data *sd, const char *type, int nameid, int amount, struct item *itm)
  83. {
  84. FILE *logfp;
  85. char *mapname;
  86. nullpo_retr(0, sd);
  87. //Should we log this item? [Lupus]
  88. if (!should_log_item(log_config.filter,nameid, amount))
  89. return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
  90. mapname = (char*)mapindex_id2name(sd->mapindex);
  91. if(mapname==NULL)
  92. mapname="";
  93. #ifndef TXT_ONLY
  94. if(log_config.sql_logs > 0)
  95. {
  96. if (itm==NULL) {
  97. //We log common item
  98. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')",
  99. log_config.log_pick_db, sd->status.char_id, type, nameid, amount, mapname);
  100. } else {
  101. //We log Extended item
  102. sprintf(tmp_sql, "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], mapname);
  104. }
  105. if(mysql_query(&logmysql_handle, tmp_sql))
  106. {
  107. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  108. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  109. return 0;
  110. }
  111. return 1;
  112. }
  113. #endif
  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%s",
  121. timestring, sd->status.char_id, type, nameid, amount, mapname, RETCODE);
  122. } else {
  123. //We log Extended item
  124. fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s%s",
  125. timestring, sd->status.char_id, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname, RETCODE);
  126. }
  127. fclose(logfp);
  128. return 1; //Logged
  129. }
  130. //Mob picked item
  131. int log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount, struct item *itm)
  132. {
  133. FILE *logfp;
  134. char *mapname;
  135. nullpo_retr(0, md);
  136. //Should we log this item? [Lupus]
  137. if (!should_log_item(log_config.filter,nameid, amount))
  138. return 0; //we skip logging this items set - they doesn't met our logging conditions [Lupus]
  139. //either PLAYER or MOB (here we get map name and objects ID)
  140. mapname = map[md->bl.m].name;
  141. if(mapname==NULL)
  142. mapname="";
  143. #ifndef TXT_ONLY
  144. if(log_config.sql_logs > 0)
  145. {
  146. if (itm==NULL) {
  147. //We log common item
  148. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `map`) VALUES (NOW(), '%d', '%s', '%d', '%d', '%s')",
  149. log_config.log_pick_db, md->class_, type, nameid, amount, mapname);
  150. } else {
  151. //We log Extended item
  152. sprintf(tmp_sql, "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')",
  153. 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);
  154. }
  155. if(mysql_query(&logmysql_handle, tmp_sql))
  156. {
  157. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  158. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  159. return 0;
  160. }
  161. return 1;
  162. }
  163. #endif
  164. if((logfp=fopen(log_config.log_pick,"a+")) == NULL)
  165. return 0;
  166. time(&curtime);
  167. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  168. if (itm==NULL) {
  169. //We log common item
  170. fprintf(logfp,"%s - %d\t%s\t%d,%d,%s%s",
  171. timestring, md->class_, type, nameid, amount, mapname, RETCODE);
  172. } else {
  173. //We log Extended item
  174. fprintf(logfp,"%s - %d\t%s\t%d,%d,%d,%d,%d,%d,%d,%s%s",
  175. timestring, md->class_, type, itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], mapname, RETCODE);
  176. }
  177. fclose(logfp);
  178. return 1; //Logged
  179. }
  180. int log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount)
  181. {
  182. // FILE *logfp;
  183. if(!log_config.enable_logs || (log_config.zeny!=1 && abs(amount)<log_config.zeny))
  184. return 0;
  185. nullpo_retr(0, sd);
  186. #ifndef TXT_ONLY
  187. if(log_config.sql_logs > 0)
  188. {
  189. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%s', '%d', '%s')",
  190. log_config.log_zeny_db, sd->status.char_id, src_sd->status.char_id, type, amount, mapindex_id2name(sd->mapindex));
  191. if(mysql_query(&logmysql_handle, tmp_sql))
  192. {
  193. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  194. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  195. return 0;
  196. }
  197. return 1;
  198. }
  199. #endif
  200. // if((logfp=fopen(log_config.log_zeny,"a+")) == NULL)
  201. // return 0;
  202. // time(&curtime);
  203. // strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  204. // fprintf(logfp,"%s - %s[%d]\t%s[%d]\t%d\t%s", timestring, sd->status.name, sd->status.account_id, target_sd->status.name, target_sd->status.account_id, sd->deal.zeny, RETCODE);
  205. // fclose(logfp);
  206. // return 1;
  207. return 0;
  208. }
  209. int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp)
  210. {
  211. FILE *logfp;
  212. if(!log_config.enable_logs)
  213. return 0;
  214. nullpo_retr(0, sd);
  215. #ifndef TXT_ONLY
  216. if(log_config.sql_logs > 0)
  217. {
  218. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ", log_config.log_mvpdrop_db, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], mapindex_id2name(sd->mapindex));
  219. if(mysql_query(&logmysql_handle, tmp_sql))
  220. {
  221. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  222. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  223. return 0;
  224. }
  225. return 1;
  226. }
  227. #endif
  228. if((logfp=fopen(log_config.log_mvpdrop,"a+")) == NULL)
  229. return 0;
  230. time(&curtime);
  231. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  232. fprintf(logfp,"%s - %s[%d:%d]\t%d\t%d,%d%s", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, log_mvp[0], log_mvp[1], RETCODE);
  233. fclose(logfp);
  234. return 0;
  235. }
  236. int log_atcommand(struct map_session_data *sd, const char *message)
  237. {
  238. FILE *logfp;
  239. #ifndef TXT_ONLY
  240. char t_name[NAME_LENGTH*2];
  241. char t_msg[CHAT_SIZE*2+1]; //These are the contents of an @ call, so there shouldn't be overflow danger here?
  242. #endif
  243. if(!log_config.enable_logs)
  244. return 0;
  245. nullpo_retr(0, sd);
  246. #ifndef TXT_ONLY
  247. if(log_config.sql_logs > 0)
  248. {
  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",
  252. sd->status.name, sd->status.account_id, sd->status.char_id);
  253. return 0;
  254. }
  255. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ",
  256. log_config.log_gm_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex), jstrescapecpy(t_msg, (char *)message));
  257. if(mysql_query(&logmysql_handle, tmp_sql))
  258. {
  259. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  260. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  261. return 0;
  262. }
  263. return 1;
  264. }
  265. #endif
  266. if((logfp=fopen(log_config.log_gm,"a+")) == NULL)
  267. return 0;
  268. time(&curtime);
  269. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  270. fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
  271. fclose(logfp);
  272. return 1;
  273. }
  274. int log_npc(struct map_session_data *sd, const char *message)
  275. { //[Lupus]
  276. FILE *logfp;
  277. #ifndef TXT_ONLY
  278. char t_name[NAME_LENGTH*2];
  279. char t_msg[255+1]; //it's 255 chars MAX.
  280. #endif
  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. sprintf(tmp_sql, "INSERT DELAYED INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES(NOW(), '%d', '%d', '%s', '%s', '%s') ",
  288. log_config.log_npc_db, sd->status.account_id, sd->status.char_id, jstrescapecpy(t_name, sd->status.name), mapindex_id2name(sd->mapindex), jstrescapecpy(t_msg, (char *)message));
  289. if(mysql_query(&logmysql_handle, tmp_sql))
  290. {
  291. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  292. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  293. return 0;
  294. }
  295. return 1;
  296. }
  297. #endif
  298. if((logfp=fopen(log_config.log_npc,"a+")) == NULL)
  299. return 0;
  300. time(&curtime);
  301. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  302. fprintf(logfp,"%s - %s[%d]: %s%s",timestring,sd->status.name,sd->status.account_id,message,RETCODE);
  303. fclose(logfp);
  304. return 1;
  305. }
  306. 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)
  307. {
  308. // Log CHAT (Global, Whisper, Party, Guild, Main chat)
  309. // LOGGING FILTERS [Lupus]
  310. //=============================================================
  311. //00 = Don't log at all
  312. //Advanced Filter Bits: ||
  313. //01 - Log Global messages
  314. //02 - Log Whisper messages
  315. //04 - Log Party messages
  316. //08 - Log Guild messages
  317. //16 - Log Main chat messages
  318. //32 - Don't log anything when WOE is on
  319. FILE *logfp;
  320. #ifndef TXT_ONLY
  321. char t_charname[NAME_LENGTH*2];
  322. char t_msg[CHAT_SIZE*2+1]; //Chat line fully escaped, with an extra space just in case.
  323. #endif
  324. //Check ON/OFF
  325. if(log_config.chat <= 0)
  326. return 0; //Deactivated
  327. #ifndef TXT_ONLY
  328. if(log_config.sql_logs > 0){
  329. if (strlen(message) > CHAT_SIZE) {
  330. if (battle_config.error_log)
  331. ShowError("log chat: Received message too long from type %d (%d:%d)!\n",
  332. type_id, src_accid, src_charid);
  333. return 0;
  334. }
  335. sprintf(tmp_sql, "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', '%s', '%s')",
  336. log_config.log_chat_db, type, type_id, src_charid, src_accid, map, x, y, jstrescapecpy(t_charname, dst_charname), jstrescapecpy(t_msg, message));
  337. if(mysql_query(&logmysql_handle, tmp_sql)){
  338. ShowSQL("DB error - %s\n",mysql_error(&logmysql_handle));
  339. ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
  340. return 0;
  341. }
  342. return 1;
  343. }
  344. #endif
  345. if((logfp = fopen(log_config.log_chat, "a+")) == NULL)
  346. return 0;
  347. time(&curtime);
  348. strftime(timestring, 254, "%m/%d/%Y %H:%M:%S", localtime(&curtime));
  349. fprintf(logfp, "%s - %s,%d,%d,%d,%s,%d,%d,%s,%s%s",
  350. timestring, type, type_id, src_charid, src_accid, map, x, y, dst_charname, message, RETCODE);
  351. fclose(logfp);
  352. return 1;
  353. }
  354. void log_set_defaults(void)
  355. {
  356. memset(&log_config, 0, sizeof(log_config));
  357. //LOG FILTER Default values
  358. log_config.refine_items_log = 5; //log refined items, with refine >= +7
  359. log_config.rare_items_log = 100; //log rare items. drop chance <= 1%
  360. log_config.price_items_log = 1000; //1000z
  361. log_config.amount_items_log = 100;
  362. }
  363. int log_config_read(char *cfgName)
  364. {
  365. static int count = 0;
  366. char line[1024], w1[1024], w2[1024];
  367. FILE *fp;
  368. if ((count++) == 0)
  369. log_set_defaults();
  370. if((fp = fopen(cfgName, "r")) == NULL)
  371. {
  372. ShowError("Log configuration file not found at: %s\n", cfgName);
  373. return 1;
  374. }
  375. while(fgets(line, sizeof(line) -1, fp))
  376. {
  377. if(line[0] == '/' && line[1] == '/')
  378. continue;
  379. if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2)
  380. {
  381. if(strcmpi(w1,"enable_logs") == 0) {
  382. log_config.enable_logs = (atoi(w2));
  383. if (log_config.enable_logs&1) //Log everything.
  384. log_config.enable_logs=0xFFFFFFFF;
  385. } else if(strcmpi(w1,"sql_logs") == 0) {
  386. log_config.sql_logs = (atoi(w2));
  387. //start of common filter settings
  388. } else if(strcmpi(w1,"rare_items_log") == 0) {
  389. log_config.rare_items_log = (atoi(w2));
  390. } else if(strcmpi(w1,"refine_items_log") == 0) {
  391. log_config.refine_items_log = (atoi(w2));
  392. } else if(strcmpi(w1,"price_items_log") == 0) {
  393. log_config.price_items_log = (atoi(w2));
  394. } else if(strcmpi(w1,"amount_items_log") == 0) {
  395. log_config.amount_items_log = (atoi(w2));
  396. //end of common filter settings
  397. } else if(strcmpi(w1,"log_branch") == 0) {
  398. log_config.branch = (atoi(w2));
  399. } else if(strcmpi(w1,"log_filter") == 0) {
  400. log_config.filter = (atoi(w2));
  401. } else if(strcmpi(w1,"log_zeny") == 0) {
  402. log_config.zeny = (atoi(w2));
  403. } else if(strcmpi(w1,"log_gm") == 0) {
  404. log_config.gm = (atoi(w2));
  405. } else if(strcmpi(w1,"log_npc") == 0) {
  406. log_config.npc = (atoi(w2));
  407. } else if(strcmpi(w1, "log_chat") == 0) {
  408. log_config.chat = (atoi(w2));
  409. } else if(strcmpi(w1,"log_mvpdrop") == 0) {
  410. log_config.mvpdrop = (atoi(w2));
  411. }
  412. #ifndef TXT_ONLY
  413. else if(strcmpi(w1, "log_branch_db") == 0) {
  414. strcpy(log_config.log_branch_db, w2);
  415. if(log_config.branch == 1)
  416. ShowNotice("Logging Dead Branch Usage to table `%s`\n", w2);
  417. } else if(strcmpi(w1, "log_pick_db") == 0) {
  418. strcpy(log_config.log_pick_db, w2);
  419. if(log_config.filter)
  420. ShowNotice("Logging Item Picks to table `%s`\n", w2);
  421. } else if(strcmpi(w1, "log_zeny_db") == 0) {
  422. strcpy(log_config.log_zeny_db, w2);
  423. if(log_config.zeny == 1)
  424. ShowNotice("Logging Zeny to table `%s`\n", w2);
  425. } else if(strcmpi(w1, "log_mvpdrop_db") == 0) {
  426. strcpy(log_config.log_mvpdrop_db, w2);
  427. if(log_config.mvpdrop == 1)
  428. ShowNotice("Logging MVP Drops to table `%s`\n", w2);
  429. } else if(strcmpi(w1, "log_gm_db") == 0) {
  430. strcpy(log_config.log_gm_db, w2);
  431. if(log_config.gm > 0)
  432. ShowNotice("Logging GM Level %d Commands to table `%s`\n", log_config.gm, w2);
  433. } else if(strcmpi(w1, "log_npc_db") == 0) {
  434. strcpy(log_config.log_npc_db, w2);
  435. if(log_config.npc > 0)
  436. ShowNotice("Logging NPC 'logmes' to table `%s`\n", w2);
  437. } else if(strcmpi(w1, "log_chat_db") == 0) {
  438. strcpy(log_config.log_chat_db, w2);
  439. if(log_config.chat > 0)
  440. ShowNotice("Logging CHAT to table `%s`\n", w2);
  441. }
  442. #endif
  443. else if(strcmpi(w1, "log_branch_file") == 0) {
  444. strcpy(log_config.log_branch, w2);
  445. if(log_config.branch > 0 && log_config.sql_logs < 1)
  446. ShowNotice("Logging Dead Branch Usage to file `%s`.txt\n", w2);
  447. } else if(strcmpi(w1, "log_pick_file") == 0) {
  448. strcpy(log_config.log_pick, w2);
  449. if(log_config.filter > 0 && log_config.sql_logs < 1)
  450. ShowNotice("Logging Item Picks to file `%s`.txt\n", w2);
  451. } else if(strcmpi(w1, "log_zeny_file") == 0) {
  452. strcpy(log_config.log_zeny, w2);
  453. if(log_config.zeny > 0 && log_config.sql_logs < 1)
  454. ShowNotice("Logging Zeny to file `%s`.txt\n", w2);
  455. } else if(strcmpi(w1, "log_mvpdrop_file") == 0) {
  456. strcpy(log_config.log_mvpdrop, w2);
  457. if(log_config.mvpdrop > 0 && log_config.sql_logs < 1)
  458. ShowNotice("Logging MVP Drops to file `%s`.txt\n", w2);
  459. } else if(strcmpi(w1, "log_gm_file") == 0) {
  460. strcpy(log_config.log_gm, w2);
  461. if(log_config.gm > 0 && log_config.sql_logs < 1)
  462. ShowNotice("Logging GM Level %d Commands to file `%s`.txt\n", log_config.gm, w2);
  463. } else if(strcmpi(w1, "log_npc_file") == 0) {
  464. strcpy(log_config.log_npc, w2);
  465. if(log_config.npc > 0 && log_config.sql_logs < 1)
  466. ShowNotice("Logging NPC 'logmes' to file `%s`.txt\n", w2);
  467. } else if(strcmpi(w1, "log_chat_file") == 0) {
  468. strcpy(log_config.log_chat, w2);
  469. if(log_config.chat > 0 && log_config.sql_logs < 1)
  470. ShowNotice("Logging CHAT to file `%s`.txt\n", w2);
  471. //support the import command, just like any other config
  472. } else if(strcmpi(w1,"import") == 0) {
  473. log_config_read(w2);
  474. }
  475. }
  476. }
  477. fclose(fp);
  478. return 0;
  479. }