log.c 18 KB

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