Untested item deletion mode for the autodump tool.

develop
Petr Mrázek 2011-04-30 04:48:28 +02:00
parent 456a979244
commit 3318487ad9
2 changed files with 68 additions and 52 deletions

@ -404,7 +404,7 @@ namespace DFHack
{"damaged obsidian wall",WALL,OBSIDIAN,VAR_1, TILE_DAMAGED },
// 330
{"worn obsidian wall",WALL,OBSIDIAN,VAR_1},
{"worn obsidian wall",WALL,OBSIDIAN,VAR_1, TILE_WORN},
{"obsidian wall",WALL,OBSIDIAN,VAR_1},
{"cracked featstone wall",WALL,FEATSTONE,VAR_1, TILE_CRACKED },
{"damaged featstone wall",WALL,FEATSTONE,VAR_1, TILE_DAMAGED },

@ -17,8 +17,12 @@ using MapExtras::MapCache;
typedef std::map <DFCoord, uint32_t> coordmap;
int main ()
int main (int argc, char * argv[])
{
// Command line options
bool destroy = false;
if(argc > 1 && strcmp(argv[1],"-d") == 0)
destroy = true;
DFHack::ContextManager CM ("Memory.xml");
DFHack::Context * DF;
@ -74,7 +78,9 @@ int main ()
int dumped_total = 0;
int cx, cy, cz;
DFCoord pos_cursor;
if(!destroy)
{
if (!Gui->getCursorCoords(cx,cy,cz))
{
cerr << "Cursor position not found. Please enabled the cursor." << endl;
@ -83,7 +89,7 @@ int main ()
#endif
return 1;
}
DFCoord pos_cursor(cx,cy,cz);
pos_cursor = DFCoord(cx,cy,cz);
{
Block * b = MC.BlockAt(pos_cursor / 16);
if(!b)
@ -96,6 +102,7 @@ int main ()
}
// TODO: check if the target is floor? maybe?
}
}
coordmap counts;
// proceed with the dumpification operation
for(uint32_t i=0; i< numItems; i++)
@ -121,9 +128,11 @@ int main ()
if (!temp.base.flags.dump || !temp.base.flags.on_ground)
continue;
if(!destroy) // move to cursor
{
// Change flags to indicate the dump was completed, as if by super-dwarfs
temp.base.flags.dump = 0;
temp.base.flags.forbid = 1;
temp.base.flags.dump = false;
temp.base.flags.forbid = true;
// Don't move items if they're already at the cursor
if (pos_cursor == pos_item)
@ -133,11 +142,18 @@ int main ()
temp.base.x = pos_cursor.x;
temp.base.y = pos_cursor.y;
temp.base.z = pos_cursor.z;
}
else // destroy
{
temp.base.flags.garbage_colect = true;
}
Items->writeItem(temp);
// keeping track of item pile sizes ;)
it->second --;
dumped_total++;
}
if(!destroy) // TODO: do we have to do any of this when destroying items?
{
// for each item pile, see if it reached zero. if so, unset item flag on the tile it's on
coordmap::iterator it = counts.begin();
coordmap::iterator end = counts.end();
@ -167,7 +183,7 @@ int main ()
MC.WriteAll();
// Is this necessary? Is "forbid" a dirtyable attribute like "dig" is?
Maps->WriteDirtyBit(cx/16, cy/16, cz, true);
}
DF->Detach();
cout << "Done. " << dumped_total << " items quickdumped." << endl;
#ifndef LINUX_BUILD