|
@@ -9,8 +9,10 @@
|
|
#include "map.h"
|
|
#include "map.h"
|
|
#include "battle.h"
|
|
#include "battle.h"
|
|
#include "itemdb.h"
|
|
#include "itemdb.h"
|
|
|
|
+#include "homunculus.h"
|
|
#include "log.h"
|
|
#include "log.h"
|
|
#include "mob.h"
|
|
#include "mob.h"
|
|
|
|
+#include "pet.h"
|
|
#include "pc.h"
|
|
#include "pc.h"
|
|
|
|
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
@@ -116,6 +118,18 @@ static char log_cashtype2char( e_log_cash_type type ){
|
|
return 'O';
|
|
return 'O';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static char log_feedingtype2char(e_log_feeding_type type) {
|
|
|
|
+ switch(type) {
|
|
|
|
+ case LOG_FEED_HOMUNCULUS:
|
|
|
|
+ return 'H';
|
|
|
|
+ case LOG_FEED_PET:
|
|
|
|
+ return 'P';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ShowDebug("log_feedingtype2char: Unknown feeding type %d.\n", type);
|
|
|
|
+ return 'O';
|
|
|
|
+}
|
|
|
|
+
|
|
/// check if this item should be logged according the settings
|
|
/// check if this item should be logged according the settings
|
|
static bool should_log_item(unsigned short nameid, int amount, int refine)
|
|
static bool should_log_item(unsigned short nameid, int amount, int refine)
|
|
{
|
|
{
|
|
@@ -508,6 +522,67 @@ void log_cash( struct map_session_data* sd, e_log_pick_type type, e_log_cash_typ
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * Log feeding activity
|
|
|
|
+ * @param sd Player, feeder
|
|
|
|
+ * @param type Log type, @see e_log_feeding_type
|
|
|
|
+ * @param nameid Item used as food
|
|
|
|
+ **/
|
|
|
|
+void log_feeding(struct map_session_data *sd, e_log_feeding_type type, unsigned short nameid) {
|
|
|
|
+ unsigned int target_id = 0, intimacy = 0;
|
|
|
|
+ unsigned short target_class = 0;
|
|
|
|
+
|
|
|
|
+ nullpo_retv( sd );
|
|
|
|
+
|
|
|
|
+ if (!(log_config.feeding&type))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ switch (type) {
|
|
|
|
+ case LOG_FEED_HOMUNCULUS:
|
|
|
|
+ if (sd->hd) {
|
|
|
|
+ target_id = sd->hd->homunculus.hom_id;
|
|
|
|
+ target_class = sd->hd->homunculus.class_;
|
|
|
|
+ intimacy = sd->hd->homunculus.intimacy;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case LOG_FEED_PET:
|
|
|
|
+ if (sd->pd) {
|
|
|
|
+ target_id = sd->pd->pet.pet_id;
|
|
|
|
+ target_class = sd->pd->pet.class_;
|
|
|
|
+ intimacy = sd->pd->pet.intimate;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (log_config.sql_logs) {
|
|
|
|
+#ifdef BETA_THREAD_TEST
|
|
|
|
+ char entry[512];
|
|
|
|
+ int e_length = 0;
|
|
|
|
+ e_length = sprintf(entry, LOG_QUERY " INTO `%s` (`time`, `char_id`, `target_id`, `target_class`, `type`, `intimacy`, `item_id`, `map`, `x`, `y`) VALUES ( NOW(), '%"PRIu32"', '%"PRIu32"', '%hu', '%c', '%"PRIu32"', '%hu', '%s', '%hu', '%hu' )",
|
|
|
|
+ log_config.log_feeding, sd->status.char_id, target_id, target_class, log_feedingtype2char(type), intimacy, nameid, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
|
|
|
|
+ queryThread_log(entry, e_length);
|
|
|
|
+#else
|
|
|
|
+ if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `target_id`, `target_class`, `type`, `intimacy`, `item_id`, `map`, `x`, `y`) VALUES ( NOW(), '%"PRIu32"', '%"PRIu32"', '%hu', '%c', '%"PRIu32"', '%hu', '%s', '%hu', '%hu' )",
|
|
|
|
+ log_config.log_feeding, sd->status.char_id, target_id, target_class, log_feedingtype2char(type), intimacy, nameid, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y))
|
|
|
|
+ {
|
|
|
|
+ Sql_ShowDebug(logmysql_handle);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+ } else {
|
|
|
|
+ char timestring[255];
|
|
|
|
+ time_t curtime;
|
|
|
|
+ FILE* logfp;
|
|
|
|
+
|
|
|
|
+ if ((logfp = fopen(log_config.log_feeding, "a")) == NULL)
|
|
|
|
+ return;
|
|
|
|
+ time(&curtime);
|
|
|
|
+ strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
|
|
|
|
+ fprintf(logfp, "%s - %s[%d]\t%d\t%d(%c)\t%d\t%hu\t%s\t%hu,%hu\n", timestring, sd->status.name, sd->status.char_id, target_id, target_class, log_feedingtype2char(type), intimacy, nameid, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
|
|
|
|
+ fclose(logfp);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void log_set_defaults(void)
|
|
void log_set_defaults(void)
|
|
{
|
|
{
|
|
memset(&log_config, 0, sizeof(log_config));
|
|
memset(&log_config, 0, sizeof(log_config));
|
|
@@ -574,6 +649,8 @@ int log_config_read(const char* cfgName)
|
|
log_config.chat = config_switch(w2);
|
|
log_config.chat = config_switch(w2);
|
|
else if( strcmpi(w1, "log_mvpdrop") == 0 )
|
|
else if( strcmpi(w1, "log_mvpdrop") == 0 )
|
|
log_config.mvpdrop = config_switch(w2);
|
|
log_config.mvpdrop = config_switch(w2);
|
|
|
|
+ else if( strcmpi(w1, "log_feeding") == 0 )
|
|
|
|
+ log_config.feeding = config_switch(w2);
|
|
else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
|
|
else if( strcmpi(w1, "log_chat_woe_disable") == 0 )
|
|
log_config.log_chat_woe_disable = (bool)config_switch(w2);
|
|
log_config.log_chat_woe_disable = (bool)config_switch(w2);
|
|
else if( strcmpi(w1, "log_branch_db") == 0 )
|
|
else if( strcmpi(w1, "log_branch_db") == 0 )
|
|
@@ -592,6 +669,8 @@ int log_config_read(const char* cfgName)
|
|
safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
|
|
safestrncpy(log_config.log_chat, w2, sizeof(log_config.log_chat));
|
|
else if( strcmpi( w1, "log_cash_db" ) == 0 )
|
|
else if( strcmpi( w1, "log_cash_db" ) == 0 )
|
|
safestrncpy( log_config.log_cash, w2, sizeof( log_config.log_cash ) );
|
|
safestrncpy( log_config.log_cash, w2, sizeof( log_config.log_cash ) );
|
|
|
|
+ else if( strcmpi( w1, "log_feeding_db" ) == 0 )
|
|
|
|
+ safestrncpy( log_config.log_feeding, w2, sizeof( log_config.log_feeding ) );
|
|
// log file timestamp format
|
|
// log file timestamp format
|
|
else if( strcmpi( w1, "log_timestamp_format" ) == 0 )
|
|
else if( strcmpi( w1, "log_timestamp_format" ) == 0 )
|
|
safestrncpy(log_timestamp_format, w2, sizeof(log_timestamp_format));
|
|
safestrncpy(log_timestamp_format, w2, sizeof(log_timestamp_format));
|
|
@@ -640,6 +719,9 @@ int log_config_read(const char* cfgName)
|
|
if( log_config.cash ){
|
|
if( log_config.cash ){
|
|
ShowInfo( "Logging Cash transactions to %s '%s'.\n", target, log_config.log_cash );
|
|
ShowInfo( "Logging Cash transactions to %s '%s'.\n", target, log_config.log_cash );
|
|
}
|
|
}
|
|
|
|
+ if( log_config.feeding ){
|
|
|
|
+ ShowInfo( "Logging Feeding items to %s '%s'.\n", target, log_config.log_feeding );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|