Sfoglia il codice sorgente

Follow up to 9925632

aleos89 9 anni fa
parent
commit
3602957660
6 ha cambiato i file con 25 aggiunte e 22 eliminazioni
  1. 1 1
      src/char/char.c
  2. 1 1
      src/login/login.c
  3. 12 10
      src/map/log.c
  4. 1 0
      src/map/log.h
  5. 3 1
      src/map/map.c
  6. 7 9
      src/map/mapreg.c

+ 1 - 1
src/char/char.c

@@ -2778,7 +2778,7 @@ bool char_config_read(const char* cfgName, bool normal){
 				ShowInfo("Console Silent Setting: %d\n", atoi(w2));
 		} else if (strcmpi(w1, "console_msg_log") == 0) {
 			console_msg_log = atoi(w2);
-		} else if  (strcmpi(w1, "console_log_filepath") == 0) {
+		} else if (strcmpi(w1, "console_log_filepath") == 0) {
 			safestrncpy(console_log_filepath, w2, sizeof(console_log_filepath));
 		} else if(strcmpi(w1,"stdout_with_ansisequence")==0){
 			stdout_with_ansisequence = config_switch(w2);

+ 1 - 1
src/login/login.c

@@ -579,7 +579,7 @@ bool login_config_read(const char* cfgName, bool normal) {
 		}
 		else if (strcmpi(w1, "console_msg_log") == 0)
 			console_msg_log = atoi(w2);
-		else if  (strcmpi(w1, "console_log_filepath") == 0)
+		else if (strcmpi(w1, "console_log_filepath") == 0)
 			safestrncpy(console_log_filepath, w2, sizeof(console_log_filepath));
 		else if(!strcmpi(w1, "log_login"))
 			login_config.log_login = (bool)config_switch(w2);

+ 12 - 10
src/map/log.c

@@ -17,8 +17,6 @@
 
 #include <stdlib.h>
 
-static char log_timestamp_format[20];
-
 /// filters for item logging
 typedef enum e_log_filter
 {
@@ -193,7 +191,7 @@ void log_branch(struct map_session_data* sd)
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.branch_table), "a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		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));
 		fclose(logfp);
 	}
@@ -237,7 +235,7 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.pick_table), "a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		fprintf(logfp,"%s - %d\t%c\t%hu,%d,%d,%hu,%hu,%hu,%hu,%s,'%"PRIu64"',%d\n", timestring, id, log_picktype2char(type), itm->nameid, amount, itm->refine, itm->card[0], itm->card[1], itm->card[2], itm->card[3], map[m].name?map[m].name:"", itm->unique_id, itm->bound);
 		fclose(logfp);
 	}
@@ -292,7 +290,7 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.zeny_table), "a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		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);
 		fclose(logfp);
 	}
@@ -333,7 +331,7 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, unsigned int* log_
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.mvpdrop_table),"a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		fprintf(logfp,"%s - %s[%d:%d]\t%d\t%hu,%u\n", timestring, sd->status.name, sd->status.account_id, sd->status.char_id, monster_id, (unsigned short)log_mvp[0], log_mvp[1]);
 		fclose(logfp);
 	}
@@ -381,7 +379,7 @@ void log_atcommand(struct map_session_data* sd, const char* message)
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.command_table), "a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
 		fclose(logfp);
 	}
@@ -427,7 +425,7 @@ void log_npc(struct map_session_data* sd, const char* message)
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.npc_table), "a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		fprintf(logfp, "%s - %s[%d]: %s\n", timestring, sd->status.name, sd->status.account_id, message);
 		fclose(logfp);
 	}
@@ -478,7 +476,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
 		if( ( logfp = fopen(StringBuf_Value(log_config.schema.chat_table), "a") ) == NULL )
 			return;
 		time(&curtime);
-		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		fprintf(logfp, "%s - %c,%d,%d,%d,%s,%d,%d,%s,%s\n", timestring, log_chattype2char(type), type_id, src_charid, src_accid, mapname, x, y, dst_charname, message);
 		fclose(logfp);
 	}
@@ -514,7 +512,7 @@ void log_cash( struct map_session_data* sd, e_log_pick_type type, e_log_cash_typ
 		if( ( logfp = fopen( StringBuf_Value(log_config.schema.cash_table), "a" ) ) == NULL )
 			return;
 		time( &curtime );
-		strftime( timestring, sizeof( timestring ), log_timestamp_format, localtime( &curtime ) );
+		strftime(timestring, sizeof(timestring), StringBuf_Value(log_config.log_timestamp), localtime(&curtime));
 		fprintf( logfp, "%s - %s[%d]\t%d(%c)\t\n", timestring, sd->status.name, sd->status.account_id, amount, log_cashtype2char( cash_type ) );
 		fclose( logfp );
 	}
