Browse Source

* Fixed DB Import that not being read some imported files. bugreport:8543 http://rathena.org/board/tracker/issue-8543-import-folder-nolonger-working/
* Fixed packet_db always be 45. bugreport:8487 http://rathena.org/board/tracker/issue-8487-packet-version-is-always-45-for-map-server/
* Follow up 46ca940

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>

Cydh Ramdh 11 years ago
parent
commit
26025e600b
14 changed files with 116 additions and 81 deletions
  1. 2 0
      src/config/const.h
  2. 1 1
      src/map/cashshop.c
  3. 1 1
      src/map/chrif.c
  4. 9 11
      src/map/clif.c
  5. 7 7
      src/map/elemental.c
  6. 2 2
      src/map/guild.c
  7. 5 5
      src/map/homunculus.c
  8. 21 11
      src/map/itemdb.c
  9. 20 13
      src/map/mob.c
  10. 19 13
      src/map/pc.c
  11. 2 2
      src/map/pet.c
  12. 1 1
      src/map/quest.c
  13. 14 8
      src/map/skill.c
  14. 12 6
      src/map/status.c

+ 2 - 0
src/config/const.h

@@ -37,6 +37,8 @@
 	#define DBPATH "pre-re/"
 	#define DBPATH "pre-re/"
 #endif
 #endif
 
 
+#define DBIMPORT "import"
+
 /**
 /**
  * DefType
  * DefType
  **/
  **/

+ 1 - 1
src/map/cashshop.c

