fixed tons of warnings, removed dependency on xtest

develop
Petr Mrázek 2009-12-13 21:03:19 +00:00
parent e5fa10c268
commit 3888d0fc06
24 changed files with 49 additions and 56 deletions

@ -82,8 +82,9 @@ IF(UNIX)
add_definitions(-DLINUX_BUILD) add_definitions(-DLINUX_BUILD)
add_definitions(-DUSE_CONFIG_H) add_definitions(-DUSE_CONFIG_H)
find_library(X11_LIBRARY X11) find_library(X11_LIBRARY X11)
find_library(XTEST_LIBRARY Xtst) SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -pedantic")
SET(PROJECT_LIBS ${X11_LIBRARY} ${XTEST_LIBRARY})
SET(PROJECT_LIBS ${X11_LIBRARY})
ELSE(UNIX) ELSE(UNIX)
SET(PROJECT_LIBS psapi) SET(PROJECT_LIBS psapi)
ENDIF(UNIX) ENDIF(UNIX)

@ -41,7 +41,7 @@ DfVector DMWindows40d::readVector (uint32_t offset, uint32_t item_size)
uint32_t end = MreadDWord(offset+8); uint32_t end = MreadDWord(offset+8);
uint32_t size = (end - start) /4; uint32_t size = (end - start) /4;
return DfVector(start,size,item_size); return DfVector(start,size,item_size);
}; }
size_t DMWindows40d::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity) size_t DMWindows40d::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity)
@ -76,7 +76,7 @@ Uint32 capacity
buffer[read_real] = 0; buffer[read_real] = 0;
return read_real; return read_real;
}; }
const string DMWindows40d::readSTLString (uint32_t offset) const string DMWindows40d::readSTLString (uint32_t offset)
{ {
@ -111,7 +111,7 @@ const string DMWindows40d::readSTLString (uint32_t offset)
string ret = temp; string ret = temp;
delete temp; delete temp;
return ret; return ret;
}; }
DfVector DMLinux40d::readVector (uint32_t offset, uint32_t item_size) DfVector DMLinux40d::readVector (uint32_t offset, uint32_t item_size)
@ -128,7 +128,7 @@ DfVector DMLinux40d::readVector (uint32_t offset, uint32_t item_size)
uint32_t end = MreadDWord(offset+4); uint32_t end = MreadDWord(offset+4);
uint32_t size = (end - start) /4; uint32_t size = (end - start) /4;
return DfVector(start,size,item_size); return DfVector(start,size,item_size);
}; }
struct _Rep_base struct _Rep_base
{ {
@ -146,7 +146,7 @@ size_t DMLinux40d::readSTLString (uint32_t offset, char * buffer, size_t bufcapa
Mread(offset,read_real,(uint8_t * )buffer); Mread(offset,read_real,(uint8_t * )buffer);
buffer[read_real] = 0; buffer[read_real] = 0;
return read_real; return read_real;
}; }
const string DMLinux40d::readSTLString (uint32_t offset) const string DMLinux40d::readSTLString (uint32_t offset)
{ {
@ -161,4 +161,4 @@ const string DMLinux40d::readSTLString (uint32_t offset)
string ret(temp); string ret(temp);
delete temp; delete temp;
return ret; return ret;
}; }

@ -283,7 +283,7 @@ bool API::getCurrentCursorCreatures (vector<uint32_t> &addresses)
return false; return false;
} }
addresses.clear(); addresses.clear();
for (int i = 0;i < creUnderCursor.getSize();i++) for (uint32_t i = 0;i < creUnderCursor.getSize();i++)
{ {
uint32_t temp = * (uint32_t *) creUnderCursor.at (i); uint32_t temp = * (uint32_t *) creUnderCursor.at (i);
addresses.push_back (temp); addresses.push_back (temp);
@ -406,7 +406,7 @@ bool API::ReadStoneMatgloss (vector<t_matgloss> & stones)
int matgloss_colors = minfo->getOffset ("matgloss_stone_color"); int matgloss_colors = minfo->getOffset ("matgloss_stone_color");
DfVector p_matgloss = d->dm->readVector (matgloss_address + matgloss_offset, 4); DfVector p_matgloss = d->dm->readVector (matgloss_address + matgloss_offset, 4);
int size = p_matgloss.getSize(); uint32_t size = p_matgloss.getSize();
stones.resize (0); stones.resize (0);
stones.reserve (size); stones.reserve (size);
for (uint32_t i = 0; i < size;i++) for (uint32_t i = 0; i < size;i++)
@ -992,7 +992,7 @@ int32_t API::ReadCreatureInBox (int32_t index, t_creature & furball,
uint16_t coords[3]; uint16_t coords[3];
assert (d->creaturesInited); assert (d->creaturesInited);
uint32_t size = d->p_cre->getSize(); uint32_t size = d->p_cre->getSize();
while (index < size) while (uint32_t(index) < size)
{ {
// read pointer from vector at position // read pointer from vector at position
uint32_t temp = * (uint32_t *) d->p_cre->at (index); uint32_t temp = * (uint32_t *) d->p_cre->at (index);
@ -1056,7 +1056,8 @@ bool API::ReadCreature (const int32_t &index, t_creature & furball)
furball.profession = MreadByte (temp + d->creature_profession_offset); furball.profession = MreadByte (temp + d->creature_profession_offset);
// current job HACK: the job object isn't cleanly represented here // current job HACK: the job object isn't cleanly represented here
uint32_t jobIdAddr = MreadDWord (temp + d->creature_current_job_offset); uint32_t jobIdAddr = MreadDWord (temp + d->creature_current_job_offset);
if (furball.current_job.active = jobIdAddr != 0) furball.current_job.active = jobIdAddr;
if (jobIdAddr)
{ {
furball.current_job.jobId = MreadByte (jobIdAddr + d->creature_current_job_id_offset); furball.current_job.jobId = MreadByte (jobIdAddr + d->creature_current_job_id_offset);
} }
@ -1081,9 +1082,8 @@ void API::InitReadNameTables (map< string, vector<string> > & nameTable)
DfVector genericVec (d->dm->readVector (genericAddress, 4)); DfVector genericVec (d->dm->readVector (genericAddress, 4));
DfVector transVec (d->dm->readVector (transAddress, 4)); DfVector transVec (d->dm->readVector (transAddress, 4));
uint32_t dwarf_entry = 0;
for (int32_t i = 0;i < genericVec.getSize();i++) for (uint32_t i = 0;i < genericVec.getSize();i++)
{ {
uint32_t genericNamePtr = * (uint32_t *) genericVec.at (i); uint32_t genericNamePtr = * (uint32_t *) genericVec.at (i);
string genericName = d->dm->readSTLString (genericNamePtr); string genericName = d->dm->readSTLString (genericNamePtr);
@ -1134,7 +1134,7 @@ string API::TranslateName (const t_squadname & squad, const map<string, vector<s
{ {
for (int i = 0;i < 7;i++) for (int i = 0;i < 7;i++)
{ {
if (squad.names[i] == 0xFFFFFFFF) if (squad.names[i] == -1)
{ {
continue; continue;
} }

@ -24,8 +24,6 @@ distribution.
#include "DFCommonInternal.h" #include "DFCommonInternal.h"
#include <X11/Xlib.h> //need for X11 functions #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 #define XK_MISCELLANY
#define XK_LATIN1 #define XK_LATIN1
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
@ -115,7 +113,7 @@ Window EnumerateWindows (Display *display, Window rootWindow, const char *search
} }
// recurse into children // recurse into children
for (int i = 0; i < noOfChildren; i++) for (uint32_t i = 0; i < noOfChildren; i++)
{ {
Window tempWindow = EnumerateWindows (display, children[i], searchString); Window tempWindow = EnumerateWindows (display, children[i], searchString);
if (tempWindow != BadWindow) if (tempWindow != BadWindow)
@ -183,14 +181,12 @@ void API::TypeStr (const char *lpszString, int delay, bool useShift)
char cChar; char cChar;
int realDelay = delay * 1000; int realDelay = delay * 1000;
KeyCode xkeycode; KeyCode xkeycode;
char prevKey = 0;
int sleepAmnt = 0;
while ( (cChar = *lpszString++)) // loops through chars while ( (cChar = *lpszString++)) // loops through chars
{ {
// HACK: the timing here is a strange beast // HACK: the timing here is a strange beast
xkeycode = XKeysymToKeycode (dpy, cChar); xkeycode = XKeysymToKeycode (dpy, cChar);
send_xkeyevent(dpy,dfWin,rootWin,XKeysymToKeycode(dpy, ksTable[DFHack::LEFT_SHIFT]),0,false, realDelay); send_xkeyevent(dpy,dfWin,rootWin,XKeysymToKeycode(dpy, ksTable[DFHack::LEFT_SHIFT]),0,false, realDelay);
if (useShift || cChar >= 'A' && cChar <= 'Z') if (useShift || (cChar >= 'A' && cChar <= 'Z'))
{ {
send_xkeyevent(dpy,dfWin,rootWin,xkeycode,ShiftMask,true, realDelay); send_xkeyevent(dpy,dfWin,rootWin,xkeycode,ShiftMask,true, realDelay);
send_xkeyevent(dpy,dfWin,rootWin,xkeycode,ShiftMask,false, realDelay); send_xkeyevent(dpy,dfWin,rootWin,xkeycode,ShiftMask,false, realDelay);
@ -243,4 +239,4 @@ void API::TypeSpecial (t_special command, int count, int delay)
{ {
usleep (delay*1000 * count); usleep (delay*1000 * count);
} }
} }

@ -83,4 +83,4 @@ enum t_special
NUM_SPECIALS NUM_SPECIALS
}; };
} }
#endif // KEYS_H_INCLUDED #endif // KEYS_H_INCLUDED

@ -241,8 +241,8 @@ bool MemInfoManager::loadFile(string path_to_xml)
for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("Entry")) for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("Entry"))
{ {
v_pEntries.push_back(pMemInfo); v_pEntries.push_back(pMemInfo);
const char *id; const char *id = pMemInfo->Attribute("id");
if(id= pMemInfo->Attribute("id")) if(id)
{ {
string str_id = id; string str_id = id;
map_pNamedEntries[str_id] = pMemInfo; map_pNamedEntries[str_id] = pMemInfo;
@ -267,4 +267,4 @@ bool MemInfoManager::loadFile(string path_to_xml)
error = true; error = true;
return false; return false;
} }
} }

@ -43,4 +43,4 @@ namespace DFHack
}; };
} }
#endif #endif

@ -135,9 +135,6 @@ bool Process::Private::validate(char * exe_file,uint32_t pid, char * memFile, ve
if(hash == (*it).getString("md5")) // are the md5 hashes the same? if(hash == (*it).getString("md5")) // are the md5 hashes the same?
{ {
memory_info * m = &*it; memory_info * m = &*it;
Process * ret;
//cout <<"Found process " << PH << ". It's DF version " << m->getVersion() << "." << endl;
// df can run under wine on Linux // df can run under wine on Linux
if(memory_info::OS_WINDOWS == (*it).getOS()) if(memory_info::OS_WINDOWS == (*it).getOS())
{ {
@ -197,12 +194,11 @@ bool Process::getThreadIDs(vector<uint32_t> & threads )
void Process::getMemRanges( vector<t_memrange> & ranges ) void Process::getMemRanges( vector<t_memrange> & ranges )
{ {
char buffer[1024]; char buffer[1024];
char name[1024];
char permissions[5]; // r/-, w/-, x/-, p/s, 0 char permissions[5]; // r/-, w/-, x/-, p/s, 0
sprintf(buffer, "/proc/%lu/maps", d->my_pid); sprintf(buffer, "/proc/%lu/maps", d->my_pid);
FILE *mapFile = ::fopen(buffer, "r"); FILE *mapFile = ::fopen(buffer, "r");
uint64_t begin, end, offset, device1, device2, node; uint64_t offset, device1, device2, node;
while (fgets(buffer, 1024, mapFile)) while (fgets(buffer, 1024, mapFile))
{ {
@ -251,6 +247,7 @@ bool Process::suspend()
} }
} }
d->suspended = true; d->suspended = true;
return true;
} }
bool Process::forceresume() bool Process::forceresume()
@ -260,7 +257,6 @@ bool Process::forceresume()
bool Process::resume() bool Process::resume()
{ {
int status;
if(!d->attached) if(!d->attached)
return false; return false;
if(!d->suspended) if(!d->suspended)
@ -272,6 +268,7 @@ bool Process::resume()
return false; return false;
} }
d->suspended = false; d->suspended = false;
return true;
} }
@ -359,4 +356,4 @@ bool Process::detach()
return true; return true;
} }
} }
} }

