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