@@ -69,7 +69,7 @@ static int cashshop_parse_dbrow( char** str, const char* source, int line ){
  * parses lines and sends them to parse_dbrow.
  * parses lines and sends them to parse_dbrow.
  */
  */
 static void cashshop_read_db_txt( void ){
 static void cashshop_read_db_txt( void ){
-	const char* filename[] = { DBPATH"item_cash_db.txt", "import/item_cash_db.txt" };
+	const char* filename[] = { DBPATH"item_cash_db.txt", DBIMPORT"/item_cash_db.txt" };
 	int fi;
 	int fi;
 
 
 	for( fi = 0; fi < ARRAYLENGTH( filename ); ++fi ){
 	for( fi = 0; fi < ARRAYLENGTH( filename ); ++fi ){

+ 1 - 1
src/map/chrif.c

@@ -564,7 +564,7 @@ void chrif_on_ready(void) {
 	//Re-save any guild castles that were modified in the disconnection time.
 	//Re-save any guild castles that were modified in the disconnection time.
 	guild_castle_reconnect(-1, 0, 0);
 	guild_castle_reconnect(-1, 0, 0);
 	
 	
-	// Charserver is ready for laoding autotrader
+	// Charserver is ready for loading autotrader
 	do_init_vending_autotrade();
 	do_init_vending_autotrade();
 }
 }
 
 

+ 9 - 11
src/map/clif.c

@@ -17371,7 +17371,7 @@ void packetdb_readdb(void)
 	int ln=0, entries=0;
 	int ln=0, entries=0;
 	int cmd,i,j,packet_ver;
 	int cmd,i,j,packet_ver;
 	int max_cmd=-1;
 	int max_cmd=-1;
-	int skip_ver = 0;
+	bool skip_ver = false;
 	int warned = 0;
 	int warned = 0;
 	char *str[64],*p,*str2[64],*p2,w1[256],w2[256];
 	char *str[64],*p,*str2[64],*p2,w1[256],w2[256];
 	int packet_len_table[MAX_PACKET_DB] = {
 	int packet_len_table[MAX_PACKET_DB] = {
@@ -17849,26 +17849,25 @@ void packetdb_readdb(void)
 		{ "ZC_PERSONAL_INFOMATION_CHN", ZC_PERSONAL_INFOMATION_CHN},
 		{ "ZC_PERSONAL_INFOMATION_CHN", ZC_PERSONAL_INFOMATION_CHN},
 		{ "ZC_CLEAR_DIALOG", ZC_CLEAR_DIALOG},
 		{ "ZC_CLEAR_DIALOG", ZC_CLEAR_DIALOG},
 	};
 	};
-	const char *filename[] = { "packet_db.txt", "import/packet_db.txt"};
+	const char *filename[] = { "packet_db.txt", DBIMPORT"/packet_db.txt"};
 	int f;
 	int f;
 
 
 	// initialize packet_db[SERVER] from hardcoded packet_len_table[] values
 	// initialize packet_db[SERVER] from hardcoded packet_len_table[] values
 	memset(packet_db,0,sizeof(packet_db));
 	memset(packet_db,0,sizeof(packet_db));
 	for( i = 0; i < ARRAYLENGTH(packet_len_table); ++i )
 	for( i = 0; i < ARRAYLENGTH(packet_len_table); ++i )
 		packet_len(i) = packet_len_table[i];
 		packet_len(i) = packet_len_table[i];
-
+	
+	clif_config.packet_db_ver = MAX_PACKET_VER;
 	for(f = 0; f<ARRAYLENGTH(filename); f++){
 	for(f = 0; f<ARRAYLENGTH(filename); f++){
 		entries = 0;
 		entries = 0;
 		sprintf(line, "%s/%s", db_path,filename[f]);
 		sprintf(line, "%s/%s", db_path,filename[f]);
 		if( (fp=fopen(line,"r"))==NULL ){
 		if( (fp=fopen(line,"r"))==NULL ){
 			if(f==0) {
 			if(f==0) {
-				ShowFatalError("can't read %s\n", line);
+				ShowFatalError("Can't read %s\n", line);
 				exit(EXIT_FAILURE);
 				exit(EXIT_FAILURE);
 			}
 			}
 			return;
 			return;
 		}
 		}
-
-		clif_config.packet_db_ver = MAX_PACKET_VER;
 		packet_ver = MAX_PACKET_VER;	// read into packet_db's version by default
 		packet_ver = MAX_PACKET_VER;	// read into packet_db's version by default
 		while( fgets(line, sizeof(line), fp) )
 		while( fgets(line, sizeof(line), fp) )
 		{
 		{
@@ -17886,21 +17885,21 @@ void packetdb_readdb(void)
 						if( (warned&1) == 0 )
 						if( (warned&1) == 0 )
 							ShowWarning("The packet_db table only has support up to version %d.\n", MAX_PACKET_VER);
 							ShowWarning("The packet_db table only has support up to version %d.\n", MAX_PACKET_VER);
 						warned &= 1;
 						warned &= 1;
-						skip_ver = 1;
+						skip_ver = true;
 					}
 					}
 					else if( packet_ver < 0 )
 					else if( packet_ver < 0 )
 					{
 					{
 						if( (warned&2) == 0 )
 						if( (warned&2) == 0 )
 							ShowWarning("Negative packet versions are not supported.\n");
 							ShowWarning("Negative packet versions are not supported.\n");
 						warned &= 2;
 						warned &= 2;
-						skip_ver = 1;
+						skip_ver = true;
 					}
 					}
 					else if( packet_ver == SERVER )
 					else if( packet_ver == SERVER )
 					{
 					{
 						if( (warned&4) == 0 )
 						if( (warned&4) == 0 )
 							ShowWarning("Packet version %d is reserved for server use only.\n", SERVER);
 							ShowWarning("Packet version %d is reserved for server use only.\n", SERVER);
 						warned &= 4;
 						warned &= 4;
-						skip_ver = 1;
+						skip_ver = true;
 					}
 					}
 
 
 					if( skip_ver )
 					if( skip_ver )
@@ -17919,12 +17918,11 @@ void packetdb_readdb(void)
 						clif_config.packet_db_ver = MAX_PACKET_VER;
 						clif_config.packet_db_ver = MAX_PACKET_VER;
 					else // to manually set the packet DB version
 					else // to manually set the packet DB version
 						clif_config.packet_db_ver = cap_value(atoi(w2), 0, MAX_PACKET_VER);
 						clif_config.packet_db_ver = cap_value(atoi(w2), 0, MAX_PACKET_VER);
-
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 
 
-			if( skip_ver != 0 )
+			if( skip_ver )
 				continue; // Skipping current packet version
 				continue; // Skipping current packet version
 
 
 			memset(str,0,sizeof(str));
 			memset(str,0,sizeof(str));

+ 7 - 7
src/map/elemental.c

@@ -777,7 +777,7 @@ int read_elementaldb(void) {
 
 
 	fp = fopen(line, "r");
 	fp = fopen(line, "r");
 	if( !fp ) {
 	if( !fp ) {
-		ShowError("read_elementaldb : can't read elemental_db.txt\n");
+		ShowError("read_elementaldb: Can't read elemental_db.txt\n");
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -796,7 +796,7 @@ int read_elementaldb(void) {
 			p = strtok(NULL, ",");
 			p = strtok(NULL, ",");
 		}
 		}
 		if( i < 26 ) {
 		if( i < 26 ) {
-			ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k);
+			ShowError("read_elementaldb: Incorrect number of columns at elemental_db.txt line %d.\n", k);
 			continue;
 			continue;
 		}
 		}
 
 
@@ -866,7 +866,7 @@ int read_elemental_skilldb(void) {
 	sprintf(line, "%s/%s", db_path, "elemental_skill_db.txt");
 	sprintf(line, "%s/%s", db_path, "elemental_skill_db.txt");
 	fp = fopen(line, "r");
 	fp = fopen(line, "r");
 	if( !fp ) {
 	if( !fp ) {
-		ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n");
+		ShowError("read_elemental_skilldb: Can't read elemental_skill_db.txt\n");
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -885,20 +885,20 @@ int read_elemental_skilldb(void) {
 			p = strtok(NULL, ",");
 			p = strtok(NULL, ",");
 		}
 		}
 		if( i < 4 ) {
 		if( i < 4 ) {
-			ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k);
+			ShowError("read_elemental_skilldb: Incorrect number of columns at elemental_skill_db.txt line %d.\n", k);
 			continue;
 			continue;
 		}
 		}
 
 
 		class_ = atoi(str[0]);
 		class_ = atoi(str[0]);
 		ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental_db[i].class_);
 		ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental_db[i].class_);
 		if( i == MAX_ELEMENTAL_CLASS ) {
 		if( i == MAX_ELEMENTAL_CLASS ) {
-			ShowError("read_elemental_skilldb : Class not found in elemental_db for skill entry, line %d.\n", k);
+			ShowError("read_elemental_skilldb: Class not found in elemental_db for skill entry, line %d.\n", k);
 			continue;
 			continue;
 		}
 		}
 
 
 		skill_id = atoi(str[1]);
 		skill_id = atoi(str[1]);
 		if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) {
 		if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) {
-			ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k);
+			ShowError("read_elemental_skilldb: Skill out of range, line %d.\n", k);
 			continue;
 			continue;
 		}
 		}
 
 
@@ -907,7 +907,7 @@ int read_elemental_skilldb(void) {
 
 
 		skillmode = atoi(str[3]);
 		skillmode = atoi(str[3]);
 		if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) {
 		if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) {
-			ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k);
+			ShowError("read_elemental_skilldb: Skillmode out of range, line %d.\n",k);
 			continue;
 			continue;
 		}
 		}
 		ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id );
 		ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id );

