diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a5d6534b..fa85ba2a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,3 +41,4 @@ add_subdirectory (dfhack/shm) #add_subdirectory (dfhack/depends/argstream) add_subdirectory (tools) add_subdirectory (examples) +add_subdirectory (playground) diff --git a/dfhack/DFProcess-windows.cpp b/dfhack/DFProcess-windows.cpp index 54254d235..ae0e688ef 100644 --- a/dfhack/DFProcess-windows.cpp +++ b/dfhack/DFProcess-windows.cpp @@ -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 diff --git a/dfhack/modules/Materials.cpp b/dfhack/modules/Materials.cpp index 3debe13ac..cdd800a84 100644 --- a/dfhack/modules/Materials.cpp +++ b/dfhack/modules/Materials.cpp @@ -265,26 +265,26 @@ bool Materials::ReadOthers(void) bool Materials::ReadDescriptorColors (void) { - Process * p = d->owner; - DfVector p_colors (p, p->getDescriptor()->getAddress ("descriptor_colors_vector")); - uint32_t size = p_colors.size(); - - color.clear(); - if(size == 0) - return false; - color.reserve(size); - for (uint32_t i = 0; i < size;i++) - { - t_descriptor_color col; - p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_rawname"), col.id, 128); - p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_name"), col.name, 128); - col.r = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_r") ); - col.v = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_v") ); - col.b = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_b") ); - color.push_back(col); - } - return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("descriptor_all_colors"), alldesc ); - return true; + Process * p = d->owner; + DfVector p_colors (p, p->getDescriptor()->getAddress ("descriptor_colors_vector")); + uint32_t size = p_colors.size(); + + color.clear(); + if(size == 0) + return false; + color.reserve(size); + for (uint32_t i = 0; i < size;i++) + { + t_descriptor_color col; + p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_rawname"), col.id, 128); + p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_name"), col.name, 128); + col.r = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_r") ); + col.v = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_v") ); + col.b = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_b") ); + color.push_back(col); + } + return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("descriptor_all_colors"), alldesc ); + return true; } bool Materials::ReadCreatureTypesEx (void) @@ -364,20 +364,18 @@ bool Materials::ReadCreatureTypesEx (void) mat.castes.push_back(caste); } - mat.tile_character = p->readByte( p_races[i] + tile_offset ); + mat.tile_character = p->readByte( p_races[i] + tile_offset ); mat.tilecolor.fore = p->readWord( p_races[i] + tile_color_offset ); mat.tilecolor.back = p->readWord( p_races[i] + tile_color_offset + 2 ); mat.tilecolor.bright = p->readWord( p_races[i] + tile_color_offset + 4 ); - - DfVector p_extract(p, p_races[i] + extract_vector_offset); - for(uint32_t j = 0; j < p_extract.size(); j++) - { - t_creatureextract extract; - p->readSTLString( p_extract[j], extract.rawname, sizeof(extract.rawname)); - mat.extract.push_back(extract); - } - + DfVector p_extract(p, p_races[i] + extract_vector_offset); + for(uint32_t j = 0; j < p_extract.size(); j++) + { + t_creatureextract extract; + p->readSTLString( p_extract[j], extract.rawname, sizeof(extract.rawname)); + mat.extract.push_back(extract); + } raceEx.push_back(mat); } return true; @@ -385,14 +383,14 @@ bool Materials::ReadCreatureTypesEx (void) void Materials::ReadAllMaterials(void) { - this->ReadInorganicMaterials(); - this->ReadOrganicMaterials(); - this->ReadWoodMaterials(); - this->ReadPlantMaterials(); - this->ReadCreatureTypes(); - this->ReadCreatureTypesEx(); - this->ReadDescriptorColors(); - this->ReadOthers(); + this->ReadInorganicMaterials(); + this->ReadOrganicMaterials(); + this->ReadWoodMaterials(); + this->ReadPlantMaterials(); + this->ReadCreatureTypes(); + this->ReadCreatureTypesEx(); + this->ReadDescriptorColors(); + this->ReadOthers(); } std::string Materials::getDescription(t_material & mat) diff --git a/output/Memory.xml b/output/Memory.xml index 467145962..fa97b261a 100755 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -1727,7 +1727,7 @@ map_data_1b60_offset 0x1B9c Creatures ========= -
0x092E3A9C
+
0x092E3AA0
0x092CB608
0x092CB5FC
0x0 diff --git a/playground/CMakeLists.txt b/playground/CMakeLists.txt new file mode 100644 index 000000000..4c689a6b0 --- /dev/null +++ b/playground/CMakeLists.txt @@ -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) + diff --git a/playground/test.cpp b/playground/test.cpp new file mode 100644 index 000000000..becd10c96 --- /dev/null +++ b/playground/test.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/tools/incrementalsearch.cpp b/tools/incrementalsearch.cpp index 71b304f4d..b7ea5352a 100644 --- a/tools/incrementalsearch.cpp +++ b/tools/incrementalsearch.cpp @@ -143,7 +143,7 @@ void searchLoopVector(DFHack::ContextManager & DFMgr, vector ReadRaw(offset, sizeof(vecTriplet), (uint8_t *) &load); if(load.start <= load.finish && load.finish <= load.alloc_finish)