2010-09-01 13:09:45 -06:00
|
|
|
// Just show some position data
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <climits>
|
|
|
|
#include <vector>
|
|
|
|
#include <sstream>
|
|
|
|
#include <ctime>
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
#define DFHACK_WANT_MISCUTILS
|
|
|
|
#define DFHACK_WANT_TILETYPES
|
|
|
|
#include <DFHack.h>
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
void printWeather(DFHack::WeatherType current)
|
|
|
|
{
|
|
|
|
switch (current)
|
|
|
|
{
|
|
|
|
case CLEAR:
|
|
|
|
cout << "The sky is clear." << endl;
|
|
|
|
cout << "Options:" << endl;
|
|
|
|
cout << "'r' to make it rain." << endl;
|
|
|
|
cout << "'s' to make it snow." << endl;
|
|
|
|
break;
|
|
|
|
case RAINING:
|
|
|
|
cout << "It is raining." << endl;
|
2010-09-02 18:15:09 -06:00
|
|
|
cout << "Options:" << endl;
|
2010-09-01 13:09:45 -06:00
|
|
|
cout << "'c' to clear the sky." << endl;
|
|
|
|
cout << "'s' to make it snow." << endl;
|
|
|
|
break;
|
|
|
|
case SNOWING:
|
|
|
|
cout << "It is snowing." << endl;
|
2010-09-02 18:15:09 -06:00
|
|
|
cout << "Options:" << endl;
|
2010-09-01 13:09:45 -06:00
|
|
|
cout << "'c' to clear the sky." << endl;
|
|
|
|
cout << "'r' to make it rain." << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cout << "'q' to quit." << endl;
|
|
|
|
cout << "anything else to refresh" << endl;
|
|
|
|
cout << ">";
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace DFHack;
|
2010-11-10 18:09:43 -07:00
|
|
|
int main (int argc, char** argv)
|
2010-09-01 13:09:45 -06:00
|
|
|
{
|
2010-11-10 18:32:33 -07:00
|
|
|
string command = "";
|
2010-11-10 18:09:43 -07:00
|
|
|
bool quiet = false;
|
2010-11-10 18:32:33 -07:00
|
|
|
bool cmdarg = false;
|
2010-11-10 18:09:43 -07:00
|
|
|
for(int i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
string test = argv[i];
|
|
|
|
if(test == "-q")
|
|
|
|
{
|
|
|
|
quiet = true;
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
command = test;
|
|
|
|
cmdarg = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
2010-09-01 13:09:45 -06:00
|
|
|
DFHack::Context *DF = DFMgr.getSingleContext();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
DF->Attach();
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
World *W = DF->getWorld();
|
|
|
|
W->Start();
|
|
|
|
bool end = false;
|
|
|
|
while(!end)
|
|
|
|
{
|
|
|
|
WeatherType current = (WeatherType) W->ReadCurrentWeather();
|
|
|
|
DF->Resume();
|
|
|
|
printWeather(current);
|
2010-11-10 18:09:43 -07:00
|
|
|
if (command == "") getline(cin, command); // only read from stdin if command hasn't been passed on the console
|
2010-09-01 13:09:45 -06:00
|
|
|
DF->Suspend();
|
|
|
|
if(command == "c")
|
|
|
|
{
|
|
|
|
W->SetCurrentWeather(CLEAR);
|
|
|
|
}
|
|
|
|
else if(command == "r")
|
|
|
|
{
|
|
|
|
W->SetCurrentWeather(RAINING);
|
|
|
|
}
|
|
|
|
else if(command == "s")
|
|
|
|
{
|
|
|
|
W->SetCurrentWeather(SNOWING);
|
|
|
|
}
|
|
|
|
else if(command == "q")
|
|
|
|
{
|
|
|
|
end = true;
|
|
|
|
}
|
2010-11-10 18:32:33 -07:00
|
|
|
command = "";
|
|
|
|
if(cmdarg) end = true; // exit the loop when a cmd line arg has been passed.
|
2010-09-01 13:09:45 -06:00
|
|
|
}
|
|
|
|
#ifndef LINUX_BUILD
|
2010-11-10 18:32:33 -07:00
|
|
|
if (!quiet)
|
|
|
|
{
|
|
|
|
std::cout << "Done. Press any key to continue" << std::endl;
|
|
|
|
cin.ignore();
|
|
|
|
}
|
2010-09-01 13:09:45 -06:00
|
|
|
#endif
|
2010-11-18 17:14:41 -07:00
|
|
|
DF->Resume();
|
2010-09-01 13:09:45 -06:00
|
|
|
DF->Detach();
|
|
|
|
return 0;
|
|
|
|
}
|