Daniele Bartolini 8 vuotta sitten
vanhempi
sitoutus
685ec57235
2 muutettua tiedostoa jossa 12 lisäystä ja 25 poistoa
  1. 4 9
      src/resource/data_compiler.cpp
  2. 8 16
      src/resource/resource_loader.cpp

+ 4 - 9
src/resource/data_compiler.cpp

@@ -350,8 +350,6 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 		TempAllocator1024 ta;
 		DynamicString path(ta);
 		DynamicString src_path(ta);
-		DynamicString type_str(ta);
-		DynamicString name_str(ta);
 		DynamicString dst_path(ta);
 
 		StringId64 _type(type);
@@ -362,14 +360,10 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 		src_path += '.';
 		src_path += type;
 
-		// Build compiled file path
-		_type.to_string(type_str);
-		_name.to_string(name_str);
-
 		// Build destination file path
-		dst_path += type_str;
-		dst_path += '-';
-		dst_path += name_str;
+		StringId64 mix;
+		mix._id = _type._id ^ _name._id;
+		mix.to_string(dst_path);
 
 		path::join(path, CROWN_DATA_DIRECTORY, dst_path.c_str());
 
@@ -378,6 +372,7 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 		if (!can_compile(_type))
 		{
 			loge(COMPILER, "Unknown resource type: '%s'", type);
+			loge(COMPILER, "Append extension to " CROWN_DATAIGNORE " to ignore the type");
 			success = false;
 			break;
 		}

+ 8 - 16
src/resource/resource_loader.cpp

@@ -33,16 +33,12 @@ ResourceLoader::~ResourceLoader()
 
 bool ResourceLoader::can_load(StringId64 type, StringId64 name)
 {
-	TempAllocator128 ta;
-	DynamicString type_str(ta);
-	DynamicString name_str(ta);
-	type.to_string(type_str);
-	name.to_string(name_str);
+	StringId64 mix;
+	mix._id = type._id ^ name._id;
 
+	TempAllocator128 ta;
 	DynamicString res_path(ta);
-	res_path += type_str;
-	res_path += '-';
-	res_path += name_str;
+	mix.to_string(res_path);
 
 	DynamicString path(ta);
 	path::join(path, CROWN_DATA_DIRECTORY, res_path.c_str());
@@ -102,16 +98,12 @@ s32 ResourceLoader::run()
 		ResourceRequest rr = queue::front(_requests);
 		_mutex.unlock();
 
-		TempAllocator128 ta;
-		DynamicString type_str(ta);
-		DynamicString name_str(ta);
-		rr.type.to_string(type_str);
-		rr.name.to_string(name_str);
+		StringId64 mix;
+		mix._id = rr.type._id ^ rr.name._id;
 
+		TempAllocator128 ta;
 		DynamicString res_path(ta);
-		res_path += type_str;
-		res_path += '-';
-		res_path += name_str;
+		mix.to_string(res_path);
 
 		DynamicString path(ta);
 		path::join(path, CROWN_DATA_DIRECTORY, res_path.c_str());