Procházet zdrojové kódy

resource: update data versions after full compilation is done

Daniele Bartolini před 5 roky
rodič
revize
c03a7cce12
2 změnil soubory, kde provedl 13 přidání a 1 odebrání
  1. 1 0
      docs/changelog.rst
  2. 12 1
      src/resource/data_compiler.cpp

+ 1 - 0
docs/changelog.rst

@@ -7,6 +7,7 @@ Changelog
 
 
 **Data Compiler**
 **Data Compiler**
 
 
+* Fixed an issue that caused resources to not be compiled with the proper version in rare circumnstances
 * Fixed an issue that caused the compiler to crash when reading empty source files
 * Fixed an issue that caused the compiler to crash when reading empty source files
 * Fixed an issue that prevented the output from external data compilers to not be read under Windows
 * Fixed an issue that prevented the output from external data compilers to not be read under Windows
 
 

+ 12 - 1
src/resource/data_compiler.cpp

@@ -1091,7 +1091,6 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 			if (!path_is_special(path.c_str()))
 			if (!path_is_special(path.c_str()))
 			{
 			{
 				hash_map::set(_data_index, id, path);
 				hash_map::set(_data_index, id, path);
-				hash_map::set(_data_versions, type_str, rtd.version);
 				hash_map::set(_data_mtimes, id, data_fs.last_modified_time(dest.c_str()));
 				hash_map::set(_data_mtimes, id, data_fs.last_modified_time(dest.c_str()));
 				hash_map::set(_data_revisions, id, _revision + 1);
 				hash_map::set(_data_revisions, id, _revision + 1);
 			}
 			}
@@ -1105,6 +1104,18 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 
 
 	if (success)
 	if (success)
 	{
 	{
+		// Data versions are stored per-type, so, before updating _data_versions, we
+		// need to make sure *all* resource files with that type have been
+		// successfully compiled.
+		auto cur = hash_map::begin(_compilers);
+		auto end = hash_map::end(_compilers);
+		for (; cur != end; ++cur)
+		{
+			HASH_MAP_SKIP_HOLE(_compilers, cur);
+
+			hash_map::set(_data_versions, cur->first, cur->second.version);
+		}
+
 		if (vector::size(to_compile))
 		if (vector::size(to_compile))
 		{
 		{
 			_revision++;
 			_revision++;