2010-08-13 15:25:14 -06:00
|
|
|
// clears the "tasked" flag on all items
|
|
|
|
// original code by Quietust (http://www.bay12forums.com/smf/index.php?action=profile;u=18111)
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
|
|
|
#include <climits>
|
|
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <DFHack.h>
|
|
|
|
#include <dfhack/DFVector.h>
|
|
|
|
#include <dfhack/DFTypes.h>
|
2011-05-17 00:36:38 -06:00
|
|
|
#include <dfhack/extra/termutil.h>
|
2010-08-13 15:25:14 -06:00
|
|
|
|
|
|
|
int main ()
|
|
|
|
{
|
2011-05-14 22:10:47 -06:00
|
|
|
bool temporary_terminal = TemporaryTerminal();
|
2010-08-13 15:25:14 -06:00
|
|
|
DFHack::Process * p;
|
|
|
|
unsigned int i;
|
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context * DF;
|
2011-05-08 03:21:52 -06:00
|
|
|
DFHack::Items * Items;
|
2010-08-13 15:25:14 -06:00
|
|
|
try
|
|
|
|
{
|
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
2011-05-14 22:10:47 -06:00
|
|
|
if(temporary_terminal)
|
2011-05-08 03:21:52 -06:00
|
|
|
cin.ignore();
|
2010-08-13 15:25:14 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = DF->getProcess();
|
|
|
|
uint32_t item_vec_offset = 0;
|
|
|
|
try
|
|
|
|
{
|
2011-05-08 03:21:52 -06:00
|
|
|
Items = DF->getItems();
|
|
|
|
DFHack::OffsetGroup* itemGroup = p->getDescriptor()->getGroup("Items");
|
|
|
|
item_vec_offset = itemGroup->getAddress("items_vector");
|
2010-08-13 15:25:14 -06:00
|
|
|
}
|
2011-05-08 03:21:52 -06:00
|
|
|
catch(DFHack::Error::All & e)
|
2010-08-13 15:25:14 -06:00
|
|
|
{
|
2011-05-08 03:21:52 -06:00
|
|
|
cerr << "Fatal error, exiting :(" << endl << e.what() << endl;
|
2011-05-14 22:10:47 -06:00
|
|
|
if(temporary_terminal)
|
2010-08-13 15:25:14 -06:00
|
|
|
cin.ignore();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DFHack::DfVector <uint32_t> p_items (p, item_vec_offset);
|
|
|
|
uint32_t size = p_items.size();
|
|
|
|
|
|
|
|
int numtasked = 0;
|
|
|
|
for (i=0;i<size;i++)
|
|
|
|
{
|
2011-05-08 03:21:52 -06:00
|
|
|
DFHack::dfh_item temp;
|
|
|
|
Items->readItem(p_items[i],temp);
|
|
|
|
DFHack::t_itemflags & flags = temp.base.flags;
|
2011-04-16 16:53:05 -06:00
|
|
|
if (flags.in_job)
|
2010-08-13 15:25:14 -06:00
|
|
|
{
|
2011-04-16 16:53:05 -06:00
|
|
|
flags.in_job = 0;
|
2011-05-08 03:21:52 -06:00
|
|
|
Items->writeItem(temp);
|
2010-08-13 15:25:14 -06:00
|
|
|
numtasked++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << "Found and untasked " << numtasked << " items." << endl;
|
|
|
|
|
2011-05-14 22:10:47 -06:00
|
|
|
if(temporary_terminal)
|
|
|
|
{
|
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
}
|
2010-08-13 15:25:14 -06:00
|
|
|
return 0;
|
2011-03-01 15:18:55 -07:00
|
|
|
}
|