Big namespace cleaning

develop
Petr Mrázek 2010-06-05 00:02:02 +02:00
parent 115e969530
commit 6b7f3e1816
16 changed files with 208 additions and 214 deletions

@ -29,6 +29,55 @@ distribution.
using namespace DFHack; using namespace DFHack;
/*
* Common data types
*/
namespace DFHack
{
struct t_type
{
t_type(uint32_t assign, uint32_t type, std::string classname)
:classname(classname),assign(assign),type(type){};
std::string classname;
uint32_t assign;
uint32_t type;
};
struct t_class
{
t_class(const t_class &old)
{
classname = old.classname;
vtable = old.vtable;
assign = old.assign;
type_offset = old.type_offset;
for(uint32_t i = 0; i < old.subs.size();i++)
{
t_type * t = new t_type (*old.subs[i]);
subs.push_back(t);
}
}
t_class ()
{
vtable = 0;
assign = 0;
type_offset = 0;
}
~t_class()
{
for(uint32_t i = 0; i < subs.size();i++)
{
delete subs[i];
}
subs.clear();
}
std::string classname;
uint32_t vtable;
uint32_t assign;// index to typeclass array if multiclass. return value if not.
uint32_t type_offset; // offset of type data for multiclass
std::vector<t_type *> subs;
};
}
/* /*
* Private data * Private data
*/ */

@ -1,6 +1,7 @@
#ifndef DFHACK_API_H #ifndef DFHACK_API_H
#define DFHACK_API_H #define DFHACK_API_H
// DFHack core classes and types
#include "dfhack/DFIntegers.h" #include "dfhack/DFIntegers.h"
#include "dfhack/DFGlobal.h" #include "dfhack/DFGlobal.h"
#include "dfhack/DFError.h" #include "dfhack/DFError.h"
@ -10,7 +11,7 @@
#include "dfhack/DFProcess.h" #include "dfhack/DFProcess.h"
#include "dfhack/DFTypes.h" #include "dfhack/DFTypes.h"
// DFHack modules
#include "dfhack/modules/Buildings.h" #include "dfhack/modules/Buildings.h"
#include "dfhack/modules/Materials.h" #include "dfhack/modules/Materials.h"
#include "dfhack/modules/Position.h" #include "dfhack/modules/Position.h"
@ -22,5 +23,10 @@
#include "dfhack/modules/Vegetation.h" #include "dfhack/modules/Vegetation.h"
#include "dfhack/modules/Maps.h" #include "dfhack/modules/Maps.h"
#include "dfhack/DFMiscUtils.h" #ifdef DFHACK_WANT_MISCUTILS
#include "dfhack/DFMiscUtils.h"
#endif
#ifdef DFHACK_WANT_TILETYPES
#include "dfhack/DFTileTypes.h"
#endif
#endif #endif

@ -35,7 +35,7 @@ distribution.
#include "dfhack/DFExport.h" #include "dfhack/DFExport.h"
#include "dfhack/DFIntegers.h" #include "dfhack/DFIntegers.h"
using namespace std;
using namespace DFHack; using namespace DFHack;
typedef void DFHackObject; typedef void DFHackObject;

