ソースを参照

` Added renaming support for the remaining 'ragnarok' tables in the inter_athena.conf file - bugreport:3317
-- Includes: homunculus, skill_homunculus, mercenary, mercenary_owner, ragsrvinfo
` Fixed a typo regarding the homunculus_db

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15508 54d463be-8e91-2dee-dedb-b68131a5f0ec

xantara 13 年 前
コミット
251362c227

+ 6 - 3
conf/inter_athena.conf

@@ -54,6 +54,7 @@ log_db_id: ragnarok
 log_db_pw: ragnarok
 log_db_db: ragnarok
 log_codepage:
+log_login_db: loginlog
 
 // DO NOT CHANGE ANYTHING BEYOND THIS LINE UNLESS YOU KNOW YOUR DATABASE DAMN WELL
 // this is meant for people who KNOW their stuff, and for some reason want to change their
@@ -61,9 +62,6 @@ log_codepage:
 
 // ALL MySQL Database Table names
 
-// Login Database Tables
-loginlog_db: loginlog
-
 // Char Database Tables
 char_db: char
 hotkey_db: hotkey
@@ -90,6 +88,11 @@ friend_db: friends
 mail_db: mail
 auction_db: auction
 quest_db: quest
+homunculus_db: homunculus
+skill_homunculus_db: skill_homunculus
+mercenary_db: mercenary
+mercenary_owner_db: mercenary_owner
+ragsrvinfo_db: ragsrvinfo
 
 // Map Database Tables
 item_db_db: item_db

+ 17 - 4
src/char/char.c

@@ -59,6 +59,11 @@ char auction_db[256] = "auction"; // Auctions System
 char friend_db[256] = "friends";
 char hotkey_db[256] = "hotkey";
 char quest_db[256] = "quest";
+char homunculus_db[256] = "homunculus";
+char skill_homunculus_db[256] = "skill_homunculus";
+char mercenary_db[256] = "mercenary";
+char mercenary_owner_db[256] = "mercenary_owner";
+char ragsrvinfo_db[256] = "ragsrvinfo";
 
 // show loading/saving messages
 int save_log = 1;
@@ -2419,7 +2424,7 @@ void mapif_server_reset(int id)
 		WBUFW(buf,2) = j * 4 + 10;
 		mapif_sendallwos(fd, buf, WBUFW(buf,2));
 	}
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo` WHERE `index`='%d'", server[id].fd) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `index`='%d'", ragsrvinfo_db, server[id].fd) )
 		Sql_ShowDebug(sql_handle);
 	online_char_db->foreach(online_char_db,char_db_setoffline,id); //Tag relevant chars as 'in disconnected' server.
 	mapif_server_destroy(id);
@@ -2974,8 +2979,8 @@ int parse_frommap(int fd)
 
 			Sql_EscapeString(sql_handle, esc_server_name, server_name);
 
-			if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
-				fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) )
+			if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
+				ragsrvinfo_db, fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) )
 				Sql_ShowDebug(sql_handle);
 			RFIFOSKIP(fd,14);
 		}
@@ -4271,6 +4276,14 @@ void sql_config_read(const char* cfgName)
 			safestrncpy(hotkey_db, w2, sizeof(hotkey_db));
 		else if(!strcmpi(w1,"quest_db"))
 			safestrncpy(quest_db,w2,sizeof(quest_db));
+		else if(!strcmpi(w1,"homunculus_db"))
+			safestrncpy(homunculus_db,w2,sizeof(homunculus_db));
+		else if(!strcmpi(w1,"skill_homunculus_db"))
+			safestrncpy(skill_homunculus_db,w2,sizeof(skill_homunculus_db));
+		else if(!strcmpi(w1,"mercenary_db"))
+			safestrncpy(mercenary_db,w2,sizeof(mercenary_db));
+		else if(!strcmpi(w1,"mercenary_owner_db"))
+			safestrncpy(mercenary_owner_db,w2,sizeof(mercenary_owner_db));
 		//support the import command, just like any other config
 		else if(!strcmpi(w1,"import"))
 			sql_config_read(w2);
@@ -4450,7 +4463,7 @@ void do_final(void)
 	do_final_mapif();
 	do_final_loginif();
 
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo`") )
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s`", ragsrvinfo_db) )
 		Sql_ShowDebug(sql_handle);
 
 	char_db_->destroy(char_db_, NULL);

+ 5 - 0
src/char/char.h

@@ -68,6 +68,11 @@ extern char pet_db[256];
 extern char mail_db[256];
 extern char auction_db[256];
 extern char quest_db[256];
+extern char homunculus_db[256];
+extern char skill_homunculus_db[256];
+extern char mercenary_db[256];
+extern char mercenary_owner_db[256];
+extern char ragsrvinfo_db[256];
 
 extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
 

+ 9 - 9
src/char/int_homun.c

@@ -92,10 +92,10 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
 
 	if( hd->hom_id == 0 )
 	{// new homunculus
-		if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `homunculus` "
+		if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
 			"(`char_id`, `class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) "
 			"VALUES ('%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
