more cleanup

develop
Petr Mrázek 2009-12-13 00:47:58 +00:00
parent 58986ef838
commit 069597f10c
12 changed files with 60 additions and 289 deletions

@ -62,11 +62,6 @@ using namespace std;
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <X11/Xlib.h> //need for X11 functions
#include <X11/extensions/XTest.h> //need for Xtest
#include <X11/Xatom.h> //for the atom stuff
#define XK_MISCELLANY
#include <X11/keysymdef.h>
#else
#define _WIN32_WINNT 0x0500 // needed for INPUT struct
#define WINVER 0x0500 // OpenThread(), PSAPI, Toolhelp32

@ -21,8 +21,14 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#define LINUX_BUILD
#include "DFCommonInternal.h"
#include <X11/Xlib.h> //need for X11 functions
#include <X11/extensions/XTest.h> //need for Xtest
#include <X11/Xatom.h> //for the atom stuff
#define XK_MISCELLANY
#include <X11/keysymdef.h>
using namespace DFHack;
// ENUMARATE THROUGH WINDOWS AND DISPLAY THEIR TITLES
@ -232,389 +238,154 @@ void API::TypeSpecial (t_special command, int count, int delay)
{
case ENTER:
mykeysym = XStringToKeysym ("Return");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case SPACE:
mykeysym = XStringToKeysym ("space");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case BACK_SPACE:
mykeysym = XStringToKeysym ("BackSpace");
xkeycode = XK_BackSpace;
xkeycode = XKeysymToKeycode (dpy, XK_BackSpace);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case TAB:
mykeysym = XStringToKeysym ("Tab");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case CAPS_LOCK:
mykeysym = XStringToKeysym ("Caps_Lock");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case LEFT_SHIFT: // I am not positive that this will work to distinguish the left and right..
case LEFT_SHIFT:
mykeysym = XStringToKeysym ("Shift_L");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case RIGHT_SHIFT:
mykeysym = XStringToKeysym ("Shift_R");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case LEFT_CONTROL:
mykeysym = XStringToKeysym ("Control_L");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case RIGHT_CONTROL:
mykeysym = XStringToKeysym ("Control_R");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case ALT:
mykeysym = XStringToKeysym ("Alt_L");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case ESCAPE:
mykeysym = XStringToKeysym ("Escape");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case UP:
mykeysym = XStringToKeysym ("Up");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case DOWN:
mykeysym = XStringToKeysym ("Down");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case LEFT:
mykeysym = XStringToKeysym ("Left");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case RIGHT:
mykeysym = XStringToKeysym ("Right");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F1:
mykeysym = XStringToKeysym ("F1");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F2:
mykeysym = XStringToKeysym ("F2");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F3:
mykeysym = XStringToKeysym ("F3");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F4:
mykeysym = XStringToKeysym ("F4");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F5:
mykeysym = XStringToKeysym ("F5");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F6:
mykeysym = XStringToKeysym ("F6");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F7:
mykeysym = XStringToKeysym ("F7");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F8:
mykeysym = XStringToKeysym ("F8");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F9:
mykeysym = XStringToKeysym ("F9");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F11:
mykeysym = XStringToKeysym ("F11");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case F12:
mykeysym = XStringToKeysym ("F12");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case PAGE_UP:
mykeysym = XStringToKeysym ("Page_Up");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case PAGE_DOWN:
mykeysym = XStringToKeysym ("Page_Down");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case INSERT:
mykeysym = XStringToKeysym ("Insert");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEY_DELETE:
case DFHack::DELETE: // collides with some windows stuff otherwise?
mykeysym = XStringToKeysym ("Delete");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case HOME:
mykeysym = XStringToKeysym ("Home");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case END:
mykeysym = XStringToKeysym ("End");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_DIVIDE:
mykeysym = XStringToKeysym ("KP_Divide");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_MULTIPLY:
mykeysym = XStringToKeysym ("KP_Multiply");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_SUBTRACT:
mykeysym = XStringToKeysym ("KP_Subtract");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_ADD:
mykeysym = XStringToKeysym ("KP_Add");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_ENTER:
mykeysym = XStringToKeysym ("KP_Enter");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_0:
mykeysym = XStringToKeysym ("KP_0");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_1:
mykeysym = XStringToKeysym ("KP_1");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_2:
mykeysym = XStringToKeysym ("KP_2");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_3:
mykeysym = XStringToKeysym ("KP_3");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_4:
mykeysym = XStringToKeysym ("KP_4");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_5:
mykeysym = XStringToKeysym ("KP_5");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_6:
mykeysym = XStringToKeysym ("KP_6");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_7:
mykeysym = XStringToKeysym ("KP_7");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_8:
mykeysym = XStringToKeysym ("KP_8");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_9:
mykeysym = XStringToKeysym ("KP_9");
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
case KEYPAD_DECIMAL_POINT:
mykeysym = XStringToKeysym ("KP_Decimal");
break;
}
xkeycode = XKeysymToKeycode (dpy, mykeysym);
XTestFakeKeyEvent (dpy, xkeycode, true, CurrentTime);
XSync (dpy, true);
XTestFakeKeyEvent (dpy, xkeycode, false, CurrentTime);
XSync (dpy, true);
break;
}
usleep(20000);
}
if (currAttr.map_state == IsUnmapped)

