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(-DUSE_CONFIG_H)
find_library(X11_LIBRARY X11)
find_library(XTEST_LIBRARY Xtst)
SET(PROJECT_LIBS ${X11_LIBRARY} ${XTEST_LIBRARY})
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -pedantic")
SET(PROJECT_LIBS ${X11_LIBRARY})
ELSE(UNIX)
SET(PROJECT_LIBS psapi)
ENDIF(UNIX)

@ -41,7 +41,7 @@ DfVector DMWindows40d::readVector (uint32_t offset, uint32_t item_size)
uint32_t end = MreadDWord(offset+8);
uint32_t size = (end - start) /4;
return DfVector(start,size,item_size);
};
}
size_t DMWindows40d::readSTLString (uint32_t offset, char * buffer, size_t bufcapacity)
@ -76,7 +76,7 @@ Uint32 capacity
buffer[read_real] = 0;
return read_real;
};
}
const string DMWindows40d::readSTLString (uint32_t offset)
{
@ -111,7 +111,7 @@ const string DMWindows40d::readSTLString (uint32_t offset)
string ret = temp;
delete temp;
return ret;
};
}
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 size = (end - start) /4;
return DfVector(start,size,item_size);
};
}
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);
buffer[read_real] = 0;
return read_real;
};
}
const string DMLinux40d::readSTLString (uint32_t offset)
{
@ -161,4 +161,4 @@ const string DMLinux40d::readSTLString (uint32_t offset)
string ret(temp);
delete temp;
return ret;
};
}

@ -283,7 +283,7 @@ bool API::getCurrentCursorCreatures (vector<uint32_t> &addresses)
return false;
}
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);
addresses.push_back (temp);
@ -406,7 +406,7 @@ bool API::ReadStoneMatgloss (vector<t_matgloss> & stones)
int matgloss_colors = minfo->getOffset ("matgloss_stone_color");
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.reserve (size);
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];
assert (d->creaturesInited);
uint32_t size = d->p_cre->getSize();
while (index < size)
while (uint32_t(index) < size)
{
// read pointer from vector at position
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);
// current job HACK: the job object isn't cleanly represented here
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);
}
@ -1081,9 +1082,8 @@ void API::InitReadNameTables (map< string, vector<string> > & nameTable)
DfVector genericVec (d->dm->readVector (genericAddress, 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);
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++)
{
if (squad.names[i] == 0xFFFFFFFF)
if (squad.names[i] == -1)
{
continue;
}

@ -24,8 +24,6 @@ distribution.
#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
#define XK_LATIN1
#include <X11/keysymdef.h>
@ -115,7 +113,7 @@ Window EnumerateWindows (Display *display, Window rootWindow, const char *search
}
// 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);
if (tempWindow != BadWindow)
@ -183,14 +181,12 @@ void API::TypeStr (const char *lpszString, int delay, bool useShift)
char cChar;
int realDelay = delay * 1000;
KeyCode xkeycode;
char prevKey = 0;
int sleepAmnt = 0;
while ( (cChar = *lpszString++)) // loops through chars
{
// HACK: the timing here is a strange beast
xkeycode = XKeysymToKeycode (dpy, cChar);
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,false, realDelay);
@ -243,4 +239,4 @@ void API::TypeSpecial (t_special command, int count, int delay)
{
usleep (delay*1000 * count);
}
}
}

@ -83,4 +83,4 @@ enum t_special
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"))
{
v_pEntries.push_back(pMemInfo);
const char *id;
if(id= pMemInfo->Attribute("id"))
const char *id = pMemInfo->Attribute("id");
if(id)
{
string str_id = id;
map_pNamedEntries[str_id] = pMemInfo;
@ -267,4 +267,4 @@ bool MemInfoManager::loadFile(string path_to_xml)
error = true;
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?
{
memory_info * m = &*it;
Process * ret;
//cout <<"Found process " << PH << ". It's DF version " << m->getVersion() << "." << endl;
// df can run under wine on Linux
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 )
{
char buffer[1024];
char name[1024];
char permissions[5]; // r/-, w/-, x/-, p/s, 0
sprintf(buffer, "/proc/%lu/maps", d->my_pid);
FILE *mapFile = ::fopen(buffer, "r");
uint64_t begin, end, offset, device1, device2, node;
uint64_t offset, device1, device2, node;
while (fgets(buffer, 1024, mapFile))
{
@ -251,6 +247,7 @@ bool Process::suspend()
}
}
d->suspended = true;
return true;
}
bool Process::forceresume()
@ -260,7 +257,6 @@ bool Process::forceresume()
bool Process::resume()
{
int status;
if(!d->attached)
return false;
if(!d->suspended)
@ -272,6 +268,7 @@ bool Process::resume()
return false;
}
d->suspended = false;
return true;
}
@ -359,4 +356,4 @@ bool Process::detach()
return true;
}
}
}
}

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

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

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

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

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

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

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

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

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

@ -78,7 +78,6 @@ int main ()
DF.ReadCreatureMatgloss(mat.creatureMat);
vector <string> buildingtypes;
uint32_t numBuildings = DF.InitReadBuildings(buildingtypes);
DF.InitViewAndCursor();
cout << "q to quit, anything else to look up items at that location\n";
while(1)
@ -140,10 +139,11 @@ int main ()
}
else{
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;
}
int value;
uint32_t value;
string input2;
stringstream ss;
getline(cin, input2);

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

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

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

@ -53,4 +53,4 @@ int main (void)
cin.ignore();
#endif
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
// 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;
if(tempvein[xi][yi] < 0)
continue;
@ -175,4 +175,4 @@ int main (int argc, const char* argv[])
cin.ignore();
#endif
return 0;
}
}

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