-			hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
+			homunculus_db, hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
 			hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) )
 		{
 			Sql_ShowDebug(sql_handle);
@@ -108,8 +108,8 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
 	}
 	else
 	{
-		if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
-			hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
+		if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
+			homunculus_db, hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
 			hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) )
 		{
 			Sql_ShowDebug(sql_handle);
@@ -121,7 +121,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
 			int i;
 
 			stmt = SqlStmt_Malloc(sql_handle);
-			if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `skill_homunculus` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", hd->hom_id) )
+			if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", skill_homunculus_db, hd->hom_id) )
 				SqlStmt_ShowDebug(stmt);
 			for( i = 0; i < MAX_HOMUNSKILL; ++i )
 			{
@@ -156,7 +156,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 
 	memset(hd, 0, sizeof(*hd));
 
-	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", homun_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -201,7 +201,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 `skill_homunculus` WHERE `homun_id`=%d", homun_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -230,8 +230,8 @@ 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 `homunculus` WHERE `homun_id` = '%u'", homun_id)
-	||	SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", homun_id)
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id)
+	||	SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id)
 	) {
 		Sql_ShowDebug(sql_handle);
 		return false;

+ 11 - 11
src/char/int_mercenary.c

@@ -19,7 +19,7 @@ bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
 {
 	char* data;
 
-	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `mercenary_owner` WHERE `char_id` = '%d'", char_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -45,8 +45,8 @@ bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
 
 bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
 {
-	if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `mercenary_owner` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
-		char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
+		mercenary_owner_db, char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -57,10 +57,10 @@ bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
 
 bool mercenary_owner_delete(int char_id)
 {
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary_owner` WHERE `char_id` = '%d'", char_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
 		Sql_ShowDebug(sql_handle);
 
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `char_id` = '%d'", char_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
 		Sql_ShowDebug(sql_handle);
 
 	return true;
@@ -73,8 +73,8 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
 	if( merc->mercenary_id == 0 )
 	{ // Create new DB entry
 		if( SQL_ERROR == Sql_Query(sql_handle,
-			"INSERT INTO `mercenary` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')",
-			merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) )
+			"INSERT INTO `%s` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')",
+			mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) )
 		{
 			Sql_ShowDebug(sql_handle);
 			flag = false;
@@ -83,8 +83,8 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
 			merc->mercenary_id = (int)Sql_LastInsertId(sql_handle);
 	}
 	else if( SQL_ERROR == Sql_Query(sql_handle,
-		"UPDATE `mercenary` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'",
-		merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) )
+		"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'",
+		mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) )
 	{ // Update DB entry
 		Sql_ShowDebug(sql_handle);
 		flag = false;
@@ -101,7 +101,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
 	merc->mercenary_id = merc_id;
 	merc->char_id = char_id;
 
-	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `mercenary` WHERE `mer_id` = '%d' AND `char_id` = '%d'", merc_id, char_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", mercenary_db, merc_id, char_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -127,7 +127,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
 
 bool mapif_mercenary_delete(int merc_id)
 {
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `mer_id` = '%d'", merc_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;

+ 5 - 5
src/login/loginlog_sql.c

@@ -23,7 +23,7 @@ static char   log_db_username[32] = "";
 static char   log_db_password[32] = "";
 static char   log_db_database[32] = "";
 static char   log_codepage[32] = "";
-static char   loginlog_table[256] = "loginlog";
+static char   log_login_db[256] = "loginlog";
 
 static Sql* sql_handle = NULL;
 static bool enabled = false;
@@ -38,7 +38,7 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes)
 		return 0;
 
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%s' AND `rcode` = '1' AND `time` > NOW() - INTERVAL %d MINUTE",
-		loginlog_table, ip2str(ip,NULL), minutes) )// how many times failed account? in one ip.
+		log_login_db, ip2str(ip,NULL), minutes) )// how many times failed account? in one ip.
 		Sql_ShowDebug(sql_handle);
 
 	if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
@@ -69,7 +69,7 @@ void login_log(uint32 ip, const char* username, int rcode, const char* message)
 
 	retcode = Sql_Query(sql_handle,
 		"INSERT INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%s', '%s', '%d', '%s')",
-		loginlog_table, ip2str(ip,NULL), esc_username, rcode, message);
+		log_login_db, ip2str(ip,NULL), esc_username, rcode, message);
 
 	if( retcode != SQL_SUCCESS )
 		Sql_ShowDebug(sql_handle);
@@ -175,8 +175,8 @@ bool loginlog_config_read(const char* key, const char* value)
 	if( strcmpi(key, "log_codepage") == 0 )
 		safestrncpy(log_codepage, value, sizeof(log_codepage));
 	else
-	if( strcmpi(key, "loginlog_db") == 0 )
-		safestrncpy(loginlog_table, value, sizeof(loginlog_table));
+	if( strcmpi(key, "log_login_db") == 0 )
+		safestrncpy(log_login_db, value, sizeof(log_login_db));
 	else
 		return false;
 

+ 1 - 1
src/map/homunculus.h

@@ -22,7 +22,7 @@ struct s_homunculus_db {
 	unsigned char element, race, base_size, evo_size;
 };
 
-extern struct s_homunculus_db homuncumlus_db[MAX_HOMUNCULUS_CLASS];
+extern struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS];
 enum { HOMUNCULUS_CLASS, HOMUNCULUS_FOOD };
 
 enum {