From 249be0c1a0e267e806a8b0b1342f1f58f53e44fd Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 10 Apr 2012 12:11:00 +0400 Subject: [PATCH] Change SC_MAP_LOADED handling: only NULL/not NULL change is meaningful. --- library/Core.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index b3c91034f..a752ae628 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -893,26 +893,31 @@ int Core::Update() if (new_wdata != last_world_data_ptr) { // we check for map change too - bool mapchange = new_mapdata != last_local_map_ptr; + bool had_map = isMapLoaded(); last_world_data_ptr = new_wdata; last_local_map_ptr = new_mapdata; getWorld()->ClearPersistentCache(); // and if the world is going away, we report the map change first - if(!new_wdata && mapchange) - plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); + if(had_map) + plug_mgr->OnStateChange(out, SC_MAP_UNLOADED); // and if the world is appearing, we report map change after that plug_mgr->OnStateChange(out, new_wdata ? SC_WORLD_LOADED : SC_WORLD_UNLOADED); - if(new_wdata && mapchange) - plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); + if(isMapLoaded()) + plug_mgr->OnStateChange(out, SC_MAP_LOADED); } // otherwise just check for map change... else if (new_mapdata != last_local_map_ptr) { + bool had_map = isMapLoaded(); last_local_map_ptr = new_mapdata; - getWorld()->ClearPersistentCache(); - plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); + + if (isMapLoaded() != had_map) + { + getWorld()->ClearPersistentCache(); + plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); + } } // detect if the viewscreen changed