2009-11-11 18:39:43 -07:00
|
|
|
// Just show some position data
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <climits>
|
|
|
|
#include <vector>
|
|
|
|
#include <ctime>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-05-25 22:48:23 -06:00
|
|
|
#include <DFHack.h>
|
2011-12-31 04:48:42 -07:00
|
|
|
#include <extra/termutil.h>
|
2011-03-01 14:18:26 -07:00
|
|
|
std::ostream &operator<<(std::ostream &stream, DFHack::t_gamemodes funzies)
|
|
|
|
{
|
2011-04-10 02:19:15 -06:00
|
|
|
const char * gm[]=
|
2011-03-01 14:18:26 -07:00
|
|
|
{
|
|
|
|
"Fort",
|
|
|
|
"Adventurer",
|
2011-03-06 22:19:12 -07:00
|
|
|
"Legends",
|
2011-03-01 14:18:26 -07:00
|
|
|
"Menus",
|
|
|
|
"Arena",
|
2011-03-23 23:13:21 -06:00
|
|
|
"Arena - Assumed",
|
|
|
|
"Kittens!",
|
|
|
|
"Worldgen"
|
2011-03-01 14:18:26 -07:00
|
|
|
};
|
2011-04-10 02:19:15 -06:00
|
|
|
const char * cm[]=
|
2011-03-01 14:18:26 -07:00
|
|
|
{
|
|
|
|
"Managing",
|
|
|
|
"Direct Control",
|
|
|
|
"Kittens!",
|
|
|
|
"Menus"
|
|
|
|
};
|
|
|
|
if(funzies.game_mode <= DFHack::GM_MAX && funzies.control_mode <= DFHack::CM_MAX)
|
|
|
|
stream << "Game mode: " << gm[funzies.game_mode] << ", Control mode: " << cm[funzies.control_mode];
|
|
|
|
else
|
|
|
|
stream << "Game mode is too funky: (" << funzies.game_mode << "," << funzies.control_mode << ")";
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
2010-11-10 18:09:43 -07:00
|
|
|
int main (int argc, char** argv)
|
2009-11-11 18:39:43 -07:00
|
|
|
{
|
2011-05-14 22:10:47 -06:00
|
|
|
bool temporary_terminal = TemporaryTerminal();
|
2010-11-10 18:09:43 -07:00
|
|
|
bool quiet = false;
|
|
|
|
for(int i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
string test = argv[i];
|
|
|
|
if(test == "-q")
|
|
|
|
{
|
|
|
|
quiet = true;
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
}
|
|
|
|
|
2011-03-18 04:38:37 -06:00
|
|
|
DFHack::Gui * Gui = 0;
|
2011-03-23 23:13:21 -06:00
|
|
|
DFHack::Maps * Maps = 0;
|
2011-02-28 22:59:23 -07:00
|
|
|
DFHack::World * World = 0;
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context * DF;
|
2011-03-23 23:13:21 -06:00
|
|
|
bool have_maps = false;
|
2010-03-26 06:01:46 -06:00
|
|
|
try
|
2009-11-11 18:39:43 -07:00
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
2011-03-18 04:38:37 -06:00
|
|
|
Gui = DF->getGui();
|
2011-03-23 23:13:21 -06:00
|
|
|
Maps = DF->getMaps();
|
2011-02-28 22:59:23 -07:00
|
|
|
World = DF->getWorld();
|
2011-03-23 23:13:21 -06:00
|
|
|
have_maps = Maps->Start();
|
2010-03-26 06:01:46 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
2011-05-14 22:10:47 -06:00
|
|
|
if(temporary_terminal)
|
2010-03-26 06:01:46 -06:00
|
|
|
cin.ignore();
|
|
|
|
return 1;
|
|
|
|
}
|
2011-03-01 14:18:26 -07:00
|
|
|
DFHack::t_gamemodes gmm;
|
|
|
|
if(World->ReadGameMode(gmm))
|
2011-02-28 22:59:23 -07:00
|
|
|
{
|
2011-03-01 14:18:26 -07:00
|
|
|
cout << gmm << endl;
|
2011-02-28 22:59:23 -07:00
|
|
|
}
|
2011-03-06 14:20:08 -07:00
|
|
|
cout << "Year: " << World->ReadCurrentYear()
|
|
|
|
<< " Month: " << World->ReadCurrentMonth()
|
|
|
|
<< " Day: " << World->ReadCurrentDay()
|
|
|
|
<< " Tick: " << World->ReadCurrentTick() << endl;
|
2011-03-18 04:38:37 -06:00
|
|
|
if (Gui)
|
2010-03-26 06:01:46 -06:00
|
|
|
{
|
2011-03-23 23:13:21 -06:00
|
|
|
int32_t vx,vy,vz;
|
|
|
|
int32_t cx,cy,cz;
|
|
|
|
int32_t wx,wy,wz;
|
2011-02-28 22:59:23 -07:00
|
|
|
int32_t width,height;
|
2011-03-23 23:13:21 -06:00
|
|
|
if(have_maps)
|
|
|
|
{
|
|
|
|
Maps->getPosition(wx,wy,wz);
|
|
|
|
cout << "Map world offset: " << wx << "/" << wy << "/" << wz << " embark squares." << endl;
|
|
|
|
}
|
|
|
|
bool have_cursor = Gui->getCursorCoords(cx,cy,cz);
|
|
|
|
bool have_view = Gui->getViewCoords(vx,vy,vz);
|
|
|
|
if(have_view)
|
|
|
|
{
|
|
|
|
cout << "view coords: " << vx << "/" << vy << "/" << vz << endl;
|
|
|
|
if(have_maps)
|
|
|
|
cout << " world: " << vx+wx*48 << "/" << vy+wy*48 << "/" << vz+wz << endl;
|
|
|
|
}
|
|
|
|
if(have_cursor)
|
|
|
|
{
|
|
|
|
cout << "cursor coords: " << cx << "/" << cy << "/" << cz << endl;
|
|
|
|
if(have_maps)
|
|
|
|
cout << " world: " << cx+wx*48 << "/" << cy+wy*48 << "/" << cz+wz << endl;
|
|
|
|
}
|
2011-03-18 04:38:37 -06:00
|
|
|
if(Gui->getWindowSize(width,height))
|
2011-02-28 22:59:23 -07:00
|
|
|
cout << "window size : " << width << " " << height << endl;
|
2009-11-17 20:35:43 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-26 06:01:46 -06:00
|
|
|
cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
if(!DF->Detach())
|
2010-03-26 06:01:46 -06:00
|
|
|
{
|
|
|
|
cerr << "Can't detach from DF" << endl;
|
2009-11-11 18:39:43 -07:00
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
|
2011-05-14 22:10:47 -06:00
|
|
|
if(!quiet && temporary_terminal)
|
|
|
|
{
|
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
}
|
2009-11-11 18:39:43 -07:00
|
|
|
return 0;
|
2009-12-13 14:03:19 -07:00
|
|
|
}
|