Change SC_MAP_LOADED handling: only NULL/not NULL change is meaningful.

develop
Alexander Gavrilov 2012-04-10 12:11:00 +04:00
parent 93c795cfc3
commit 249be0c1a0
1 changed files with 12 additions and 7 deletions

@ -893,27 +893,32 @@ int Core::Update()
if (new_wdata != last_world_data_ptr) if (new_wdata != last_world_data_ptr)
{ {
// we check for map change too // 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_world_data_ptr = new_wdata;
last_local_map_ptr = new_mapdata; last_local_map_ptr = new_mapdata;
getWorld()->ClearPersistentCache(); getWorld()->ClearPersistentCache();
// and if the world is going away, we report the map change first // and if the world is going away, we report the map change first
if(!new_wdata && mapchange) if(had_map)
plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); plug_mgr->OnStateChange(out, SC_MAP_UNLOADED);
// and if the world is appearing, we report map change after that // and if the world is appearing, we report map change after that
plug_mgr->OnStateChange(out, new_wdata ? SC_WORLD_LOADED : SC_WORLD_UNLOADED); plug_mgr->OnStateChange(out, new_wdata ? SC_WORLD_LOADED : SC_WORLD_UNLOADED);
if(new_wdata && mapchange) if(isMapLoaded())
plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); plug_mgr->OnStateChange(out, SC_MAP_LOADED);
} }
// otherwise just check for map change... // otherwise just check for map change...
else if (new_mapdata != last_local_map_ptr) else if (new_mapdata != last_local_map_ptr)
{ {
bool had_map = isMapLoaded();
last_local_map_ptr = new_mapdata; last_local_map_ptr = new_mapdata;
if (isMapLoaded() != had_map)
{
getWorld()->ClearPersistentCache(); getWorld()->ClearPersistentCache();
plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED);
} }
}
// detect if the viewscreen changed // detect if the viewscreen changed
if (df::global::gview) if (df::global::gview)