diff options
| author | Petr Mrázek | 2011-08-21 23:02:05 +0200 |
|---|---|---|
| committer | Petr Mrázek | 2011-08-21 23:02:05 +0200 |
| commit | b1868f802cda6be502c494199a7a2f3feecc896e (patch) | |
| tree | 1c8f4dea6047800c4afdae7d4a45810a6e2b8861 /plugins/autodump.cpp | |
| parent | 0808c9c0abac980bf14258a7a1390b6d2ad5fd34 (diff) | |
| download | dfhack-b1868f802cda6be502c494199a7a2f3feecc896e.tar.gz dfhack-b1868f802cda6be502c494199a7a2f3feecc896e.tar.bz2 dfhack-b1868f802cda6be502c494199a7a2f3feecc896e.tar.xz | |
Make autodump fix the block-local item ID vectors.
Diffstat (limited to 'plugins/autodump.cpp')
| -rw-r--r-- | plugins/autodump.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/autodump.cpp b/plugins/autodump.cpp index 701b091a..c50e2931 100644 --- a/plugins/autodump.cpp +++ b/plugins/autodump.cpp @@ -14,7 +14,9 @@ using namespace std; #include <dfhack/PluginManager.h> #include <vector> #include <string> +#include <algorithm> #include <dfhack/modules/Maps.h> + #include <dfhack/modules/Gui.h> #include <dfhack/modules/Items.h> #include <dfhack/modules/Materials.h> @@ -166,6 +168,31 @@ DFhackCExport command_result df_autodump (Core * c, vector <string> & parameters if (pos_cursor == pos_item) continue; + // Do we need to fix block-local item ID vector? + if(pos_item/16 != pos_cursor/16) + { + // yes... + cerr << "Moving from block to block!" << endl; + df_block * bl_src = Maps->getBlock(itm->x /16, itm->y/16, itm->z); + df_block * bl_tgt = Maps->getBlock(cx /16, cy/16, cz); + if(bl_src) + { + std::remove(bl_src->items.begin(), bl_src->items.end(),itm->id); + } + else + { + cerr << "No source block" << endl; + } + if(bl_tgt) + { + bl_tgt->items.push_back(itm->id); + } + else + { + cerr << "No target block" << endl; + } + } + // Move the item itm->x = pos_cursor.x; itm->y = pos_cursor.y; |