@ -27,64 +27,13 @@ distribution.
#include "DFPragma.h" #include "DFPragma.h"
#include "DFExport.h" #include "DFExport.h"
#include <map>
#include <vector>
#include <string>
namespace DFHack namespace DFHack
{ {
/* /*
* Stubs * Stubs
*/ */
class Process; class Process;
struct t_class;
/*
* Common data types
*/
struct t_type
{
t_type(uint32_t assign, uint32_t type, std::string classname)
:classname(classname),assign(assign),type(type){};
std::string classname;
uint32_t assign;
uint32_t type;
};
struct t_class
{
t_class(const t_class &old)
{
classname = old.classname;
vtable = old.vtable;
assign = old.assign;
type_offset = old.type_offset;
for(uint32_t i = 0; i < old.subs.size();i++)
{
t_type * t = new t_type (*old.subs[i]);
subs.push_back(t);
}
}
t_class ()
{
vtable = 0;
assign = 0;
type_offset = 0;
}
~t_class()
{
for(uint32_t i = 0; i < subs.size();i++)
{
delete subs[i];
}
subs.clear();
}
std::string classname;
uint32_t vtable;
uint32_t assign;// index to typeclass array if multiclass. return value if not.
uint32_t type_offset; // offset of type data for multiclass
vector<t_type *> subs;
};
class DFHACK_EXPORT memory_info class DFHACK_EXPORT memory_info
{ {
@ -184,7 +133,7 @@ namespace DFHack
/** /**
* Get the internal classID->classname mapping (for speed). DO NOT MANIPULATE THE VECTOR! * Get the internal classID->classname mapping (for speed). DO NOT MANIPULATE THE VECTOR!
*/ */
const vector<std::string> * getClassIDMapping(); const std::vector<std::string> * getClassIDMapping();
}; };
} }
#endif // MEMINFO_H_INCLUDED #endif // MEMINFO_H_INCLUDED

