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