Fix for MSVC build, added prototype cmd.exe detection on windows.

develop
Petr Mrázek 2011-05-15 05:19:51 +02:00
parent 4d3f4c2c23
commit fe6eb4b70a
7 changed files with 42 additions and 31 deletions

@ -17,8 +17,8 @@ SET(DFHACK_CONSISTENCY 1)
set(CPACK_PACKAGE_VERSION_MAJOR "0") set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "5") set(CPACK_PACKAGE_VERSION_MINOR "5")
set(CPACK_PACKAGE_VERSION_PATCH "14") set(CPACK_PACKAGE_VERSION_PATCH "15")
set(DFHACK_REVISION "1") set(DFHACK_REVISION "dev1")
set(DFHACK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(DFHACK_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION ${DFHACK_VERSION}) set(CPACK_PACKAGE_VERSION ${DFHACK_VERSION})

@ -43,7 +43,7 @@ bool DFContextShared::InitReadNames()
name_language_offset = OG->getOffset("language"); name_language_offset = OG->getOffset("language");
name_set_offset = OG->getOffset("has_name"); name_set_offset = OG->getOffset("has_name");
} }
catch(exception & e) catch(exception &)
{ {
namesFailed = true; namesFailed = true;
return false; return false;

@ -185,7 +185,8 @@ namespace DFHack
/// get class name of an object with rtti/type info /// get class name of an object with rtti/type info
virtual std::string doReadClassName(uint32_t vptr) = 0; virtual std::string doReadClassName(uint32_t vptr) = 0;
std::string readClassName(uint32_t vptr) { std::string readClassName(uint32_t vptr)
{
std::map<uint32_t, std::string>::iterator it = classNameCache.find(vptr); std::map<uint32_t, std::string>::iterator it = classNameCache.find(vptr);
if (it != classNameCache.end()) if (it != classNameCache.end())
return it->second; return it->second;
@ -223,20 +224,24 @@ namespace DFHack
virtual bool SetAndWait (uint32_t state) = 0; virtual bool SetAndWait (uint32_t state) = 0;
}; };
class DFHACK_EXPORT ClassNameCheck { class DFHACK_EXPORT ClassNameCheck
{
std::string name; std::string name;
uint32_t vptr; uint32_t vptr;
public: public:
ClassNameCheck() : vptr(0) {} ClassNameCheck() : vptr(0) {};
ClassNameCheck(std::string _name) : name(_name), vptr(0) {} ClassNameCheck(std::string _name) : name(_name), vptr(0) {};
ClassNameCheck &operator= (const ClassNameCheck &b) { ClassNameCheck &operator= (const ClassNameCheck &b)
{
name = b.name; vptr = b.vptr; return *this; name = b.name; vptr = b.vptr; return *this;
} };
bool operator() (Process *p, uint32_t ptr) { bool operator() (Process *p, uint32_t ptr)
if (vptr == 0 && p->readClassName(ptr) == name) {
if(vptr == 0)
if (p->readClassName(ptr) == name)
vptr = ptr; vptr = ptr;
return (vptr && vptr == ptr); return (vptr && vptr == ptr);
} };
}; };
} }
#endif #endif