@@ -609,6 +607,7 @@ void log_config_init(void) {
 
 	log_config.log_path      = StringBuf_FromStr("log/");
 	log_config.log_ext       = StringBuf_FromStr(".log");
+	log_config.log_timestamp = StringBuf_FromStr("%m/%d/%Y %H:%M:%S");
 
 	log_config.schema.branch_table  = StringBuf_FromStr("branchlog");
 	log_config.schema.cash_table    = StringBuf_FromStr("cashlog");
@@ -624,6 +623,7 @@ void log_config_init(void) {
 void log_config_final(void) {
 	StringBuf_Free(log_config.log_path);
 	StringBuf_Free(log_config.log_ext);
+	StringBuf_Free(log_config.log_timestamp);
 
 	StringBuf_Free(log_config.schema.branch_table);
 	StringBuf_Free(log_config.schema.cash_table);
@@ -857,6 +857,8 @@ int log_config_read(const char* cfgName)
 				StringBuf_PrintfClear(log_config.log_path, "%s", w2);
 			else if( strcmpi( w1, "log_extension" ) == 0 )
 				StringBuf_PrintfClear(log_config.log_ext, "%s", w2);
+			else if( strcmpi( w1, "log_timestamp_format" ) == 0 )
+				StringBuf_PrintfClear(log_config.log_timestamp, w2);
 			//support the import command, just like any other config
 			else if( strcmpi(w1,"import") == 0 )
 				log_config_read(w2);

+ 1 - 0
src/map/log.h

@@ -105,6 +105,7 @@ struct Log_Config {
 
 	StringBuf *log_path;          ///< Path to log file (Used if 'sql_logs' is no)
 	StringBuf *log_ext;	          ///< Log file extension (Used if 'sql_logs' is no)
+	StringBuf *log_timestamp;	  ///< Time Stamp format for logs
 
 	struct s_log_schema_config {
 		StringBuf *branch_table;  ///< Branch log table/file with path

+ 3 - 1
src/map/map.c

@@ -3696,7 +3696,7 @@ static bool map_schema_read_conf(const char *w1, const char *w2) {
 	SCHEMA_CONF(buyingstore_items_table, "buyingstore_items_table")
 	SCHEMA_CONF(mapreg_table, "mapreg_table")
 	SCHEMA_CONF(market_table, "market_table")
-	SCHEMA_CONF(roulette_table, "db_roulette")
+	SCHEMA_CONF(roulette_table, "roulette_table")
 	SCHEMA_CONF(vendings_table, "vending_table")
 	SCHEMA_CONF(vending_items_table, "vending_items_table")
 
@@ -3810,6 +3810,8 @@ int map_config_read(char *cfgName)
 			map_config.enable_grf = config_switch(w2);
 		else if (strcmpi(w1, "console_msg_log") == 0)
 			console_msg_log = atoi(w2);//[Ind]
+		else if (strcmpi(w1, "console_log_filepath") == 0)
+			safestrncpy(console_log_filepath, w2, sizeof(console_log_filepath));
 		else if (strcmpi(w1,"check_tables") == 0)
 			map_config.check_tables = config_switch(w2);
 		else if (map_schema_read_conf(w1, w2))

+ 7 - 9
src/map/mapreg.c

@@ -19,8 +19,6 @@
 static struct eri *mapreg_ers;
 
 bool skip_insert = false;
-
-static char mapreg_table[32];
 static bool mapreg_dirty = false;
 
 #define MAPREG_AUTOSAVE_INTERVAL (300*1000)
@@ -85,7 +83,7 @@ bool mapreg_setreg(int64 uid, int val)
 			if (name[1] != '@' && !skip_insert) {// write new variable to database
 				char tmp_str[32 * 2 + 1];
 				Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
-				if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val))
+				if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapserv_table(mapreg_table), tmp_str, i, val))
 					Sql_ShowDebug(mmysql_handle);
 			}
 			i64db_put(regs.vars, uid, m);
@@ -99,7 +97,7 @@ bool mapreg_setreg(int64 uid, int val)
 		i64db_remove(regs.vars, uid);
 
 		if (name[1] != '@') {// Remove from database because it is unused.
-			if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i))
+			if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapserv_table(mapreg_table), name, i))
 				Sql_ShowDebug(mmysql_handle);
 		}
 	}
@@ -125,7 +123,7 @@ bool mapreg_setregstr(int64 uid, const char* str)
 		if (i)
 			script_array_update(&regs, uid, true);
 		if (name[1] != '@') {
-			if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i))
+			if (SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapserv_table(mapreg_table), name, i))
 				Sql_ShowDebug(mmysql_handle);
 		}
 		if ((m = i64db_get(regs.vars, uid))) {
@@ -159,7 +157,7 @@ bool mapreg_setregstr(int64 uid, const char* str)
 				char tmp_str2[255 * 2 + 1];
 				Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
 				Sql_EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255));
-				if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2))
+				if (SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapserv_table(mapreg_table), tmp_str, i, tmp_str2))
 					Sql_ShowDebug(mmysql_handle);
 			}
 			i64db_put(regs.vars, uid, m);
@@ -186,7 +184,7 @@ static void script_load_mapreg(void)
 	char value[255+1];
 	uint32 length;
 
-	if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table)
+	if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapserv_table(mapreg_table))
 	  || SQL_ERROR == SqlStmt_Execute(stmt)
 	  ) {
 		SqlStmt_ShowDebug(stmt);
@@ -235,12 +233,12 @@ static void script_save_mapreg(void)
 				int i = script_getvaridx(m->uid);
 				const char* name = get_str(num);
 				if (!m->is_string) {
-					if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i))
+					if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapserv_table(mapreg_table), m->u.i, name, i))
 						Sql_ShowDebug(mmysql_handle);
 				} else {
 					char tmp_str2[2 * 255 + 1];
 					Sql_EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255));
-					if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i))
+					if (SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapserv_table(mapreg_table), tmp_str2, name, i))
 						Sql_ShowDebug(mmysql_handle);
 				}
 				m->save = false;