using D pointer, a proper interface

develop
Petr Mrázek 2009-11-11 03:37:28 +00:00
parent 88771ab973
commit 4f279680b5
20 changed files with 557 additions and 706 deletions

@ -1,7 +1,7 @@
# don't use this file directly. use the one in the root folder of the project
SET(PROJECT_HDRS
DFCommon.h
DFCommonInternal.h
DFDataModel.h
DFHackAPI.h
DFMemAccess.h

@ -1,69 +0,0 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef DFCOMMON_H_INCLUDED
#define DFCOMMON_H_INCLUDED
///TODO: separate into extrenal and internal
#include <string>
#include <vector>
#include <map>
//#include <boost/bimap/bimap.hpp>
//using namespace boost::bimaps;
#include <fstream>
using namespace std;
#include "integers.h"
#include <assert.h>
#include <string.h>
#ifdef LINUX_BUILD
#include <sys/types.h>
#include <sys/ptrace.h>
#include <dirent.h>
#define __USE_FILE_OFFSET64
#define _FILE_OFFSET_BITS 64
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#else
#define WINVER 0x0500 // OpenThread(), PSAPI, Toolhelp32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winbase.h>
#include <winnt.h>
#include <psapi.h>
#endif
#include "DFTypes.h"
#include "DFDataModel.h"
#include "DFProcessManager.h"
#include "DFMemAccess.h"
#include "DFVector.h"
//#include "DfMap.h"
#endif // DFCOMMON_H_INCLUDED

@ -0,0 +1,108 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED
#include <string>
#include <vector>
#include <map>
#include <fstream>
using namespace std;
#include "integers.h"
#include <assert.h>
#include <string.h>
/*
#ifdef __KDE_HAVE_GCC_VISIBILITY
#define NO_EXPORT __attribute__ ((visibility("hidden")))
#define EXPORT __attribute__ ((visibility("default")))
#define IMPORT __attribute__ ((visibility("default")))
#elif defined(_WIN32) || defined(_WIN64)
#define NO_EXPORT
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#else
#define NO_EXPORT
#define EXPORT
#define IMPORT
#endif
*/
#ifdef LINUX_BUILD
#include <sys/types.h>
#include <sys/ptrace.h>
#include <dirent.h>
#define __USE_FILE_OFFSET64
#define _FILE_OFFSET_BITS 64
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
#else
#define WINVER 0x0500 // OpenThread(), PSAPI, Toolhelp32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winbase.h>
#include <winnt.h>
#include <psapi.h>
#endif
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFTypes.h"
#include "DFDataModel.h"
#include "DFProcessManager.h"
#include "DFMemAccess.h"
#include "DFVector.h"
#include "DFMemInfo.h"
#include <stdlib.h>
#include "tinyxml/tinyxml.h"
#include "md5/md5wrapper.h"
#include <iostream>
#include "DFHackAPI.h"
#define _QUOTEME(x) #x
#define QUOT(x) _QUOTEME(x)
#ifdef USE_CONFIG_H
#include "config.h"
#else
#define MEMXML_DATA_PATH .
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400
#define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str())
#else
#define fill_char_buf(buf, str) strncpy((buf), (str).c_str(), sizeof(buf) / sizeof((buf)[0]))
#endif
#endif // DFCOMMONINTERNAL_H_INCLUDED

@ -22,11 +22,7 @@ must not be misrepresented as being the original software.
distribution.
*/
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFCommon.h"
#include "DFCommonInternal.h"
DfVector DMWindows40d::readVector (uint32_t offset, uint32_t item_size)

File diff suppressed because it is too large Load Diff

@ -25,18 +25,20 @@ distribution.
#ifndef SIMPLEAPI_H_INCLUDED
#define SIMPLEAPI_H_INCLUDED
/// TODO: add visibility for GCC?
#ifdef LINUX_BUILD
# ifndef DFHACKAPI
# define DFHACKAPI
# ifndef DFHACK_EXPORT
# define DFHACK_EXPORT
# endif
#else
# ifdef BUILD_DFHACK_LIB
# ifndef DFHACKAPI
# define DFHACKAPI extern "C" __declspec(dllexport)
# ifndef DFHACK_EXPORT
# define DFHACK_EXPORT __declspec(dllexport)
# endif
# else
# ifndef DFHACKAPI
# define DFHACKAPI extern "C" __declspec(dllimport)
# ifndef DFHACK_EXPORT
# define DFHACK_EXPORT __declspec(dllimport)
# endif
# endif
#endif
@ -44,210 +46,34 @@ distribution.
#include <string>
#include <vector>
#include "integers.h"
using namespace std;
class DFHackAPI;
// Imported function for actually creating an instance
DFHACKAPI DFHackAPI *CreateDFHackAPI0(const char *path_to_xml);
// C++ wrapper for convenience
inline DFHackAPI *CreateDFHackAPI(const string &path_to_xml)
namespace DFHack
{
return CreateDFHackAPI0(path_to_xml.c_str());
}
// Technically the functions that use std::vector are unsafe.
class DFHackAPI
enum VegetationType
{
public:
virtual ~DFHackAPI() {}
virtual bool Attach() = 0;
virtual bool Detach() = 0;
virtual bool isAttached() = 0;
/**
* Matgloss. next four methods look very similar. I could use two and move the processing one level up...
* I'll keep it like this, even with the code duplication as it will hopefully get more features and separate data types later.
* Yay for nebulous plans for a rock survey tool that tracks how much of which metal could be smelted from available resorces
*/
virtual bool ReadStoneMatgloss(vector<t_matgloss> & output) = 0;
virtual bool ReadWoodMatgloss (vector<t_matgloss> & output) = 0;
virtual bool ReadMetalMatgloss(vector<t_matgloss> & output) = 0;
virtual bool ReadPlantMatgloss(vector<t_matgloss> & output) = 0;
virtual bool ReadCreatureMatgloss(vector<t_matgloss> & output) = 0;
// FIXME: add creatures for all the creature products
// read region surroundings, get their vectors of geolayers so we can do translation (or just hand the translation table to the client)
// returns an array of 9 vectors of indices into stone matgloss
/**
Method for reading the geological surrounding of the currently loaded region.
assign is a reference to an array of nine vectors of unsigned words that are to be filled with the data
array is indexed by the BiomeOffset enum
I omitted resolving the layer matgloss in this API, because it would
introduce overhead by calling some method for each tile. You have to do it
yourself. First get the stuff from ReadGeology and then for each block get
the RegionOffsets. For each tile get the real region from RegionOffsets and
cross-reference it with the geology stuff (region -- array of vectors, depth --
vector). I'm thinking about turning that Geology stuff into a
two-dimensional array with static size.
this is the algorithm for applying matgloss:
void DfMap::applyGeoMatgloss(Block * b)
{
// load layer matgloss
for(int x_b = 0; x_b < BLOCK_SIZE; x_b++)
{
for(int y_b = 0; y_b < BLOCK_SIZE; y_b++)
{
int geolayer = b->designation[x_b][y_b].bits.geolayer_index;
int biome = b->designation[x_b][y_b].bits.biome;
b->material[x_b][y_b].type = Mat_Stone;
b->material[x_b][y_b].index = v_geology[b->RegionOffsets[biome]][geolayer];
}
}
}
*/
virtual bool ReadGeology( vector < vector <uint16_t> >& assign ) = 0;
/*
* BLOCK DATA
*/
/// allocate and read pointers to map blocks
virtual bool InitMap() = 0;
/// destroy the mapblock cache
virtual bool DestroyMap() = 0;
/// get size of the map in tiles
virtual void getSize(uint32_t& x, uint32_t& y, uint32_t& z) = 0;
/**
* Return false/0 on failure, buffer allocated by client app, 256 items long
*/
virtual bool isValidBlock(uint32_t blockx, uint32_t blocky, uint32_t blockz) = 0;
virtual bool ReadTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer) = 0; // 256 * sizeof(uint16_t)
virtual bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer) = 0; // 256 * sizeof(uint16_t)
virtual bool ReadDesignations(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) = 0; // 256 * sizeof(uint32_t)
virtual bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) = 0;
virtual bool ReadOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) = 0; // 256 * sizeof(uint32_t)
virtual bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) = 0; // 256 * sizeof(uint32_t)
/// read region offsets of a block
virtual bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer) = 0; // 16 * sizeof(uint8_t)
/// read aggregated veins of a block
virtual bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, vector <t_vein> & veins) = 0;
/**
* Buildings, constructions, plants, all pretty straighforward. InitReadBuildings returns all the building types as a mapping between a numeric values and strings
*/
virtual uint32_t InitReadConstructions() = 0;
virtual bool ReadConstruction(const uint32_t &index, t_construction & construction) = 0;
virtual void FinishReadConstructions() = 0;
virtual uint32_t InitReadBuildings(vector <string> &v_buildingtypes) = 0;
virtual bool ReadBuilding(const uint32_t &index, t_building & building) = 0;
virtual void FinishReadBuildings() = 0;
virtual uint32_t InitReadVegetation() = 0;
virtual bool ReadVegetation(const uint32_t &index, t_tree_desc & shrubbery) = 0;
virtual void FinishReadVegetation() = 0;
virtual uint32_t InitReadCreatures() = 0;
virtual bool ReadCreature(const uint32_t &index, t_creature & furball) = 0;
virtual void FinishReadCreatures() = 0;
virtual void ReadRaw (const uint32_t &offset, const uint32_t &size, uint8_t *target) = 0;
TREE_DEAD,
TREE_OK,
SAPLING_DEAD,
SAPLING_OK,
SHRUB_DEAD,
SHRUB_OK
};
#ifdef BUILD_DFHACK_LIB
class memory_info;
class DfVector;
class ProcessManager;
class Process;
class DataModel;
DFHACK_EXPORT bool isWallTerrain(int in);
DFHACK_EXPORT bool isFloorTerrain(int in);
DFHACK_EXPORT bool isRampTerrain(int in);
DFHACK_EXPORT bool isStairTerrain(int in);
DFHACK_EXPORT bool isOpenTerrain(int in);
DFHACK_EXPORT int getVegetationType(int in);
//FIXME: better control over state, creation and destruction
//TODO: give this the pimpl treatment?
class DFHackAPIImpl : public DFHackAPI
class DFHACK_EXPORT API
{
private:
// internals
uint32_t * block;
uint32_t x_block_count, y_block_count, z_block_count;
uint32_t regionX, regionY, regionZ;
uint32_t worldSizeX, worldSizeY;
uint32_t tile_type_offset;
uint32_t designation_offset;
uint32_t occupancy_offset;
uint32_t creature_pos_offset;
uint32_t creature_type_offset;
uint32_t creature_flags1_offset;
uint32_t creature_flags2_offset;
uint32_t creature_first_name_offset;
uint32_t creature_nick_name_offset;
uint32_t creature_last_name_offset;
uint32_t creature_custom_profession_offset;
uint32_t creature_profession_offset;
uint32_t creature_sex_offset;
uint32_t creature_id_offset;
uint32_t creature_squad_name_offset;
uint32_t creature_squad_leader_id_offset;
uint32_t creature_money_offset;
uint32_t creature_current_job_offset;
uint32_t creature_current_job_id_offset;
uint32_t creature_strength_offset;
uint32_t creature_agility_offset;
uint32_t creature_toughness_offset;
uint32_t creature_skills_offset;
uint32_t creature_labors_offset;
uint32_t creature_happiness_offset;
uint32_t creature_traits_offset;
uint32_t dwarf_lang_table_offset;
ProcessManager* pm;
Process* p;
DataModel* dm;
memory_info* offset_descriptor;
vector<uint16_t> v_geology[eBiomeCount];
string xml;
bool constructionsInited;
bool buildingsInited;
bool vegetationInited;
bool creaturesInited;
bool nameTablesInited;
uint32_t tree_offset;
DfVector *p_cre;
DfVector *p_cons;
DfVector *p_bld;
DfVector *p_veg;
DfVector *p_trans;
DfVector *p_generic;
DfVector *p_dwarf_names;
string getLastNameByAddress(const uint32_t &address, bool use_generic=false);
string getSquadNameByAddress(const uint32_t &address, bool use_generic=false);
string getProfessionByAddress(const uint32_t &address);
string getCurrentJobByAddress(const uint32_t &address);
void getSkillsByAddress(const uint32_t &address, vector<t_skill> &);
void getTraitsByAddress(const uint32_t &address, vector<t_trait> &);
void getLaborsByAddress(const uint32_t &address, vector<t_labor> &);
class Private;
Private * const d;
public:
DFHackAPIImpl(const string path_to_xml);
API(const string path_to_xml);
~API();
bool Attach();
bool Detach();
bool isAttached();
@ -344,20 +170,7 @@ public:
bool ReadCreature(const uint32_t &index, t_creature & furball);
void FinishReadCreatures();
void InitReadNameTables();
void FinishReadNameTables();
void ReadRaw (const uint32_t &offset, const uint32_t &size, uint8_t *target);
string getLastName(const uint32_t &index, bool);
string getSquadName(const uint32_t &index, bool);
string getProfession(const uint32_t &index);
string getCurrentJob(const uint32_t &index);
vector<t_skill> getSkills(const uint32_t &index);
vector<t_trait> getTraits(const uint32_t &index);
vector<t_labor> getLabors(const uint32_t &index);
};
#endif
}
#endif // SIMPLEAPI_H_INCLUDED

