More moving of things

develop
Petr Mrázek 2010-04-02 17:27:35 +02:00
parent 66eb8c3e23
commit bcbc540283
49 changed files with 5813 additions and 3229 deletions

@ -26,11 +26,13 @@ SET( LIBRARY_OUTPUT_PATH ${dfhack_SOURCE_DIR}/output CACHE PATH "Output director
SET( EXECUTABLE_OUTPUT_PATH ${dfhack_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack tools" ) SET( EXECUTABLE_OUTPUT_PATH ${dfhack_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack tools" )
SET( CMAKE_SWIG_OUTDIR ${dfhack_SOURCE_DIR}/output CACHE PATH "Global output directory for swig generated language wrappers" ) SET( CMAKE_SWIG_OUTDIR ${dfhack_SOURCE_DIR}/output CACHE PATH "Global output directory for swig generated language wrappers" )
include_directories (${CMAKE_SOURCE_DIR}/dfhack/) include_directories (${CMAKE_SOURCE_DIR}/dfhack/include/)
include_directories (${CMAKE_SOURCE_DIR}/shmserver/) include_directories (${CMAKE_SOURCE_DIR}/dfhack/shm/)
include_directories (${CMAKE_SOURCE_DIR}/depends/) include_directories (${CMAKE_SOURCE_DIR}/dfhack/md5/)
include_directories (${CMAKE_SOURCE_DIR}/dfhack/tinyxml/)
include_directories (${CMAKE_SOURCE_DIR}/dfhack/argstream/)
add_subdirectory (dfhack) add_subdirectory (dfhack)
add_subdirectory (dfhack/shm)
add_subdirectory (tools) add_subdirectory (tools)
add_subdirectory (examples) add_subdirectory (examples)
add_subdirectory (shmserver)

File diff suppressed because it is too large Load Diff

@ -1,6 +0,0 @@
#!/bin/bash
exec 3< cpfile
while read <&3
do echo $REPLY | cpio -pvdm cleansed
done
exec 3>&-

@ -1,18 +1,18 @@
# don't use this file directly. use the one in the root folder of the project # don't use this file directly. use the one in the root folder of the project
SET(PROJECT_HDRS SET(PROJECT_HDRS
DFCommonInternal.h include/DFCommonInternal.h
DFError.h include/DFError.h
DFHackAPI.h include/DFHackAPI.h
DFMemInfo.h include/DFMemInfo.h
DFMemInfoManager.h include/DFMemInfoManager.h
DFProcessEnumerator.h include/DFProcessEnumerator.h
DFProcess.h include/DFProcess.h
DFTileTypes.h include/DFTileTypes.h
DFTypes.h include/DFTypes.h
DFVector.h include/DFVector.h
DFWindow.h include/DFWindow.h
integers.h include/integers.h
md5/md5.h md5/md5.h
md5/md5wrapper.h md5/md5wrapper.h
@ -22,7 +22,7 @@ tinyxml/tinyxml.h
argstream/argstream.h argstream/argstream.h
../shmserver/shms.h shm/shms.h
) )
SET(PROJECT_SRCS SET(PROJECT_SRCS
@ -79,7 +79,7 @@ SET( MEMXML_DATA_PATH . CACHE PATH "search path for Memory.xml")
#OPTION( WITH_BAR "Enable BAR component" OFF ) #OPTION( WITH_BAR "Enable BAR component" OFF )
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/dfhack/config.h.cmake ${CMAKE_SOURCE_DIR}/dfhack/config.h ) CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/dfhack/config.h.cmake ${CMAKE_SOURCE_DIR}/dfhack/include/config.h )

@ -27,8 +27,8 @@ distribution.
#include <sys/types.h> #include <sys/types.h>
#include <sys/ipc.h> #include <sys/ipc.h>
#include <time.h> #include <time.h>
#include "../shmserver/shms.h" #include <shms.h>
#include "../shmserver/mod-core.h" #include <mod-core.h>
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <sched.h> #include <sched.h>

@ -27,7 +27,7 @@ distribution.
#include <sys/types.h> #include <sys/types.h>
#include <sys/ipc.h> #include <sys/ipc.h>
#include <time.h> #include <time.h>
#include "../shmserver/shms.h" #include "shms.h"
using namespace DFHack; using namespace DFHack;

@ -88,8 +88,8 @@ namespace DFHack
#include "DFError.h" #include "DFError.h"
#include <stdlib.h> #include <stdlib.h>
#include "tinyxml/tinyxml.h" #include <tinyxml.h>
#include "md5/md5wrapper.h" #include <md5wrapper.h>
#include <iostream> #include <iostream>
#include "DFHackAPI.h" #include "DFHackAPI.h"

@ -0,0 +1,6 @@
#ifndef CONFIG_H
#define CONFIG_H
#define MEMXML_DATA_PATH .
#endif // CONFIG_H

@ -45,7 +45,7 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//STL includes //STL includes
#include <string> #include <string>
#include "../integers.h" #include <integers.h>
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//typedefs //typedefs
typedef unsigned char *POINTER; typedef unsigned char *POINTER;

@ -47,6 +47,7 @@ typedef struct
uint32_t veinvector;// = d->offset_descriptor->getOffset ("v_vein"); uint32_t veinvector;// = d->offset_descriptor->getOffset ("v_vein");
uint32_t vein_mineral_vptr; uint32_t vein_mineral_vptr;
uint32_t vein_ice_vptr; uint32_t vein_ice_vptr;
uint32_t vein_spatter_vptr;
/* /*
GEOLOGY GEOLOGY
uint32_t region_x_offset;// = minfo->getAddress ("region_x"); uint32_t region_x_offset;// = minfo->getAddress ("region_x");

@ -1,361 +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 BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
#include "DFCommon.h"
#include "DFHackAPI.h"
#include "DFHackAPIc.h"
#ifdef LINUX_BUILD
# ifndef secure_strcpy
# define secure_strcpy(dst, size, buf) strcpy((dst), (buf))
# endif
#else
# if defined(_MSC_VER) && _MSC_VER >= 1400
# ifndef secure_strcpy
# define secure_strcpy(dst, size, buf) strcpy_s((dst), (size), (buf))
# endif
# else
# ifndef secure_strcpy
# define secure_strcpy(dst, size, buf) strcpy((dst), (buf))
# endif
# endif
#endif
#ifdef __cplusplus
extern "C"
{
#endif
// The C interface for vector management
DFHACKAPI void DFHackAPIVector_free (DFHackAPIVectorC *vector)
{
uint32_t i;
switch (vector->type)
{
case DFHackAPIVectorTypeC_Normal:
delete [] (vector->data);
break;
case DFHackAPIVectorTypeC_Matgloss:
delete [] ( (t_matgloss *) vector->data);
break;
case DFHackAPIVectorTypeC_Uint16:
delete [] ( (uint16_t *) vector->data);
break;
case DFHackAPIVectorTypeC_Vein:
delete [] ( (t_vein *) vector->data);
break;
case DFHackAPIVectorTypeC_String:
for (i = 0; i < vector->length; i++)
delete [] ( (char **) vector->data) [i];
delete [] ( (char **) vector->data);
break;
case DFHackAPIVectorTypeC_Recursive:
for (i = 0; i < vector->length; i++)
DFHackAPIVector_free (& ( (DFHackAPIVectorC *) vector->data) [i]);
delete [] ( (DFHackAPIVectorC *) vector->data);
break;
}
vector->type = DFHackAPIVectorTypeC_Normal;
vector->length = 0;
vector->data = 0;
}
// The C interface to DFHackAPI (for multiple language support)
DFHACKAPI DFHackAPIHandle CreateDFHackAPI (const char *path_to_xml)
{
return new DFHackAPIImpl (path_to_xml);
}
DFHACKAPI void DestroyDFHackAPI (DFHackAPIHandle self)
{
if (self != NULL)
delete self;
}
DFHACKAPI bool DFHackAPI_Attach (DFHackAPIHandle self)
{
return self->Attach();
}
DFHACKAPI bool DFHackAPI_Detach (DFHackAPIHandle self)
{
return self->Detach();
}
DFHACKAPI bool DFHackAPI_isAttached (DFHackAPIHandle self)
{
return self->isAttached();
}
DFHACKAPI bool DFHackAPI_ReadStoneMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output)
{
vector<t_matgloss> result;
uint32_t i;
bool retn = self->ReadStoneMatgloss (result);
output->type = DFHackAPIVectorTypeC_Matgloss;
output->length = result.size();
output->data = new t_matgloss[output->length];
for (i = 0; i < output->length; i++)
( (t_matgloss *) output->data) [i] = result[i];
return retn;
}
DFHACKAPI bool DFHackAPI_ReadWoodMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output)
{
vector<t_matgloss> result;
uint32_t i;
bool retn = self->ReadWoodMatgloss (result);
output->type = DFHackAPIVectorTypeC_Matgloss;
output->length = result.size();
output->data = new t_matgloss[output->length];
for (i = 0; i < output->length; i++)
( (t_matgloss *) output->data) [i] = result[i];
return retn;
}
DFHACKAPI bool DFHackAPI_ReadMetalMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output)
{
vector<t_matgloss> result;
uint32_t i;
bool retn = self->ReadMetalMatgloss (result);
output->type = DFHackAPIVectorTypeC_Matgloss;
output->length = result.size();
output->data = new t_matgloss[output->length];
for (i = 0; i < output->length; i++)
( (t_matgloss *) output->data) [i] = result[i];
return retn;
}
DFHACKAPI bool DFHackAPI_ReadPlantMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output)
{
vector<t_matgloss> result;
uint32_t i;
bool retn = self->ReadPlantMatgloss (result);
output->type = DFHackAPIVectorTypeC_Matgloss;
output->length = result.size();
output->data = new t_matgloss[output->length];
for (i = 0; i < output->length; i++)
( (t_matgloss *) output->data) [i] = result[i];
return retn;
}
DFHACKAPI bool DFHackAPI_ReadCreatureMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output)
{
vector<t_matgloss> result;
uint32_t i;
bool retn = self->ReadCreatureMatgloss (result);
output->type = DFHackAPIVectorTypeC_Matgloss;
output->length = result.size();
output->data = new t_matgloss[output->length];
for (i = 0; i < output->length; i++)
( (t_matgloss *) output->data) [i] = result[i];
return retn;
}
DFHACKAPI bool DFHackAPI_ReadGeology (DFHackAPIHandle self, DFHackAPIVectorC *assign)
{
vector< vector<uint16_t> > result;
uint32_t i, j;
bool retn = self->ReadGeology (result);
assign->type = DFHackAPIVectorTypeC_Recursive;
assign->length = result.size();
assign->data = new DFHackAPIVectorC[assign->length];
for (i = 0; i < assign->length; i++)
{
DFHackAPIVectorC &current = ( (DFHackAPIVectorC *) assign->data) [i];
current.type = DFHackAPIVectorTypeC_Uint16;
current.length = result[i].size();
current.data = new uint16_t[current.length];
for (j = 0; j < current.length; j++)
( (uint16_t *) current.data) [j] = result[i][j];
}
return retn;
}
DFHACKAPI bool DFHackAPI_InitMap (DFHackAPIHandle self)
{
return self->InitMap();
}
DFHACKAPI bool DFHackAPI_DestroyMap (DFHackAPIHandle self)
{
return self->DestroyMap();
}
DFHACKAPI void DFHackAPI_getSize (DFHackAPIHandle self, uint32_t* x, uint32_t* y, uint32_t* z)
{
return self->getSize (*x, *y, *z);
}
DFHACKAPI bool DFHackAPI_isValidBlock (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz)
{
return self->isValidBlock (blockx, blocky, blockz);
}
DFHACKAPI bool DFHackAPI_ReadTileTypes (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer)
{
return self->ReadTileTypes (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_WriteTileTypes (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer)
{
return self->WriteTileTypes (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_ReadDesignations (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer)
{
return self->ReadDesignations (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_WriteDesignations (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer)
{
return self->WriteDesignations (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_ReadOccupancy (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer)
{
return self->ReadOccupancy (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_WriteOccupancy (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer)
{
return self->WriteOccupancy (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_ReadRegionOffsets (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer)
{
return self->ReadRegionOffsets (blockx, blocky, blockz, buffer);
}
DFHACKAPI bool DFHackAPI_ReadVeins (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, DFHackAPIVectorC * veins)
{
vector<t_vein> result;
uint32_t i;
bool retn = self->ReadVeins (blockx, blocky, blockz, result);
veins->type = DFHackAPIVectorTypeC_Vein;
veins->length = result.size();
veins->data = new t_vein[veins->length];
for (i = 0; i < veins->length; i++)
( (t_vein *) veins->data) [i] = result[i];
return retn;
}
DFHACKAPI uint32_t DFHackAPI_InitReadConstructions (DFHackAPIHandle self)
{
return self->InitReadConstructions();
}
DFHACKAPI bool DFHackAPI_ReadConstruction (DFHackAPIHandle self, const uint32_t *index, t_construction * construction)
{
return self->ReadConstruction (*index, *construction);
}
DFHACKAPI void DFHackAPI_FinishReadConstructions (DFHackAPIHandle self)
{
self->FinishReadConstructions();
}
DFHACKAPI uint32_t DFHackAPI_InitReadBuildings (DFHackAPIHandle self, DFHackAPIVectorC *v_buildingtypes)
{
vector<string> result;
uint32_t i;
uint32_t retn = self->InitReadBuildings (result);
v_buildingtypes->type = DFHackAPIVectorTypeC_String;
v_buildingtypes->length = result.size();
v_buildingtypes->data = new char *[v_buildingtypes->length];
for (i = 0; i < v_buildingtypes->length; i++)
{
char *str = new char[result[i].size() + 1];
secure_strcpy (str, result[i].size() + 1, result[i].c_str());
( (char **) v_buildingtypes->data) [i] = str;
}
return retn;
}
DFHACKAPI bool DFHackAPI_ReadBuilding (DFHackAPIHandle self, const uint32_t *index, t_building * building)
{
return self->ReadBuilding (*index, *building);
}
DFHACKAPI void DFHackAPI_FinishReadBuildings (DFHackAPIHandle self)
{
self->FinishReadBuildings();
}
DFHACKAPI uint32_t DFHackAPI_InitReadVegetation (DFHackAPIHandle self)
{
return self->InitReadVegetation();
}
DFHACKAPI bool DFHackAPI_ReadVegetation (DFHackAPIHandle self, const uint32_t *index, t_tree_desc * shrubbery)
{
return self->ReadVegetation (*index, *shrubbery);
}
DFHACKAPI void DFHackAPI_FinishReadVegetation (DFHackAPIHandle self)
{
self->FinishReadVegetation();
}
DFHACKAPI uint32_t DFHackAPI_InitReadCreatures (DFHackAPIHandle self)
{
return self->InitReadCreatures();
}
DFHACKAPI bool DFHackAPI_ReadCreature (DFHackAPIHandle self, const uint32_t *index, t_creature * furball)
{
return self->ReadCreature (*index, *furball);
}
DFHACKAPI void DFHackAPI_FinishReadCreatures (DFHackAPIHandle self)
{
self->FinishReadCreatures();
}
DFHACKAPI void DFHackAPI_ReadRaw (DFHackAPIHandle self, const uint32_t &offset, const uint32_t &size, uint8_t *target)
{
self->ReadRaw(offset, size, target);
}
#ifdef __cplusplus
}
#endif

@ -1,483 +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 SIMPLEAPIC_H_INCLUDED
#define SIMPLEAPIC_H_INCLUDED
#ifdef LINUX_BUILD
# ifndef DFHACKAPI
# define DFHACKAPI extern "C"
# 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
#include "integers.h"
#ifdef __cplusplus
# include <vector>
# include <string>
using namespace std;
#endif
typedef enum DFHackAPIVectorTypeC
{
DFHackAPIVectorTypeC_Normal, // array of struct's
DFHackAPIVectorTypeC_Matgloss, // array of t_matgloss's
DFHackAPIVectorTypeC_Uint16, // array of uint16_t's
DFHackAPIVectorTypeC_Vein, // array of t_vein's
DFHackAPIVectorTypeC_String, // array of const char *'s
DFHackAPIVectorTypeC_Recursive, // array of DFHackAPIVectorC struct's
DFHackAPIVectorTypeC_DWord = 0xffffffff // Unused
} DFHackAPIVectorTypeC;
typedef struct DFHackAPIVectorC
{
void *data;
uint32_t length;
DFHackAPIVectorTypeC type;
} DFHackAPIVector;
#ifdef __cplusplus
typedef class DFHackAPIImpl *DFHackAPIHandle;
#else
typedef struct DFHackAPIImpl *DFHackAPIHandle;
typedef char bool;
#endif
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
// The C interface for vector management
DFHACKAPI void DFHackAPIVector_free (DFHackAPIVectorC *vector);
// The C interface to DFHackAPI (for multiple language support)
DFHACKAPI DFHackAPIHandle CreateDFHackAPI (const char *path_to_xml);
DFHACKAPI void DestroyDFHackAPI (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_Attach (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_Detach (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_isAttached (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_ReadStoneMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output);
DFHACKAPI bool DFHackAPI_ReadWoodMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output);
DFHACKAPI bool DFHackAPI_ReadMetalMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output);
DFHACKAPI bool DFHackAPI_ReadPlantMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output);
DFHACKAPI bool DFHackAPI_ReadCreatureMatgloss (DFHackAPIHandle self, DFHackAPIVectorC *output);
DFHACKAPI bool DFHackAPI_ReadGeology (DFHackAPIHandle self, DFHackAPIVectorC *assign);
DFHACKAPI bool DFHackAPI_InitMap (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_DestroyMap (DFHackAPIHandle self);
DFHACKAPI void DFHackAPI_getSize (DFHackAPIHandle self, uint32_t* x, uint32_t* y, uint32_t* z);
DFHACKAPI bool DFHackAPI_isValidBlock (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz);
DFHACKAPI bool DFHackAPI_ReadTileTypes (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer);
DFHACKAPI bool DFHackAPI_WriteTileTypes (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer);
DFHACKAPI bool DFHackAPI_ReadDesignations (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer);
DFHACKAPI bool DFHackAPI_WriteDesignations (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer);
DFHACKAPI bool DFHackAPI_ReadOccupancy (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer);
DFHACKAPI bool DFHackAPI_WriteOccupancy (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer);
DFHACKAPI bool DFHackAPI_ReadRegionOffsets (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer);
DFHACKAPI bool DFHackAPI_ReadVeins (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, DFHackAPIVectorC * veins);
DFHACKAPI uint32_t DFHackAPI_InitReadConstructions (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_ReadConstruction (DFHackAPIHandle self, const uint32_t *index, t_construction * construction);
DFHACKAPI void DFHackAPI_FinishReadConstructions (DFHackAPIHandle self);
DFHACKAPI uint32_t DFHackAPI_InitReadBuildings (DFHackAPIHandle self, DFHackAPIVectorC *v_buildingtypes);
DFHACKAPI bool DFHackAPI_ReadBuilding (DFHackAPIHandle self, const uint32_t *index, t_building * building);
DFHACKAPI void DFHackAPI_FinishReadBuildings (DFHackAPIHandle self);
DFHACKAPI uint32_t DFHackAPI_InitReadVegetation (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_ReadVegetation (DFHackAPIHandle self, const uint32_t *index, t_tree_desc * shrubbery);
DFHACKAPI void DFHackAPI_FinishReadVegetation (DFHackAPIHandle self);
DFHACKAPI uint32_t DFHackAPI_InitReadCreatures (DFHackAPIHandle self);
DFHACKAPI bool DFHackAPI_ReadCreature (DFHackAPIHandle self, const uint32_t *index, t_creature * furball);
DFHACKAPI void DFHackAPI_FinishReadCreatures (DFHackAPIHandle self);
DFHACKAPI void DFHackAPI_ReadRaw (DFHackAPIHandle self, const uint32_t &offset, const uint32_t &size, uint8_t *target);
#ifdef __cplusplus
}
#endif // __cplusplus
// C++ wrappers for C API that use vectors
#ifdef __cplusplus
inline bool DFHackAPI_ReadStoneMatgloss (DFHackAPIHandle self, vector<t_matgloss> & output)
{
DFHackAPIVectorC vector;
bool result = DFHackAPI_ReadStoneMatgloss (self, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
output.push_back ( ( (t_matgloss *) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
inline bool DFHackAPI_ReadWoodMatgloss (DFHackAPIHandle self, vector<t_matgloss> & output)
{
DFHackAPIVectorC vector;
bool result = DFHackAPI_ReadWoodMatgloss (self, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
output.push_back ( ( (t_matgloss *) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
inline bool DFHackAPI_ReadMetalMatgloss (DFHackAPIHandle self, vector<t_matgloss> & output)
{
DFHackAPIVectorC vector;
bool result = DFHackAPI_ReadMetalMatgloss (self, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
output.push_back ( ( (t_matgloss *) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
inline bool DFHackAPI_ReadPlantMatgloss (DFHackAPIHandle self, vector<t_matgloss> & output)
{
DFHackAPIVectorC vector;
bool result = DFHackAPI_ReadPlantMatgloss (self, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
output.push_back ( ( (t_matgloss *) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
inline bool DFHackAPI_ReadCreatureMatgloss (DFHackAPIHandle self, vector<t_matgloss> & output)
{
DFHackAPIVectorC vector;
bool result = DFHackAPI_ReadCreatureMatgloss (self, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
output.push_back ( ( (t_matgloss *) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
inline bool DFHackAPI_ReadGeology (DFHackAPIHandle self, vector< vector<uint16_t> > &assign)
{
DFHackAPIVectorC vec;
bool result = DFHackAPI_ReadGeology (self, &vec);
uint32_t i;
for (i = 0; i < vec.length; i++)
{
DFHackAPIVectorC &current = ( (DFHackAPIVectorC *) vec.data) [i];
vector<uint16_t> fill;
uint32_t j;
for (j = 0; j < current.length; j++)
fill.push_back ( ( (uint16_t *) current.data) [j]);
assign.push_back (fill);
}
DFHackAPIVector_free (&vec);
return result;
}
inline bool DFHackAPI_ReadVeins (DFHackAPIHandle self, uint32_t blockx, uint32_t blocky, uint32_t blockz, vector <t_vein> & veins)
{
DFHackAPIVectorC vector;
bool result = DFHackAPI_ReadVeins (self, blockx, blocky, blockz, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
veins.push_back ( ( (t_vein *) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
inline uint32_t DFHackAPI_InitReadBuildings (DFHackAPIHandle self, vector <string> &v_buildingtypes)
{
DFHackAPIVectorC vector;
uint32_t result = DFHackAPI_InitReadBuildings (self, &vector);
uint32_t i;
for (i = 0; i < vector.length; i++)
v_buildingtypes.push_back ( ( (const char **) vector.data) [i]);
DFHackAPIVector_free (&vector);
return result;
}
#endif // __cplusplus
// C++ class wrapper for C DFHackAPI
#ifdef __cplusplus
class CDFHackAPI
{
DFHackAPIHandle handle;
public:
CDFHackAPI (const string &path_to_xml)
: handle (CreateDFHackAPI (path_to_xml.c_str()))
{
if (handle == NULL)
{
// TODO: handle failure
}
}
inline ~CDFHackAPI()
{
DestroyDFHackAPI (handle);
handle = NULL;
}
inline bool Attach()
{
return DFHackAPI_Attach (handle);
}
inline bool Detach()
{
return DFHackAPI_Detach (handle);
}
inline bool isAttached()
{
return DFHackAPI_isAttached (handle);
}
/**
* 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
*/
inline bool ReadStoneMatgloss (vector<t_matgloss> & output)
{
return DFHackAPI_ReadStoneMatgloss (handle, output);
}
inline bool ReadWoodMatgloss (vector<t_matgloss> & output)
{
return DFHackAPI_ReadWoodMatgloss (handle, output);
}
inline bool ReadMetalMatgloss (vector<t_matgloss> & output)
{
return DFHackAPI_ReadMetalMatgloss (handle, output);
}
inline bool ReadPlantMatgloss (vector<t_matgloss> & output)
{
return DFHackAPI_ReadPlantMatgloss (handle, output);
}
inline bool ReadCreatureMatgloss (vector<t_matgloss> & output)
{
return DFHackAPI_ReadCreatureMatgloss (handle, output);
}
// 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];
}
}
}
*/
inline bool ReadGeology (vector < vector <uint16_t> >& assign)
{
return DFHackAPI_ReadGeology (handle, assign);
}
/*
* BLOCK DATA
*/
/// allocate and read pointers to map blocks
inline bool InitMap()
{
return DFHackAPI_InitMap (handle);
}
/// destroy the mapblock cache
inline bool DestroyMap()
{
return DFHackAPI_DestroyMap (handle);
}
/// get size of the map in tiles
inline void getSize (uint32_t& x, uint32_t& y, uint32_t& z)
{
DFHackAPI_getSize (handle, &x, &y, &z);
}
/**
* Return false/0 on failure, buffer allocated by client app, 256 items long
*/
inline bool isValidBlock (uint32_t blockx, uint32_t blocky, uint32_t blockz)
{
return DFHackAPI_isValidBlock (handle, blockx, blocky, blockz);
}
inline bool ReadTileTypes (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer) // 256 * sizeof(uint16_t)
{
return DFHackAPI_ReadTileTypes (handle, blockx, blocky, blockz, buffer);
}
inline bool WriteTileTypes (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer) // 256 * sizeof(uint16_t)
{
return DFHackAPI_WriteTileTypes (handle, blockx, blocky, blockz, buffer);
}
inline bool ReadDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) // 256 * sizeof(uint32_t)
{
return DFHackAPI_ReadDesignations (handle, blockx, blocky, blockz, buffer);
}
inline bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer)
{
return DFHackAPI_WriteDesignations (handle, blockx, blocky, blockz, buffer);
}
inline bool ReadOccupancy (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) // 256 * sizeof(uint32_t)
{
return DFHackAPI_ReadOccupancy (handle, blockx, blocky, blockz, buffer);
}
inline bool WriteOccupancy (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer) // 256 * sizeof(uint32_t)
{
return DFHackAPI_WriteOccupancy (handle, blockx, blocky, blockz, buffer);
}
/// read region offsets of a block
inline bool ReadRegionOffsets (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer) // 16 * sizeof(uint8_t)
{
return DFHackAPI_ReadRegionOffsets (handle, blockx, blocky, blockz, buffer);
}
/// read aggregated veins of a block
inline bool ReadVeins (uint32_t blockx, uint32_t blocky, uint32_t blockz, vector <t_vein> & veins)
{
return DFHackAPI_ReadVeins (handle, blockx, blocky, blockz, veins);
}
/**
* Buildings, constructions, plants, all pretty straighforward. InitReadBuildings returns all the building types as a mapping between a numeric values and strings
*/
inline uint32_t InitReadConstructions()
{
return DFHackAPI_InitReadConstructions (handle);
}
inline bool ReadConstruction (const uint32_t &index, t_construction & construction)
{
return DFHackAPI_ReadConstruction (handle, &index, & construction);
}
inline void FinishReadConstructions()
{
DFHackAPI_FinishReadConstructions (handle);
}
inline uint32_t InitReadBuildings (vector <string> &v_buildingtypes)
{
return DFHackAPI_InitReadBuildings (handle, v_buildingtypes);
}
inline bool ReadBuilding (const uint32_t &index, t_building & building)
{
return DFHackAPI_ReadBuilding (handle, &index, &building);
}
inline void FinishReadBuildings()
{
DFHackAPI_FinishReadBuildings (handle);
}
inline uint32_t InitReadVegetation()
{
return DFHackAPI_InitReadVegetation (handle);
}
inline bool ReadVegetation (const uint32_t &index, t_tree_desc & shrubbery)
{
return DFHackAPI_ReadVegetation (handle, &index, &shrubbery);
}
inline void FinishReadVegetation()
{
DFHackAPI_FinishReadVegetation (handle);
}
inline uint32_t InitReadCreatures()
{
return DFHackAPI_InitReadCreatures (handle);
}
inline bool ReadCreature (const uint32_t &index, t_creature & furball)
{
return DFHackAPI_ReadCreature (handle, &index, &furball);
}
inline void FinishReadCreatures()
{
DFHackAPI_FinishReadCreatures (handle);
}
inline void ReadRaw(const uint32_t &offset, const uint32_t &size, uint8_t *target)
{
DFHackAPI_ReadRaw(handle, offset, size, target);
}
};
#endif // __cplusplus
#endif // SIMPLEAPIC_H_INCLUDED