+ 2 - 2
src/map/guild.c

@@ -2088,7 +2088,7 @@ void guild_flags_clear(void) {
 void do_init_guild(void) {
 void do_init_guild(void) {
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"import/",
+		"/"DBIMPORT,
 	};
 	};
 	int i;
 	int i;
 	
 	
@@ -2104,7 +2104,7 @@ void do_init_guild(void) {
 	
 	
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
-		char* dbsubpath1 = aMalloc(n1+1);
+		char* dbsubpath1 = (char*)aMalloc(n1+1);
 		safesnprintf(dbsubpath1,n1+1,"%s%s",db_path,dbsubpath[i]);
 		safesnprintf(dbsubpath1,n1+1,"%s%s",db_path,dbsubpath[i]);
 		
 		
 		sv_readdb(dbsubpath1, "castle_db.txt", ',', 4, 4, -1, &guild_read_castledb, i);
 		sv_readdb(dbsubpath1, "castle_db.txt", ',', 4, 4, -1, &guild_read_castledb, i);

+ 5 - 5
src/map/homunculus.c

@@ -1219,7 +1219,7 @@ static bool read_homunculusdb_sub(char* str[], int columns, int current)
 int read_homunculusdb(void)
 int read_homunculusdb(void)
 {
 {
 	int i;
 	int i;
-	const char *filename[]={DBPATH"homunculus_db.txt","import/homunculus_db.txt"};
+	const char *filename[]={DBPATH"homunculus_db.txt",DBIMPORT"/homunculus_db.txt"};
 	memset(homunculus_db,0,sizeof(homunculus_db));
 	memset(homunculus_db,0,sizeof(homunculus_db));
 	for(i = 0; i<ARRAYLENGTH(filename); i++){
 	for(i = 0; i<ARRAYLENGTH(filename); i++){
 		sv_readdb(db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, &read_homunculusdb_sub, i);
 		sv_readdb(db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, &read_homunculusdb_sub, i);
@@ -1271,7 +1271,7 @@ static bool read_homunculus_skilldb_sub(char* split[], int columns, int current)
 
 
 int read_homunculus_skilldb(void)
 int read_homunculus_skilldb(void)
 {
 {
-	const char *filename[]={ "homun_skill_tree.txt","import/homun_skill_tree.txt"};
+	const char *filename[]={ "homun_skill_tree.txt",DBIMPORT"/homun_skill_tree.txt"};
 	int i;
 	int i;
 	memset(hskill_tree,0,sizeof(hskill_tree));
 	memset(hskill_tree,0,sizeof(hskill_tree));
 	for(i = 0; i<ARRAYLENGTH(filename); i++){
 	for(i = 0; i<ARRAYLENGTH(filename); i++){
@@ -1285,7 +1285,7 @@ void read_homunculus_expdb(void)
 	int i;
 	int i;
 	char *filename[]={
 	char *filename[]={
 		DBPATH"exp_homun.txt",
 		DBPATH"exp_homun.txt",
-		"import/exp_homun.txt"
+		DBIMPORT"/exp_homun.txt"
 	};
 	};
 
 
 	memset(hexptbl,0,sizeof(hexptbl));
 	memset(hexptbl,0,sizeof(hexptbl));
@@ -1299,7 +1299,7 @@ void read_homunculus_expdb(void)
 		if(fp == NULL){
 		if(fp == NULL){
 			if(i != 0)
 			if(i != 0)
 				continue;
 				continue;
-			if(i==0) ShowError("can't read %s\n",line);
+			if(i==0) ShowError("Can't read %s\n",line);
 			return;
 			return;
 		}
 		}
 		while(fgets(line, sizeof(line), fp) && j < MAX_LEVEL)
 		while(fgets(line, sizeof(line), fp) && j < MAX_LEVEL)
@@ -1317,7 +1317,7 @@ void read_homunculus_expdb(void)
 			hexptbl[MAX_LEVEL - 1] = 0;
 			hexptbl[MAX_LEVEL - 1] = 0;
 		}
 		}
 		fclose(fp);
 		fclose(fp);
-		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s"CL_RESET"'.\n", j, filename[i]);
+		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' levels in '"CL_WHITE"%s/%s"CL_RESET"'.\n", j, db_path, filename[i]);
 	}
 	}
 }
 }
 
 

+ 21 - 11
src/map/itemdb.c

@@ -667,7 +667,7 @@ static void itemdb_read_itemgroup_sub(const char* filename, bool silent)
 	char line[1024];
 	char line[1024];
 
 
 	if ((fp=fopen(filename,"r")) == NULL) {
 	if ((fp=fopen(filename,"r")) == NULL) {
-		if(silent == 0) ShowError("can't read %s\n", filename);
+		if(silent == 0) ShowError("Can't read %s\n", filename);
 		return;
 		return;
 	}
 	}
 	
 	
@@ -1311,7 +1311,7 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr
 static int itemdb_readdb(void){
 static int itemdb_readdb(void){
 	const char* filename[] = {
 	const char* filename[] = {
 		DBPATH"item_db.txt",
 		DBPATH"item_db.txt",
-		"import/item_db.txt" 
+		DBIMPORT"/item_db.txt" 
 	};
 	};
 
 
 	int fi;
 	int fi;
@@ -1556,7 +1556,7 @@ static void itemdb_read(void) {
 	int i;
 	int i;
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"/import",
+		"/"DBIMPORT,
 	};
 	};
 	
 	
 	if (db_use_sqldbs)
 	if (db_use_sqldbs)
@@ -1567,22 +1567,32 @@ static void itemdb_read(void) {
 	memset(&itemgroup_db, 0, sizeof(itemgroup_db));
 	memset(&itemgroup_db, 0, sizeof(itemgroup_db));
 	
 	
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
-		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
-		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
-		char* dbsubpath2 = aMalloc(n2+1);
-		safesnprintf(dbsubpath2,n1,"%s%s",db_path,dbsubpath[i]);
+		uint8 n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
+		uint8 n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
+		char* dbsubpath1 = (char*)aMalloc(n1+1);
+		char* dbsubpath2 = (char*)aMalloc(n2+1);
 		
 		
-		sv_readdb(dbsubpath2, "item_avail.txt",         ',', 2, 2, -1, &itemdb_read_itemavail, i);
-		sv_readdb(dbsubpath2, "item_stack.txt",         ',', 3, 3, -1, &itemdb_read_stack, i);
-		sv_readdb(dbsubpath2, "item_nouse.txt",         ',', 3, 3, -1, &itemdb_read_nouse, i);
+
+		if(i==0) {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
+		}
+		else {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n1,"%s%s",db_path,dbsubpath[i]);
+		}
+		
+		sv_readdb(dbsubpath1, "item_avail.txt",         ',', 2, 2, -1, &itemdb_read_itemavail, i);
+		sv_readdb(dbsubpath1, "item_stack.txt",         ',', 3, 3, -1, &itemdb_read_stack, i);
+		sv_readdb(dbsubpath1, "item_nouse.txt",         ',', 3, 3, -1, &itemdb_read_nouse, i);
 		
 		
-		if(i==0) safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
 		itemdb_read_itemgroup(dbsubpath2, i);
 		itemdb_read_itemgroup(dbsubpath2, i);
 		itemdb_read_combos(dbsubpath2,i); //TODO change this to sv_read ? id#script ?
 		itemdb_read_combos(dbsubpath2,i); //TODO change this to sv_read ? id#script ?
 		sv_readdb(dbsubpath2, "item_noequip.txt",       ',', 2, 2, -1, &itemdb_read_noequip, i);
 		sv_readdb(dbsubpath2, "item_noequip.txt",       ',', 2, 2, -1, &itemdb_read_noequip, i);
 		sv_readdb(dbsubpath2, "item_trade.txt",         ',', 3, 3, -1, &itemdb_read_itemtrade, i);
 		sv_readdb(dbsubpath2, "item_trade.txt",         ',', 3, 3, -1, &itemdb_read_itemtrade, i);
 		sv_readdb(dbsubpath2, "item_delay.txt",         ',', 2, 2, -1, &itemdb_read_itemdelay, i);
 		sv_readdb(dbsubpath2, "item_delay.txt",         ',', 2, 2, -1, &itemdb_read_itemdelay, i);
 		sv_readdb(dbsubpath2, "item_buyingstore.txt",   ',', 1, 1, -1, &itemdb_read_buyingstore, i);
 		sv_readdb(dbsubpath2, "item_buyingstore.txt",   ',', 1, 1, -1, &itemdb_read_buyingstore, i);
+		aFree(dbsubpath1);
 		aFree(dbsubpath2);
 		aFree(dbsubpath2);
 	}
 	}
 	itemdb_uid_load();
 	itemdb_uid_load();

+ 20 - 13
src/map/mob.c

@@ -4030,11 +4030,11 @@ static int mob_read_randommonster(void)
 		DBPATH"mob_boss.txt",
 		DBPATH"mob_boss.txt",
 		"mob_pouch.txt",
 		"mob_pouch.txt",
 		"mob_classchange.txt",
 		"mob_classchange.txt",
-		"import/mob_branch.txt",
-		"import/mob_poring.txt",
-		"import/mob_boss.txt",
-		"import/mob_pouch.txt",
-		"import/mob_classchange.txt"
+		DBIMPORT"/mob_branch.txt",
+		DBIMPORT"/mob_poring.txt",
+		DBIMPORT"/mob_boss.txt",
+		DBIMPORT"/mob_pouch.txt",
+		DBIMPORT"/mob_classchange.txt"
 	};
 	};
 
 
 	memset(&summon, 0, sizeof(summon));
 	memset(&summon, 0, sizeof(summon));
@@ -4076,7 +4076,7 @@ static int mob_read_randommonster(void)
 				if( summon[k].qty < ARRAYLENGTH(summon[k].mob_id) ) //MvPs
 				if( summon[k].qty < ARRAYLENGTH(summon[k].mob_id) ) //MvPs
 					summon[k].mob_id[summon[k].qty++] = mob_id;
 					summon[k].mob_id[summon[k].qty++] = mob_id;
 				else {
 				else {
-					ShowDebug("Can't store more random mobs from %s, increase size of mob.c:summon variable!\n", mobfile[i]);
+					ShowDebug("Can't store more random mobs from %s/%s, increase size of mob.c:summon variable!\n", db_path, mobfile[i]);
 					break;
 					break;
 				}
 				}
 			}
 			}