@ -22,13 +22,7 @@ must not be misrepresented as being the original software.
distribution.
*/
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFCommon.h"
#include "DFMemInfo.h"
#include <stdlib.h>
#include "DFCommonInternal.h"
memory_info::memory_info()
{

@ -22,14 +22,7 @@ must not be misrepresented as being the original software.
distribution.
*/
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFCommon.h"
#ifdef LINUX_BUILD
#include <sys/wait.h>
#endif
#include "DFCommonInternal.h"
Process::Process(DataModel * dm, memory_info* mi, ProcessHandle ph, uint32_t pid)

@ -22,17 +22,7 @@ must not be misrepresented as being the original software.
distribution.
*/
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFCommon.h"
#include "DFDataModel.h"
#include "DFMemInfo.h"
#include "tinyxml/tinyxml.h"
#include <iostream>
#include "DFCommonInternal.h"
/// HACK: global variables (only one process can be attached at the same time.)
Process * g_pProcess; ///< current process. non-NULL when picked
@ -45,8 +35,6 @@ int g_ProcessMemFile; ///< opened /proc/PID/mem, valid when attached
* LINUX version of the process finder.
*/
#include "md5/md5wrapper.h"
Process* ProcessManager::addProcess(const string & exe,ProcessHandle PH, const string & memFile)
{
md5wrapper md5;

@ -21,13 +21,10 @@ must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFTileTypes.h"
#include "DFCommonInternal.h"
DFHACKAPI bool isWallTerrain(int in)
bool DFHack::isWallTerrain(int in)
{
switch (in)
{
@ -185,7 +182,7 @@ DFHACKAPI bool isWallTerrain(int in)
return false;
}
DFHACKAPI bool isFloorTerrain(int in)
bool DFHack::isFloorTerrain(int in)
{
switch (in)
{
@ -344,7 +341,7 @@ DFHACKAPI bool isFloorTerrain(int in)
return false;
}
DFHACKAPI bool isRampTerrain(int in)
bool DFHack::isRampTerrain(int in)
{
switch (in)
{
@ -366,7 +363,7 @@ DFHACKAPI bool isRampTerrain(int in)
return false;
}
DFHACKAPI bool isStairTerrain(int in)
bool DFHack::isStairTerrain(int in)
{
switch (in)
{
@ -413,7 +410,7 @@ DFHACKAPI bool isStairTerrain(int in)
return false;
}
DFHACKAPI bool isOpenTerrain(int in)
bool DFHack::isOpenTerrain(int in)
{
switch (in)
{
@ -1051,22 +1048,22 @@ int picktexture(int in)
return 6;
}*/
DFHACKAPI int getVegetationType(int in)
int DFHack::getVegetationType(int in)
{
switch(in)
{
case 391: //dead tree
return TREE_DEAD;
return DFHack::TREE_DEAD;
case 392: //dead sapling
return SAPLING_DEAD;
return DFHack::SAPLING_DEAD;
case 393: //dead shrub
return SHRUB_DEAD;
return DFHack::SHRUB_DEAD;
case 24: //tree
return TREE_OK;
return DFHack::TREE_OK;
case 231: //sapling
return SAPLING_OK;
return DFHack::SAPLING_OK;
case 34: //shrub
return SHRUB_OK;
return DFHack::SHRUB_OK;
}
// ????
return -1;

@ -25,37 +25,4 @@ distribution.
#ifndef TILETYPES_H_INCLUDED
#define TILETYPES_H_INCLUDED
#ifdef LINUX_BUILD
# ifndef DFHACKAPI
# define DFHACKAPI
# endif
#else
# ifdef BUILD_DFHACK_LIB
# ifndef DFHACKAPI
# define DFHACKAPI extern "C" __declspec(dllexport)
# endif
# else
# ifndef DFHACKAPI
# define DFHACKAPI extern "C" __declspec(dllimport)
# endif
# endif
#endif
enum VegetationType{
TREE_DEAD,
TREE_OK,
SAPLING_DEAD,
SAPLING_OK,
SHRUB_DEAD,
SHRUB_OK
};
DFHACKAPI bool isWallTerrain(int in);
DFHACKAPI bool isFloorTerrain(int in);
DFHACKAPI bool isRampTerrain(int in);
DFHACKAPI bool isStairTerrain(int in);
DFHACKAPI bool isOpenTerrain(int in);
DFHACKAPI int getVegetationType(int in);
DFHACKAPI int picktexture(int in);
#endif // TILETYPES_H_INCLUDED

@ -15,10 +15,7 @@ int main (void)
{
time_t start, end;
double time_diff;
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -69,7 +66,5 @@ int main (void)
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
delete pDF;
return 0;
}

@ -24,7 +24,7 @@ default 256
address = absolute address of dump start
length = length in lines. 1 line = 16 bytes
*/
void hexdump (DFHackAPI& DF, uint32_t address, uint32_t length)
void hexdump (DFHack::API& DF, uint32_t address, uint32_t length)
{
char *buf = new char[length * 16];
@ -50,7 +50,7 @@ void hexdump (DFHackAPI& DF, uint32_t address, uint32_t length)
delete buf;
}
void interleave_hex (DFHackAPI& DF, vector < uint32_t > & addresses, uint32_t length)
void interleave_hex (DFHack::API& DF, vector < uint32_t > & addresses, uint32_t length)
{
vector <char * > bufs;
@ -129,8 +129,7 @@ int main (int argc,const char* argv[])
vector<t_matgloss> creaturestypes;
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -154,7 +153,6 @@ int main (int argc,const char* argv[])
interleave_hex(DF,addresses,lines / 4);
DF.FinishReadBuildings();
DF.Detach();
delete pDF;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -15,8 +15,7 @@ int main (void)
uint32_t bytes_read = 0;
t_occupancy occupancies[256];
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -48,7 +47,6 @@ int main (void)
}
}
DF.Detach();
delete pDF;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -25,8 +25,7 @@ int main (void)
{
vector<t_matgloss> creaturestypes;
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -173,7 +172,6 @@ int main (void)
}
DF.FinishReadCreatures();
DF.Detach();
delete pDF;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -21,8 +21,7 @@ int main (void)
t_designation designations[16][16];
t_occupancy occupancies[16][16];
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -67,6 +66,5 @@ int main (void)
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
delete pDF;
return 0;
}

@ -13,8 +13,7 @@ using namespace std;
int main (void)
{
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -38,7 +37,6 @@ int main (void)
cout << "Creature: " << CreatureTypes[0].id << endl;
DF.Detach();
delete pDF;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -55,8 +55,7 @@ int main (int argc, const char* argv[])
vector< vector <uint16_t> > layerassign;
// init the API
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF("Memory.xml");
// attach
if(!DF.Attach())
@ -146,7 +145,7 @@ int main (int argc, const char* argv[])
{
// hidden tiles are ignored unless '-a' is provided on the command line
// non-wall tiles are ignored
if(designations[xi][yi].bits.hidden && !showhidden || !isWallTerrain(tiletypes[xi][yi]))
if(designations[xi][yi].bits.hidden && !showhidden || !DFHack::isWallTerrain(tiletypes[xi][yi]))
continue;
if(tempvein[xi][yi] < 0)
continue;
@ -175,6 +174,5 @@ int main (int argc, const char* argv[])
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
delete pDF;
return 0;
}

@ -15,8 +15,7 @@ int main (void)
uint32_t bytes_read = 0;
t_designation designations[256];
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
@ -48,7 +47,6 @@ int main (void)
}
}
DF.Detach();
delete pDF;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();