@ -27,6 +27,9 @@ distribution.
#include "Export.h"
namespace DFHack
{
struct t_matgloss
{
char id[128];
@ -675,7 +678,7 @@ enum t_special
PAGE_UP,
PAGE_DOWN,
INSERT,
KEY_DELETE, // DELETE is already defined in winnt.h, so can't redefine it here
DELETE,
HOME,
END,
KEYPAD_DIVIDE,
@ -701,4 +704,6 @@ struct t_viewscreen
int32_t type;
//There is more info in these objects, but I don't know what it is yet
};
}// namespace DFHack
#endif // TYPES_H_INCLUDED

@ -127,7 +127,7 @@ int main (int argc,const char* argv[])
ins >> lines; // Reads the integers from the string.
}
vector<t_matgloss> creaturestypes;
vector<DFHack::t_matgloss> creaturestypes;
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
@ -141,7 +141,7 @@ int main (int argc,const char* argv[])
vector < uint32_t > addresses;
for(uint32_t i = 0; i < numBuildings; i++)
{
t_building temp;
DFHack::t_building temp;
DF.ReadBuilding(i, temp);
if(buildingtypes[temp.type] == argv[1])
{

@ -13,7 +13,7 @@ int main (void)
uint32_t x_max,y_max,z_max;
uint32_t num_blocks = 0;
uint32_t bytes_read = 0;
t_occupancy occupancies[256];
DFHack::t_occupancy occupancies[256];
DFHack::API DF ("Memory.xml");
if(!DF.Attach())

@ -24,7 +24,7 @@ void print_bits ( T val, std::ostream& out )
int main (void)
{
vector<t_matgloss> creaturestypes;
vector<DFHack::t_matgloss> creaturestypes;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
@ -46,7 +46,7 @@ int main (void)
uint32_t numCreatures = DF.InitReadCreatures();
for(uint32_t i = 0; i < numCreatures; i++)
{
t_creature temp;
DFHack::t_creature temp;
DF.ReadCreature(i, temp);
cout << "address: " << temp.origin << " creature type: " << creaturestypes[temp.type].id << ", position: " << temp.x << "x " << temp.y << "y "<< temp.z << "z" << endl;
bool addendl = false;

@ -24,13 +24,13 @@ void print_bits ( T val, std::ostream& out )
vector <string> buildingtypes;
map<string, vector<string> > names;
uint32_t numCreatures;
vector<t_matgloss> creaturestypes;
vector<DFHack::t_matgloss> creaturestypes;
void printDwarves(DFHack::API & DF)
{
int dwarfCounter = 0;
for(uint32_t i = 0; i < numCreatures; i++)
{
t_creature temp;
DFHack::t_creature temp;
DF.ReadCreature(i, temp);
string type = creaturestypes[temp.type].id;
if(type == "DWARF" && !temp.flags1.bits.dead && !temp.flags2.bits.killed){
@ -55,7 +55,7 @@ void printDwarves(DFHack::API & DF)
}
}
bool getDwarfSelection(DFHack::API & DF, t_creature & toChange,string & changeString, string & commandString,int & eraseAmount,int &dwarfNum,bool &isName)
bool getDwarfSelection(DFHack::API & DF, DFHack::t_creature & toChange,string & changeString, string & commandString,int & eraseAmount,int &dwarfNum,bool &isName)
{
DF.ForceResume();
static string lastText;
@ -138,14 +138,14 @@ bool getDwarfSelection(DFHack::API & DF, t_creature & toChange,string & changeSt
bool waitTillChanged(DFHack::API &DF, int creatureToCheck, string changeValue, bool isName)
{
DF.Suspend();
t_creature testCre;
DFHack::t_creature testCre;
DF.ReadCreature(creatureToCheck,testCre);
int tryCount = 0;
if(isName)
{
while(testCre.nick_name != changeValue && tryCount <50)
{
DF.TypeSpecial(WAIT,1,100);
DF.TypeSpecial(DFHack::WAIT,1,100);
DF.Suspend();
DF.ReadCreature(creatureToCheck,testCre);
tryCount++;
@ -155,7 +155,7 @@ bool waitTillChanged(DFHack::API &DF, int creatureToCheck, string changeValue, b
{
while(testCre.custom_profession != changeValue && tryCount < 50)
{
DF.TypeSpecial(WAIT,1,100);
DF.TypeSpecial(DFHack::WAIT,1,100);
DF.Suspend();
DF.ReadCreature(creatureToCheck,testCre);
tryCount++;
@ -169,12 +169,12 @@ bool waitTillChanged(DFHack::API &DF, int creatureToCheck, string changeValue, b
}
bool waitTillScreenState(DFHack::API &DF, string screenState)
{
t_viewscreen current;
DFHack::t_viewscreen current;
DF.Suspend();
DF.ReadViewScreen(current);
int tryCount = 0;
while(buildingtypes[current.type] != screenState && tryCount < 50){
DF.TypeSpecial(WAIT,1,100);
DF.TypeSpecial(DFHack::WAIT,1,100);
DF.Suspend();
DF.ReadViewScreen(current);
tryCount++;
@ -194,7 +194,7 @@ bool waitTillCursorState(DFHack::API &DF, bool On)
bool cursorResult = DF.getCursorCoords(x,y,z);
while(tryCount < 50 && On && !cursorResult || !On && cursorResult)
{
DF.TypeSpecial(WAIT,1,100);
DF.TypeSpecial(DFHack::WAIT,1,100);
tryCount++;
DF.Suspend();
cursorResult = DF.getCursorCoords(x,y,z);
@ -230,7 +230,7 @@ int main (void)
DF.InitViewAndCursor();
DF.Suspend();
printDwarves(DF);
t_creature toChange;
DFHack::t_creature toChange;
string changeString,commandString;
int eraseAmount;
int toChangeNum;
@ -252,7 +252,7 @@ int main (void)
vector<uint32_t> underCursor;
while(!DF.getCurrentCursorCreatures(underCursor))
{
DF.TypeSpecial(WAIT,1,100);
DF.TypeSpecial(DFHack::WAIT,1,100);
DF.Suspend();
DF.setCursorCoords(toChange.x, toChange.y,toChange.z);
}
@ -275,20 +275,20 @@ int main (void)
DF.TypeStr(commandString.c_str());
if(waitTillScreenState(DF,"viewscreen_customize_unit"))
{
DF.TypeSpecial(BACK_SPACE,eraseAmount);
DF.TypeSpecial(DFHack::BACK_SPACE,eraseAmount);
if(waitTillChanged(DF,toChangeNum,"",isName))
{
DF.TypeStr(changeString.c_str());
if(waitTillChanged(DF,toChangeNum,changeString,isName))
{
DF.TypeSpecial(ENTER);
DF.TypeSpecial(SPACE); // should take you to unit screen if everything worked
DF.TypeSpecial(DFHack::ENTER);
DF.TypeSpecial(DFHack::SPACE); // should take you to unit screen if everything worked
if(waitTillScreenState(DF,"viewscreen_unit"))
{
DF.TypeSpecial(SPACE);
DF.TypeSpecial(DFHack::SPACE);
if(waitTillScreenState(DF,"viewscreen_dwarfmode"))
{
DF.TypeSpecial(SPACE);
DF.TypeSpecial(DFHack::SPACE);
if(waitTillCursorState(DF,false))
{
completed = true;

@ -13,14 +13,14 @@ using namespace std;
struct matGlosses
{
vector<t_matgloss> plantMat;
vector<t_matgloss> woodMat;
vector<t_matgloss> stoneMat;
vector<t_matgloss> metalMat;
vector<t_matgloss> creatureMat;
vector<DFHack::t_matgloss> plantMat;
vector<DFHack::t_matgloss> woodMat;
vector<DFHack::t_matgloss> stoneMat;
vector<DFHack::t_matgloss> metalMat;
vector<DFHack::t_matgloss> creatureMat;
};
void printItem(t_item item, const vector<string> & buildingTypes,const matGlosses & mat){
void printItem(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat){
cout << dec << "Item at x:" << item.x << " y:" << item.y << " z:" << item.z << endl;
cout << "Type: " << (int) item.type << " " << buildingTypes[item.type] << " Address: " << hex << item.origin << endl;
cout << "Material: ";
@ -120,10 +120,10 @@ int main ()
// }
int32_t x,y,z;
DF.getCursorCoords(x,y,z);
vector <t_item> foundItems;
vector <DFHack::t_item> foundItems;
for(uint32_t i = 0; i < numItems; i++)
{
t_item temp;
DFHack::t_item temp;
DF.ReadItem(i, temp);
if(temp.x == x && temp.y == y && temp.z == z)
{

@ -18,8 +18,8 @@ int main (void)
uint32_t num_blocks = 0;
uint32_t bytes_read = 0;
uint16_t tiletypes[16][16];
t_designation designations[16][16];
t_occupancy occupancies[16][16];
DFHack::t_designation designations[16][16];
DFHack::t_occupancy occupancies[16][16];
DFHack::API DF("Memory.xml");
if(!DF.Attach())

@ -19,16 +19,16 @@ int main (void)
cerr << "DF not found" << endl;
return 1;
}
vector <t_matgloss> Plants;
vector <DFHack::t_matgloss> Plants;
DF.ReadPlantMatgloss(Plants);
vector <t_matgloss> Metals;
vector <DFHack::t_matgloss> Metals;
DF.ReadMetalMatgloss(Metals);
vector <t_matgloss> Stones;
vector <DFHack::t_matgloss> Stones;
DF.ReadStoneMatgloss(Stones);
vector <t_matgloss> CreatureTypes;
vector <DFHack::t_matgloss> CreatureTypes;
DF.ReadCreatureMatgloss(CreatureTypes);
cout << "Plant: " << Plants[0].id << endl;

@ -47,11 +47,11 @@ int main (int argc, const char* argv[])
#endif
uint32_t x_max,y_max,z_max;
uint16_t tiletypes[16][16];
t_designation designations[16][16];
DFHack::t_designation designations[16][16];
uint8_t regionoffsets[16];
map <int16_t, uint32_t> materials;
materials.clear();
vector<t_matgloss> stonetypes;
vector<DFHack::t_matgloss> stonetypes;
vector< vector <uint16_t> > layerassign;
// init the API
@ -84,7 +84,7 @@ int main (int argc, const char* argv[])
}
int16_t tempvein [16][16];
vector <t_vein> veins;
vector <DFHack::t_vein> veins;
// walk the map!
for(uint32_t x = 0; x< x_max;x++)
{

@ -13,7 +13,7 @@ int main (void)
uint32_t x_max,y_max,z_max;
uint32_t num_blocks = 0;
uint32_t bytes_read = 0;
t_designation designations[256];
DFHack::t_designation designations[256];
DFHack::API DF("Memory.xml");
if(!DF.Attach())