@@ -4088,7 +4088,7 @@ static int mob_read_randommonster(void)
 			summon[k].qty = 1;
 			summon[k].qty = 1;
 		}
 		}
 		fclose(fp);
 		fclose(fp);
-		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", entries, mobfile[i]);
+		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s/%s"CL_RESET"'.\n", entries, db_path, mobfile[i]);
 	}
 	}
 	return 0;
 	return 0;
 }
 }
@@ -4534,17 +4534,24 @@ static void mob_load(void)
 	int i;
 	int i;
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"import",
+		"/"DBIMPORT,
 	};
 	};
 	
 	
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){	
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){	
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
 		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
-		char* dbsubpath1 = aMalloc(n1+1);
-		char* dbsubpath2 = aMalloc(n2+1);
-		safesnprintf(dbsubpath1,n1+1,"%s%s",db_path,dbsubpath[i]);
-		if(i==0) safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
-		else safesnprintf(dbsubpath2,n2,"%s%s",db_path,dbsubpath[i]);
+
+		char* dbsubpath1 = (char*)aMalloc(n1+1);
+		char* dbsubpath2 = (char*)aMalloc(n2+1);
+		
+		if(i==0) {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
+		}
+		else {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n1,"%s%s",db_path,dbsubpath[i]);
+		}
 		
 		
 		sv_readdb(dbsubpath1, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio, i); // must be read before mobdb
 		sv_readdb(dbsubpath1, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio, i); // must be read before mobdb
 		sv_readdb(dbsubpath1, "mob_chat_db.txt", '#', 3, 3, MAX_MOB_CHAT, &mob_parse_row_chatdb, i);
 		sv_readdb(dbsubpath1, "mob_chat_db.txt", '#', 3, 3, MAX_MOB_CHAT, &mob_parse_row_chatdb, i);

