Sfoglia il codice sorgente

Move table names from inter_athena.conf to their perspective server config file as suggested by @Lemongrass

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
Cydh Ramdh 10 anni fa
parent
commit
4ca0690a98

+ 39 - 2
conf/char_athena.conf

@@ -178,6 +178,9 @@ char_del_option: 2
 // What folder the DB files are in (item_db.txt, etc.)
 db_path: db
 
+// Should we check if sql-tables are correct on server startup ?
+char_checkdb: yes
+
 //===================================
 // Pincode system
 //===================================
@@ -224,8 +227,42 @@ char_movetoused: yes
 // Allow users to move characters as often as they like?
 char_moves_unlimited: no
 
-// Should we check if sql-tables are correct on server startup ?
-char_checkdb: yes
+//===================================
+// Char/Inter-server Tables
+//===================================
+auction_table: auction
+bonus_script_table: bonus_script
+cart_table: cart_inventory
+char_table: char
+charlog_table: charlog
+elemental_table: elemental
+friend_table: friends
+guild_table: guild
+guild_alliance_table: guild_alliance
+guild_castle_table: guild_castle
+guild_expulsion_table: guild_expulsion
+guild_member_table: guild_member
+guild_position_table: guild_position
+guild_skill_table: guild_skill
+guild_storage_table: guild_storage
+hotkey_table: hotkey
+homunculus_table: homunculus
+homunculus_skill_table: skill_homunculus
+interlog_table: interlog
+inventory_table: inventory
+mail_table: mail
+memo_table: memo
+mercenary_table: mercenary
+mercenary_owner_table: mercenary_owner
+party_table: party
+pet_table: pet
+quest_table: quest
+ragsrvinfo_table: ragsrvinfo
+reg_table: global_reg_value
+scdata_table: sc_data
+skill_table: skill
+skillcooldown_table: skillcooldown
+storage_table: storage
 
 // Default map if character is in not-existing map when loaded.
 default_map: prontera

+ 7 - 0
conf/login_athena.conf

@@ -176,5 +176,12 @@ allowed_regs: 1
 //Time in second before the counter for the number of registration is reset
 time_allowed: 10
 
+//===================================
+// Login-server Tables
+//===================================
+login_server_account_table: login
+login_server_accreg_table: global_reg_value
+ipban_list_table: ipbanlist
+
 import: conf/inter_athena.conf
 import: conf/import/login_conf.txt

+ 3 - 3
src/char/int_homun.c

@@ -118,7 +118,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
 			int i;
 
 			stmt = SqlStmt_Malloc(sql_handle);