@ -136,13 +136,13 @@ namespace DFHack
virtual void write(uint32_t address, uint32_t length, uint8_t* buffer) = 0; virtual void write(uint32_t address, uint32_t length, uint8_t* buffer) = 0;
/// read an STL string /// read an STL string
virtual const string readSTLString (uint32_t offset) = 0; virtual const std::string readSTLString (uint32_t offset) = 0;
/// read an STL string /// read an STL string
virtual size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity) = 0; virtual size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity) = 0;
/// write an STL string /// write an STL string
virtual void writeSTLString(const uint32_t address, const std::string writeString) = 0; virtual void writeSTLString(const uint32_t address, const std::string writeString) = 0;
/// get class name of an object with rtti/type info /// get class name of an object with rtti/type info
virtual string readClassName(uint32_t vptr) = 0; virtual std::string readClassName(uint32_t vptr) = 0;
/// read a null-terminated C string /// read a null-terminated C string
virtual const std::string readCString (uint32_t offset) = 0; virtual const std::string readCString (uint32_t offset) = 0;
@ -155,9 +155,9 @@ namespace DFHack
virtual bool isIdentified() = 0; virtual bool isIdentified() = 0;
/// find the thread IDs of the process /// find the thread IDs of the process
virtual bool getThreadIDs(vector<uint32_t> & threads ) = 0; virtual bool getThreadIDs(std::vector<uint32_t> & threads ) = 0;
/// get virtual memory ranges of the process (what is mapped where) /// get virtual memory ranges of the process (what is mapped where)
virtual void getMemRanges( vector<t_memrange> & ranges ) = 0; virtual void getMemRanges(std::vector<t_memrange> & ranges ) = 0;
/// get the flattened Memory.xml entry of this process /// get the flattened Memory.xml entry of this process
virtual memory_info *getDescriptor() = 0; virtual memory_info *getDescriptor() = 0;
@ -182,7 +182,7 @@ namespace DFHack
private: private:
Private * const d; Private * const d;
public: public:
NormalProcess(uint32_t pid, vector <memory_info *> & known_versions); NormalProcess(uint32_t pid, std::vector <memory_info *> & known_versions);
~NormalProcess(); ~NormalProcess();
bool attach(); bool attach();
bool detach(); bool detach();
@ -214,11 +214,11 @@ namespace DFHack
void read( uint32_t address, uint32_t length, uint8_t* buffer); void read( uint32_t address, uint32_t length, uint8_t* buffer);
void write(uint32_t address, uint32_t length, uint8_t* buffer); void write(uint32_t address, uint32_t length, uint8_t* buffer);
const string readSTLString (uint32_t offset); const std::string readSTLString (uint32_t offset);
size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity); size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity);
void writeSTLString(const uint32_t address, const std::string writeString){}; void writeSTLString(const uint32_t address, const std::string writeString){};
// get class name of an object with rtti/type info // get class name of an object with rtti/type info
string readClassName(uint32_t vptr); std::string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset); const std::string readCString (uint32_t offset);
@ -226,8 +226,8 @@ namespace DFHack
bool isAttached(); bool isAttached();
bool isIdentified(); bool isIdentified();
bool getThreadIDs(vector<uint32_t> & threads ); bool getThreadIDs(std::vector<uint32_t> & threads );
void getMemRanges( vector<t_memrange> & ranges ); void getMemRanges(std::vector<t_memrange> & ranges );
memory_info *getDescriptor(); memory_info *getDescriptor();
int getPID(); int getPID();
// get module index by name and version. bool 1 = error // get module index by name and version. bool 1 = error
@ -246,7 +246,7 @@ namespace DFHack
Private * const d; Private * const d;
public: public:
SHMProcess(uint32_t PID, vector <memory_info *> & known_versions); SHMProcess(uint32_t PID, std::vector <memory_info *> & known_versions);
~SHMProcess(); ~SHMProcess();
// Set up stuff so we can read memory // Set up stuff so we can read memory
bool attach(); bool attach();
@ -279,11 +279,11 @@ namespace DFHack
void read( uint32_t address, uint32_t length, uint8_t* buffer); void read( uint32_t address, uint32_t length, uint8_t* buffer);
void write(uint32_t address, uint32_t length, uint8_t* buffer); void write(uint32_t address, uint32_t length, uint8_t* buffer);
const string readSTLString (uint32_t offset); const std::string readSTLString (uint32_t offset);
size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity); size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity);
void writeSTLString(const uint32_t address, const std::string writeString); void writeSTLString(const uint32_t address, const std::string writeString);
// get class name of an object with rtti/type info // get class name of an object with rtti/type info
string readClassName(uint32_t vptr); std::string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset); const std::string readCString (uint32_t offset);
@ -291,8 +291,8 @@ namespace DFHack
bool isAttached(); bool isAttached();
bool isIdentified(); bool isIdentified();
bool getThreadIDs(vector<uint32_t> & threads ); bool getThreadIDs(std::vector<uint32_t> & threads );
void getMemRanges( vector<t_memrange> & ranges ); void getMemRanges(std::vector<t_memrange> & ranges );
memory_info *getDescriptor(); memory_info *getDescriptor();
int getPID(); int getPID();
// get module index by name and version. bool 1 = error // get module index by name and version. bool 1 = error
@ -311,7 +311,7 @@ namespace DFHack
Private * const d; Private * const d;
public: public:
WineProcess(uint32_t pid, vector <memory_info *> & known_versions); WineProcess(uint32_t pid, std::vector <memory_info *> & known_versions);
~WineProcess(); ~WineProcess();
bool attach(); bool attach();
bool detach(); bool detach();
@ -343,11 +343,11 @@ namespace DFHack
void read( uint32_t address, uint32_t length, uint8_t* buffer); void read( uint32_t address, uint32_t length, uint8_t* buffer);
void write(uint32_t address, uint32_t length, uint8_t* buffer); void write(uint32_t address, uint32_t length, uint8_t* buffer);
const string readSTLString (uint32_t offset); const std::string readSTLString (uint32_t offset);
size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity); size_t readSTLString (uint32_t offset, char * buffer, size_t bufcapacity);
void writeSTLString(const uint32_t address, const std::string writeString){}; void writeSTLString(const uint32_t address, const std::string writeString){};
// get class name of an object with rtti/type info // get class name of an object with rtti/type info
string readClassName(uint32_t vptr); std::string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset); const std::string readCString (uint32_t offset);
@ -355,8 +355,8 @@ namespace DFHack
bool isAttached(); bool isAttached();
bool isIdentified(); bool isIdentified();
bool getThreadIDs(vector<uint32_t> & threads ); bool getThreadIDs(std::vector<uint32_t> & threads );
void getMemRanges( vector<t_memrange> & ranges ); void getMemRanges(std::vector<t_memrange> & ranges );
memory_info *getDescriptor(); memory_info *getDescriptor();
int getPID(); int getPID();
// get module index by name and version. bool 1 = error // get module index by name and version. bool 1 = error