@ -85,4 +85,4 @@ namespace DFHack
DataModel *getDataModel(); DataModel *getDataModel();
}; };
} }
#endif #endif

@ -87,14 +87,14 @@ bool ProcessEnumerator::findProcessess()
uint32_t ProcessEnumerator::size() uint32_t ProcessEnumerator::size()
{ {
return d->processes.size(); return d->processes.size();
}; }
Process * ProcessEnumerator::operator[](uint32_t index) Process * ProcessEnumerator::operator[](uint32_t index)
{ {
assert(index < d->processes.size()); assert(index < d->processes.size());
return d->processes[index]; return d->processes[index];
}; }
ProcessEnumerator::ProcessEnumerator( string path_to_xml ) ProcessEnumerator::ProcessEnumerator( string path_to_xml )

@ -192,7 +192,7 @@ enum MatglossType
Mat_Potash = 20, Mat_Potash = 20,
Mat_Ashes = 20, Mat_Ashes = 20,
Mat_PearlAsh = 21, Mat_PearlAsh = 21,
Mat_Soap = 24, Mat_Soap = 24
//NUM_MATGLOSS_TYPES //NUM_MATGLOSS_TYPES
}; };

@ -37,7 +37,7 @@ void Mread (const uint32_t &offset, const uint32_t &size, uint8_t *target)
{ {
if(size == 0) return; if(size == 0) return;
int result; ssize_t result;
result = pread(DFHack::g_ProcessMemFile, target,size,offset); result = pread(DFHack::g_ProcessMemFile, target,size,offset);
if(result != size) if(result != size)
{ {
@ -162,6 +162,7 @@ bool Mwrite (uint32_t offset, uint32_t size, uint8_t *source)
return true; return true;
} }
} }
return false; // dead code
} }
inline inline

