From d07e5929fd2f1512b092006527f2ac4a0d350cdc Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Tue, 6 Jan 2015 16:21:51 +0100 Subject: [PATCH] Fixed a small issue and cleaned up the code a little --- src/map/map.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/map/map.c b/src/map/map.c index 6c4b73292c..c0a1a4aa48 100644 --- a/src/map/map.c +++ b/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);