@ -37,7 +37,7 @@ namespace DFHack
bool Finish(); bool Finish();
// read a vector of names // read a vector of names
bool ReadCustomWorkshopTypes(map <uint32_t, string> & btypes); bool ReadCustomWorkshopTypes(std::map <uint32_t, std::string> & btypes);
// returns -1 on error, >= 0 for real value // returns -1 on error, >= 0 for real value
int32_t GetCustomWorkshopType(t_building & building); int32_t GetCustomWorkshopType(t_building & building);

@ -84,81 +84,70 @@ namespace DFHack
struct t_matglossOther struct t_matglossOther
{ {
char rawname[128]; char rawname[128];
}; };
struct t_creatureextract struct t_creatureextract
{ {
char rawname[128]; char rawname[128];
}; };
// this doesn't transfer well across the shm gap... // this doesn't transfer well across the shm gap...
struct t_creaturetype struct t_creaturetype
{ {
char rawname[128]; char rawname[128];
std::vector <t_creaturecaste> castes; std::vector <t_creaturecaste> castes;
std::vector <t_creatureextract> extract; std::vector <t_creatureextract> extract;
uint8_t tile_character; uint8_t tile_character;
struct struct
{ {
uint16_t fore; uint16_t fore;
uint16_t back; uint16_t back;
uint16_t bright; uint16_t bright;
} tilecolor; } tilecolor;
}; };
// this structure describes what are things made of in the DF world // this structure describes what are things made of in the DF world
struct t_material struct t_material
{ {
int16_t itemType; int16_t itemType;
int16_t subType; int16_t subType;
int16_t subIndex; int16_t subIndex;
int32_t index; int32_t index;
uint32_t flags; uint32_t flags;
}; };
class DFHACK_EXPORT Materials class DFHACK_EXPORT Materials
{ {
public: public:
Materials(DFHack::DFContextShared * _d); Materials(DFHack::DFContextShared * _d);
~Materials(); ~Materials();
std::vector<t_matgloss> inorganic; std::vector<t_matgloss> inorganic;
std::vector<t_matgloss> organic; std::vector<t_matgloss> organic;
std::vector<t_matgloss> tree; std::vector<t_matgloss> tree;
std::vector<t_matgloss> plant; std::vector<t_matgloss> plant;
std::vector<t_matgloss> race; std::vector<t_matgloss> race;
std::vector<t_creaturetype> raceEx; std::vector<t_creaturetype> raceEx;
std::vector<t_descriptor_color> color; std::vector<t_descriptor_color> color;
std::vector<t_matglossOther> other; std::vector<t_matglossOther> other;
std::vector<t_matgloss> alldesc; std::vector<t_matgloss> alldesc;
bool ReadInorganicMaterials (void); bool ReadInorganicMaterials (void);
bool ReadOrganicMaterials (void); bool ReadOrganicMaterials (void);
bool ReadWoodMaterials (void); bool ReadWoodMaterials (void);
bool ReadPlantMaterials (void); bool ReadPlantMaterials (void);
bool ReadCreatureTypes (void); bool ReadCreatureTypes (void);
bool ReadCreatureTypesEx (void); bool ReadCreatureTypesEx (void);
bool ReadDescriptorColors(void); bool ReadDescriptorColors(void);
bool ReadOthers (void); bool ReadOthers (void);
void ReadAllMaterials(void); void ReadAllMaterials(void);
std::string getDescription(t_material & mat); std::string getDescription(t_material & mat);
/* private:
bool ReadInorganicMaterials (std::vector<t_matgloss> & output); class Private;
bool ReadOrganicMaterials (std::vector<t_matgloss> & output); Private* d;
bool ReadWoodMaterials (std::vector<t_matgloss> & output); };
bool ReadPlantMaterials (std::vector<t_matgloss> & output);
// TODO: maybe move to creatures?
bool ReadCreatureTypes (std::vector<t_matgloss> & output);
bool ReadCreatureTypesEx (vector<t_creaturetype> & creatures);
bool ReadDescriptorColors(std::vector<t_descriptor_color> & output);
*/
private:
class Private;
Private* d;
};
} }
#endif #endif

