Added playground folder for quick hacks

develop
Petr Mrázek 2010-05-25 23:52:04 +02:00
parent e26b6269f1
commit 863eb2546f
7 changed files with 103 additions and 41 deletions

@ -41,3 +41,4 @@ add_subdirectory (dfhack/shm)
#add_subdirectory (dfhack/depends/argstream)
add_subdirectory (tools)
add_subdirectory (examples)
add_subdirectory (playground)

@ -438,7 +438,7 @@ const string NormalProcess::readCString (const uint32_t offset)
{
string temp;
char temp_c[256];
DWORD read;
SIZE_T read;
if(!ReadProcessMemory(d->my_handle, (int *) offset, temp_c, 254, &read))
throw Error::MemoryAccessDenied();
// needs to be 254+1 byte for the null term

@ -376,8 +376,6 @@ bool Materials::ReadCreatureTypesEx (void)
p->readSTLString( p_extract[j], extract.rawname, sizeof(extract.rawname));
mat.extract.push_back(extract);
}
raceEx.push_back(mat);
}
return true;

@ -1727,7 +1727,7 @@ map_data_1b60_offset 0x1B9c
Creatures
=========
<Address name="creature_vector">0x092E3A9C</Address>
<Address name="creature_vector">0x092E3AA0</Address>
<Address name="dwarf_race_index">0x092CB608</Address>
<Address name="dwarf_civ_id">0x092CB5FC</Address>
<Offset name="creature_name">0x0</Offset>

@ -0,0 +1,11 @@
# don't use this file directly. use the one in the root folder of the project
# this is required to ensure we use the right configuration for the system.
IF(UNIX)
add_definitions(-DLINUX_BUILD)
ENDIF(UNIX)
# for trying out some 'stuff'
ADD_EXECUTABLE(dftest test.cpp)
TARGET_LINK_LIBRARIES(dftest dfhack)

@ -0,0 +1,52 @@
#include <iostream>
#include <iomanip>
#include <climits>
#include <integers.h>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
#include <DFGlobal.h>
#include <DFTypes.h>
#include <DFContextManager.h>
#include <DFContext.h>
#include <DFProcess.h>
#include <DFMemInfo.h>
#include <DFVector.h>
#include <DFTypes.h>
#include <modules/Materials.h>
#include <modules/Position.h>
#include <modules/Maps.h>
#include <modules/Constructions.h>
#include <DFMiscUtils.h>
#include <DFTileTypes.h>
using namespace DFHack;
int main (int numargs, const char ** args)
{
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
// DO STUFF HERE
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -143,7 +143,7 @@ void searchLoopVector(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange
if(!ranges[i].read)
continue;
//loop
for(uint64_t offset = ranges[i].start;offset <= ranges[i].end - sizeof(vecTriplet); offset++)
for(uint64_t offset = ranges[i].start;offset <= ranges[i].end - sizeof(vecTriplet); offset+=4)
{
DF->ReadRaw(offset, sizeof(vecTriplet), (uint8_t *) &load);
if(load.start <= load.finish && load.finish <= load.alloc_finish)