@ -354,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
} }
else else
{ {
while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) while ( (*p && IsWhiteSpace( *p )) || *p == '\n' || *p =='\r' )
++p; ++p;
} }

@ -82,4 +82,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -158,4 +158,4 @@ int main (int argc,const char* argv[])
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -52,4 +52,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -182,4 +182,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -78,7 +78,6 @@ int main ()
DF.ReadCreatureMatgloss(mat.creatureMat); DF.ReadCreatureMatgloss(mat.creatureMat);
vector <string> buildingtypes; vector <string> buildingtypes;
uint32_t numBuildings = DF.InitReadBuildings(buildingtypes);
DF.InitViewAndCursor(); DF.InitViewAndCursor();
cout << "q to quit, anything else to look up items at that location\n"; cout << "q to quit, anything else to look up items at that location\n";
while(1) while(1)
@ -140,10 +139,11 @@ int main ()
} }
else{ else{
cerr << "Please Select which item you want to display\n"; cerr << "Please Select which item you want to display\n";
for(int j = 0; j < foundItems.size(); ++j){ for(uint32_t j = 0; j < foundItems.size(); ++j)
{
cerr << j << " " << buildingtypes[foundItems[j].type] << endl; cerr << j << " " << buildingtypes[foundItems[j].type] << endl;
} }
int value; uint32_t value;
string input2; string input2;
stringstream ss; stringstream ss;
getline(cin, input2); getline(cin, input2);

@ -68,4 +68,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -217,4 +217,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -43,4 +43,4 @@ int main (void)
#endif #endif
return 0; return 0;
} }

@ -53,4 +53,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -145,7 +145,7 @@ int main (int argc, const char* argv[])
{ {
// hidden tiles are ignored unless '-a' is provided on the command line // hidden tiles are ignored unless '-a' is provided on the command line
// non-wall tiles are ignored // non-wall tiles are ignored
if(designations[xi][yi].bits.hidden && !showhidden || !DFHack::isWallTerrain(tiletypes[xi][yi])) if( (designations[xi][yi].bits.hidden && !showhidden) || !DFHack::isWallTerrain(tiletypes[xi][yi]))
continue; continue;
if(tempvein[xi][yi] < 0) if(tempvein[xi][yi] < 0)
continue; continue;
@ -175,4 +175,4 @@ int main (int argc, const char* argv[])
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }

@ -11,8 +11,6 @@ using namespace std;
int main (void) int main (void)
{ {
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;
uint32_t num_blocks = 0;
uint32_t bytes_read = 0;
DFHack::t_designation designations[256]; DFHack::t_designation designations[256];
DFHack::API DF("Memory.xml"); DFHack::API DF("Memory.xml");
@ -52,4 +50,4 @@ int main (void)
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
} }