@ -18,21 +18,19 @@ namespace DFHack
/** /**
* \ingroup grp_vegetation * \ingroup grp_vegetation
*/ */
#pragma pack(push, 2)
struct t_plant struct t_plant
{ {
// +0x3C // +0x3C
#pragma pack(push, 1)
union union
{ {
uint16_t type; uint16_t type;
struct struct
{ {
unsigned int watery : 1; bool watery : 1;
unsigned int is_shrub : 1; bool is_shrub : 1;
unsigned int unknown : 14;
}; };
}; };
#pragma pack(pop)
uint16_t material; // +0x3E uint16_t material; // +0x3E
uint16_t x; // +0x40 uint16_t x; // +0x40
uint16_t y; // +0x42 uint16_t y; // +0x42
@ -50,6 +48,7 @@ namespace DFHack
// a vector is here // a vector is here
// some more temperature stuff after that // some more temperature stuff after that
}; };
#pragma pack(pop)
/** /**
* Plant object read from the game * Plant object read from the game
* \ingroup grp_vegetation * \ingroup grp_vegetation

@ -26,6 +26,7 @@ distribution.
#include <vector> #include <vector>
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#include <string>
using namespace std; using namespace std;

@ -24,6 +24,7 @@ distribution.
#include <vector> #include <vector>
#include <map> #include <map>
#include <string>
using namespace std; using namespace std;
#include "dfhack-c/Common.h" #include "dfhack-c/Common.h"
#include "dfhack/modules/World.h" #include "dfhack/modules/World.h"

@ -16,6 +16,7 @@ using namespace std;
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/extra/MapExtras.h> #include <dfhack/extra/MapExtras.h>
#include <xgetopt.h> #include <xgetopt.h>
#include "termutil.h"
typedef std::map<int16_t, unsigned int> MatMap; typedef std::map<int16_t, unsigned int> MatMap;
typedef std::vector< pair<int16_t, unsigned int> > MatSorter; typedef std::vector< pair<int16_t, unsigned int> > MatSorter;
@ -89,6 +90,11 @@ void printMats(MatMap &mat, std::vector<DFHack::t_matgloss> &materials)
std::sort(sorting_vector.begin(), sorting_vector.end(), compare_pair_second<>()); std::sort(sorting_vector.begin(), sorting_vector.end(), compare_pair_second<>());
for (MatSorter::const_iterator it = sorting_vector.begin(); it != sorting_vector.end(); ++it) 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]; DFHack::t_matgloss mat = materials[it->first];
std::cout << std::setw(25) << mat.id << " : " << it->second << std::endl; std::cout << std::setw(25) << mat.id << " : " << it->second << std::endl;
total += it->second; total += it->second;
@ -99,6 +105,7 @@ void printMats(MatMap &mat, std::vector<DFHack::t_matgloss> &materials)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool temporary_terminal = TemporaryTerminal();
bool showHidden = false; bool showHidden = false;
bool showPlants = true; bool showPlants = true;
bool showSlade = true; bool showSlade = true;
@ -116,9 +123,8 @@ int main(int argc, char *argv[])
if (!context->Attach()) if (!context->Attach())
{ {
std::cerr << "Unable to attach to DF!" << std::endl; std::cerr << "Unable to attach to DF!" << std::endl;
#ifndef LINUX_BUILD if(temporary_terminal)
std::cin.ignore(); std::cin.ignore();
#endif
return 1; return 1;
} }
@ -127,9 +133,8 @@ int main(int argc, char *argv[])
{ {
std::cerr << "Cannot get map info!" << std::endl; std::cerr << "Cannot get map info!" << std::endl;
context->Detach(); context->Detach();
#ifndef LINUX_BUILD if(temporary_terminal)
std::cin.ignore(); std::cin.ignore();
#endif
return 1; return 1;
} }
maps->getSize(x_max, y_max, z_max); 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; std::cerr << "Unable to read inorganic material definitons!" << std::endl;
context->Detach(); context->Detach();
#ifndef LINUX_BUILD if(temporary_terminal)
std::cin.ignore(); std::cin.ignore();
#endif
return 1; return 1;
} }
if (showPlants && !mats->ReadOrganicMaterials()) if (showPlants && !mats->ReadOrganicMaterials())
@ -382,10 +386,11 @@ int main(int argc, char *argv[])
mats->Finish(); mats->Finish();
maps->Finish(); maps->Finish();
context->Detach(); context->Detach();
#ifndef LINUX_BUILD if(temporary_terminal)
{
std::cout << " Press any key to finish."; std::cout << " Press any key to finish.";
std::cin.ignore(); std::cin.ignore();
#endif }
std::cout << std::endl; std::cout << std::endl;
return 0; return 0;
} }