diff options
| author | Alexander Gavrilov | 2012-04-01 16:43:40 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-04-01 16:43:40 +0400 |
| commit | afe4eba957dadf219ff4b4d2a3aa89b773f44fdd (patch) | |
| tree | 62a5df09f82e5cf8dc9843525710a2399bb8e3f5 /library/Core.cpp | |
| parent | a9a6fbd8b597203083eb30e408d3982b01e611b8 (diff) | |
| download | dfhack-afe4eba957dadf219ff4b4d2a3aa89b773f44fdd.tar.gz dfhack-afe4eba957dadf219ff4b4d2a3aa89b773f44fdd.tar.bz2 dfhack-afe4eba957dadf219ff4b4d2a3aa89b773f44fdd.tar.xz | |
Improve performance of the persistent data api, and wrap it for lua.
Use an stl table for string keys to avoid linear cost of lookup.
This uncovered a bug in the new luaL_getsubtable function.
Diffstat (limited to 'library/Core.cpp')
| -rw-r--r-- | library/Core.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/library/Core.cpp b/library/Core.cpp index 0a7cbefd..ffc17472 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -879,31 +879,30 @@ int Core::Update() new_wdata = wdata; new_mapdata = df::global::world->map.block_index; } + // if the world changes if (new_wdata != last_world_data_ptr) { // we check for map change too bool mapchange = new_mapdata != last_local_map_ptr; + 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) - { - last_local_map_ptr = new_mapdata; plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : 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) - { - last_local_map_ptr = new_mapdata; plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); - } - // update tracking variable - last_world_data_ptr = new_wdata; } // otherwise just check for map change... else if (new_mapdata != last_local_map_ptr) { last_local_map_ptr = new_mapdata; + getWorld()->ClearPersistentCache(); plug_mgr->OnStateChange(out, new_mapdata ? SC_MAP_LOADED : SC_MAP_UNLOADED); } |
