Browse Source

Fixed a small issue and cleaned up the code a little

Lemongrass3110 10 năm trước cách đây
mục cha
commit
d07e5929fd
1 tập tin đã thay đổi với 19 bổ sung13 xóa
  1. 19 13
      src/map/map.c

+ 19 - 13
src/map/map.c

@@ -3380,27 +3380,33 @@ int map_readallmaps (void)
 
 	for(i = 0; i < map_num; i++) {
 		size_t size;
+		bool success = false;
 
-		// show progress
 		if( enable_grf ){
+			// show progress
 			ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map_num, map[i].name);
 
 			// try to load the map
-			if( !map_readgat(&map[i]) ){
-				map_delmapid(i);
-				maps_removed++;
-				i--;
-				continue;
-			}
+			success = map_readgat(&map[i]) != 0;
 		}else{
 			// try to load the map
-			if( ( map_cache_buffer[1] != NULL && !map_readfromcache( &map[i], map_cache_buffer[1], map_cache_decode_buffer ) ) && // Read from import first, in case of override
-				!map_readfromcache( &map[i], map_cache_buffer[0], map_cache_decode_buffer ) ){
-				map_delmapid(i);
-				maps_removed++;
-				i--;
-				continue;
+			// Read from import first, in case of override
+			if( map_cache_buffer[1] != NULL ){
+				success = map_readfromcache( &map[i], map_cache_buffer[1], map_cache_decode_buffer ) != 0;
 			}
+
+			// Nothing was found in import - try to find it in the main file
+			if( !success ){
+				success = map_readfromcache( &map[i], map_cache_buffer[0], map_cache_decode_buffer ) != 0;
+			}
+		}
+
+		// The map was not found - remove it
+		if( !success ){
+			map_delmapid(i);
+			maps_removed++;
+			i--;
+			continue;
 		}
 
 		map[i].index = mapindex_name2id(map[i].name);