@ -23,7 +23,7 @@ distribution.
*/ */
#include "dfhack-c/modules/Buildings_C.h" #include "dfhack-c/modules/Buildings_C.h"
using namespace std;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -70,33 +70,27 @@ int Buildings_GetCustomWorkshopType(DFHackObject* b_Ptr, t_building* building)
int Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr, void* (*t_customWorkshop_buffer_create)(uint32_t)) int Buildings_ReadCustomWorkshopTypes(DFHackObject* b_Ptr, void* (*t_customWorkshop_buffer_create)(uint32_t))
{ {
if(b_Ptr != NULL) if(b_Ptr != NULL)
{ {
int i; int i;
t_customWorkshop* cw_Ptr; t_customWorkshop* cw_Ptr;
map<uint32_t, string> bTypes; std::map<uint32_t, string> bTypes;
map<uint32_t, string>::iterator bIter; map<uint32_t, string>::iterator bIter;
bool result = ((DFHack::Buildings*)b_Ptr)->ReadCustomWorkshopTypes(bTypes); if(!((DFHack::Buildings*)b_Ptr)->ReadCustomWorkshopTypes(bTypes))
return 0;
if(!result)
return 0; cw_Ptr = (t_customWorkshop*)((*t_customWorkshop_buffer_create)(bTypes.size()));
for(i = 0, bIter = bTypes.begin(); bIter != bTypes.end(); bIter++, i++)
cw_Ptr = (t_customWorkshop*)((*t_customWorkshop_buffer_create)(bTypes.size())); {
cw_Ptr[i].index = (*bIter).first;
for(i = 0, bIter = bTypes.begin(); bIter != bTypes.end(); bIter++, i++) size_t length = (*bIter).second.copy(cw_Ptr[i].name, 256);
{ cw_Ptr[i].name[length] = '\0';
cw_Ptr[i].index = (*bIter).first; }
return 1;
size_t length = (*bIter).second.copy(cw_Ptr[i].name, 256); }
cw_Ptr[i].name[length] = '\0'; return -1;
}
return 1;
}
return -1;
} }
#ifdef __cplusplus #ifdef __cplusplus