@ -1,182 +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.
*/
/**
* DO NOT USE THIS FILE DIRECTLY! USE MemAccess.h INSTEAD!
*/
#include "integers.h"
inline
uint8_t MreadByte (const uint32_t &offset)
{
return ptrace(PTRACE_PEEKDATA,g_ProcessHandle, offset, NULL);
}
inline
void MreadByte (const uint32_t &offset, uint8_t &val )
{
val = ptrace(PTRACE_PEEKDATA,g_ProcessHandle, offset, NULL);
}
inline
uint16_t MreadWord (const uint32_t &offset)
{
return ptrace(PTRACE_PEEKDATA,g_ProcessHandle, offset, NULL);
}
inline
void MreadWord (const uint32_t &offset, uint16_t &val)
{
val = ptrace(PTRACE_PEEKDATA,g_ProcessHandle, offset, NULL);
}
inline
uint32_t MreadDWord (const uint32_t &offset)
{
return ptrace(PTRACE_PEEKDATA,g_ProcessHandle, offset, NULL);
}
inline
void MreadDWord (const uint32_t &offset, uint32_t &val)
{
val = ptrace(PTRACE_PEEKDATA,g_ProcessHandle, offset, NULL);
}
// extremely terrible braindamage
inline
bool Mread ( uint32_t offset, uint32_t size, uint8_t *target)
{
uint8_t *mover = target;
while (size)
{
if(size >= 4)
{
* (uint32_t *)mover = MreadDWord(offset);
mover+=4;
offset +=4;
size -=4;
}
else if(size >= 2)
{
* (uint16_t *)mover = MreadWord(offset);
mover+=2;
offset +=2;
size -=2;
}
else if(size == 1)
{
* (uint8_t *)mover = MreadByte(offset);
mover+=1;
offset ++;
size --;
}
}
return true;
}
/*
* WRITING
*/
inline
void MwriteDWord (uint32_t offset, uint32_t data)
{
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, data);
}
// using these is expensive.
inline
void MwriteWord (uint32_t offset, uint16_t data)
{
uint32_t orig = MreadDWord(offset);
orig &= 0xFFFF0000;
orig |= data;
/*
orig |= 0x0000FFFF;
orig &= data;
*/
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, orig);
}
inline
void MwriteByte (uint32_t offset, uint8_t data)
{
uint32_t orig = MreadDWord(offset);
orig &= 0xFFFFFF00;
orig |= data;
/*
orig |= 0x000000FF;
orig &= data;
*/
ptrace(PTRACE_POKEDATA,g_ProcessHandle, offset, orig);
}
// blah. I hate the kernel devs for crippling /proc/PID/mem. THIS IS RIDICULOUS
inline
bool Mwrite (uint32_t offset, uint32_t size, uint8_t *source)
{
uint32_t indexptr = 0;
while (size > 0)
{
// default: we push 4 bytes
if(size >= 4)
{
MwriteDWord(offset, *(uint32_t *) (source + indexptr));
offset +=4;
indexptr +=4;
size -=4;
}
// last is either three or 2 bytes
else if(size >= 2)
{
MwriteWord(offset, *(uint16_t *) (source + indexptr));
offset +=2;
indexptr +=2;
size -=2;
}
// finishing move
else if(size == 1)
{
MwriteByte(offset, *(uint8_t *) (source + indexptr));
return true;
}
}
}
inline
const std::string MreadCString (uint32_t offset)
{
std::string temp;
char temp_c[256];
int counter = 0;
char r;
do
{
r = MreadByte(offset+counter);
temp_c[counter] = r;
counter++;
} while (r && counter < 255);
temp_c[counter] = 0;
temp = temp_c;
return temp;
}

