dfhack/tools/supported/unstuck.cpp

42 lines
802 B
C++

2010-04-11 05:20:15 -06:00
// Make stuck DF run again.
#include <iostream>
#include <climits>
#include <vector>
#include <ctime>
#include <string>
using namespace std;
2010-05-25 22:48:23 -06:00
#include <DFHack.h>
#include <dfhack/extra/termutil.h>
2010-04-11 05:20:15 -06:00
int main (void)
{
bool temporary_terminal = TemporaryTerminal();
2010-04-11 05:20:15 -06:00
string blah;
2010-05-23 15:06:10 -06:00
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
2010-04-11 05:20:15 -06:00
try
{
2010-05-23 15:06:10 -06:00
DF = DFMgr.getSingleContext();
DF->Attach();
2010-04-11 05:20:15 -06:00
}
catch (exception& e)
{
cerr << e.what() << endl;
if(temporary_terminal)
2010-04-11 05:20:15 -06:00
cin.ignore();
return 1;
}
2010-05-23 15:06:10 -06:00
DF->ForceResume();
2010-04-11 05:20:15 -06:00
cout << "DF should be running again :)" << endl;
getline(cin, blah);
2010-05-23 15:06:10 -06:00
if(!DF->Detach())
2010-04-11 05:20:15 -06:00
{
cerr << "Can't detach from DF" << endl;
return 1;
}
return 0;
}