diff options
author | shennetsind <ind@henn.et> | 2013-06-09 00:55:03 -0300 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-06-09 00:55:03 -0300 |
commit | 2db09c2e6442aa3abe573d35a3a5a1c6fa3db5fa (patch) | |
tree | c7f5dbb515a926c04e2cd4f38872730e0e7c3429 /src | |
parent | 89a571a3c5d4c9366843a462c40efdebb24d17fe (diff) | |
download | hercules-2db09c2e6442aa3abe573d35a3a5a1c6fa3db5fa.tar.gz hercules-2db09c2e6442aa3abe573d35a3a5a1c6fa3db5fa.tar.bz2 hercules-2db09c2e6442aa3abe573d35a3a5a1c6fa3db5fa.tar.xz hercules-2db09c2e6442aa3abe573d35a3a5a1c6fa3db5fa.zip |
Fixed Bug #7319
Special Thanks to KeiKun~!
http://hercules.ws/board/tracker/issue-7319-db-name/
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 5 | ||||
-rw-r--r-- | src/char/char.h | 1 | ||||
-rw-r--r-- | src/char/inter.h | 3 | ||||
-rw-r--r-- | src/map/itemdb.c | 7 | ||||
-rw-r--r-- | src/map/map.c | 117 | ||||
-rw-r--r-- | src/map/map.h | 1 |
6 files changed, 65 insertions, 69 deletions
diff --git a/src/char/char.c b/src/char/char.c index 8672d10ef..524c3029d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -66,6 +66,7 @@ char skill_homunculus_db[256] = "skill_homunculus"; char mercenary_db[256] = "mercenary"; char mercenary_owner_db[256] = "mercenary_owner"; char ragsrvinfo_db[256] = "ragsrvinfo"; +char interreg_db[32] = "interreg"; // show loading/saving messages int save_log = 1; @@ -4686,6 +4687,10 @@ void sql_config_read(const char* cfgName) safestrncpy(mercenary_db,w2,sizeof(mercenary_db)); else if(!strcmpi(w1,"mercenary_owner_db")) safestrncpy(mercenary_owner_db,w2,sizeof(mercenary_owner_db)); + else if(!strcmpi(w1,"ragsrvinfo_db")) + safestrncpy(ragsrvinfo_db,w2,sizeof(ragsrvinfo_db)); + else if(!strcmpi(w1,"interreg_db")) + safestrncpy(interreg_db,w2,sizeof(interreg_db)); //support the import command, just like any other config else if(!strcmpi(w1,"import")) sql_config_read(w2); diff --git a/src/char/char.h b/src/char/char.h index 996a0e845..1a9441868 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -103,6 +103,7 @@ extern char skill_homunculus_db[256]; extern char mercenary_db[256]; extern char mercenary_owner_db[256]; extern char ragsrvinfo_db[256]; +extern char interreg_db[32]; extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris] diff --git a/src/char/inter.h b/src/char/inter.h index de27b0473..f6663813a 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -7,6 +7,7 @@ struct accreg; #include "../common/sql.h" +#include "char.h" int inter_init_sql(const char *file); void inter_final(void); @@ -32,7 +33,7 @@ uint64 inter_chk_lastuid(int8 flag, uint64 value); #define dbUpdateUid(handler_)\ { \ uint64 unique_id_ = inter_chk_lastuid(0, 0); \ - if (unique_id_ && SQL_ERROR == SQL->Query(handler_, "UPDATE `interreg` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", unique_id_)) \ + if (unique_id_ && SQL_ERROR == SQL->Query(handler_, "UPDATE `%s` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", interreg_db, unique_id_)) \ Sql_ShowDebug(handler_);\ } #else diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 4b6275047..cb845111d 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1293,14 +1293,13 @@ uint64 itemdb_unique_id(int8 flag, int64 value) { return ++item_uid; } -int itemdb_uid_load(){ +int itemdb_uid_load() { char * uid; - if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `interreg` WHERE `varname`='unique_id'")) + if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",iMap->interreg_db)) Sql_ShowDebug(mmysql_handle); - if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) - { + if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) { ShowError("itemdb_uid_load: Unable to fetch unique_id data\n"); SQL->FreeResult(mmysql_handle); return -1; diff --git a/src/map/map.c b/src/map/map.c index f0db40c39..70aa777e3 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3526,82 +3526,71 @@ void map_reloadnpc(bool clear) #endif } -int inter_config_read(char *cfgName) -{ +int inter_config_read(char *cfgName) { char line[1024],w1[1024],w2[1024]; FILE *fp; - fp=fopen(cfgName,"r"); - if(fp==NULL){ + if( !( fp = fopen(cfgName,"r") ) ){ ShowError("File not found: %s\n",cfgName); return 1; } - while(fgets(line, sizeof(line), fp)) - { + while(fgets(line, sizeof(line), fp)) { if(line[0] == '/' && line[1] == '/') continue; + if( sscanf(line,"%[^:]: %[^\r\n]",w1,w2) < 2 ) continue; - + /* table names */ if(strcmpi(w1,"item_db_db")==0) strcpy(iMap->item_db_db,w2); - else - if(strcmpi(w1,"mob_db_db")==0) - strcpy(iMap->mob_db_db,w2); - else - if(strcmpi(w1,"item_db2_db")==0) - strcpy(iMap->item_db2_db,w2); - else - if(strcmpi(w1,"item_db_re_db")==0) - strcpy(iMap->item_db_re_db,w2); - else - if(strcmpi(w1,"mob_db2_db")==0) - strcpy(iMap->mob_db2_db,w2); - else - //Map Server SQL DB - if(strcmpi(w1,"map_server_ip")==0) - strcpy(map_server_ip, w2); - else - if(strcmpi(w1,"map_server_port")==0) - map_server_port=atoi(w2); - else - if(strcmpi(w1,"map_server_id")==0) - strcpy(map_server_id, w2); - else - if(strcmpi(w1,"map_server_pw")==0) - strcpy(map_server_pw, w2); - else - if(strcmpi(w1,"map_server_db")==0) - strcpy(map_server_db, w2); - else - if(strcmpi(w1,"default_codepage")==0) - strcpy(default_codepage, w2); - else - if(strcmpi(w1,"use_sql_db")==0) { - iMap->db_use_sqldbs = config_switch(w2); - ShowStatus ("Using SQL dbs: %s\n",w2); - } else - if(strcmpi(w1,"log_db_ip")==0) - strcpy(log_db_ip, w2); - else - if(strcmpi(w1,"log_db_id")==0) - strcpy(log_db_id, w2); - else - if(strcmpi(w1,"log_db_pw")==0) - strcpy(log_db_pw, w2); - else - if(strcmpi(w1,"log_db_port")==0) - log_db_port = atoi(w2); - else - if(strcmpi(w1,"log_db_db")==0) - strcpy(log_db_db, w2); - else - if( mapreg_config_read(w1,w2) ) - continue; - //support the import command, just like any other config - else - if(strcmpi(w1,"import")==0) - inter_config_read(w2); + else if(strcmpi(w1,"mob_db_db")==0) + strcpy(iMap->mob_db_db,w2); + else if(strcmpi(w1,"item_db2_db")==0) + strcpy(iMap->item_db2_db,w2); + else if(strcmpi(w1,"item_db_re_db")==0) + strcpy(iMap->item_db_re_db,w2); + else if(strcmpi(w1,"mob_db2_db")==0) + strcpy(iMap->mob_db2_db,w2); + else if(strcmpi(w1,"mob_skill_db_db")==0) + strcpy(iMap->mob_skill_db_db,w2); + else if(strcmpi(w1,"mob_skill_db2_db")==0) + strcpy(iMap->mob_skill_db2_db,w2); + else if(strcmpi(w1,"interreg_db")==0) + strcpy(iMap->interreg_db,w2); + /* map sql stuff */ + else if(strcmpi(w1,"map_server_ip")==0) + strcpy(map_server_ip, w2); + else if(strcmpi(w1,"map_server_port")==0) + map_server_port=atoi(w2); + else if(strcmpi(w1,"map_server_id")==0) + strcpy(map_server_id, w2); + else if(strcmpi(w1,"map_server_pw")==0) + strcpy(map_server_pw, w2); + else if(strcmpi(w1,"map_server_db")==0) + strcpy(map_server_db, w2); + else if(strcmpi(w1,"default_codepage")==0) + strcpy(default_codepage, w2); + else if(strcmpi(w1,"use_sql_db")==0) { + iMap->db_use_sqldbs = config_switch(w2); + ShowStatus ("Using SQL dbs: %s\n",w2); + } + /* sql log db */ + else if(strcmpi(w1,"log_db_ip")==0) + strcpy(log_db_ip, w2); + else if(strcmpi(w1,"log_db_id")==0) + strcpy(log_db_id, w2); + else if(strcmpi(w1,"log_db_pw")==0) + strcpy(log_db_pw, w2); + else if(strcmpi(w1,"log_db_port")==0) + log_db_port = atoi(w2); + else if(strcmpi(w1,"log_db_db")==0) + strcpy(log_db_db, w2); + /* mapreg */ + else if( mapreg_config_read(w1,w2) ) + continue; + /* import */ + else if(strcmpi(w1,"import")==0) + inter_config_read(w2); } fclose(fp); diff --git a/src/map/map.h b/src/map/map.h index 9126f39a7..3e7c45bc3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -796,6 +796,7 @@ struct map_interface { char mob_db2_db[32]; char mob_skill_db_db[32]; char mob_skill_db2_db[32]; + char interreg_db[32]; /* funcs */ void (*zone_init) (void); |