+ 19 - 13
src/map/pc.c

@@ -10155,7 +10155,7 @@ static int pc_read_statsdb(const char *basedir, int last_s, bool silent){
 	fp=fopen(line,"r");
 	fp=fopen(line,"r");
 	if(fp == NULL){
 	if(fp == NULL){
 		if(silent==0) ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
 		if(silent==0) ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
-		return -1;
+		return max(last_s,i);
 	} else {
 	} else {
 		int entries=0;
 		int entries=0;
 		while(fgets(line, sizeof(line), fp))
 		while(fgets(line, sizeof(line), fp))
@@ -10192,7 +10192,7 @@ int pc_readdb(void)
 	int i, k, s = 1;
 	int i, k, s = 1;
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"import"
+		"/"DBIMPORT,
 		//add other path here
 		//add other path here
 	};
 	};
 		
 		
@@ -10202,11 +10202,11 @@ int pc_readdb(void)
 	// Reset and read skilltree
 	// Reset and read skilltree
 	memset(skill_tree,0,sizeof(skill_tree));
 	memset(skill_tree,0,sizeof(skill_tree));
 	sv_readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree, 0);
 	sv_readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree, 0);
-	sv_readdb(db_path, "import/skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree, 1);
+	sv_readdb(db_path, DBIMPORT"/skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree, 1);
 
 
 #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
 #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
 	sv_readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty, 0);
 	sv_readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty, 0);
