summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorexpwnent2012-09-28 19:06:22 -0400
committerexpwnent2012-09-28 19:06:22 -0400
commit1bde32fa5b72a070a81c142b4044f8fd355e2145 (patch)
tree990bb1fc1b7a58394b935874184790ec7b25f522 /plugins
parent79ac1a81b9c2751c162fc413c91ef0ee84766d01 (diff)
downloaddfhack-1bde32fa5b72a070a81c142b4044f8fd355e2145.tar.gz
dfhack-1bde32fa5b72a070a81c142b4044f8fd355e2145.tar.bz2
dfhack-1bde32fa5b72a070a81c142b4044f8fd355e2145.tar.xz
Fixed a tile occupancy problem with teleporting dwarves.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/fastdwarf.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/fastdwarf.cpp b/plugins/fastdwarf.cpp
index 400bff23..4c235394 100644
--- a/plugins/fastdwarf.cpp
+++ b/plugins/fastdwarf.cpp
@@ -2,6 +2,7 @@
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
+#include "modules/MapCache.h"
#include "DataDefs.h"
#include "df/ui.h"
@@ -48,6 +49,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
}
}
if ( enable_teledwarf ) {
+ MapExtras::MapCache *MCache = new MapExtras::MapCache();
for (size_t i = 0; i < world->units.all.size(); i++)
{
df::unit *unit = world->units.all[i];
@@ -59,11 +61,19 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
if (unit->relations.following != 0)
continue;
+ MapExtras::Block* block = MCache->BlockAtTile(unit->pos);
+ df::coord2d pos(unit->pos.x % 16, unit->pos.y % 16);
+ df::tile_occupancy occ = block->OccupancyAt(pos);
+ occ.bits.unit = 0;
+ block->setOccupancyAt(pos, occ);
+
//move immediately to destination
unit->pos.x = unit->path.dest.x;
unit->pos.y = unit->path.dest.y;
unit->pos.z = unit->path.dest.z;
}
+ MCache->WriteAll();
+ delete MCache;
}
return CR_OK;
}