diff --git a/CMakeLists.txt b/CMakeLists.txt index 29a2e8a9c..6b8e7ab2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,8 @@ SET(DFHACK_CONSISTENCY 1) set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MINOR "5") -set(CPACK_PACKAGE_VERSION_PATCH "14") -set(DFHACK_REVISION "1") +set(CPACK_PACKAGE_VERSION_PATCH "15") +set(DFHACK_REVISION "dev1") set(DFHACK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_PACKAGE_VERSION ${DFHACK_VERSION}) diff --git a/library/ContextShared.cpp b/library/ContextShared.cpp index 566f6db6c..1aaed1d1c 100644 --- a/library/ContextShared.cpp +++ b/library/ContextShared.cpp @@ -43,7 +43,7 @@ bool DFContextShared::InitReadNames() name_language_offset = OG->getOffset("language"); name_set_offset = OG->getOffset("has_name"); } - catch(exception & e) + catch(exception &) { namesFailed = true; return false; diff --git a/library/include/dfhack/DFProcess.h b/library/include/dfhack/DFProcess.h index 32c24b554..4105f866b 100644 --- a/library/include/dfhack/DFProcess.h +++ b/library/include/dfhack/DFProcess.h @@ -185,7 +185,8 @@ namespace DFHack /// get class name of an object with rtti/type info virtual std::string doReadClassName(uint32_t vptr) = 0; - std::string readClassName(uint32_t vptr) { + std::string readClassName(uint32_t vptr) + { std::map::iterator it = classNameCache.find(vptr); if (it != classNameCache.end()) return it->second; @@ -223,20 +224,24 @@ namespace DFHack virtual bool SetAndWait (uint32_t state) = 0; }; - class DFHACK_EXPORT ClassNameCheck { + class DFHACK_EXPORT ClassNameCheck + { std::string name; uint32_t vptr; public: - ClassNameCheck() : vptr(0) {} - ClassNameCheck(std::string _name) : name(_name), vptr(0) {} - ClassNameCheck &operator= (const ClassNameCheck &b) { + ClassNameCheck() : vptr(0) {}; + ClassNameCheck(std::string _name) : name(_name), vptr(0) {}; + ClassNameCheck &operator= (const ClassNameCheck &b) + { name = b.name; vptr = b.vptr; return *this; - } - bool operator() (Process *p, uint32_t ptr) { - if (vptr == 0 && p->readClassName(ptr) == name) - vptr = ptr; + }; + bool operator() (Process *p, uint32_t ptr) + { + if(vptr == 0) + if (p->readClassName(ptr) == name) + vptr = ptr; return (vptr && vptr == ptr); - } + }; }; } #endif diff --git a/library/include/dfhack/modules/Vegetation.h b/library/include/dfhack/modules/Vegetation.h index 0e8b121ac..9639228f7 100644 --- a/library/include/dfhack/modules/Vegetation.h +++ b/library/include/dfhack/modules/Vegetation.h @@ -18,21 +18,19 @@ namespace DFHack /** * \ingroup grp_vegetation */ + #pragma pack(push, 2) struct t_plant { // +0x3C - #pragma pack(push, 1) union { uint16_t type; struct { - unsigned int watery : 1; - unsigned int is_shrub : 1; - unsigned int unknown : 14; + bool watery : 1; + bool is_shrub : 1; }; }; - #pragma pack(pop) uint16_t material; // +0x3E uint16_t x; // +0x40 uint16_t y; // +0x42 @@ -50,6 +48,7 @@ namespace DFHack // a vector is here // some more temperature stuff after that }; + #pragma pack(pop) /** * Plant object read from the game * \ingroup grp_vegetation diff --git a/library/modules/Maps_C.cpp b/library/modules/Maps_C.cpp index 94ed834e9..9ebe6e4b2 100644 --- a/library/modules/Maps_C.cpp +++ b/library/modules/Maps_C.cpp @@ -26,6 +26,7 @@ distribution. #include #include #include +#include using namespace std; diff --git a/library/modules/World_C.cpp b/library/modules/World_C.cpp index 37e034ccd..a87a7f6f1 100644 --- a/library/modules/World_C.cpp +++ b/library/modules/World_C.cpp @@ -24,6 +24,7 @@ distribution. #include #include +#include using namespace std; #include "dfhack-c/Common.h" #include "dfhack/modules/World.h" diff --git a/tools/supported/prospector.cpp b/tools/supported/prospector.cpp index e543adc60..1cdf6064d 100644 --- a/tools/supported/prospector.cpp +++ b/tools/supported/prospector.cpp @@ -16,6 +16,7 @@ using namespace std; #include #include #include +#include "termutil.h" typedef std::map MatMap; typedef std::vector< pair > MatSorter; @@ -89,6 +90,11 @@ void printMats(MatMap &mat, std::vector &materials) std::sort(sorting_vector.begin(), sorting_vector.end(), compare_pair_second<>()); for (MatSorter::const_iterator it = sorting_vector.begin(); it != sorting_vector.end(); ++it) { + if(it->first >= materials.size()) + { + cerr << "Bad index: " << it->first << " out of " << materials.size() << endl; + continue; + } DFHack::t_matgloss mat = materials[it->first]; std::cout << std::setw(25) << mat.id << " : " << it->second << std::endl; total += it->second; @@ -99,6 +105,7 @@ void printMats(MatMap &mat, std::vector &materials) int main(int argc, char *argv[]) { + bool temporary_terminal = TemporaryTerminal(); bool showHidden = false; bool showPlants = true; bool showSlade = true; @@ -116,9 +123,8 @@ int main(int argc, char *argv[]) if (!context->Attach()) { std::cerr << "Unable to attach to DF!" << std::endl; - #ifndef LINUX_BUILD - std::cin.ignore(); - #endif + if(temporary_terminal) + std::cin.ignore(); return 1; } @@ -127,9 +133,8 @@ int main(int argc, char *argv[]) { std::cerr << "Cannot get map info!" << std::endl; context->Detach(); - #ifndef LINUX_BUILD - std::cin.ignore(); - #endif + if(temporary_terminal) + std::cin.ignore(); return 1; } maps->getSize(x_max, y_max, z_max); @@ -140,9 +145,8 @@ int main(int argc, char *argv[]) { std::cerr << "Unable to read inorganic material definitons!" << std::endl; context->Detach(); - #ifndef LINUX_BUILD - std::cin.ignore(); - #endif + if(temporary_terminal) + std::cin.ignore(); return 1; } if (showPlants && !mats->ReadOrganicMaterials()) @@ -382,10 +386,11 @@ int main(int argc, char *argv[]) mats->Finish(); maps->Finish(); context->Detach(); - #ifndef LINUX_BUILD - std::cout << " Press any key to finish."; - std::cin.ignore(); - #endif + if(temporary_terminal) + { + std::cout << " Press any key to finish."; + std::cin.ignore(); + } std::cout << std::endl; return 0; }