Daniele Bartolini 10 лет назад
Родитель
Сommit
3e502a30fc

+ 1 - 3
src/resource/font_resource.cpp

@@ -28,8 +28,6 @@ namespace font_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -50,7 +48,7 @@ namespace font_resource
 		}
 		}
 
 
 		FontResource fr;
 		FontResource fr;
-		fr.version = VERSION;
+		fr.version = FONT_VERSION;
 		fr.num_glyphs = array::size(m_glyphs);
 		fr.num_glyphs = array::size(m_glyphs);
 		fr.texture_size = size.to_int();
 		fr.texture_size = size.to_int();
 		fr.font_size = font_size.to_int();
 		fr.font_size = font_size.to_int();

+ 1 - 3
src/resource/level_resource.cpp

@@ -175,8 +175,6 @@ namespace level_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -215,7 +213,7 @@ namespace level_resource
 		}
 		}
 
 
 		LevelResource lr;
 		LevelResource lr;
-		lr.version = VERSION;
+		lr.version = LEVEL_VERSION;
 		lr.num_units = array::size(units);
 		lr.num_units = array::size(units);
 		lr.num_sounds = array::size(sounds);
 		lr.num_sounds = array::size(sounds);
 
 

+ 1 - 3
src/resource/lua_resource.cpp

@@ -23,8 +23,6 @@ namespace lua_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		TempAllocator1024 alloc;
 		TempAllocator1024 alloc;
 		DynamicString res_abs_path(alloc);
 		DynamicString res_abs_path(alloc);
 		TempAllocator1024 alloc2;
 		TempAllocator1024 alloc2;
@@ -52,7 +50,7 @@ namespace lua_resource
 		opts.delete_file(bc_abs_path.c_str());
 		opts.delete_file(bc_abs_path.c_str());
 
 
 		LuaResource lr;
 		LuaResource lr;
-		lr.version = VERSION;
+		lr.version = SCRIPT_VERSION;
 		lr.size = array::size(blob);
 		lr.size = array::size(blob);
 
 
 		opts.write(lr.version);
 		opts.write(lr.version);

+ 1 - 3
src/resource/material_resource.cpp

@@ -147,8 +147,6 @@ namespace material_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -163,7 +161,7 @@ namespace material_resource
 		parse_uniforms(root, unidata, names, dynblob);
 		parse_uniforms(root, unidata, names, dynblob);
 
 
 		MaterialResource mr;
 		MaterialResource mr;
-		mr.version = VERSION;
+		mr.version = MATERIAL_VERSION;
 		mr.shader = shader;
 		mr.shader = shader;
 		mr.num_textures = array::size(texdata);
 		mr.num_textures = array::size(texdata);
 		mr.texture_data_offset = sizeof(mr);
 		mr.texture_data_offset = sizeof(mr);

+ 1 - 3
src/resource/mesh_resource.cpp

@@ -33,8 +33,6 @@ namespace mesh_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -148,7 +146,7 @@ namespace mesh_resource
 		decl.end();
 		decl.end();
 
 
 		// Write
 		// Write
-		opts.write(VERSION);
+		opts.write(MESH_VERSION);
 		opts.write(decl);
 		opts.write(decl);
 		opts.write(array::size(vertices));
 		opts.write(array::size(vertices));
 		for (uint32_t i = 0; i < array::size(vertices); ++i)
 		for (uint32_t i = 0; i < array::size(vertices); ++i)

+ 1 - 3
src/resource/package_resource.cpp