@ -5,8 +5,10 @@
#include <sstream> #include <sstream>
#include <climits> #include <climits>
#include <vector> #include <vector>
using namespace std; #include <stdio.h>
//using namespace std;
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h> #include <DFHack.h>
int main (int argc,const char* argv[]) int main (int argc,const char* argv[])
@ -27,14 +29,14 @@ int main (int argc,const char* argv[])
} }
else if(argc == 3) else if(argc == 3)
{ {
string s = argv[2]; //blah. I don't care std::string s = argv[2]; //blah. I don't care
istringstream ins; // Declare an input string stream. std::istringstream ins; // Declare an input string stream.
ins.str(s); // Specify string to read. ins.str(s); // Specify string to read.
ins >> lines; // Reads the integers from the string. ins >> lines; // Reads the integers from the string.
mode = 1; mode = 1;
} }
map <uint32_t, string> custom_workshop_types; std::map <uint32_t, std::string> custom_workshop_types;
DFHack::ContextManager DFMgr ("Memory.xml"); DFHack::ContextManager DFMgr ("Memory.xml");
DFHack::Context *DF; DFHack::Context *DF;
@ -43,9 +45,9 @@ int main (int argc,const char* argv[])
DF = DFMgr.getSingleContext(); DF = DFMgr.getSingleContext();
DF->Attach(); DF->Attach();
} }
catch (exception& e) catch (std::exception& e)
{ {
cerr << e.what() << endl; std::cerr << e.what() << std::endl;
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cin.ignore(); cin.ignore();
#endif #endif
@ -62,17 +64,17 @@ int main (int argc,const char* argv[])
Bld->ReadCustomWorkshopTypes(custom_workshop_types); Bld->ReadCustomWorkshopTypes(custom_workshop_types);
if(mode) if(mode)
{ {
cout << numBuildings << endl; std::cout << numBuildings << std::endl;
vector < uint32_t > addresses; std::vector < uint32_t > addresses;
for(uint32_t i = 0; i < numBuildings; i++) for(uint32_t i = 0; i < numBuildings; i++)
{ {
DFHack::t_building temp; DFHack::t_building temp;
Bld->Read(i, temp); Bld->Read(i, temp);
if(temp.type != 0xFFFFFFFF) // check if type isn't invalid if(temp.type != 0xFFFFFFFF) // check if type isn't invalid
{ {
string typestr; std::string typestr;
mem->resolveClassIDToClassname(temp.type, typestr); mem->resolveClassIDToClassname(temp.type, typestr);
cout << typestr << endl; std::cout << typestr << std::endl;
if(typestr == argv[1]) if(typestr == argv[1])
{ {
//cout << buildingtypes[temp.type] << " 0x" << hex << temp.origin << endl; //cout << buildingtypes[temp.type] << " 0x" << hex << temp.origin << endl;
@ -83,7 +85,7 @@ int main (int argc,const char* argv[])
else else
{ {
// couldn't translate type, print out the vtable // couldn't translate type, print out the vtable
cout << "unknown vtable: " << temp.vtable << endl; std::cout << "unknown vtable: " << temp.vtable << std::endl;
} }
} }
interleave_hex(DF,addresses,lines / 4); interleave_hex(DF,addresses,lines / 4);
@ -105,7 +107,7 @@ int main (int argc,const char* argv[])
&& (uint32_t)z == temp.z && (uint32_t)z == temp.z
) )
{ {
string typestr; std::string typestr;
mem->resolveClassIDToClassname(temp.type, typestr); mem->resolveClassIDToClassname(temp.type, typestr);
printf("Address 0x%x, type %d (%s), %d/%d/%d\n",temp.origin, temp.type, typestr.c_str(), temp.x1,temp.y1,temp.z); printf("Address 0x%x, type %d (%s), %d/%d/%d\n",temp.origin, temp.type, typestr.c_str(), temp.x1,temp.y1,temp.z);
printf("Material %d %d\n", temp.material.type, temp.material.index); printf("Material %d %d\n", temp.material.type, temp.material.index);
@ -120,12 +122,12 @@ int main (int argc,const char* argv[])
} }
else else
{ {
cout << numBuildings << endl; std::cout << numBuildings << std::endl;
for(uint32_t i = 0; i < numBuildings; i++) for(uint32_t i = 0; i < numBuildings; i++)
{ {
DFHack::t_building temp; DFHack::t_building temp;
Bld->Read(i, temp); Bld->Read(i, temp);
string typestr; std::string typestr;
mem->resolveClassIDToClassname(temp.type, typestr); mem->resolveClassIDToClassname(temp.type, typestr);
printf("Address 0x%x, type %d (%s), %d/%d/%d\n",temp.origin, temp.type, typestr.c_str(), temp.x1,temp.y1,temp.z); printf("Address 0x%x, type %d (%s), %d/%d/%d\n",temp.origin, temp.type, typestr.c_str(), temp.x1,temp.y1,temp.z);
} }
@ -135,12 +137,12 @@ int main (int argc,const char* argv[])
} }
else else
{ {
cerr << "buildings not supported for this DF version" << endl; std::cerr << "buildings not supported for this DF version" << std::endl;
} }
DF->Detach(); DF->Detach();
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl; std::cout << "Done. Press any key to continue" << std::endl;
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;

@ -7,8 +7,9 @@
#include <sstream> #include <sstream>
#include <ctime> #include <ctime>
#include <cstdio> #include <cstdio>
using namespace std; #include <stdio.h>
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h> #include <DFHack.h>
using namespace DFHack; using namespace DFHack;
@ -21,9 +22,9 @@ int main (int numargs, const char ** args)
DF = DFMgr.getSingleContext(); DF = DFMgr.getSingleContext();
DF->Attach(); DF->Attach();
} }
catch (exception& e) catch (std::exception& e)
{ {
cerr << e.what() << endl; std::cerr << e.what() << std::endl;
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cin.ignore(); cin.ignore();
#endif #endif
@ -51,7 +52,7 @@ int main (int numargs, const char ** args)
printf("Construction %d/%d/%d @ 0x%x\n", con.x, con.y, con.z,con.origin); printf("Construction %d/%d/%d @ 0x%x\n", con.x, con.y, con.z,con.origin);
// inorganic stuff - we can recognize that // inorganic stuff - we can recognize that
printf("Material: form %d, type %d, index %d\n",con.form, con.mat_type, con.mat_idx); printf("Material: form %d, type %d, index %d\n",con.form, con.mat_type, con.mat_idx);
string matstr = "unknown"; std::string matstr = "unknown";
if(con.mat_type == 0) if(con.mat_type == 0)
{ {
if(con.mat_idx != 0xffffffff) if(con.mat_idx != 0xffffffff)

@ -4,8 +4,10 @@
#include <climits> #include <climits>
#include <string.h> #include <string.h>
#include <vector> #include <vector>
#include <stdio.h>
using namespace std; using namespace std;
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h> #include <DFHack.h>
enum likeType enum likeType

@ -11,6 +11,7 @@
using namespace std; using namespace std;
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/DFVector.h>
DFHack::Materials * Materials; DFHack::Materials * Materials;

@ -8,7 +8,7 @@
#include <ctime> #include <ctime>
#include <cstdio> #include <cstdio>
using namespace std; using namespace std;
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h> #include <DFHack.h>
using namespace DFHack; using namespace DFHack;

@ -9,6 +9,7 @@
#include <cstdio> #include <cstdio>
using namespace std; using namespace std;
#define DFHACK_WANT_MISCUTILS
#include <DFHack.h> #include <DFHack.h>
int main (int numargs, const char ** args) int main (int numargs, const char ** args)
@ -34,18 +35,17 @@ int main (int numargs, const char ** args)
#endif #endif
return 1; return 1;
} }
DFHack::Process* p = DF->getProcess(); DFHack::Process* p = DF->getProcess();
DFHack::memory_info* mem = DF->getMemoryInfo(); DFHack::memory_info* mem = DF->getMemoryInfo();
DFHack::Position * pos = DF->getPosition(); DFHack::Position * pos = DF->getPosition();
DFHack::Vegetation * v = DF->getVegetation(); DFHack::Vegetation * v = DF->getVegetation();
DFHack::Materials * mat = DF->getMaterials(); DFHack::Materials * mat = DF->getMaterials();
mat->ReadOrganicMaterials(); mat->ReadOrganicMaterials();
int32_t x,y,z; int32_t x,y,z;
pos->getCursorCoords(x,y,z); pos->getCursorCoords(x,y,z);
uint32_t numVegs = 0; uint32_t numVegs = 0;
v->Start(numVegs); v->Start(numVegs);
if(x == -30000) if(x == -30000)
@ -89,7 +89,7 @@ int main (int numargs, const char ** args)
} }
} }
v->Finish(); v->Finish();
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl; cout << "Done. Press any key to continue" << endl;
cin.ignore(); cin.ignore();

@ -15,8 +15,9 @@ using namespace std;
#include <locale.h> #include <locale.h>
#include <math.h> #include <math.h>
#define DFHACK_WANT_MISCUTILS
#define DFHACK_WANT_TILETYPES
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/DFTileTypes.h>
using namespace DFHack; using namespace DFHack;

@ -7,10 +7,10 @@
#include <sstream> #include <sstream>
#include <ctime> #include <ctime>
#include <cstdio> #include <cstdio>
using namespace std;
#define DFHACK_WANT_MISCUTILS
#define DFHACK_WANT_TILETYPES
#include <DFHack.h> #include <DFHack.h>
#include <dfhack/DFTileTypes.h>
using namespace DFHack; using namespace DFHack;
int main (int numargs, const char ** args) int main (int numargs, const char ** args)
@ -22,9 +22,9 @@ int main (int numargs, const char ** args)
{ {
DF->Attach(); DF->Attach();
} }
catch (exception& e) catch (std::exception& e)
{ {
cerr << e.what() << endl; std::cerr << e.what() << std::endl;
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cin.ignore(); cin.ignore();
#endif #endif
@ -68,59 +68,59 @@ int main (int numargs, const char ** args)
int16_t tiletype = block.tiletypes[tileX][tileY]; int16_t tiletype = block.tiletypes[tileX][tileY];
naked_designation &des = block.designation[tileX][tileY].bits; naked_designation &des = block.designation[tileX][tileY].bits;
uint32_t &desw = block.designation[tileX][tileY].whole; uint32_t &desw = block.designation[tileX][tileY].whole;
print_bits<uint32_t>(block.designation[tileX][tileY].whole,cout); print_bits<uint32_t>(block.designation[tileX][tileY].whole,std::cout);
cout << endl; std::cout << endl;
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,cout); print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,std::cout);
cout << endl; std::cout << endl;
// tiletype // tiletype
cout <<"tiletype: " << tiletype; std::cout <<"tiletype: " << tiletype;
if(tileTypeTable[tiletype].name) if(tileTypeTable[tiletype].name)
cout << " = " << tileTypeTable[tiletype].name; std::cout << " = " << tileTypeTable[tiletype].name;
cout << endl; std::cout << std::endl;
cout <<"temperature1: " << tmpb1[tileX][tileY] << " U" << endl; std::cout <<"temperature1: " << tmpb1[tileX][tileY] << " U" << std::endl;
cout <<"temperature2: " << tmpb2[tileX][tileY] << " U" << endl; std::cout <<"temperature2: " << tmpb2[tileX][tileY] << " U" << std::endl;
// biome, geolayer // biome, geolayer
cout << "biome: " << des.biome << endl; std::cout << "biome: " << des.biome << std::endl;
cout << "geolayer: " << des.geolayer_index << endl; std::cout << "geolayer: " << des.geolayer_index << std::endl;
// liquids // liquids
if(des.flow_size) if(des.flow_size)
{ {
if(des.liquid_type == DFHack::liquid_magma) if(des.liquid_type == DFHack::liquid_magma)
cout <<"magma: "; std::cout <<"magma: ";
else cout <<"water: "; else std::cout <<"water: ";
cout << des.flow_size << endl; std::cout << des.flow_size << std::endl;
} }
if(des.flow_forbid) if(des.flow_forbid)
cout << "flow forbid" << endl; std::cout << "flow forbid" << std::endl;
if(des.pile) if(des.pile)
cout << "stockpile?" << endl; std::cout << "stockpile?" << std::endl;
if(des.rained) if(des.rained)
cout << "rained?" << endl; std::cout << "rained?" << std::endl;
if(des.smooth) if(des.smooth)
cout << "smooth?" << endl; std::cout << "smooth?" << std::endl;
uint32_t designato = block.origin + designatus + (tileX * 16 + tileY) * sizeof(t_designation); uint32_t designato = block.origin + designatus + (tileX * 16 + tileY) * sizeof(t_designation);
printf("designation offset: 0x%x\n", designato); printf("designation offset: 0x%x\n", designato);
if(des.light) if(des.light)
cout << "Light "; std::cout << "Light ";
else else
cout << " "; std::cout << " ";
if(des.skyview) if(des.skyview)
cout << "SkyView "; std::cout << "SkyView ";
else else
cout << " "; std::cout << " ";
if(des.subterranean) if(des.subterranean)
cout << "Underground "; std::cout << "Underground ";
else else
cout << " "; std::cout << " ";
cout << endl; std::cout << std::endl;
} }
} }
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl; std::cout << "Done. Press any key to continue" << std::endl;
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;