-			if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", charserv_table(skill_homunculus_table), hd->hom_id) )
+			if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", charserv_table(homunculus_skill_table), hd->hom_id) )
 				SqlStmt_ShowDebug(stmt);
 			for( i = 0; i < MAX_HOMUNSKILL; ++i )
 			{
@@ -199,7 +199,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 	hd->hunger = cap_value(hd->hunger, 0, 100);
 
 	// Load Homunculus Skill
-	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", charserv_table(skill_homunculus_table), homun_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", charserv_table(homunculus_skill_table), homun_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -230,7 +230,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 bool mapif_homunculus_delete(int homun_id)
 {
 	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", charserv_table(homunculus_table), homun_id)
-	||	SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", charserv_table(skill_homunculus_table), homun_id)
+	||	SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", charserv_table(homunculus_skill_table), homun_id)
 	) {
 		Sql_ShowDebug(sql_handle);
 		return false;

+ 3 - 1
src/login/account.c

@@ -297,8 +297,10 @@ static bool account_db_sql_set_property(AccountDB* self, const char* key, const
 		if( strcmpi(key, "db") == 0 )
 			StringBuf_PrintfClear(db->db_database, value);
 		else
-		if( strcmpi(key, "account_db") == 0 )
+		if( strcmpi(key, "account_table") == 0 ) {
 			StringBuf_PrintfClear(db->account_table, value);
+			ShowDebug("set account_table: %s\n", StringBuf_Value(db->account_table));
+		}
 		else
 		if( strcmpi(key, "global_acc_reg_num_table") == 0 )
 			StringBuf_PrintfClear(db->global_acc_reg_num_table, value);

+ 1 - 1
src/login/ipban.c

@@ -192,7 +192,7 @@ bool ipban_config_read(const char* key, const char* value) {
 		if( strcmpi(key, "codepage") == 0 )
 			StringBuf_PrintfClear(ipban_config.ipban_codepage, value);
 		else
-		if( strcmpi(key, "ipban_table") == 0 )
+		if( strcmpi(key, "list_table") == 0 )
 			StringBuf_PrintfClear(ipban_config.ipban_table, value);
 		else
 		if( strcmpi(key, "enable") == 0 )

+ 4 - 78
src/login/loginlog.c

@@ -18,14 +18,6 @@
 static Sql* sql_handle = NULL;
 
 struct Loginlog_Config {
-	// global sql settings (in ipban_sql.c)
-	uint16 global_db_port;
-	StringBuf *global_db_hostname;
-	StringBuf *global_db_username;
-	StringBuf *global_db_password;
-	StringBuf *global_db_database;
-	StringBuf *global_codepage;
-
 	// local sql settings
 	uint16 log_db_port;
 	StringBuf *log_db_hostname;
@@ -40,13 +32,6 @@ struct Loginlog_Config {
 struct Loginlog_Config loginlog_config; /// LoginLog config
 
 void loginlog_config_init(void) {
-	loginlog_config.global_db_port = 3306;
-	loginlog_config.global_db_hostname = StringBuf_FromStr("127.0.0.1");
-	loginlog_config.global_db_username = StringBuf_FromStr("ragnarok");
-	loginlog_config.global_db_password = StringBuf_FromStr("");
-	loginlog_config.global_db_database = StringBuf_FromStr("ragnarok");
-	loginlog_config.global_codepage    = StringBuf_FromStr("");
-	
 	loginlog_config.log_db_port = 3306;
 	loginlog_config.log_db_hostname = StringBuf_FromStr("127.0.0.1");
 	loginlog_config.log_db_username = StringBuf_FromStr("ragnarok");
@@ -59,11 +44,6 @@ void loginlog_config_init(void) {
 }
 
 static void loginlog_config_final(void) {
-	StringBuf_Free(loginlog_config.global_db_hostname);
-	StringBuf_Free(loginlog_config.global_db_username);
-	StringBuf_Free(loginlog_config.global_db_password);
-	StringBuf_Free(loginlog_config.global_db_database);
-	StringBuf_Free(loginlog_config.global_codepage);
 	StringBuf_Free(loginlog_config.log_db_hostname);
 	StringBuf_Free(loginlog_config.log_db_username);
 	StringBuf_Free(loginlog_config.log_db_password);
@@ -146,34 +126,6 @@ void login_log(uint32 ip, const char* username, int rcode, const char* message)
  * @return true if successful, false if config not complete or server already running
  */
 bool loginlog_config_read(const char* key, const char* value) {
-	const char* signature;
-
-	signature = "sql.";
-	if( strncmpi(key, signature, strlen(signature)) == 0 )
-	{
-		key += strlen(signature);
-		if( strcmpi(key, "db_hostname") == 0 )
-			StringBuf_PrintfClear(loginlog_config.global_db_hostname, value);
-		else
-		if( strcmpi(key, "db_port") == 0 )
-			loginlog_config.global_db_port = (uint16)strtoul(value, NULL, 10);
-		else
-		if( strcmpi(key, "db_username") == 0 )
-			StringBuf_PrintfClear(loginlog_config.global_db_username, value);
-		else
-		if( strcmpi(key, "db_password") == 0 )
-			StringBuf_PrintfClear(loginlog_config.global_db_password, value);
-		else
-		if( strcmpi(key, "db_database") == 0 )
-			StringBuf_PrintfClear(loginlog_config.global_db_database, value);
-		else
-		if( strcmpi(key, "codepage") == 0 )
-			StringBuf_PrintfClear(loginlog_config.global_codepage, value);
-		else
-			return false;// not found
-		return true;
-	}
-
 	if( strcmpi(key, "log_db_ip") == 0 )
 		StringBuf_PrintfClear(loginlog_config.log_db_hostname, value);
 	else
@@ -208,44 +160,18 @@ bool loginlog_config_read(const char* key, const char* value) {
  * @return true if success else exit execution
  */
 bool loginlog_init(void) {
-	StringBuf* username;
-	StringBuf* password;
-	StringBuf* hostname;
-	uint16     port;
-	StringBuf* database;
-	StringBuf* codepage;
-
-	if( StringBuf_Length(loginlog_config.log_db_hostname) )
-	{// local settings
-		username = loginlog_config.log_db_username;
-		password = loginlog_config.log_db_password;
-		hostname = loginlog_config.log_db_hostname;
-		port     = loginlog_config.log_db_port;
-		database = loginlog_config.log_db_database;
-		codepage = loginlog_config.log_codepage;
-	}
-	else
-	{// global settings
-		username = loginlog_config.global_db_username;
-		password = loginlog_config.global_db_password;
-		hostname = loginlog_config.global_db_hostname;
-		port     = loginlog_config.global_db_port;
-		database = loginlog_config.global_db_database;
-		codepage = loginlog_config.global_codepage;
-	}
-
 	sql_handle = Sql_Malloc();
 
-	if( SQL_ERROR == Sql_Connect(sql_handle, StringBuf_Value(username), StringBuf_Value(password), StringBuf_Value(hostname), port, StringBuf_Value(database)) )
+	if( SQL_ERROR == Sql_Connect(sql_handle, StringBuf_Value(loginlog_config.log_db_username), StringBuf_Value(loginlog_config.log_db_password), StringBuf_Value(loginlog_config.log_db_hostname), loginlog_config.log_db_port, StringBuf_Value(loginlog_config.log_db_database)) )
 	{
 		ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
-			StringBuf_Value(username), StringBuf_Value(password), StringBuf_Value(hostname), port, StringBuf_Value(database));
+			StringBuf_Value(loginlog_config.log_db_username), StringBuf_Value(loginlog_config.log_db_password), StringBuf_Value(loginlog_config.log_db_hostname), loginlog_config.log_db_port, StringBuf_Value(loginlog_config.log_db_database));
 		Sql_ShowDebug(sql_handle);
 		Sql_Free(sql_handle);
 		exit(EXIT_FAILURE);
 	}
 
-	if( StringBuf_Length(codepage) && SQL_ERROR == Sql_SetEncoding(sql_handle, StringBuf_Value(codepage)) )
+	if( StringBuf_Length(loginlog_config.log_codepage) && SQL_ERROR == Sql_SetEncoding(sql_handle, StringBuf_Value(loginlog_config.log_codepage)) )
 		Sql_ShowDebug(sql_handle);
 
 	if (!loginlog_check_table()) {
@@ -255,7 +181,7 @@ bool loginlog_init(void) {
 
 	loginlog_config.enabled = true;
 
-	ShowStatus("Loginlog connection: Database '"CL_WHITE"%s"CL_RESET"' at '"CL_WHITE"%s"CL_RESET"'\n", StringBuf_Value(database), StringBuf_Value(username));
+	ShowStatus("Loginlog connection: Database '"CL_WHITE"%s"CL_RESET"' at '"CL_WHITE"%s"CL_RESET"'\n", StringBuf_Value(loginlog_config.log_db_database), StringBuf_Value(loginlog_config.log_db_username));
 	return true;
 }
 

+ 1 - 0
src/map/map.h

@@ -74,6 +74,7 @@ struct MapServer_Schema {
 	StringBuf *roulette_table;			///< Roulette table
 	StringBuf *vendings_table;		    ///< Vending table (vendor & autotrader)
 	StringBuf *vending_items_table;	    ///< Vending items table (vendor & autotrader)
+	StringBuf *mapreg_table;		    ///< Mapreg table, used in mapreg.c
 };
 extern struct MapServer_Schema mapserv_schema_config; /// map-server tables
 /// Get map-server table value. Table names @see MapServer_Schema

+ 5 - 20
src/map/mapreg.c

@@ -20,8 +20,8 @@ static struct eri *mapreg_ers;
 
 bool skip_insert = false;
 
-static char mapreg_table[32] = "mapreg";
-static bool mapreg_dirty = false; // Whether there are modified regs to be saved
+static char mapreg_table[32];
+static bool mapreg_dirty = false;
 
 #define MAPREG_AUTOSAVE_INTERVAL (300*1000)
 
@@ -323,27 +323,12 @@ void mapreg_final(void)
  */
 void mapreg_init(void)
 {
-	regs.vars = i64db_alloc(DB_OPT_BASE);
-	mapreg_ers = ers_new(sizeof(struct mapreg_save), "mapreg.c:mapreg_ers", ERS_OPT_CLEAN);
-
-	skip_insert = false;
-	regs.arrays = NULL;
+	mapreg_db = idb_alloc(DB_OPT_BASE);
+	mapregstr_db = idb_alloc(DB_OPT_RELEASE_DATA);
+	safestrncpy(mapreg_table, StringBuf_Value(mapserv_schema_config.mapreg_table), sizeof(mapreg_table));
 
 	script_load_mapreg();
 
 	add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg");
 	add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL);
 }
-
-/**
- * Loads the mapreg configuration file.
- */
-bool mapreg_config_read(const char* w1, const char* w2)
-{
-	if(!strcmpi(w1, "mapreg_table"))
-		safestrncpy(mapreg_table, w2, sizeof(mapreg_table));
-	else
-		return false;
-
-	return true;
-}

+ 0 - 1
src/map/mapreg.h

@@ -22,7 +22,6 @@ extern bool skip_insert;
 void mapreg_reload(void);
 void mapreg_final(void);
 void mapreg_init(void);
-bool mapreg_config_read(const char* w1, const char* w2);
 
 int mapreg_readreg(int64 uid);
 char* mapreg_readregstr(int64 uid);