some code restructure to make digger not exit insantly on fail

develop
mizipzor 2010-02-21 01:08:07 +01:00
parent 9bbc68fd71
commit cfddcf38eb
1 changed files with 19 additions and 9 deletions

@ -327,17 +327,27 @@ int main (int argc, char** argv)
else else
{ {
DFHack::API DF("Memory.xml"); DFHack::API DF("Memory.xml");
if(!DF.Attach()) if(DF.Attach())
{
if (DF.InitMap())
{ {
cerr << "DF not found" << endl;
return 1;
}
DF.InitMap();
int count = dig(DF, targets, 10, origin[0],origin[1],origin[2], verbose); int count = dig(DF, targets, 10, origin[0],origin[1],origin[2], verbose);
cout << count << " targets designated" << endl; cout << count << " targets designated" << endl;
DF.Detach(); if (!DF.Detach())
{
cerr << "Unable to detach DF process" << endl;
}
}
else
{
cerr << "Unable to init map" << endl;
}
}
else
{
cerr << "Unable to attach to DF process" << endl;
}
} }
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl; cout << "Done. Press any key to continue" << endl;