@@ -17,8 +17,6 @@ namespace package_resource
 {
 {
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -52,7 +50,7 @@ namespace package_resource
 		const uint32_t num_sprite_animations = sprite_animation.is_nil() ? 0 : sprite_animation.size();
 		const uint32_t num_sprite_animations = sprite_animation.is_nil() ? 0 : sprite_animation.size();
 
 
 		// Write header
 		// Write header
-		opts.write(VERSION);
+		opts.write(PACKAGE_VERSION);
 		opts.write(num_textures);
 		opts.write(num_textures);
 		uint32_t offt = sizeof(PackageResource);
 		uint32_t offt = sizeof(PackageResource);
 		opts.write(offt);
 		opts.write(offt);

+ 2 - 6
src/resource/physics_resource.cpp

@@ -225,8 +225,6 @@ namespace physics_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -255,7 +253,7 @@ namespace physics_resource
 		if (root.has_key("joints")) parse_joints(root.key("joints"), m_joints);
 		if (root.has_key("joints")) parse_joints(root.key("joints"), m_joints);
 
 
 		PhysicsResource pr;
 		PhysicsResource pr;
-		pr.version = VERSION;
+		pr.version = PHYSICS_VERSION;
 		pr.num_controllers = m_has_controller ? 1 : 0;
 		pr.num_controllers = m_has_controller ? 1 : 0;
 		pr.num_actors = array::size(m_actors);
 		pr.num_actors = array::size(m_actors);
 		pr.num_joints = array::size(m_joints);
 		pr.num_joints = array::size(m_joints);
@@ -588,8 +586,6 @@ namespace physics_config_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -620,7 +616,7 @@ namespace physics_config_resource
 
 
 		// Setup struct for writing
 		// Setup struct for writing
 		PhysicsConfigResource pcr;
 		PhysicsConfigResource pcr;
-		pcr.version = VERSION;
+		pcr.version = PHYSICS_CONFIG_VERSION;
 		pcr.num_materials = array::size(material_names);
 		pcr.num_materials = array::size(material_names);
 		pcr.num_shapes = array::size(shape_names);
 		pcr.num_shapes = array::size(shape_names);
 		pcr.num_actors = array::size(actor_names);
 		pcr.num_actors = array::size(actor_names);

+ 14 - 14
src/resource/resource_types.h

@@ -35,20 +35,20 @@
 #define TEXTURE_TYPE               StringId64(0xcd4238c6a0c69e32)
 #define TEXTURE_TYPE               StringId64(0xcd4238c6a0c69e32)
 #define UNIT_TYPE                  StringId64(0xe0a48d0be9a7453f)
 #define UNIT_TYPE                  StringId64(0xe0a48d0be9a7453f)
 
 
-// #define FONT_VERSION               uint32_t(1)
-// #define LEVEL_VERSION              uint32_t(1)
-// #define LUA_VERSION                uint32_t(1)
-// #define MATERIAL_VERSION           uint32_t(1)
-// #define MESH_VERSION               uint32_t(1)
-// #define PACKAGE_VERSION            uint32_t(1)
-// #define PHYSICS_CONFIG_VERSION     uint32_t(1)
-// #define PHYSICS_VERSION            uint32_t(1)
-// #define SHADER_VERSION             uint32_t(1)
-// #define SOUND_VERSION              uint32_t(1)
-// #define SPRITE_ANIMATION_VERSION   uint32_t(1)
-// #define SPRITE_VERSION             uint32_t(1)
-// #define TEXTURE_VERSION            uint32_t(1)
-// #define UNIT_VERSION               uint32_t(1)
+#define FONT_VERSION               uint32_t(1)
+#define LEVEL_VERSION              uint32_t(1)
+#define SCRIPT_VERSION             uint32_t(1)
+#define MATERIAL_VERSION           uint32_t(1)
+#define MESH_VERSION               uint32_t(1)
+#define PACKAGE_VERSION            uint32_t(1)
+#define PHYSICS_CONFIG_VERSION     uint32_t(1)
+#define PHYSICS_VERSION            uint32_t(1)
+#define SHADER_VERSION             uint32_t(1)
+#define SOUND_VERSION              uint32_t(1)
+#define SPRITE_ANIMATION_VERSION   uint32_t(1)
+#define SPRITE_VERSION             uint32_t(1)
+#define TEXTURE_VERSION            uint32_t(1)
+#define UNIT_VERSION               uint32_t(1)
 
 
 namespace crown
 namespace crown
 {
 {

+ 1 - 3
src/resource/sound_resource.cpp

@@ -32,8 +32,6 @@ namespace sound_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -47,7 +45,7 @@ namespace sound_resource
 
 
 		// Write
 		// Write
 		SoundResource sr;
 		SoundResource sr;
-		sr.version = VERSION;
+		sr.version = SOUND_VERSION;
 		sr.size = wav->data_size;
 		sr.size = wav->data_size;
 		sr.sample_rate = wav->fmt_sample_rate;
 		sr.sample_rate = wav->fmt_sample_rate;
 		sr.avg_bytes_ps = wav->fmt_avarage;
 		sr.avg_bytes_ps = wav->fmt_avarage;

+ 2 - 6
src/resource/sprite_resource.cpp

@@ -43,8 +43,6 @@ namespace sprite_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -102,7 +100,7 @@ namespace sprite_resource
 		const uint32_t num_indices = array::size(indices);
 		const uint32_t num_indices = array::size(indices);
 
 
 		// Write header
 		// Write header
-		opts.write(VERSION);
+		opts.write(SPRITE_VERSION);
 
 
 		opts.write(num_vertices);
 		opts.write(num_vertices);
 		for (uint32_t i = 0; i < array::size(vertices); i++)
 		for (uint32_t i = 0; i < array::size(vertices); i++)
@@ -198,8 +196,6 @@ namespace sprite_animation_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -211,7 +207,7 @@ namespace sprite_animation_resource
 		parse_animations(root, anim_names, anim_data, anim_frames);
 		parse_animations(root, anim_names, anim_data, anim_frames);
 
 
 		SpriteAnimationResource sar;
 		SpriteAnimationResource sar;
-		sar.version = VERSION;
+		sar.version = SPRITE_ANIMATION_VERSION;
 		sar.num_animations = array::size(anim_names);
 		sar.num_animations = array::size(anim_names);
 		sar.num_frames = array::size(anim_frames);
 		sar.num_frames = array::size(anim_frames);
 		sar.frames_offset = uint32_t(sizeof(SpriteAnimationResource) +
 		sar.frames_offset = uint32_t(sizeof(SpriteAnimationResource) +

+ 1 - 3
src/resource/texture_resource.cpp

@@ -558,8 +558,6 @@ namespace texture_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -595,7 +593,7 @@ namespace texture_resource
 		opts._fs.close(source);
 		opts._fs.close(source);
 
 
 		// Write DDS
 		// Write DDS
-		opts.write(VERSION); // Version
+		opts.write(TEXTURE_VERSION); // Version
 		opts.write(uint32_t(0)); // Size
 		opts.write(uint32_t(0)); // Size
 		write_dds(opts._bw, image);
 		write_dds(opts._bw, image);
 
 

+ 1 - 3
src/resource/unit_resource.cpp

@@ -239,8 +239,6 @@ namespace unit_resource
 
 
 	void compile(const char* path, CompileOptions& opts)
 	void compile(const char* path, CompileOptions& opts)
 	{
 	{
-		static const uint32_t VERSION = 1;
-
 		Buffer buf = opts.read(path);
 		Buffer buf = opts.read(path);
 		JSONParser json(buf);
 		JSONParser json(buf);
 		JSONElement root = json.root();
 		JSONElement root = json.root();
@@ -285,7 +283,7 @@ namespace unit_resource
 			sprite_anim = root.key("sprite_animation").to_resource_id();
 			sprite_anim = root.key("sprite_animation").to_resource_id();
 
 
 		UnitResource ur;
 		UnitResource ur;
-		ur.version = VERSION;
+		ur.version = UNIT_VERSION;
 		ur.name = StringId64(unit_name.c_str());
 		ur.name = StringId64(unit_name.c_str());
 		ur.physics_resource = m_physics_resource;
 		ur.physics_resource = m_physics_resource;
 		ur.sprite_animation = sprite_anim;
 		ur.sprite_animation = sprite_anim;