-	sv_readdb(db_path, "import/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty, 1);
+	sv_readdb(db_path, DBIMPORT"/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty, 1);
 	for( k=1; k < 3; k++ ){ // fill in the blanks
 	for( k=1; k < 3; k++ ){ // fill in the blanks
 		int j;
 		int j;
 		for( j = 0; j < CLASS_ALL; j++ ){
 		for( j = 0; j < CLASS_ALL; j++ ){
@@ -10226,19 +10226,25 @@ int pc_readdb(void)
 	 // reset then read statspoint
 	 // reset then read statspoint
 	memset(statp,0,sizeof(statp));
 	memset(statp,0,sizeof(statp));
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
-		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
-		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
-		char* dbsubpath1 = aMalloc(n1+1);
-		char* dbsubpath2 = aMalloc(n2+1);
-		safesnprintf(dbsubpath1,n1+1,"%s%s",db_path,dbsubpath[i]);
-		if(i==0) safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
-		else safesnprintf(dbsubpath2,n2,"%s%s",db_path,dbsubpath[i]);
+		uint8 n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
+		uint8 n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
+		char* dbsubpath1 = (char*)aMalloc(n1+1);
+		char* dbsubpath2 = (char*)aMalloc(n2+1);
+
+		if(i==0) {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
+		}
+		else {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n1,"%s%s",db_path,dbsubpath[i]);
+		}
 
 
 		s = pc_read_statsdb(dbsubpath2,s,i);
 		s = pc_read_statsdb(dbsubpath2,s,i);
 #ifdef RENEWAL_ASPD
 #ifdef RENEWAL_ASPD
-		sv_readdb(dbsubpath1, "re/job_db1.txt",',',6+MAX_WEAPON_TYPE,6+MAX_WEAPON_TYPE,CLASS_COUNT,&pc_readdb_job1, i);
+		sv_readdb(dbsubpath2, "job_db1.txt",',',6+MAX_WEAPON_TYPE,6+MAX_WEAPON_TYPE,CLASS_COUNT,&pc_readdb_job1, i);
 #else
 #else
-		sv_readdb(dbsubpath1, "pre-re/job_db1.txt",',',5+MAX_WEAPON_TYPE,5+MAX_WEAPON_TYPE,CLASS_COUNT,&pc_readdb_job1, i);
+		sv_readdb(dbsubpath2, "job_db1.txt",',',5+MAX_WEAPON_TYPE,5+MAX_WEAPON_TYPE,CLASS_COUNT,&pc_readdb_job1, i);
 #endif
 #endif
 		sv_readdb(dbsubpath1, "job_db2.txt",',',1,1+MAX_LEVEL,CLASS_COUNT,&pc_readdb_job2, i);
 		sv_readdb(dbsubpath1, "job_db2.txt",',',1,1+MAX_LEVEL,CLASS_COUNT,&pc_readdb_job2, i);
 		sv_readdb(dbsubpath2, "job_exp.txt",',',4,1000+3,CLASS_COUNT*2,&pc_readdb_job_exp, i); //support till 1000lvl
 		sv_readdb(dbsubpath2, "job_exp.txt",',',4,1000+3,CLASS_COUNT*2,&pc_readdb_job_exp, i); //support till 1000lvl

+ 2 - 2
src/map/pet.c

@@ -1213,7 +1213,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
  *------------------------------------------*/
  *------------------------------------------*/
 int read_petdb()
 int read_petdb()
 {
 {
-	char* filename[] = {"pet_db.txt","import/pet_db.txt"};
+	char* filename[] = {"pet_db.txt",DBIMPORT"/pet_db.txt"};
 	FILE *fp;
 	FILE *fp;
 	int nameid,i,j,k;
 	int nameid,i,j,k;
 
 
@@ -1349,7 +1349,7 @@ int read_petdb()
 		if( j >= MAX_PET_DB )
 		if( j >= MAX_PET_DB )
 			ShowWarning("read_petdb: Reached max number of pets [%d]. Remaining pets were not read.\n ", MAX_PET_DB);
 			ShowWarning("read_petdb: Reached max number of pets [%d]. Remaining pets were not read.\n ", MAX_PET_DB);
 		fclose(fp);
 		fclose(fp);
-		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' pets in '"CL_WHITE"%s"CL_RESET"'.\n", entries, filename[i]);
+		ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' pets in '"CL_WHITE"%s/%s"CL_RESET"'.\n", entries, db_path, filename[i]);
 	}
 	}
 	return 0;
 	return 0;
 }
 }

+ 1 - 1
src/map/quest.c

@@ -300,7 +300,7 @@ int quest_check(TBL_PC * sd, int quest_id, quest_check_type type) {
 int quest_read_db(void) {
 int quest_read_db(void) {
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"import/",
+		DBIMPORT"/",
 	};
 	};
 	int f;
 	int f;
 
 

+ 14 - 8
src/map/skill.c

@@ -19227,7 +19227,7 @@ static void skill_readdb(void) {
 	int i;
 	int i;
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"import"
+		"/"DBIMPORT,
 		//add other path here
 		//add other path here
 	};
 	};
 	
 	
@@ -19247,18 +19247,24 @@ static void skill_readdb(void) {
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
 		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
-		char* dbsubpath1 = aMalloc(n1+1);
-		char* dbsubpath2 = aMalloc(n2+1);
-		safesnprintf(dbsubpath1,n1+1,"%s%s",db_path,dbsubpath[i]);
-		if(i==0) safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
-		else safesnprintf(dbsubpath2,n2,"%s%s",db_path,dbsubpath[i]);
+		char* dbsubpath1 = (char*)aMalloc(n1+1);
+		char* dbsubpath2 = (char*)aMalloc(n2+1);
+
+		if(i==0) {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
+		}
+		else {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n1,"%s%s",db_path,dbsubpath[i]);
+		}
 		
 		
 		sv_readdb(dbsubpath2, "skill_db.txt"          , ',',  18, 18, MAX_SKILL_DB, skill_parse_row_skilldb, i);
 		sv_readdb(dbsubpath2, "skill_db.txt"          , ',',  18, 18, MAX_SKILL_DB, skill_parse_row_skilldb, i);
 		sv_readdb(dbsubpath2, "skill_require_db.txt"  , ',',  34, 34, MAX_SKILL_DB, skill_parse_row_requiredb, i);
 		sv_readdb(dbsubpath2, "skill_require_db.txt"  , ',',  34, 34, MAX_SKILL_DB, skill_parse_row_requiredb, i);
 #ifdef RENEWAL_CAST
 #ifdef RENEWAL_CAST
-		sv_readdb(dbsubpath1, "re/skill_cast_db.txt"        , ',',   8,  8, MAX_SKILL_DB, skill_parse_row_castdb, i);
+		sv_readdb(dbsubpath2, "skill_cast_db.txt"        , ',',   8,  8, MAX_SKILL_DB, skill_parse_row_castdb, i);
 #else
 #else
-		sv_readdb(dbsubpath1, "pre-re/skill_cast_db.txt"    , ',',   7,  7, MAX_SKILL_DB, skill_parse_row_castdb, i);
+		sv_readdb(dbsubpath2, "skill_cast_db.txt"    , ',',   7,  7, MAX_SKILL_DB, skill_parse_row_castdb, i);
 #endif
 #endif
 		sv_readdb(dbsubpath2, "skill_castnodex_db.txt", ',',   2,  3, MAX_SKILL_DB, skill_parse_row_castnodexdb, i);
 		sv_readdb(dbsubpath2, "skill_castnodex_db.txt", ',',   2,  3, MAX_SKILL_DB, skill_parse_row_castnodexdb, i);
 		sv_readdb(dbsubpath2, "skill_unit_db.txt"     , ',',   8,  8, MAX_SKILL_DB, skill_parse_row_unitdb, i);
 		sv_readdb(dbsubpath2, "skill_unit_db.txt"     , ',',   8,  8, MAX_SKILL_DB, skill_parse_row_unitdb, i);

+ 12 - 6
src/map/status.c

@@ -12353,7 +12353,7 @@ int status_readdb(void)
 	int i, j, k;
 	int i, j, k;
 	const char* dbsubpath[] = {
 	const char* dbsubpath[] = {
 		"",
 		"",
-		"import"
+		"/"DBIMPORT,
 		//add other path here
 		//add other path here
 	};
 	};
 	// Initialize databases to default
 	// Initialize databases to default
@@ -12382,11 +12382,17 @@ int status_readdb(void)
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 	for(i=0; i<ARRAYLENGTH(dbsubpath); i++){
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n1 = strlen(db_path)+strlen(dbsubpath[i])+1;
 		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
 		int n2 = strlen(db_path)+strlen(DBPATH)+strlen(dbsubpath[i])+1;
-		char* dbsubpath1 = aMalloc(n1+1);
-		char* dbsubpath2 = aMalloc(n2+1);
-		safesnprintf(dbsubpath1,n1+1,"%s%s",db_path,dbsubpath[i]);
-		if(i==0) safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
-		else safesnprintf(dbsubpath2,n2,"%s%s",db_path,dbsubpath[i]);
+		char* dbsubpath1 = (char*)aMalloc(n1+1);
+		char* dbsubpath2 = (char*)aMalloc(n2+1);
+
+		if(i==0) {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n2,"%s/%s%s",db_path,DBPATH,dbsubpath[i]);
+		}
+		else {
+			safesnprintf(dbsubpath1,n1,"%s%s",db_path,dbsubpath[i]);
+			safesnprintf(dbsubpath2,n1,"%s%s",db_path,dbsubpath[i]);
+		}
 		
 		
 		status_readdb_attrfix(dbsubpath2,i); // !TODO use sv_readdb ?
 		status_readdb_attrfix(dbsubpath2,i); // !TODO use sv_readdb ?
 		sv_readdb(dbsubpath1, "size_fix.txt",',',MAX_WEAPON_TYPE,MAX_WEAPON_TYPE,ARRAYLENGTH(atkmods),&status_readdb_sizefix, i);
 		sv_readdb(dbsubpath1, "size_fix.txt",',',MAX_WEAPON_TYPE,MAX_WEAPON_TYPE,ARRAYLENGTH(atkmods),&status_readdb_sizefix, i);