Prechádzať zdrojové kódy

Register .unit compiler into BundleCompiler and fix compiled resource names

Daniele Bartolini 12 rokov pred
rodič
commit
743262ecf6

+ 5 - 1
engine/compilers/BundleCompiler.cpp

@@ -97,7 +97,7 @@ bool BundleCompiler::compile(const char* bundle_dir, const char* source_dir, con
 		uint32_t resource_type_hash = hash::murmur2_32(filename_extension, string::strlen(filename_extension), 0);
 
 		char out_name[65];
-		snprintf(out_name, 65, "%"PRIx64"", filename_hash);
+		snprintf(out_name, 65, "%.16"PRIx64"", filename_hash);
 
 		// Skip crown.config file
 		if (resource_type_hash == CONFIG_TYPE)
@@ -128,6 +128,10 @@ bool BundleCompiler::compile(const char* bundle_dir, const char* source_dir, con
 		{
 			result = m_package.compile(source_dir, bundle_dir, filename, out_name);
 		}
+		else if (resource_type_hash == UNIT_TYPE)
+		{
+			result = m_unit.compile(source_dir, bundle_dir, filename, out_name);
+		}
 		else
 		{
 			Log::e("Oops, unknown resource type!");

+ 2 - 0
engine/compilers/BundleCompiler.h

@@ -34,6 +34,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "DynamicString.h"
 #include "Vector.h"
 #include "DiskFilesystem.h"
+#include "UnitCompiler.h"
 
 namespace crown
 {
@@ -60,6 +61,7 @@ private:
 	LuaCompiler 	m_lua;
 	SoundCompiler	m_sound;
 	PackageCompiler m_package;
+	UnitCompiler	m_unit;
 };
 
 } // namespace crown

+ 1 - 1
engine/resource/FileBundle.cpp

@@ -64,7 +64,7 @@ public:
 	{
 		// Convert name/type into strings
 		char resource_name[512];
-		snprintf(resource_name, 512, "%"PRIx64"", name.id);
+		snprintf(resource_name, 512, "%.16"PRIx64"", name.id);
 		
 		// Search the resource in the filesystem
 		// bool exists = m_filesystem.exists(resource_name);

+ 4 - 4
engine/resource/ResourceManager.cpp

@@ -63,7 +63,7 @@ ResourceId ResourceManager::load(const char* type, const char* name)
 //-----------------------------------------------------------------------------
 void ResourceManager::unload(ResourceId name)
 {
-	CE_ASSERT(has(name), "Resource not loaded:" "%"PRIx64"", name.id);
+	CE_ASSERT(has(name), "Resource not loaded:" "%.16"PRIx64"", name.id);
 
 	ResourceEntry* entry = find(name);
 
@@ -103,7 +103,7 @@ bool ResourceManager::has(ResourceId name) const
 //-----------------------------------------------------------------------------
 const void* ResourceManager::data(ResourceId name) const
 {
-	CE_ASSERT(has(name), "Resource not loaded:" "%"PRIx64"", name.id);
+	CE_ASSERT(has(name), "Resource not loaded:" "%.16"PRIx64"", name.id);
 
 	return find(name)->resource;
 }
@@ -111,7 +111,7 @@ const void* ResourceManager::data(ResourceId name) const
 //-----------------------------------------------------------------------------
 bool ResourceManager::is_loaded(ResourceId name) const
 {
-	CE_ASSERT(has(name), "Resource not loaded:" "%"PRIx64"", name.id);
+	CE_ASSERT(has(name), "Resource not loaded:" "%.16"PRIx64"", name.id);
 
 	return find(name)->resource != NULL;
 }
@@ -119,7 +119,7 @@ bool ResourceManager::is_loaded(ResourceId name) const
 //-----------------------------------------------------------------------------
 uint32_t ResourceManager::references(ResourceId name) const
 {
-	CE_ASSERT(has(name), "Resource not loaded:" "%"PRIx64"", name.id);
+	CE_ASSERT(has(name), "Resource not loaded:" "%.16"PRIx64"", name.id);
 
 	return find(name)->references;
 }