File diff suppressed because it is too large Load Diff

@ -20,7 +20,7 @@ using namespace std;
#include <DFHackAPI.h> #include <DFHackAPI.h>
#include <DFMemInfo.h> #include <DFMemInfo.h>
#include <DFProcess.h> #include <DFProcess.h>
#include <argstream/argstream.h> #include <argstream.h>
vector<DFHack::t_matgloss> creaturestypes; vector<DFHack::t_matgloss> creaturestypes;

@ -0,0 +1,75 @@
.rodata:08773064 t_building_templest
.rodata:08772FE4 t_building_dark_towerst
.rodata:08772EE4 t_building_home_apartment_roomst
.rodata:08772F24 t_building_home_apartmentst
.rodata:08772F64 t_building_home_singlest
.rodata:08773024 t_building_keepst
.rodata:08772FA4 t_building_mead_hallst
.rodata:087730A4 t_building_storest
.rodata:08776784 23building_constructionst
.rodata:087771E4 21building_road_pavedst
.rodata:08777064 20building_road_dirtst
.rodata:08777AC4 15building_roadst
.rodata:08779424 16building_wagonst
.rodata:087792A4 21building_tradedepotst
.rodata:087789C4 19building_workshopst
.rodata:08778E44 18building_furnacest
.rodata:08778244 21building_animaltrapst
.rodata:08778FC4 19building_farmplotst
.rodata:08777644 17building_windowst
.rodata:087777C4 17building_statuest
.rodata:08777944 15building_wellst
.rodata:08777364 17building_coffinst
.rodata:087795A4 15building_shopst
.rodata:087783C4 16building_chairst
.rodata:08777C44 16building_tablest
.rodata:08777C44 14building_bedst
.rodata:08778B44 22building_siegeenginest
.rodata:08776D64 15building_cagest
.rodata:08776EE4 16building_chainst
.rodata:08776184 19building_windmillst
.rodata:08776304 22building_water_wheelst
.rodata:08776004 21building_screw_pumpst
.rodata:08778844 24building_archerytargetst
.rodata:08778544 17building_weaponst
.rodata:087786C4 18building_supportst
.rodata:08776604 24building_axle_verticalst
.rodata:08776484 26building_axle_horizontalst
.rodata:08776BE4 24building_gear_assemblyst
.rodata:08778CC4 15building_trapst
.rodata:08779EA4 21building_bars_floorst
.rodata:0877A024 24building_bars_verticalst
.rodata:0877A324 22building_grate_floorst
.rodata:0877A1A4 21building_grate_wallst
.rodata:0877A4A4 20building_floodgatest
.rodata:08779D24 17building_bridgest
.rodata:08779A24 16building_hatchst
.rodata:08779BA4 15building_doorst
.rodata:08777DC4 21building_armorstandst
.rodata:08777F44 21building_weaponrackst
.rodata:087798A4 18building_cabinetst
.rodata:08779724 14building_boxst
.rodata:08776A64 17building_actualst
.rodata:08779144 18building_civzonest
.rodata:087774E4 20building_stockpilest
0:FFFFFFFF 21building_window_gemst
0:FFFFFFFF 23building_window_glassst
.rodata:08787664 t_building_interactst
.rodata:08788DE4 n_building_selectorst
.rodata:08788E44 n_building_permit_foreign_armorst
.rodata:08788E24 n_building_permit_itemst
.rodata:08788E64 n_building_permit_foreign_siegeammost
.rodata:08788E84 n_building_permit_foreign_weaponst
.rodata:08788EA4 n_building_permit_trapcompst
.rodata:08788F04 n_building_new_jobst
.rodata:08788EC4 n_building_category_selectorst
.rodata:08788EE4 n_building_material_selectorst
0:FFFFFFFF f_building_well_tagst
0:FFFFFFFF E_BUILDING_TEMPLE
0:FFFFFFFF E_BUILDING_KEEP
0:FFFFFFFF f_building_civzone_assignedst
0:FFFFFFFF f_building_triggerst
0:FFFFFFFF f_building_triggertargetst
0:FFFFFFFF f_building_chainst
0:FFFFFFFF f_building_cagedst
0:FFFFFFFF f_building_holderst

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because it is too large Load Diff

@ -0,0 +1 @@
.rodata:08779424 16building_wagonst

@ -16,7 +16,7 @@ using namespace std;
#include <DFTypes.h> #include <DFTypes.h>
#include <DFTileTypes.h> #include <DFTileTypes.h>
#include <DFHackAPI.h> #include <DFHackAPI.h>
#include <argstream/argstream.h> #include <argstream.h>
// counts the occurances of a certain element in a vector // counts the occurances of a certain element in a vector
// used to determine of a given tile is a target // used to determine of a given tile is a target