Merge branch 'master' of git://github.com/peterix/dfhack
commit
04a16c4996
@ -1,150 +0,0 @@
|
|||||||
# don't use this file directly. use the one in the root folder of the project
|
|
||||||
|
|
||||||
SET(PROJECT_HDRS
|
|
||||||
include/DFCommonInternal.h
|
|
||||||
include/DFError.h
|
|
||||||
include/DFHackAPI.h
|
|
||||||
include/DFMemInfo.h
|
|
||||||
include/DFMemInfoManager.h
|
|
||||||
include/DFProcessEnumerator.h
|
|
||||||
include/DFProcess.h
|
|
||||||
include/DFTileTypes.h
|
|
||||||
include/DFTypes.h
|
|
||||||
include/DFVector.h
|
|
||||||
include/DFWindow.h
|
|
||||||
include/DFHackAPI_C.h
|
|
||||||
include/integers.h
|
|
||||||
shm/shms.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_SRCS
|
|
||||||
DFMemInfo.cpp
|
|
||||||
DFMemInfoManager.cpp
|
|
||||||
DFHackAPI.cpp
|
|
||||||
APIPrivate.cpp
|
|
||||||
DFTileTypes.cpp
|
|
||||||
DFVector.cpp
|
|
||||||
DFHackAPI_C.cpp
|
|
||||||
DFTypes_C.cpp
|
|
||||||
|
|
||||||
depends/md5/md5.cpp
|
|
||||||
depends/md5/md5wrapper.cpp
|
|
||||||
|
|
||||||
depends/tinyxml/tinystr.cpp
|
|
||||||
depends/tinyxml/tinyxml.cpp
|
|
||||||
depends/tinyxml/tinyxmlerror.cpp
|
|
||||||
depends/tinyxml/tinyxmlparser.cpp
|
|
||||||
|
|
||||||
modules/Creatures.cpp
|
|
||||||
modules/Gui.cpp
|
|
||||||
modules/World.cpp
|
|
||||||
modules/Items.cpp
|
|
||||||
modules/Maps.cpp
|
|
||||||
modules/Materials.cpp
|
|
||||||
modules/Position.cpp
|
|
||||||
modules/Translation.cpp
|
|
||||||
modules/Vegetation.cpp
|
|
||||||
modules/Buildings.cpp
|
|
||||||
modules/Constructions.cpp
|
|
||||||
|
|
||||||
modules/Position_C.cpp
|
|
||||||
modules/Gui_C.cpp
|
|
||||||
modules/Materials_C.cpp
|
|
||||||
modules/Buildings_C.cpp
|
|
||||||
modules/Constructions_C.cpp
|
|
||||||
modules/Maps_C.cpp
|
|
||||||
modules/Vegetation_C.cpp
|
|
||||||
modules/Creatures_C.cpp
|
|
||||||
modules/Translation_C.cpp
|
|
||||||
modules/Items_C.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_HDRS_LINUX
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_HDRS_WINDOWS
|
|
||||||
include/stdint_win.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_SRCS_LINUX
|
|
||||||
DFProcess-linux.cpp
|
|
||||||
DFProcess-linux-SHM.cpp
|
|
||||||
DFProcess-linux-wine.cpp
|
|
||||||
DFWindow-linux.cpp
|
|
||||||
DFProcessEnumerator-linux.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_SRCS_WINDOWS
|
|
||||||
DFProcess-windows.cpp
|
|
||||||
DFProcess-windows-SHM.cpp
|
|
||||||
DFWindow-windows.cpp
|
|
||||||
DFProcessEnumerator-windows.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(UNIX)
|
|
||||||
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_LINUX})
|
|
||||||
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_LINUX})
|
|
||||||
ELSE(UNIX)
|
|
||||||
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_WINDOWS})
|
|
||||||
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_WINDOWS})
|
|
||||||
ENDIF(UNIX)
|
|
||||||
|
|
||||||
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
|
|
||||||
|
|
||||||
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
|
|
||||||
|
|
||||||
SET( MEMXML_DATA_PATH . CACHE PATH "search path for Memory.xml")
|
|
||||||
# OPTION( VARIABLE "Description" Initial state)
|
|
||||||
#OPTION( WITH_FOO "Enable FOO support" ON )
|
|
||||||
#OPTION( WITH_BAR "Enable BAR component" OFF )
|
|
||||||
|
|
||||||
# Are we 64bit? (Damn you, ptrace()!)
|
|
||||||
IF( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
|
||||||
SET( HAVE_64_BIT 0 )
|
|
||||||
ELSE( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
|
||||||
SET( HAVE_64_BIT 1 )
|
|
||||||
ENDIF( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
|
||||||
|
|
||||||
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/dfhack/config.h.cmake ${CMAKE_SOURCE_DIR}/dfhack/include/config.h )
|
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DBUILD_DFHACK_LIB)
|
|
||||||
|
|
||||||
IF(UNIX)
|
|
||||||
add_definitions(-DLINUX_BUILD)
|
|
||||||
add_definitions(-DUSE_CONFIG_H)
|
|
||||||
find_library(X11_LIBRARY X11)
|
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
|
|
||||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden")
|
|
||||||
|
|
||||||
SET(PROJECT_LIBS ${X11_LIBRARY} rt ) #dfhack-md5 dfhack-tixml
|
|
||||||
ELSE(UNIX)
|
|
||||||
SET(PROJECT_LIBS psapi)
|
|
||||||
ENDIF(UNIX)
|
|
||||||
|
|
||||||
ADD_LIBRARY(dfhack SHARED ${PROJECT_SRCS})
|
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
|
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS})
|
|
||||||
|
|
||||||
IF(UNIX)
|
|
||||||
install(TARGETS dfhack LIBRARY DESTINATION lib)
|
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/output/Memory.xml DESTINATION share/dfhack)
|
|
||||||
ENDIF(UNIX)
|
|
||||||
|
|
||||||
# SWIG stuff is dead
|
|
||||||
# FIND_PACKAGE(SWIG)
|
|
||||||
|
|
||||||
#IF(SWIG_FOUND)
|
|
||||||
# INCLUDE(${SWIG_USE_FILE})
|
|
||||||
# FIND_PACKAGE(PythonLibs)
|
|
||||||
# IF(PYTHONLIBS_FOUND)
|
|
||||||
# INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
|
|
||||||
# SET(CMAKE_SWIG_FLAGS "-c++")
|
|
||||||
# SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES CPLUSPLUS ON)
|
|
||||||
# SET(CMAKE_DFHACK_SWIG_OUTDIR ${dfhack_SOURCE_DIR}/output CACHE PATH "Directory where Java wrapped libraries will be saved.")
|
|
||||||
# # SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES SWIG_FLAGS "-includeall")
|
|
||||||
# SWIG_ADD_MODULE(pydfhack python pydfhack.i)
|
|
||||||
# SWIG_LINK_LIBRARIES(pydfhack ${PYTHON_LIBRARIES} dfhack)
|
|
||||||
# ENDIF(PYTHONLIBS_FOUND)
|
|
||||||
#ENDIF(SWIG_FOUND)
|
|
@ -1,293 +0,0 @@
|
|||||||
/*
|
|
||||||
www.sourceforge.net/projects/dfhack
|
|
||||||
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
|
||||||
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Tranquility.h"
|
|
||||||
#include "Export.h"
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include "integers.h"
|
|
||||||
#include "DFTileTypes.h"
|
|
||||||
#include "DFTypes.h"
|
|
||||||
#include "DFWindow.h"
|
|
||||||
#include "DFHackAPI.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace DFHack;
|
|
||||||
|
|
||||||
#include "DFHackAPI_C.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DFHackObject* API_Alloc(const char* path_to_xml)
|
|
||||||
{
|
|
||||||
DFHack::API* api = new DFHack::API(std::string(path_to_xml));
|
|
||||||
return (DFHackObject*)api;
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME: X:\dfhack\DFHackAPI_C.cpp:56: warning: deleting `DFHackObject* ' is undefined
|
|
||||||
//DC: Yeah, I forgot that trying to delete a void pointer might be a bad idea. This works now.
|
|
||||||
void API_Free(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
DFHack::API* a = (DFHack::API*)api;
|
|
||||||
delete a;
|
|
||||||
|
|
||||||
api = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_Attach(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->Attach();
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_Detach(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->Detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_isAttached(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->isAttached();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_Suspend(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->Suspend();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_Resume(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->Resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_isSuspended(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->isSuspended();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_ForceResume(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->ForceResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int API_AsyncSuspend(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return ((DFHack::API*)api)->AsyncSuspend();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//module getters
|
|
||||||
|
|
||||||
DFHackObject* API_getMemoryInfo(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getMemoryInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getProcess(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getWindow(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getCreatures(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getCreatures();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getMaps(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getGui(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getGui();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getPosition(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getMaterials(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getMaterials();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getTranslation(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getTranslation();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getVegetation(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getVegetation();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getBuildings(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getBuildings();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getConstructions(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getConstructions();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHackObject* API_getItems(DFHackObject* api)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
return (DFHackObject*)((DFHack::API*)api)->getItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
((DFHack::API*)api)->ReadRaw(offset, size, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source)
|
|
||||||
{
|
|
||||||
if(api != NULL)
|
|
||||||
{
|
|
||||||
((DFHack::API*)api)->WriteRaw(offset, size, source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,226 +0,0 @@
|
|||||||
/*
|
|
||||||
www.sourceforge.net/projects/dfhack
|
|
||||||
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
|
||||||
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "integers.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "string.h"
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "DFCommonInternal.h"
|
|
||||||
#include "DFTypes.h"
|
|
||||||
#include "modules/Materials.h"
|
|
||||||
#include "DFTypes_C.h"
|
|
||||||
|
|
||||||
using namespace DFHack;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
c_colormodifier* ColorModifier_New()
|
|
||||||
{
|
|
||||||
c_colormodifier* temp;
|
|
||||||
|
|
||||||
temp = (c_colormodifier*)malloc(sizeof(c_colormodifier));
|
|
||||||
|
|
||||||
if(temp == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
temp->part[0] = '\0';
|
|
||||||
temp->colorlist = NULL;
|
|
||||||
temp->colorlistLength = 0;
|
|
||||||
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ColorModifier_Free(c_colormodifier* src)
|
|
||||||
{
|
|
||||||
if(src != NULL)
|
|
||||||
{
|
|
||||||
if(src->colorlist != NULL)
|
|
||||||
free(src->colorlist);
|
|
||||||
|
|
||||||
free(src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c_creaturecaste* CreatureCaste_New()
|
|
||||||
{
|
|
||||||
c_creaturecaste* temp;
|
|
||||||
|
|
||||||
temp = (c_creaturecaste*)malloc(sizeof(c_creaturecaste));
|
|
||||||
|
|
||||||
if(temp == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
temp->rawname[0] = '\0';
|
|
||||||
temp->singular[0] = '\0';
|
|
||||||
temp->plural[0] = '\0';
|
|
||||||
temp->adjective[0] = '\0';
|
|
||||||
|
|
||||||
temp->ColorModifier = NULL;
|
|
||||||
temp->colorModifierLength = 0;
|
|
||||||
|
|
||||||
temp->bodypart = NULL;
|
|
||||||
temp->bodypartLength = 0;
|
|
||||||
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreatureCaste_Free(c_creaturecaste* src)
|
|
||||||
{
|
|
||||||
if(src != NULL)
|
|
||||||
{
|
|
||||||
if(src->bodypart != NULL)
|
|
||||||
free(src->bodypart);
|
|
||||||
|
|
||||||
if(src->ColorModifier != NULL)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < src->colorModifierLength; i++)
|
|
||||||
ColorModifier_Free(&src->ColorModifier[i]);
|
|
||||||
|
|
||||||
free(src->ColorModifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
c_creaturetype* CreatureType_New()
|
|
||||||
{
|
|
||||||
c_creaturetype* temp;
|
|
||||||
|
|
||||||
temp = (c_creaturetype*)malloc(sizeof(c_creaturetype));
|
|
||||||
|
|
||||||
if(temp == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
temp->rawname[0] = '\0';
|
|
||||||
|
|
||||||
temp->castes = NULL;
|
|
||||||
temp->castesCount = 0;
|
|
||||||
|
|
||||||
temp->extract = NULL;
|
|
||||||
temp->extractCount = 0;
|
|
||||||
|
|
||||||
temp->tile_character = 0;
|
|
||||||
|
|
||||||
temp->tilecolor.fore = 0;
|
|
||||||
temp->tilecolor.back = 0;
|
|
||||||
temp->tilecolor.bright = 0;
|
|
||||||
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreatureType_Free(c_creaturetype* src)
|
|
||||||
{
|
|
||||||
if(src != NULL)
|
|
||||||
{
|
|
||||||
if(src->castes != NULL)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < src->castesCount; i++)
|
|
||||||
CreatureCaste_Free(&src->castes[i]);
|
|
||||||
|
|
||||||
free(src->castes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(src->extract != NULL)
|
|
||||||
free(src->extract);
|
|
||||||
|
|
||||||
free(src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int ColorListConvert(t_colormodifier* src, c_colormodifier* dest)
|
|
||||||
{
|
|
||||||
if(src == NULL || dest == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
strcpy(dest->part, src->part);
|
|
||||||
|
|
||||||
dest->colorlistLength = src->colorlist.size();
|
|
||||||
dest->colorlist = (uint32_t*)malloc(sizeof(uint32_t) * dest->colorlistLength);
|
|
||||||
|
|
||||||
copy(src->colorlist.begin(), src->colorlist.end(), dest->colorlist);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CreatureCasteConvert(t_creaturecaste* src, c_creaturecaste* dest)
|
|
||||||
{
|
|
||||||
if(src == NULL || dest == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
strcpy(dest->rawname, src->rawname);
|
|
||||||
strcpy(dest->singular, src->singular);
|
|
||||||
strcpy(dest->plural, src->plural);
|
|
||||||
strcpy(dest->adjective, src->adjective);
|
|
||||||
|
|
||||||
dest->colorModifierLength = src->ColorModifier.size();
|
|
||||||
dest->ColorModifier = (c_colormodifier*)malloc(sizeof(c_colormodifier) * dest->colorModifierLength);
|
|
||||||
|
|
||||||
for(int i = 0; i < dest->colorModifierLength; i++)
|
|
||||||
ColorListConvert(&src->ColorModifier[i], &dest->ColorModifier[i]);
|
|
||||||
|
|
||||||
dest->bodypartLength = src->bodypart.size();
|
|
||||||
dest->bodypart = (t_bodypart*)malloc(sizeof(t_bodypart) * dest->bodypartLength);
|
|
||||||
|
|
||||||
copy(src->bodypart.begin(), src->bodypart.end(), dest->bodypart);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CreatureTypeConvert(t_creaturetype* src, c_creaturetype* dest)
|
|
||||||
{
|
|
||||||
if(src == NULL || dest == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
strcpy(dest->rawname, src->rawname);
|
|
||||||
|
|
||||||
dest->tilecolor.fore = src->tilecolor.fore;
|
|
||||||
dest->tilecolor.back = src->tilecolor.back;
|
|
||||||
dest->tilecolor.bright = src->tilecolor.bright;
|
|
||||||
|
|
||||||
dest->tile_character = src->tile_character;
|
|
||||||
|
|
||||||
dest->castesCount = src->castes.size();
|
|
||||||
dest->castes = (c_creaturecaste*)malloc(sizeof(c_creaturecaste) * dest->castesCount);
|
|
||||||
|
|
||||||
for(int i = 0; i < dest->castesCount; i++)
|
|
||||||
CreatureCasteConvert(&src->castes[i], &dest->castes[i]);
|
|
||||||
|
|
||||||
dest->extractCount = src->extract.size();
|
|
||||||
dest->extract = (t_creatureextract*)malloc(sizeof(t_creatureextract) * dest->extractCount);
|
|
||||||
|
|
||||||
copy(src->extract.begin(), src->extract.end(), dest->extract);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
www.sourceforge.net/projects/dfhack
|
|
||||||
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
|
||||||
|
|
||||||
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 DFHACK_C_API
|
|
||||||
#define DFHACK_C_API
|
|
||||||
|
|
||||||
#include "Export.h"
|
|
||||||
#include "integers.h"
|
|
||||||
|
|
||||||
typedef void DFHackObject;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DFHACK_EXPORT DFHackObject* API_Alloc(const char* path_to_xml);
|
|
||||||
DFHACK_EXPORT void API_Free(DFHackObject* api);
|
|
||||||
|
|
||||||
DFHACK_EXPORT int API_Attach(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT int API_Detach(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT int API_isAttached(DFHackObject* api);
|
|
||||||
|
|
||||||
DFHACK_EXPORT int API_Suspend(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT int API_Resume(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT int API_isSuspended(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT int API_ForceResume(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT int API_AsyncSuspend(DFHackObject* api);
|
|
||||||
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getMemoryInfo(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getProcess(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getWindow(DFHackObject* api);
|
|
||||||
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getCreatures(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getMaps(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getGui(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getPosition(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getMaterials(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getTranslation(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getVegetation(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getBuildings(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getConstructions(DFHackObject* api);
|
|
||||||
DFHACK_EXPORT DFHackObject* API_getItems(DFHackObject* api);
|
|
||||||
|
|
||||||
//these are DANGEROUS...can crash/segfault DF, turn the seas to blood, call up the Antichrist, etc
|
|
||||||
DFHACK_EXPORT void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target);
|
|
||||||
DFHACK_EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
www.sourceforge.net/projects/dfhack
|
|
||||||
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
|
||||||
|
|
||||||
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 TYPES_C_API
|
|
||||||
#define TYPES_C_API
|
|
||||||
|
|
||||||
#include "Export.h"
|
|
||||||
#include "integers.h"
|
|
||||||
#include "DFTypes.h"
|
|
||||||
#include "modules/Materials.h"
|
|
||||||
#include "DFHackAPI_C.h"
|
|
||||||
|
|
||||||
using namespace DFHack;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct c_colormodifier
|
|
||||||
{
|
|
||||||
char part[128];
|
|
||||||
uint32_t* colorlist;
|
|
||||||
uint32_t colorlistLength;
|
|
||||||
};
|
|
||||||
|
|
||||||
c_colormodifier* ColorModifier_New();
|
|
||||||
void ColorModifier_Free(c_colormodifier* src);
|
|
||||||
|
|
||||||
struct c_creaturecaste
|
|
||||||
{
|
|
||||||
char rawname[128];
|
|
||||||
char singular[128];
|
|
||||||
char plural[128];
|
|
||||||
char adjective[128];
|
|
||||||
|
|
||||||
c_colormodifier* ColorModifier;
|
|
||||||
uint32_t colorModifierLength;
|
|
||||||
|
|
||||||
t_bodypart* bodypart;
|
|
||||||
uint32_t bodypartLength;
|
|
||||||
};
|
|
||||||
|
|
||||||
c_creaturecaste* CreatureCaste_New();
|
|
||||||
void CreatureCaste_Free(c_creaturecaste* src);
|
|
||||||
|
|
||||||
struct c_creaturetype
|
|
||||||
{
|
|
||||||
char rawname[128];
|
|
||||||
|
|
||||||
c_creaturecaste* castes;
|
|
||||||
uint32_t castesCount;
|
|
||||||
|
|
||||||
t_creatureextract* extract;
|
|
||||||
uint32_t extractCount;
|
|
||||||
|
|
||||||
uint8_t tile_character;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint16_t fore;
|
|
||||||
uint16_t back;
|
|
||||||
uint16_t bright;
|
|
||||||
} tilecolor;
|
|
||||||
};
|
|
||||||
|
|
||||||
c_creaturetype* CreatureType_New();
|
|
||||||
void CreatureType_Free(c_creaturetype* src);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int CreatureTypeConvert(t_creaturetype* src, c_creaturetype* dest);
|
|
||||||
int CreatureCasteConvert(t_creaturecaste* src, c_creaturecaste* dest);
|
|
||||||
int ColorListConvert(t_colormodifier* src, c_colormodifier* dest);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,219 +0,0 @@
|
|||||||
%module pydfhack
|
|
||||||
%include "std_string.i"
|
|
||||||
%include "std_vector.i"
|
|
||||||
%include "std_map.i"
|
|
||||||
%include "stdint.i"
|
|
||||||
%include "typemaps.i"
|
|
||||||
|
|
||||||
/* This goes to the header of the wrapper code */
|
|
||||||
%{
|
|
||||||
#define LINUX_BUILD
|
|
||||||
#define SWIG_WRAPPER
|
|
||||||
#include "DFTypes.h"
|
|
||||||
#include "DFHackAPI.h"
|
|
||||||
using namespace std;
|
|
||||||
using namespace DFHack;
|
|
||||||
%}
|
|
||||||
|
|
||||||
/* make swig not react to the macro */
|
|
||||||
%define DFHACK_EXPORT
|
|
||||||
|
|
||||||
/* Parse the header file to generate wrappers */
|
|
||||||
%include "DFTypes.h"
|
|
||||||
|
|
||||||
/* templates have to be instantiated for swig */
|
|
||||||
%template(MatglossVector) std::vector<DFHack::t_matgloss>;
|
|
||||||
%template(PlantMatglossVector) std::vector<DFHack::t_matglossPlant>;
|
|
||||||
%template(VeinVector) std::vector <DFHack::t_vein>;
|
|
||||||
%template(IceVeinVector) std::vector <DFHack::t_frozenliquidvein>;
|
|
||||||
|
|
||||||
/*
|
|
||||||
This causes swig to generate BS uncompilable code
|
|
||||||
%template(GeologyAssign) std::vector < std::vector <uint16_t> >;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
SWIG typemaps recipe
|
|
||||||
%apply double *OUTPUT { double *result }; // 'double *result' is to be treated as OUTPUT
|
|
||||||
%clear double *result; // Remove all typemaps for double *result
|
|
||||||
|
|
||||||
INPUT
|
|
||||||
int *INPUT
|
|
||||||
short *INPUT
|
|
||||||
long *INPUT
|
|
||||||
unsigned int *INPUT
|
|
||||||
unsigned short *INPUT
|
|
||||||
unsigned long *INPUT
|
|
||||||
double *INPUT
|
|
||||||
float *INPUT
|
|
||||||
|
|
||||||
OUTPUT
|
|
||||||
int *OUTPUT
|
|
||||||
short *OUTPUT
|
|
||||||
long *OUTPUT
|
|
||||||
unsigned int *OUTPUT
|
|
||||||
unsigned short *OUTPUT
|
|
||||||
unsigned long *OUTPUT
|
|
||||||
double *OUTPUT
|
|
||||||
float *OUTPUT
|
|
||||||
|
|
||||||
INOUT
|
|
||||||
int *INOUT
|
|
||||||
short *INOUT
|
|
||||||
long *INOUT
|
|
||||||
unsigned int *INOUT
|
|
||||||
unsigned short *INOUT
|
|
||||||
unsigned long *INOUT
|
|
||||||
double *INOUT
|
|
||||||
float *INOUT
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace DFHack
|
|
||||||
{
|
|
||||||
class memory_info;
|
|
||||||
class Process;
|
|
||||||
class API
|
|
||||||
{
|
|
||||||
|
|
||||||
class Private;
|
|
||||||
|
|
||||||
Private * const d;
|
|
||||||
public:
|
|
||||||
API(const std::string path_to_xml);
|
|
||||||
~API();
|
|
||||||
bool Attach();
|
|
||||||
bool Detach();
|
|
||||||
bool isAttached();
|
|
||||||
|
|
||||||
bool ReadPauseState();
|
|
||||||
|
|
||||||
bool ReadViewScreen(t_viewscreen &);
|
|
||||||
|
|
||||||
uint32_t ReadMenuState();
|
|
||||||
|
|
||||||
bool Suspend();
|
|
||||||
bool AsyncSuspend();
|
|
||||||
bool Resume();
|
|
||||||
bool ForceResume();
|
|
||||||
bool isSuspended();
|
|
||||||
bool ReadStoneMatgloss(std::vector<t_matgloss> & OUTPUT);
|
|
||||||
bool ReadWoodMatgloss (std::vector<t_matgloss> & OUTPUT);
|
|
||||||
bool ReadMetalMatgloss(std::vector<t_matgloss> & OUTPUT);
|
|
||||||
bool ReadPlantMatgloss(std::vector<t_matgloss> & OUTPUT);
|
|
||||||
/*
|
|
||||||
* SWIG reports that it can't wrap the second method here
|
|
||||||
*/
|
|
||||||
bool ReadPlantMatgloss (std::vector<t_matglossPlant> & OUTPUT);
|
|
||||||
bool ReadCreatureMatgloss(std::vector<t_matgloss> & OUTPUT);
|
|
||||||
|
|
||||||
bool ReadGeology( std::vector < std::vector <uint16_t> >& OUTPUT );
|
|
||||||
|
|
||||||
bool InitMap();
|
|
||||||
bool DestroyMap();
|
|
||||||
|
|
||||||
%apply uint32_t& OUTPUT { uint32_t& x };
|
|
||||||
%apply uint32_t& OUTPUT { uint32_t& y };
|
|
||||||
%apply uint32_t& OUTPUT { uint32_t& z };
|
|
||||||
void getSize(uint32_t& x, uint32_t& y, uint32_t& z);
|
|
||||||
|
|
||||||
bool isValidBlock(uint32_t blockx, uint32_t blocky, uint32_t blockz);
|
|
||||||
uint32_t getBlockPtr (uint32_t blockx, uint32_t blocky, uint32_t blockz);
|
|
||||||
|
|
||||||
bool ReadBlock40d(uint32_t blockx, uint32_t blocky, uint32_t blockz, mapblock40d * OUTPUT);
|
|
||||||
|
|
||||||
bool ReadTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, tiletypes40d *OUTPUT);
|
|
||||||
bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, tiletypes40d *INPUT);
|
|
||||||
|
|
||||||
bool ReadDesignations(uint32_t blockx, uint32_t blocky, uint32_t blockz, designations40d *OUTPUT);
|
|
||||||
bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, designations40d *INPUT);
|
|
||||||
|
|
||||||
bool ReadOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, occupancies40d *OUTPUT);
|
|
||||||
bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, occupancies40d *INPUT);
|
|
||||||
|
|
||||||
bool ReadDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool &OUTPUT);
|
|
||||||
bool WriteDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool dirtybit);
|
|
||||||
|
|
||||||
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, biome_indices40d *OUTPUT);
|
|
||||||
|
|
||||||
bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, std::vector <t_vein> & veins, std::vector <t_frozenliquidvein>& ices);
|
|
||||||
|
|
||||||
%apply uint32_t& OUTPUT { uint32_t & numObjs };
|
|
||||||
|
|
||||||
bool InitReadConstructions( uint32_t & numObjs );
|
|
||||||
bool ReadConstruction(const int32_t index, t_construction & OUTPUT);
|
|
||||||
void FinishReadConstructions();
|
|
||||||
|
|
||||||
bool InitReadBuildings ( uint32_t & numObjs );
|
|
||||||
bool ReadBuilding(const int32_t index, t_building & OUTPUT);
|
|
||||||
void FinishReadBuildings();
|
|
||||||
|
|
||||||
bool InitReadVegetation( uint32_t & numObjs );
|
|
||||||
bool ReadVegetation(const int32_t index, t_tree_desc & OUTPUT);
|
|
||||||
void FinishReadVegetation();
|
|
||||||
|
|
||||||
bool InitReadCreatures( uint32_t & numObjs );
|
|
||||||
int32_t ReadCreatureInBox(int32_t index, t_creature & OUTPUT,
|
|
||||||
const uint16_t x1, const uint16_t y1,const uint16_t z1,
|
|
||||||
const uint16_t x2, const uint16_t y2,const uint16_t z2);
|
|
||||||
|
|
||||||
bool ReadCreature(const int32_t index, t_creature & OUTPUT);
|
|
||||||
void FinishReadCreatures();
|
|
||||||
|
|
||||||
/*
|
|
||||||
A conundrum really.
|
|
||||||
*/
|
|
||||||
void ReadRaw (const uint32_t offset, const uint32_t size, uint8_t *target);
|
|
||||||
void WriteRaw (const uint32_t offset, const uint32_t size, uint8_t *source);
|
|
||||||
|
|
||||||
bool InitViewAndCursor();
|
|
||||||
|
|
||||||
bool InitReadNotes( uint32_t & numnotes );
|
|
||||||
bool ReadNote(const int32_t index, t_note & OUTPUT);
|
|
||||||
void FinishReadNotes();
|
|
||||||
|
|
||||||
bool InitReadSettlements( uint32_t & numObjs );
|
|
||||||
bool ReadSettlement(const int32_t index, t_settlement & OUTPUT);
|
|
||||||
bool ReadCurrentSettlement(t_settlement & settlement);
|
|
||||||
void FinishReadSettlements();
|
|
||||||
|
|
||||||
bool InitReadHotkeys( );
|
|
||||||
bool ReadHotkeys(t_hotkey hotkeys[]);
|
|
||||||
|
|
||||||
%apply int32_t& OUTPUT { int32_t& x };
|
|
||||||
%apply int32_t& OUTPUT { int32_t& y };
|
|
||||||
%apply int32_t& OUTPUT { int32_t& z };
|
|
||||||
bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
||||||
bool setViewCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
||||||
|
|
||||||
bool getCursorCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
||||||
bool setCursorCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
||||||
|
|
||||||
bool getCurrentCursorCreature(uint32_t &OUTPUT);
|
|
||||||
|
|
||||||
bool InitViewSize();
|
|
||||||
|
|
||||||
%apply int32_t& OUTPUT { int32_t& width };
|
|
||||||
%apply int32_t& OUTPUT { int32_t& height };
|
|
||||||
bool getWindowSize(int32_t & width, int32_t & height);
|
|
||||||
bool getItemIndexesInBox(std::vector<uint32_t> &indexes,
|
|
||||||
const uint16_t x1, const uint16_t y1, const uint16_t z1,
|
|
||||||
const uint16_t x2, const uint16_t y2, const uint16_t z2);
|
|
||||||
bool InitReadNameTables (std::vector< std::vector<std::string> > & translations , std::vector< std::vector<std::string> > & foreign_languages);
|
|
||||||
void FinishReadNameTables();
|
|
||||||
|
|
||||||
std::string TranslateName(const t_name & name,const std::vector< std::vector<std::string> > & translations ,const std::vector< std::vector<std::string> > & foreign_languages, bool inEnglish=true);
|
|
||||||
|
|
||||||
void WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
|
|
||||||
|
|
||||||
bool InitReadItems(uint32_t & numitems);
|
|
||||||
bool ReadItem(const uint32_t index, t_item & OUTPUT);
|
|
||||||
void FinishReadItems();
|
|
||||||
|
|
||||||
memory_info *getMemoryInfo();
|
|
||||||
Process * getProcess();
|
|
||||||
DFWindow * getWindow();
|
|
||||||
bool ReadItemTypes(std::vector< std::vector< t_itemType > > & itemTypes);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
%enddef DFHACK_EXPORT
|
|
@ -1,14 +0,0 @@
|
|||||||
from ctypes import *
|
|
||||||
|
|
||||||
def _uintify(x, y, z):
|
|
||||||
return (c_uint(x), c_uint(y), c_uint(z))
|
|
||||||
|
|
||||||
def _allocate_array(t_type, count):
|
|
||||||
arr_type = t_type * count
|
|
||||||
|
|
||||||
arr = arr_type()
|
|
||||||
|
|
||||||
ptr = c_void_p()
|
|
||||||
ptr = addressof(arr)
|
|
||||||
|
|
||||||
return (arr, ptr)
|
|
@ -1,54 +0,0 @@
|
|||||||
# don't use this file directly. use the one in the root folder of the project
|
|
||||||
|
|
||||||
SET(PROJECT_HDRS
|
|
||||||
shms.h
|
|
||||||
mod-core.h
|
|
||||||
mod-maps.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_SRCS
|
|
||||||
mod-core.cpp
|
|
||||||
mod-maps.cpp
|
|
||||||
mod-creature40d.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_HDRS_LINUX
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_HDRS_WINDOWS
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_SRCS_LINUX
|
|
||||||
shms-linux.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PROJECT_SRCS_WINDOWS
|
|
||||||
shms-windows.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(UNIX)
|
|
||||||
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_LINUX})
|
|
||||||
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_LINUX})
|
|
||||||
ELSE(UNIX)
|
|
||||||
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_WINDOWS})
|
|
||||||
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_WINDOWS})
|
|
||||||
ENDIF(UNIX)
|
|
||||||
|
|
||||||
|
|
||||||
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
|
|
||||||
|
|
||||||
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
|
|
||||||
|
|
||||||
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
||||||
IF(UNIX)
|
|
||||||
add_definitions(-DLINUX_BUILD)
|
|
||||||
SET(PROJECT_LIBS rt)
|
|
||||||
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden")
|
|
||||||
ADD_LIBRARY(dfconnect SHARED ${PROJECT_SRCS})
|
|
||||||
TARGET_LINK_LIBRARIES(dfconnect ${PROJECT_LIBS})
|
|
||||||
ELSE(UNIX)
|
|
||||||
# SET(PROJECT_LIBS psapi)
|
|
||||||
ADD_LIBRARY(SDL SHARED ${PROJECT_SRCS})
|
|
||||||
TARGET_LINK_LIBRARIES(SDL ${PROJECT_LIBS})
|
|
||||||
ENDIF(UNIX)
|
|
||||||
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
@ -1,204 +0,0 @@
|
|||||||
// Just show some position data
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <climits>
|
|
||||||
#include <integers.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <sstream>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cstdio>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <DFGlobal.h>
|
|
||||||
#include <DFTypes.h>
|
|
||||||
#include <DFHackAPI.h>
|
|
||||||
#include <DFProcess.h>
|
|
||||||
#include <DFMemInfo.h>
|
|
||||||
#include <DFVector.h>
|
|
||||||
#include <DFTypes.h>
|
|
||||||
#include <modules/Materials.h>
|
|
||||||
#include <modules/Position.h>
|
|
||||||
#include <modules/Maps.h>
|
|
||||||
#include <modules/Constructions.h>
|
|
||||||
#include <DFMiscUtils.h>
|
|
||||||
#include <DFTileTypes.h>
|
|
||||||
|
|
||||||
using namespace DFHack;
|
|
||||||
/*
|
|
||||||
int __userpurge get_feature_at<eax>(__int16 tZ<ax>, __int16 tY<cx>, int world_base<ebx>, signed __int16 tX)
|
|
||||||
{
|
|
||||||
int block; // ebp@1
|
|
||||||
signed __int16 __tX; // di@1
|
|
||||||
signed int _tY; // esi@1
|
|
||||||
int designation; // eax@2
|
|
||||||
int _tX; // ecx@2
|
|
||||||
signed int v9; // eax@4
|
|
||||||
int v10; // edx@4
|
|
||||||
__int64 region_x_local; // qax@4
|
|
||||||
__int16 v12; // cx@4
|
|
||||||
__int16 v13; // ax@5
|
|
||||||
int v14; // esi@5
|
|
||||||
int result; // eax@7
|
|
||||||
unsigned int some_stuff; // ebp@10
|
|
||||||
int v17; // edx@11
|
|
||||||
int _designation; // [sp+10h] [bp+4h]@2
|
|
||||||
|
|
||||||
__tX = tX;
|
|
||||||
LOWORD(_tY) = tY;
|
|
||||||
block = getBlock(world_base, tX, tY, tZ);
|
|
||||||
if ( !block )
|
|
||||||
goto LABEL_17;
|
|
||||||
_tX = tX;
|
|
||||||
_tY = (signed __int16)_tY;
|
|
||||||
designation = *(_DWORD *)(block + 0x29C + 4 * ((signed __int16)_tY % 16 + 16 * tX % 16));
|
|
||||||
_designation = designation;
|
|
||||||
if ( designation & 0x10000000 && *(_WORD *)(block + 0x2C) != -1 )// first feature_present bit - adamantine
|
|
||||||
{
|
|
||||||
region_x_local = __tX / 48 + *(_DWORD *)(world_base + 0x525C8);// tile_x / 48 + region_x
|
|
||||||
v12 = ((BYTE4(region_x_local) & 0xF) + (_DWORD)region_x_local) >> 4;
|
|
||||||
WORD2(region_x_local) = (_tY / 48 + *(_DWORD *)(world_base + 0x525CC)) / 16;// tile_y / 48 + region_y
|
|
||||||
v9 = v12;
|
|
||||||
_tX = SWORD2(region_x_local);
|
|
||||||
v10 = *(_DWORD *)(*(_DWORD *)(*(_DWORD *)(world_base + 0x54440) + 4 * (v9 >> 4))
|
|
||||||
+ 16 * (SWORD2(region_x_local) >> 4)
|
|
||||||
+ 4);
|
|
||||||
if ( v10 )
|
|
||||||
{
|
|
||||||
_tX %= 16;
|
|
||||||
v14 = v10 + 24 * ((signed __int16)_tX + 16 * v9 % 16);
|
|
||||||
v13 = *(_WORD *)(block + 0x2C);
|
|
||||||
if ( v13 >= 0 )
|
|
||||||
{
|
|
||||||
_tX = (*(_DWORD *)(v14 + 16) - *(_DWORD *)(v14 + 12)) >> 2;
|
|
||||||
if ( v13 < (unsigned int)_tX )
|
|
||||||
return *(_DWORD *)sub_519100(_tX, v10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
designation = _designation;
|
|
||||||
}
|
|
||||||
if ( designation & 0x20000000 && (some_stuff = *(_DWORD *)(block + 0x30), some_stuff != -1) )// second feature_present bit - slade and hell
|
|
||||||
{
|
|
||||||
v17 = (*(_DWORD *)(world_base + 0x54384) - *(_DWORD *)(world_base + 0x54380)) >> 2;
|
|
||||||
if ( some_stuff >= v17 )
|
|
||||||
_invalid_parameter_noinfo(_tX, v17);
|
|
||||||
result = *(_DWORD *)(*(_DWORD *)(*(_DWORD *)(world_base + 0x54380) + 4 * some_stuff) + 0x100);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LABEL_17:
|
|
||||||
result = 0;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
int main (int numargs, const char ** args)
|
|
||||||
{
|
|
||||||
DFHack::API DF("Memory.xml");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DF.Attach();
|
|
||||||
}
|
|
||||||
catch (exception& e)
|
|
||||||
{
|
|
||||||
cerr << e.what() << endl;
|
|
||||||
#ifndef LINUX_BUILD
|
|
||||||
cin.ignore();
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DFHack::Position *Pos = DF.getPosition();
|
|
||||||
DFHack::memory_info* mem = DF.getMemoryInfo();
|
|
||||||
DFHack::Maps *Maps = DF.getMaps();
|
|
||||||
DFHack::Process * p = DF.getProcess();
|
|
||||||
uint32_t designatus = mem->getOffset("map_data_designation");
|
|
||||||
uint32_t block_feature1 = mem->getOffset("map_data_feature_local");
|
|
||||||
uint32_t block_feature2 = mem->getOffset("map_data_feature_global");
|
|
||||||
uint32_t region_x_offset = mem->getAddress("region_x");
|
|
||||||
uint32_t region_y_offset = mem->getAddress("region_y");
|
|
||||||
uint32_t region_z_offset = mem->getAddress("region_z");
|
|
||||||
uint32_t feature1_start_ptr = mem->getAddress("local_feature_start_ptr");
|
|
||||||
int32_t regionX, regionY, regionZ;
|
|
||||||
|
|
||||||
// read position of the region inside DF world
|
|
||||||
p->readDWord (region_x_offset, (uint32_t &)regionX);
|
|
||||||
p->readDWord (region_y_offset, (uint32_t &)regionY);
|
|
||||||
p->readDWord (region_z_offset, (uint32_t &)regionZ);
|
|
||||||
|
|
||||||
Maps->Start();
|
|
||||||
|
|
||||||
int32_t cursorX, cursorY, cursorZ;
|
|
||||||
Pos->getCursorCoords(cursorX,cursorY,cursorZ);
|
|
||||||
if(cursorX != -30000)
|
|
||||||
{
|
|
||||||
uint32_t blockX = cursorX / 16;
|
|
||||||
uint32_t tileX = cursorX % 16;
|
|
||||||
uint32_t blockY = cursorY / 16;
|
|
||||||
uint32_t tileY = cursorY % 16;
|
|
||||||
t_temperatures tmpb1, tmpb2;
|
|
||||||
mapblock40d block;
|
|
||||||
if(Maps->ReadBlock40d(blockX,blockY,cursorZ,&block))
|
|
||||||
{
|
|
||||||
Maps->ReadTemperatures(blockX,blockY,cursorZ,&tmpb1, &tmpb2);
|
|
||||||
printf("block addr: 0x%x\n", block.origin);
|
|
||||||
int16_t tiletype = block.tiletypes[tileX][tileY];
|
|
||||||
naked_designation &des = block.designation[tileX][tileY].bits;
|
|
||||||
uint32_t &desw = block.designation[tileX][tileY].whole;
|
|
||||||
print_bits<uint32_t>(block.designation[tileX][tileY].whole,cout);
|
|
||||||
cout << endl;
|
|
||||||
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,cout);
|
|
||||||
cout << endl;
|
|
||||||
|
|
||||||
// tiletype
|
|
||||||
cout <<"tiletype: " << tiletype;
|
|
||||||
if(tileTypeTable[tiletype].name)
|
|
||||||
cout << " = " << tileTypeTable[tiletype].name;
|
|
||||||
cout << endl;
|
|
||||||
|
|
||||||
|
|
||||||
cout <<"temperature1: " << tmpb1[tileX][tileY] << " U" << endl;
|
|
||||||
cout <<"temperature2: " << tmpb2[tileX][tileY] << " U" << endl;
|
|
||||||
|
|
||||||
// biome, geolayer
|
|
||||||
cout << "biome: " << des.biome << endl;
|
|
||||||
cout << "geolayer: " << des.geolayer_index << endl;
|
|
||||||
// liquids
|
|
||||||
if(des.flow_size)
|
|
||||||
{
|
|
||||||
if(des.liquid_type == DFHack::liquid_magma)
|
|
||||||
cout <<"magma: ";
|
|
||||||
else cout <<"water: ";
|
|
||||||
cout << des.flow_size << endl;
|
|
||||||
}
|
|
||||||
if(des.flow_forbid)
|
|
||||||
cout << "flow forbid" << endl;
|
|
||||||
if(des.pile)
|
|
||||||
cout << "stockpile?" << endl;
|
|
||||||
if(des.rained)
|
|
||||||
cout << "rained?" << endl;
|
|
||||||
if(des.smooth)
|
|
||||||
cout << "smooth?" << endl;
|
|
||||||
uint32_t designato = block.origin + designatus + (tileX * 16 + tileY) * sizeof(t_designation);
|
|
||||||
printf("designation offset: 0x%x\n", designato);
|
|
||||||
if(des.light)
|
|
||||||
cout << "L";
|
|
||||||
else
|
|
||||||
cout << " ";
|
|
||||||
if(des.skyview)
|
|
||||||
cout << "S";
|
|
||||||
else
|
|
||||||
cout << " ";
|
|
||||||
if(des.subterranean)
|
|
||||||
cout << "U";
|
|
||||||
else
|
|
||||||
cout << " ";
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifndef LINUX_BUILD
|
|
||||||
cout << "Done. Press any key to continue" << endl;
|
|
||||||
cin.ignore();
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -0,0 +1,225 @@
|
|||||||
|
# don't use this file directly. use the one in the root folder of the project
|
||||||
|
PROJECT (dfhack-library)
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
|
||||||
|
|
||||||
|
# disable warning, autosearch
|
||||||
|
if(COMMAND cmake_policy)
|
||||||
|
cmake_policy(SET CMP0003 NEW)
|
||||||
|
endif(COMMAND cmake_policy)
|
||||||
|
|
||||||
|
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||||
|
message(SEND_ERROR "In-source builds are not allowed.")
|
||||||
|
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||||
|
|
||||||
|
IF(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||||
|
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
|
||||||
|
ENDIF(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
|
SET( LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack library" )
|
||||||
|
SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack tools" )
|
||||||
|
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/library/include/)
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/library/shm/)
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/library/depends/md5/)
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/library/depends/tinyxml/)
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/)
|
||||||
|
include_directories (${CMAKE_SOURCE_DIR}/library/private/)
|
||||||
|
|
||||||
|
SET(PROJECT_HDRS
|
||||||
|
include/dfhack/DFError.h
|
||||||
|
include/dfhack/DFMemInfo.h
|
||||||
|
include/dfhack/DFMemInfoManager.h
|
||||||
|
include/dfhack/DFProcessEnumerator.h
|
||||||
|
include/dfhack/DFProcess.h
|
||||||
|
include/dfhack/DFTileTypes.h
|
||||||
|
include/dfhack/DFTypes.h
|
||||||
|
include/dfhack/DFVector.h
|
||||||
|
include/dfhack-c/DFTypes_C.h
|
||||||
|
include/dfhack-c/DFContext_C.h
|
||||||
|
include/dfhack/DFIntegers.h
|
||||||
|
include/dfhack/modules/Buildings.h
|
||||||
|
include/dfhack/modules/Constructions.h
|
||||||
|
include/dfhack/modules/Creatures.h
|
||||||
|
include/dfhack/modules/Gui.h
|
||||||
|
include/dfhack/modules/Items.h
|
||||||
|
include/dfhack/modules/Maps.h
|
||||||
|
include/dfhack/modules/Materials.h
|
||||||
|
include/dfhack/modules/Position.h
|
||||||
|
include/dfhack/modules/Translation.h
|
||||||
|
include/dfhack/modules/Vegetation.h
|
||||||
|
include/dfhack/modules/WindowIO.h
|
||||||
|
include/dfhack/modules/World.h
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_SRCS
|
||||||
|
DFMemInfo.cpp
|
||||||
|
DFMemInfoManager.cpp
|
||||||
|
DFContextManager.cpp
|
||||||
|
DFContext.cpp
|
||||||
|
ContextShared.cpp
|
||||||
|
DFContext_C.cpp
|
||||||
|
DFTypes_C.cpp
|
||||||
|
|
||||||
|
depends/md5/md5.cpp
|
||||||
|
depends/md5/md5wrapper.cpp
|
||||||
|
|
||||||
|
depends/tinyxml/tinystr.cpp
|
||||||
|
depends/tinyxml/tinyxml.cpp
|
||||||
|
depends/tinyxml/tinyxmlerror.cpp
|
||||||
|
depends/tinyxml/tinyxmlparser.cpp
|
||||||
|
|
||||||
|
modules/Buildings.cpp
|
||||||
|
modules/Constructions.cpp
|
||||||
|
modules/Creatures.cpp
|
||||||
|
modules/Gui.cpp
|
||||||
|
modules/Items.cpp
|
||||||
|
modules/Maps.cpp
|
||||||
|
modules/Materials.cpp
|
||||||
|
modules/Position.cpp
|
||||||
|
modules/Translation.cpp
|
||||||
|
modules/Vegetation.cpp
|
||||||
|
modules/World.cpp
|
||||||
|
|
||||||
|
modules/Buildings_C.cpp
|
||||||
|
modules/Constructions_C.cpp
|
||||||
|
modules/Creatures_C.cpp
|
||||||
|
modules/Gui_C.cpp
|
||||||
|
modules/Items_C.cpp
|
||||||
|
modules/Maps_C.cpp
|
||||||
|
modules/Position_C.cpp
|
||||||
|
modules/Materials_C.cpp
|
||||||
|
modules/Translation_C.cpp
|
||||||
|
modules/Vegetation_C.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_HDRS_LINUX
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_HDRS_WINDOWS
|
||||||
|
include/dfhack/DFstdint_win.h
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_SRCS_LINUX
|
||||||
|
DFProcess-linux.cpp
|
||||||
|
DFProcess-linux-SHM.cpp
|
||||||
|
DFProcess-linux-wine.cpp
|
||||||
|
modules/WindowIO-linux.cpp
|
||||||
|
DFProcessEnumerator-linux.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_SRCS_WINDOWS
|
||||||
|
DFProcess-windows.cpp
|
||||||
|
DFProcess-windows-SHM.cpp
|
||||||
|
modules/WindowIO-windows.cpp
|
||||||
|
DFProcessEnumerator-windows.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_LINUX})
|
||||||
|
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_LINUX})
|
||||||
|
ELSE(UNIX)
|
||||||
|
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_WINDOWS})
|
||||||
|
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_WINDOWS})
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
|
||||||
|
|
||||||
|
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
|
||||||
|
|
||||||
|
SET( MEMXML_DATA_PATH . CACHE PATH "search path for Memory.xml")
|
||||||
|
# OPTION( VARIABLE "Description" Initial state)
|
||||||
|
#OPTION( WITH_FOO "Enable FOO support" ON )
|
||||||
|
#OPTION( WITH_BAR "Enable BAR component" OFF )
|
||||||
|
|
||||||
|
# Are we 64bit? (Damn you, ptrace()!)
|
||||||
|
IF( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
||||||
|
SET( HAVE_64_BIT 0 )
|
||||||
|
ELSE( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
||||||
|
SET( HAVE_64_BIT 1 )
|
||||||
|
ENDIF( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
||||||
|
|
||||||
|
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/library/config.h.cmake ${CMAKE_SOURCE_DIR}/library/private/config.h )
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DBUILD_DFHACK_LIB)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
add_definitions(-DLINUX_BUILD)
|
||||||
|
add_definitions(-DUSE_CONFIG_H)
|
||||||
|
find_library(X11_LIBRARY X11)
|
||||||
|
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
|
||||||
|
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden")
|
||||||
|
|
||||||
|
SET(PROJECT_LIBS ${X11_LIBRARY} rt ) #dfhack-md5 dfhack-tixml
|
||||||
|
ELSE(UNIX)
|
||||||
|
SET(PROJECT_LIBS psapi)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
ADD_LIBRARY(dfhack SHARED ${PROJECT_SRCS})
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS})
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
install(TARGETS dfhack LIBRARY DESTINATION lib)
|
||||||
|
install(FILES ${CMAKE_SOURCE_DIR}/output/Memory.xml DESTINATION share/dfhack)
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# DFCONNECT
|
||||||
|
###
|
||||||
|
|
||||||
|
SET(DFCONNECT_HDRS
|
||||||
|
shm/shms.h
|
||||||
|
shm/mod-core.h
|
||||||
|
shm/mod-maps.h
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_SRCS
|
||||||
|
shm/mod-core.cpp
|
||||||
|
shm/mod-maps.cpp
|
||||||
|
#mod-creature40d.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_HDRS_LINUX
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_HDRS_WINDOWS
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_SRCS_LINUX
|
||||||
|
shm/shms-linux.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(PROJECT_SRCS_WINDOWS
|
||||||
|
shm/shms-windows.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
IF(UNIX)
|
||||||
|
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_LINUX})
|
||||||
|
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_LINUX})
|
||||||
|
ELSE(UNIX)
|
||||||
|
LIST(APPEND PROJECT_HDRS ${PROJECT_HDRS_WINDOWS})
|
||||||
|
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_WINDOWS})
|
||||||
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
|
||||||
|
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
|
||||||
|
|
||||||
|
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
|
||||||
|
|
||||||
|
#IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
IF(UNIX)
|
||||||
|
add_definitions(-DLINUX_BUILD)
|
||||||
|
SET(PROJECT_LIBS rt)
|
||||||
|
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden")
|
||||||
|
ADD_LIBRARY(dfconnect SHARED ${PROJECT_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(dfconnect ${PROJECT_LIBS})
|
||||||
|
ELSE(UNIX)
|
||||||
|
# SET(PROJECT_LIBS psapi)
|
||||||
|
ADD_LIBRARY(SDL SHARED ${PROJECT_SRCS})
|
||||||
|
TARGET_LINK_LIBRARIES(SDL ${PROJECT_LIBS})
|
||||||
|
ENDIF(UNIX)
|
||||||
|
#ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
|
@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Internal.h"
|
||||||
|
|
||||||
|
#include "dfhack/DFProcess.h"
|
||||||
|
#include "dfhack/DFProcessEnumerator.h"
|
||||||
|
#include "dfhack/DFMemInfoManager.h"
|
||||||
|
#include "dfhack/DFError.h"
|
||||||
|
|
||||||
|
#include "dfhack/DFContext.h"
|
||||||
|
#include "dfhack/DFContextManager.h"
|
||||||
|
|
||||||
|
#include <shms.h>
|
||||||
|
#include <mod-core.h>
|
||||||
|
#include <mod-maps.h>
|
||||||
|
#include <mod-creature40d.h>
|
||||||
|
#include "private/ContextShared.h"
|
||||||
|
|
||||||
|
using namespace DFHack;
|
||||||
|
namespace DFHack
|
||||||
|
{
|
||||||
|
class DFContextMgrPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DFContextMgrPrivate(){};
|
||||||
|
~DFContextMgrPrivate(){};
|
||||||
|
string xml; // path to xml
|
||||||
|
vector <Context *> contexts;
|
||||||
|
ProcessEnumerator * pEnum;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextManager::ContextManager (const string path_to_xml) : d (new DFContextMgrPrivate())
|
||||||
|
{
|
||||||
|
d->pEnum = 0;
|
||||||
|
d->xml = QUOT (MEMXML_DATA_PATH);
|
||||||
|
d->xml += "/";
|
||||||
|
d->xml += path_to_xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextManager::~ContextManager()
|
||||||
|
{
|
||||||
|
purge();
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ContextManager::Refresh()
|
||||||
|
{
|
||||||
|
purge();
|
||||||
|
if(d->pEnum != 0)
|
||||||
|
d->pEnum = new ProcessEnumerator(d->xml);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete d->pEnum;
|
||||||
|
d->pEnum = new ProcessEnumerator(d->xml);
|
||||||
|
}
|
||||||
|
d->pEnum->purge();
|
||||||
|
d->pEnum->findProcessess();
|
||||||
|
int numProcesses = d->pEnum->size();
|
||||||
|
for(int i = 0; i < numProcesses; i++)
|
||||||
|
{
|
||||||
|
Context * c = new Context(d->pEnum->operator[](i));
|
||||||
|
d->contexts.push_back(c);
|
||||||
|
}
|
||||||
|
return d->contexts.size();
|
||||||
|
}
|
||||||
|
uint32_t ContextManager::size()
|
||||||
|
{
|
||||||
|
return d->contexts.size();
|
||||||
|
}
|
||||||
|
Context * ContextManager::operator[](uint32_t index)
|
||||||
|
{
|
||||||
|
if (index < d->contexts.size())
|
||||||
|
return d->contexts[index];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Context * ContextManager::getSingleContext()
|
||||||
|
{
|
||||||
|
if(!d->contexts.size())
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
for(int i = 0; i < d->contexts.size();i++)
|
||||||
|
{
|
||||||
|
if(d->contexts[i]->isValid())
|
||||||
|
{
|
||||||
|
return d->contexts[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw DFHack::Error::NoProcess();
|
||||||
|
}
|
||||||
|
void ContextManager::purge(void)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < d->contexts.size();i++)
|
||||||
|
delete d->contexts[i];
|
||||||
|
d->contexts.clear();
|
||||||
|
// process enumerator has to be destroyed after we detach from processes
|
||||||
|
// because it tracks and destroys them
|
||||||
|
if(d->pEnum)
|
||||||
|
{
|
||||||
|
delete d->pEnum;
|
||||||
|
d->pEnum = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,367 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/dfhack
|
||||||
|
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dfhack/DFPragma.h"
|
||||||
|
#include "dfhack/DFExport.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include "dfhack/DFIntegers.h"
|
||||||
|
#include "dfhack/DFTileTypes.h"
|
||||||
|
#include "dfhack/DFTypes.h"
|
||||||
|
//#include "dfhack/modules/WindowIO.h"
|
||||||
|
#include "dfhack/DFContextManager.h"
|
||||||
|
#include "dfhack/DFContext.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace DFHack;
|
||||||
|
|
||||||
|
#include "dfhack-c/DFContext_C.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DFHackObject* ContextManager_Alloc(const char* path_to_xml)
|
||||||
|
{
|
||||||
|
DFHack::ContextManager* contextMgr = new DFHack::ContextManager(std::string(path_to_xml));
|
||||||
|
return (DFHackObject*)contextMgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIXME: X:\dfhack\DFHackContext_C.cpp:56: warning: deleting `DFHackObject* ' is undefined
|
||||||
|
//DC: Yeah, I forgot that trying to delete a void pointer might be a bad idea. This works now.
|
||||||
|
void ContextManager_Free(DFHackObject* contextMgr)
|
||||||
|
{
|
||||||
|
if(contextMgr != NULL)
|
||||||
|
{
|
||||||
|
DFHack::ContextManager* a = (DFHack::ContextManager*)contextMgr;
|
||||||
|
delete a;
|
||||||
|
|
||||||
|
contextMgr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ContextManager_Refresh(DFHackObject* contextMgr)
|
||||||
|
{
|
||||||
|
if(contextMgr != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::ContextManager*)contextMgr)->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ContextManager_size(DFHackObject* contextMgr, uint32_t* size)
|
||||||
|
{
|
||||||
|
if(contextMgr != NULL)
|
||||||
|
{
|
||||||
|
uint32_t result = ((DFHack::ContextManager*)contextMgr)->size();
|
||||||
|
|
||||||
|
*size = result;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ContextManager_purge(DFHackObject* contextMgr)
|
||||||
|
{
|
||||||
|
if(contextMgr != NULL)
|
||||||
|
{
|
||||||
|
((DFHack::ContextManager*)contextMgr)->purge();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* ContextManager_getContext(DFHackObject* contextMgr, uint32_t index)
|
||||||
|
{
|
||||||
|
if(contextMgr != NULL)
|
||||||
|
{
|
||||||
|
DFHack::ContextManager* mgr = ((DFHack::ContextManager*)contextMgr);
|
||||||
|
|
||||||
|
if(index >= mgr->size())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return (DFHackObject*)((DFHack::Context*)((*mgr)[index]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* ContextManager_getSingleContext(DFHackObject* contextMgr)
|
||||||
|
{
|
||||||
|
if(contextMgr != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::ContextManager*)contextMgr)->getSingleContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context_Free(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
DFHack::Context* c = (DFHack::Context*)context;
|
||||||
|
delete c;
|
||||||
|
|
||||||
|
context = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_Attach(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->Attach();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_Detach(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->Detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_isAttached(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->isAttached();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_Suspend(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->Suspend();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_Resume(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->Resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_isSuspended(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->isSuspended();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_ForceResume(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->ForceResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Context_AsyncSuspend(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return ((DFHack::Context*)context)->AsyncSuspend();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//module getters
|
||||||
|
|
||||||
|
DFHackObject* Context_getMemoryInfo(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getMemoryInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getProcess(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getWindow(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getCreatures(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getCreatures();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getMaps(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getMaps();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getGui(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getPosition(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getMaterials(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getMaterials();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getTranslation(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getTranslation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getVegetation(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getVegetation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getBuildings(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getBuildings();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getConstructions(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getConstructions();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DFHackObject* Context_getItems(DFHackObject* context)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
return (DFHackObject*)((DFHack::Context*)context)->getItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context_ReadRaw(DFHackObject* context, const uint32_t offset, const uint32_t size, uint8_t* target)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
((DFHack::Context*)context)->ReadRaw(offset, size, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context_WriteRaw(DFHackObject* context, const uint32_t offset, const uint32_t size, uint8_t* source)
|
||||||
|
{
|
||||||
|
if(context != NULL)
|
||||||
|
{
|
||||||
|
((DFHack::Context*)context)->WriteRaw(offset, size, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/dfhack
|
||||||
|
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dfhack/DFIntegers.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "string.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#include "Internal.h"
|
||||||
|
#include "dfhack/DFTypes.h"
|
||||||
|
#include "dfhack-c/DFTypes_C.h"
|
||||||
|
#include "dfhack/modules/Materials.h"
|
||||||
|
|
||||||
|
using namespace DFHack;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int8_t* (*alloc_byte_buffer_callback)(uint32_t) = NULL;
|
||||||
|
int16_t* (*alloc_short_buffer_callback)(uint32_t) = NULL;
|
||||||
|
int32_t* (*alloc_int_buffer_callback)(uint32_t) = NULL;
|
||||||
|
|
||||||
|
uint8_t* (*alloc_ubyte_buffer_callback)(uint32_t) = NULL;
|
||||||
|
uint16_t* (*alloc_ushort_buffer_callback)(uint32_t) = NULL;
|
||||||
|
uint32_t* (*alloc_uint_buffer_callback)(uint32_t) = NULL;
|
||||||
|
|
||||||
|
char* (*alloc_char_buffer_callback)(uint32_t) = NULL;
|
||||||
|
|
||||||
|
t_matgloss* (*alloc_matgloss_buffer_callback)(int) = NULL;
|
||||||
|
t_descriptor_color* (*alloc_descriptor_buffer_callback)(int) = NULL;
|
||||||
|
t_matglossOther* (*alloc_matgloss_other_buffer_callback)(int) = NULL;
|
||||||
|
|
||||||
|
c_colormodifier* (*alloc_empty_colormodifier_callback)(void) = NULL;
|
||||||
|
c_colormodifier* (*alloc_colormodifier_callback)(const char*, uint32_t) = NULL;
|
||||||
|
c_colormodifier* (*alloc_colormodifier_buffer_callback)(uint32_t) = NULL;
|
||||||
|
|
||||||
|
c_creaturecaste* (*alloc_empty_creaturecaste_callback)(void) = NULL;
|
||||||
|
c_creaturecaste* (*alloc_creaturecaste_callback)(const char*, const char*, const char*, const char*, uint32_t, uint32_t) = NULL;
|
||||||
|
c_creaturecaste* (*alloc_creaturecaste_buffer_callback)(uint32_t) = NULL;
|
||||||
|
|
||||||
|
c_creaturetype* (*alloc_empty_creaturetype_callback)(void) = NULL;
|
||||||
|
c_creaturetype* (*alloc_creaturetype_callback)(const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t) = NULL;
|
||||||
|
c_creaturetype* (*alloc_creaturetype_buffer_callback)(uint32_t) = NULL;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int ColorListConvert(t_colormodifier* src, c_colormodifier* dest)
|
||||||
|
{
|
||||||
|
if(src == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dest = ((*alloc_colormodifier_callback)(src->part, src->colorlist.size()));
|
||||||
|
|
||||||
|
copy(src->colorlist.begin(), src->colorlist.end(), dest->colorlist);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CreatureCasteConvert(t_creaturecaste* src, c_creaturecaste* dest)
|
||||||
|
{
|
||||||
|
if(src == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dest = ((*alloc_creaturecaste_callback)(src->rawname, src->singular, src->plural, src->adjective, src->ColorModifier.size(), src->bodypart.size()));
|
||||||
|
|
||||||
|
for(int i = 0; i < dest->colorModifierLength; i++)
|
||||||
|
ColorListConvert(&src->ColorModifier[i], &dest->ColorModifier[i]);
|
||||||
|
|
||||||
|
copy(src->bodypart.begin(), src->bodypart.end(), dest->bodypart);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CreatureTypeConvert(t_creaturetype* src, c_creaturetype* dest)
|
||||||
|
{
|
||||||
|
if(src == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
dest = ((*alloc_creaturetype_callback)(src->rawname, src->castes.size(), src->extract.size(), src->tile_character, src->tilecolor.fore, src->tilecolor.back, src->tilecolor.bright));
|
||||||
|
|
||||||
|
for(int i = 0; i < dest->castesCount; i++)
|
||||||
|
CreatureCasteConvert(&src->castes[i], &dest->castes[i]);
|
||||||
|
|
||||||
|
copy(src->extract.begin(), src->extract.end(), dest->extract);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef DFHACK_API_H
|
||||||
|
#define DFHACK_API_H
|
||||||
|
|
||||||
|
#include "dfhack/DFIntegers.h"
|
||||||
|
#include "dfhack/DFGlobal.h"
|
||||||
|
#include "dfhack/DFError.h"
|
||||||
|
#include "dfhack/DFContextManager.h"
|
||||||
|
#include "dfhack/DFContext.h"
|
||||||
|
#include "dfhack/DFMemInfo.h"
|
||||||
|
#include "dfhack/DFProcess.h"
|
||||||
|
#include "dfhack/DFTypes.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "dfhack/modules/Buildings.h"
|
||||||
|
#include "dfhack/modules/Materials.h"
|
||||||
|
#include "dfhack/modules/Position.h"
|
||||||
|
#include "dfhack/modules/Constructions.h"
|
||||||
|
#include "dfhack/modules/Creatures.h"
|
||||||
|
#include "dfhack/modules/Translation.h"
|
||||||
|
#include "dfhack/modules/World.h"
|
||||||
|
#include "dfhack/modules/Items.h"
|
||||||
|
#include "dfhack/modules/Vegetation.h"
|
||||||
|
#include "dfhack/modules/Maps.h"
|
||||||
|
|
||||||
|
#include "dfhack/DFMiscUtils.h"
|
||||||
|
#endif
|
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/dfhack
|
||||||
|
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
||||||
|
|
||||||
|
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 DFHACK_C_CONTEXT
|
||||||
|
#define DFHACK_C_CONTEXT
|
||||||
|
|
||||||
|
#include "dfhack/DFExport.h"
|
||||||
|
#include "dfhack/DFIntegers.h"
|
||||||
|
|
||||||
|
typedef void DFHackObject;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DFHACK_EXPORT DFHackObject* ContextManager_Alloc(const char* path_to_xml);
|
||||||
|
DFHACK_EXPORT void ContextManager_Free(DFHackObject* contextMgr);
|
||||||
|
|
||||||
|
DFHACK_EXPORT int ContextManager_Refresh(DFHackObject* contextMgr);
|
||||||
|
DFHACK_EXPORT int ContextManager_size(DFHackObject* contextMgr, uint32_t* size);
|
||||||
|
DFHACK_EXPORT int ContextManager_purge(DFHackObject* contextMgr);
|
||||||
|
|
||||||
|
DFHACK_EXPORT DFHackObject* ContextManager_getContext(DFHackObject* contextMgr, uint32_t index);
|
||||||
|
DFHACK_EXPORT DFHackObject* ContextManager_getSingleContext(DFHackObject* contextMgr);
|
||||||
|
|
||||||
|
DFHACK_EXPORT void Context_Free(DFHackObject* context);
|
||||||
|
|
||||||
|
DFHACK_EXPORT int Context_Attach(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT int Context_Detach(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT int Context_isAttached(DFHackObject* context);
|
||||||
|
|
||||||
|
DFHACK_EXPORT int Context_Suspend(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT int Context_Resume(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT int Context_isSuspended(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT int Context_ForceResume(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT int Context_AsyncSuspend(DFHackObject* context);
|
||||||
|
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getMemoryInfo(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getProcess(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getWindow(DFHackObject* context);
|
||||||
|
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getCreatures(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getMaps(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getGui(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getPosition(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getMaterials(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getTranslation(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getVegetation(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getBuildings(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getConstructions(DFHackObject* context);
|
||||||
|
DFHACK_EXPORT DFHackObject* Context_getItems(DFHackObject* context);
|
||||||
|
|
||||||
|
//these are DANGEROUS...can crash/segfault DF, turn the seas to blood, call up the Antichrist, etc
|
||||||
|
DFHACK_EXPORT void Context_ReadRaw(DFHackObject* context, const uint32_t offset, const uint32_t size, uint8_t* target);
|
||||||
|
DFHACK_EXPORT void Context_WriteRaw(DFHackObject* context, const uint32_t offset, const uint32_t size, uint8_t* source);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/dfhack
|
||||||
|
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
|
||||||
|
|
||||||
|
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 TYPES_C_API
|
||||||
|
#define TYPES_C_API
|
||||||
|
|
||||||
|
#include "dfhack/DFExport.h"
|
||||||
|
#include "dfhack/DFIntegers.h"
|
||||||
|
#include "dfhack/DFTypes.h"
|
||||||
|
#include "dfhack/modules/Materials.h"
|
||||||
|
|
||||||
|
using namespace DFHack;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern int8_t* (*alloc_byte_buffer_callback)(uint32_t);
|
||||||
|
DFHACK_EXPORT extern int16_t* (*alloc_short_buffer_callback)(uint32_t);
|
||||||
|
DFHACK_EXPORT extern int32_t* (*alloc_int_buffer_callback)(uint32_t);
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern uint8_t* (*alloc_ubyte_buffer_callback)(uint32_t);
|
||||||
|
DFHACK_EXPORT extern uint16_t* (*alloc_ushort_buffer_callback)(uint32_t);
|
||||||
|
DFHACK_EXPORT extern uint32_t* (*alloc_uint_buffer_callback)(uint32_t);
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern char* (*alloc_char_buffer_callback)(uint32_t);
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern t_matgloss* (*alloc_matgloss_buffer_callback)(int);
|
||||||
|
DFHACK_EXPORT extern t_descriptor_color* (*alloc_descriptor_buffer_callback)(int);
|
||||||
|
DFHACK_EXPORT extern t_matglossOther* (*alloc_matgloss_other_buffer_callback)(int);
|
||||||
|
|
||||||
|
struct c_colormodifier
|
||||||
|
{
|
||||||
|
char part[128];
|
||||||
|
uint32_t* colorlist;
|
||||||
|
uint32_t colorlistLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern c_colormodifier* (*alloc_empty_colormodifier_callback)(void);
|
||||||
|
DFHACK_EXPORT extern c_colormodifier* (*alloc_colormodifier_callback)(const char*, uint32_t);
|
||||||
|
DFHACK_EXPORT extern c_colormodifier* (*alloc_colormodifier_buffer_callback)(uint32_t);
|
||||||
|
|
||||||
|
struct c_creaturecaste
|
||||||
|
{
|
||||||
|
char rawname[128];
|
||||||
|
char singular[128];
|
||||||
|
char plural[128];
|
||||||
|
char adjective[128];
|
||||||
|
|
||||||
|
c_colormodifier* ColorModifier;
|
||||||
|
uint32_t colorModifierLength;
|
||||||
|
|
||||||
|
t_bodypart* bodypart;
|
||||||
|
uint32_t bodypartLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern c_creaturecaste* (*alloc_empty_creaturecaste_callback)(void);
|
||||||
|
DFHACK_EXPORT extern c_creaturecaste* (*alloc_creaturecaste_callback)(const char*, const char*, const char*, const char*, uint32_t, uint32_t);
|
||||||
|
DFHACK_EXPORT extern c_creaturecaste* (*alloc_creaturecaste_buffer_callback)(uint32_t);
|
||||||
|
|
||||||
|
struct c_creaturetype
|
||||||
|
{
|
||||||
|
char rawname[128];
|
||||||
|
|
||||||
|
c_creaturecaste* castes;
|
||||||
|
uint32_t castesCount;
|
||||||
|
|
||||||
|
t_creatureextract* extract;
|
||||||
|
uint32_t extractCount;
|
||||||
|
|
||||||
|
uint8_t tile_character;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint16_t fore;
|
||||||
|
uint16_t back;
|
||||||
|
uint16_t bright;
|
||||||
|
} tilecolor;
|
||||||
|
};
|
||||||
|
|
||||||
|
DFHACK_EXPORT extern c_creaturetype* (*alloc_empty_creaturetype_callback)(void);
|
||||||
|
DFHACK_EXPORT extern c_creaturetype* (*alloc_creaturetype_callback)(const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t);
|
||||||
|
DFHACK_EXPORT extern c_creaturetype* (*alloc_creaturetype_buffer_callback)(uint32_t);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int CreatureTypeConvert(t_creaturetype* src, c_creaturetype* dest);
|
||||||
|
int CreatureCasteConvert(t_creaturecaste* src, c_creaturecaste* dest);
|
||||||
|
int ColorListConvert(t_colormodifier* src, c_colormodifier* dest);
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef DFHACK_GLOBAL
|
#ifndef DFHACK_GLOBAL
|
||||||
#define DFHACK_GLOBAL
|
#define DFHACK_GLOBAL
|
||||||
#include "Export.h"
|
#include "DFExport.h"
|
||||||
|
|
||||||
// globals, if any, should be placed here.
|
// globals, if any, should be placed here.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue