diff --git a/CMakeLists.txt b/CMakeLists.txt index 9acd2f2dc..e4dc7ab5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,16 +8,16 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) -if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message(SEND_ERROR "In-source builds are not allowed.") -endif("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") +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 ${dfhack_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack library" ) -SET( EXECUTABLE_OUTPUT_PATH ${dfhack_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack tools" ) +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/) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 4061c703c..ce44079cf 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -1,7 +1,32 @@ # 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/DFCommonInternal.h include/dfhack/DFError.h include/dfhack/DFMemInfo.h include/dfhack/DFMemInfoManager.h @@ -10,11 +35,21 @@ include/dfhack/DFProcess.h include/dfhack/DFTileTypes.h include/dfhack/DFTypes.h include/dfhack/DFVector.h -include/dfhack/DFWindow.h include/dfhack-c/DFTypes_C.h include/dfhack-c/DFContext_C.h include/dfhack/DFIntegers.h -shm/shms.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 @@ -22,9 +57,7 @@ DFMemInfo.cpp DFMemInfoManager.cpp DFContextManager.cpp DFContext.cpp -APIPrivate.cpp -DFTileTypes.cpp -DFVector.cpp +ContextShared.cpp DFContext_C.cpp DFTypes_C.cpp @@ -36,28 +69,28 @@ 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/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/World.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/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 @@ -71,14 +104,14 @@ SET(PROJECT_SRCS_LINUX DFProcess-linux.cpp DFProcess-linux-SHM.cpp DFProcess-linux-wine.cpp -DFWindow-linux.cpp +modules/WindowIO-linux.cpp DFProcessEnumerator-linux.cpp ) SET(PROJECT_SRCS_WINDOWS DFProcess-windows.cpp DFProcess-windows-SHM.cpp -DFWindow-windows.cpp +modules/WindowIO-windows.cpp DFProcessEnumerator-windows.cpp ) @@ -106,7 +139,7 @@ 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/include/config.h ) +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/library/config.h.cmake ${CMAKE_SOURCE_DIR}/library/private/config.h ) ADD_DEFINITIONS(-DBUILD_DFHACK_LIB) diff --git a/library/APIPrivate.cpp b/library/ContextShared.cpp similarity index 84% rename from library/APIPrivate.cpp rename to library/ContextShared.cpp index 768f5bd9e..c25fecc90 100644 --- a/library/APIPrivate.cpp +++ b/library/ContextShared.cpp @@ -1,9 +1,9 @@ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include #include #include #include -#include "private/APIPrivate.h" +#include "private/ContextShared.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -20,7 +20,7 @@ using namespace DFHack; -DFContextPrivate::DFContextPrivate() +DFContextShared::DFContextShared() { // init modules creatures = 0; @@ -34,9 +34,10 @@ DFContextPrivate::DFContextPrivate() buildings = 0; constructions = 0; items = 0; + windowio = 0; } -DFContextPrivate::~DFContextPrivate() +DFContextShared::~DFContextShared() { if(creatures) delete creatures; if(maps) delete maps; @@ -48,9 +49,10 @@ DFContextPrivate::~DFContextPrivate() if(buildings) delete buildings; if(constructions) delete constructions; if(world) delete world; + if(windowio) delete windowio; } -bool DFContextPrivate::InitReadNames() +bool DFContextShared::InitReadNames() { name_firstname_offset = offset_descriptor->getOffset("name_firstname"); name_nickname_offset = offset_descriptor->getOffset("name_nickname"); @@ -58,7 +60,7 @@ bool DFContextPrivate::InitReadNames() return true; } -void DFContextPrivate::readName(t_name & name, uint32_t address) +void DFContextShared::readName(t_name & name, uint32_t address) { p->readSTLString(address + name_firstname_offset , name.first_name, 128); p->readSTLString(address + name_nickname_offset , name.nickname, 128); diff --git a/library/DFContext.cpp b/library/DFContext.cpp index 2b339ebed..fe2d5002e 100644 --- a/library/DFContext.cpp +++ b/library/DFContext.cpp @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" #include "dfhack/DFProcessEnumerator.h" @@ -34,7 +34,7 @@ distribution. #include #include #include -#include "private/APIPrivate.h" +#include "private/ContextShared.h" #include "dfhack/modules/Maps.h" #include "dfhack/modules/Materials.h" @@ -47,10 +47,11 @@ distribution. #include "dfhack/modules/Vegetation.h" #include "dfhack/modules/Buildings.h" #include "dfhack/modules/Constructions.h" +#include "dfhack/modules/WindowIO.h" using namespace DFHack; -Context::Context (Process* p) : d (new DFContextPrivate()) +Context::Context (Process* p) : d (new DFContextShared()) { d->p = p; d->offset_descriptor = p->getDescriptor(); @@ -191,16 +192,12 @@ memory_info *Context::getMemoryInfo() { return d->offset_descriptor; } + Process * Context::getProcess() { return d->p; } -DFWindow * Context::getWindow() -{ - return d->p->getWindow(); -} - /******************************************************************************* M O D U L E S *******************************************************************************/ @@ -225,6 +222,13 @@ Gui * Context::getGui() return d->gui; } +WindowIO * Context::getWindow() +{ + if(!d->windowio) + d->windowio = new WindowIO(d); + return d->windowio; +} + World * Context::getWorld() { if(!d->world) diff --git a/library/DFContextManager.cpp b/library/DFContextManager.cpp index 30494fd7d..636325bdc 100644 --- a/library/DFContextManager.cpp +++ b/library/DFContextManager.cpp @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" #include "dfhack/DFProcessEnumerator.h" @@ -36,7 +36,7 @@ distribution. #include #include #include -#include "private/APIPrivate.h" +#include "private/ContextShared.h" using namespace DFHack; namespace DFHack diff --git a/library/DFContext_C.cpp b/library/DFContext_C.cpp index 2e9212194..3de599df0 100644 --- a/library/DFContext_C.cpp +++ b/library/DFContext_C.cpp @@ -30,7 +30,7 @@ distribution. #include "dfhack/DFIntegers.h" #include "dfhack/DFTileTypes.h" #include "dfhack/DFTypes.h" -#include "dfhack/DFWindow.h" +//#include "dfhack/modules/WindowIO.h" #include "dfhack/DFContextManager.h" #include "dfhack/DFContext.h" diff --git a/library/DFHackAPI.cpp b/library/DFHackAPI.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/library/DFHackAPI_C.cpp b/library/DFHackAPI_C.cpp deleted file mode 100644 index bf025add8..000000000 --- a/library/DFHackAPI_C.cpp +++ /dev/null @@ -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 "DFPragma.h" -#include "DFExport.h" -#include -#include -#include -#include "DFIntegers.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::ContextManager* api = new DFHack::ContextManager(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::ContextManager* a = (DFHack::ContextManager*)api; - delete a; - - api = NULL; - } -} - -int API_Attach(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->Attach(); - } - return -1; -} - -int API_Detach(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->Detach(); - } - - return -1; -} - -int API_isAttached(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->isAttached(); - } - - return -1; -} - -int API_Suspend(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->Suspend(); - } - - return -1; -} - -int API_Resume(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->Resume(); - } - - return -1; -} - -int API_isSuspended(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->isSuspended(); - } - - return -1; -} - -int API_ForceResume(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->ForceResume(); - } - - return -1; -} - -int API_AsyncSuspend(DFHackObject* api) -{ - if(api != NULL) - { - return ((DFHack::ContextManager*)api)->AsyncSuspend(); - } - - return -1; -} - -//module getters - -DFHackObject* API_getMemoryInfo(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getMemoryInfo(); - } - - return NULL; -} - -DFHackObject* API_getProcess(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getProcess(); - } - - return NULL; -} - -DFHackObject* API_getWindow(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getWindow(); - } - - return NULL; -} - -DFHackObject* API_getCreatures(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getCreatures(); - } - - return NULL; -} - -DFHackObject* API_getMaps(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getMaps(); - } - - return NULL; -} - -DFHackObject* API_getGui(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getGui(); - } - - return NULL; -} - -DFHackObject* API_getPosition(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getPosition(); - } - - return NULL; -} - -DFHackObject* API_getMaterials(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getMaterials(); - } - - return NULL; -} - -DFHackObject* API_getTranslation(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getTranslation(); - } - - return NULL; -} - -DFHackObject* API_getVegetation(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getVegetation(); - } - - return NULL; -} - -DFHackObject* API_getBuildings(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getBuildings(); - } - - return NULL; -} - -DFHackObject* API_getConstructions(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getConstructions(); - } - - return NULL; -} - -DFHackObject* API_getItems(DFHackObject* api) -{ - if(api != NULL) - { - return (DFHackObject*)((DFHack::ContextManager*)api)->getItems(); - } - - return NULL; -} - -void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target) -{ - if(api != NULL) - { - ((DFHack::ContextManager*)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::ContextManager*)api)->WriteRaw(offset, size, source); - } -} - -#ifdef __cplusplus -} -#endif diff --git a/library/DFMemInfo.cpp b/library/DFMemInfo.cpp index ca589116f..8ac0a2c94 100644 --- a/library/DFMemInfo.cpp +++ b/library/DFMemInfo.cpp @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFError.h" #include "dfhack/DFProcess.h" diff --git a/library/DFMemInfoManager.cpp b/library/DFMemInfoManager.cpp index d2e612821..4b7f537e0 100644 --- a/library/DFMemInfoManager.cpp +++ b/library/DFMemInfoManager.cpp @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFMemInfoManager.h" #include "dfhack/DFError.h" diff --git a/library/DFProcess-linux-SHM.cpp b/library/DFProcess-linux-SHM.cpp index b5e5b5cf0..7ee235a74 100644 --- a/library/DFProcess-linux-SHM.cpp +++ b/library/DFProcess-linux-SHM.cpp @@ -21,9 +21,8 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" -#include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFError.h" @@ -53,7 +52,6 @@ class SHMProcess::Private shm_addr = 0; //shm_addr_with_cl_idx = 0; shm_ID = -1; - window = NULL; attached = false; identified = false; useYield = false; @@ -66,7 +64,6 @@ class SHMProcess::Private }; ~Private(){}; memory_info * memdescriptor; - DFWindow * window; Process * self; pid_t process_ID; char *shm_addr; @@ -76,16 +73,14 @@ class SHMProcess::Private int client_lock; int suspend_lock; int attachmentIdx; - - bool attached; bool locked; bool identified; bool useYield; - + bool validate(std::vector< memory_info* >& known_versions); - + bool Aux_Core_Attach(bool & versionOK, pid_t & PID); //bool waitWhile (uint32_t state); bool SetAndWait (uint32_t state); @@ -290,8 +285,6 @@ SHMProcess::SHMProcess(uint32_t PID, vector< memory_info* >& known_versions) // try to identify the DF version (md5 the binary, compare with known versions) d->validate(known_versions); - d->window = new DFWindow(this); - // detach detach(); } @@ -362,10 +355,6 @@ SHMProcess::~SHMProcess() } if(d->memdescriptor) delete d->memdescriptor; - if(d->window) - { - delete d->window; - } delete d; } @@ -374,11 +363,6 @@ memory_info * SHMProcess::getDescriptor() return d->memdescriptor; } -DFWindow * SHMProcess::getWindow() -{ - return d->window; -} - int SHMProcess::getPID() { return d->process_ID; diff --git a/library/DFProcess-linux-wine.cpp b/library/DFProcess-linux-wine.cpp index 6c370ab00..b9ef2339b 100644 --- a/library/DFProcess-linux-wine.cpp +++ b/library/DFProcess-linux-wine.cpp @@ -21,9 +21,8 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" -#include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFError.h" #include @@ -38,7 +37,6 @@ class WineProcess::Private { my_descriptor = NULL; my_handle = NULL; - my_window = NULL; my_pid = 0; attached = false; suspended = false; @@ -46,7 +44,6 @@ class WineProcess::Private self = self_; }; ~Private(){}; - DFWindow* my_window; memory_info * my_descriptor; Process * self; pid_t my_handle; @@ -108,7 +105,6 @@ WineProcess::WineProcess(uint32_t pid, vector & known_versions) // create wine process, add it to the vector d->identified = d->validate(exe_link,pid,mem_name,known_versions); - d->my_window = new DFWindow(this); return; } } @@ -174,8 +170,6 @@ WineProcess::~WineProcess() // destroy our copy of the memory descriptor if(d->my_descriptor) delete d->my_descriptor; - if(d->my_window) - delete d->my_window; delete d; } @@ -184,11 +178,6 @@ memory_info * WineProcess::getDescriptor() return d->my_descriptor; } -DFWindow * WineProcess::getWindow() -{ - return d->my_window; -} - int WineProcess::getPID() { return d->my_pid; @@ -513,7 +502,6 @@ void WineProcess::writeByte (uint32_t offset, uint8_t data) // blah. I hate the kernel devs for crippling /proc/PID/mem. THIS IS RIDICULOUS void WineProcess::write (uint32_t offset, uint32_t size, uint8_t *source) { - uint32_t count = 0; uint32_t indexptr = 0; while (size > 0) { diff --git a/library/DFProcess-linux.cpp b/library/DFProcess-linux.cpp index 5b0d14378..343985a3d 100644 --- a/library/DFProcess-linux.cpp +++ b/library/DFProcess-linux.cpp @@ -21,9 +21,8 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" -#include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFError.h" #include @@ -37,7 +36,6 @@ class NormalProcess::Private { my_descriptor = NULL; my_handle = NULL; - my_window = NULL; my_pid = 0; attached = false; suspended = false; @@ -45,7 +43,7 @@ class NormalProcess::Private self = self_; }; ~Private(){}; - DFWindow* my_window; + Window* my_window; memory_info * my_descriptor; pid_t my_handle; uint32_t my_pid; @@ -92,7 +90,6 @@ NormalProcess::NormalProcess(uint32_t pid, vector< memory_info* >& known_version { // create linux process, add it to the vector d->identified = d->validate(target_name,pid,mem_name,known_versions ); - d->my_window = new DFWindow(this); return; } } @@ -161,9 +158,6 @@ NormalProcess::~NormalProcess() // destroy our copy of the memory descriptor if(d->my_descriptor) delete d->my_descriptor; - // destroy data model. this is assigned by processmanager - if(d->my_window) - delete d->my_window; delete d; } @@ -172,11 +166,6 @@ memory_info * NormalProcess::getDescriptor() return d->my_descriptor; } -DFWindow * NormalProcess::getWindow() -{ - return d->my_window; -} - int NormalProcess::getPID() { return d->my_pid; @@ -498,7 +487,6 @@ void NormalProcess::writeByte (uint32_t offset, uint8_t data) // blah. I hate the kernel devs for crippling /proc/PID/mem. THIS IS RIDICULOUS void NormalProcess::write (uint32_t offset, uint32_t size, uint8_t *source) { - uint32_t count = 0; uint32_t indexptr = 0; while (size > 0) { diff --git a/library/DFProcess-windows-SHM.cpp b/library/DFProcess-windows-SHM.cpp index c86e045a1..6ecf28d4b 100644 --- a/library/DFProcess-windows-SHM.cpp +++ b/library/DFProcess-windows-SHM.cpp @@ -21,7 +21,7 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" #include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" @@ -39,7 +39,6 @@ class SHMProcess::Private memdescriptor = NULL; process_ID = 0; shm_addr = 0; - window = NULL; attached = false; locked = false; identified = false; @@ -51,7 +50,6 @@ class SHMProcess::Private }; ~Private(){}; memory_info * memdescriptor; - DFWindow * window; SHMProcess * self; uint32_t process_ID; char *shm_addr; @@ -300,7 +298,6 @@ SHMProcess::SHMProcess(uint32_t PID, vector & known_versions) throw Error::SHMVersionMismatch(); } d->validate(known_versions); - d->window = new DFWindow(this); // at this point, DF is attached and suspended, make it run detach(); } @@ -386,10 +383,6 @@ SHMProcess::~SHMProcess() { delete d->memdescriptor; } - if(d->window) - { - delete d->window; - } delete d; } @@ -398,11 +391,6 @@ memory_info * SHMProcess::getDescriptor() return d->memdescriptor; } -DFWindow * SHMProcess::getWindow() -{ - return d->window; -} - int SHMProcess::getPID() { return d->process_ID; diff --git a/library/DFProcess-windows.cpp b/library/DFProcess-windows.cpp index a9d4834ed..bb87f9e8d 100644 --- a/library/DFProcess-windows.cpp +++ b/library/DFProcess-windows.cpp @@ -21,7 +21,7 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcess.h" #include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" @@ -36,14 +36,12 @@ class NormalProcess::Private my_descriptor = NULL; my_handle = NULL; my_main_thread = NULL; - my_window = NULL; my_pid = 0; attached = false; suspended = false; }; ~Private(){}; memory_info * my_descriptor; - DFWindow * my_window; HANDLE my_handle; HANDLE my_main_thread; uint32_t my_pid; @@ -147,10 +145,6 @@ NormalProcess::NormalProcess(uint32_t pid, vector & known_versio { CloseHandle(hProcess); } - else - { - d->my_window = new DFWindow(this); - } } /* */ @@ -171,10 +165,6 @@ NormalProcess::~NormalProcess() { CloseHandle(d->my_main_thread); } - if(d->my_window) - { - delete d->my_window; - } delete d; } @@ -183,11 +173,6 @@ memory_info * NormalProcess::getDescriptor() return d->my_descriptor; } -DFWindow * NormalProcess::getWindow() -{ - return d->my_window; -} - int NormalProcess::getPID() { return d->my_pid; diff --git a/library/DFProcessEnumerator-linux.cpp b/library/DFProcessEnumerator-linux.cpp index 2094261cf..3ee14ef80 100644 --- a/library/DFProcessEnumerator-linux.cpp +++ b/library/DFProcessEnumerator-linux.cpp @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcessEnumerator.h" #include "dfhack/DFProcess.h" #include "dfhack/DFMemInfo.h" diff --git a/library/DFProcessEnumerator-windows.cpp b/library/DFProcessEnumerator-windows.cpp index 27bf78323..bec67361d 100644 --- a/library/DFProcessEnumerator-windows.cpp +++ b/library/DFProcessEnumerator-windows.cpp @@ -22,7 +22,7 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFProcessEnumerator.h" #include "dfhack/DFProcess.h" #include "dfhack/DFMemInfo.h" diff --git a/library/DFTileTypes.cpp b/library/DFTileTypes.cpp deleted file mode 100644 index fc4b5ca87..000000000 --- a/library/DFTileTypes.cpp +++ /dev/null @@ -1,29 +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. -*/ - -#include "dfhack/DFCommonInternal.h" -#include "dfhack/DFTileTypes.h" - -using namespace DFHack; - diff --git a/library/DFTypes_C.cpp b/library/DFTypes_C.cpp index 8f953e7e4..2a27ad292 100644 --- a/library/DFTypes_C.cpp +++ b/library/DFTypes_C.cpp @@ -30,7 +30,7 @@ distribution. using namespace std; -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack-c/DFTypes_C.h" #include "dfhack/modules/Materials.h" diff --git a/library/DFVector.cpp b/library/DFVector.cpp deleted file mode 100644 index 474a2a219..000000000 --- a/library/DFVector.cpp +++ /dev/null @@ -1,31 +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. -*/ - -#include "dfhack/DFPragma.h" -#include "dfhack/DFCommonInternal.h" -#include "dfhack/DFMemInfo.h" -#include "dfhack/DFProcess.h" -#include "dfhack/DFVector.h" -using namespace DFHack; - diff --git a/library/include/DFHack.h b/library/include/DFHack.h index c2dd3f711..d80bce8bb 100644 --- a/library/include/DFHack.h +++ b/library/include/DFHack.h @@ -4,7 +4,6 @@ #include "dfhack/DFIntegers.h" #include "dfhack/DFGlobal.h" #include "dfhack/DFError.h" -#include "dfhack/DFTypes.h" #include "dfhack/DFContextManager.h" #include "dfhack/DFContext.h" #include "dfhack/DFMemInfo.h" diff --git a/library/include/dfhack-c/modules/Items_C.h b/library/include/dfhack-c/modules/Items_C.h index d2c737e2d..0568e9088 100644 --- a/library/include/dfhack-c/modules/Items_C.h +++ b/library/include/dfhack-c/modules/Items_C.h @@ -27,7 +27,7 @@ distribution. #include "dfhack/DFExport.h" #include "dfhack/DFIntegers.h" -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" using namespace DFHack; diff --git a/library/include/dfhack/DFContext.h b/library/include/dfhack/DFContext.h index 09da5cb9c..658d90ee1 100644 --- a/library/include/dfhack/DFContext.h +++ b/library/include/dfhack/DFContext.h @@ -41,7 +41,9 @@ namespace DFHack class Buildings; class Constructions; class memory_info; - class DFContextPrivate; + class DFContextShared; + class WindowIO; + class Process; class DFHACK_EXPORT Context { @@ -69,7 +71,6 @@ namespace DFHack bool ForceResume(); memory_info *getMemoryInfo(); - DFWindow * getWindow(); Process* getProcess(); void ReadRaw (const uint32_t offset, const uint32_t size, uint8_t *target); @@ -108,6 +109,9 @@ namespace DFHack // get the constructions module Constructions * getConstructions(); + + // get the Window management and I/O module + WindowIO * getWindow(); /* * Effects like mist, dragonfire or dust */ @@ -167,7 +171,7 @@ namespace DFHack */ //bool ReadItemTypes(std::vector< std::vector< t_itemType > > & itemTypes); private: - DFContextPrivate * d; + DFContextShared * d; }; } #endif //CONTEXT_H_INCLUDED diff --git a/library/include/dfhack/DFContextManager.h b/library/include/dfhack/DFContextManager.h index ae152ddd6..3337755d7 100644 --- a/library/include/dfhack/DFContextManager.h +++ b/library/include/dfhack/DFContextManager.h @@ -25,15 +25,12 @@ distribution. #ifndef CONTEXTMANAGER_H_INCLUDED #define CONTEXTMANAGER_H_INCLUDED + #include "DFPragma.h" #include "DFExport.h" #include #include #include -#include "DFIntegers.h" -#include "DFTileTypes.h" -#include "DFTypes.h" -#include "DFWindow.h" namespace DFHack { diff --git a/library/include/dfhack/DFProcess.h b/library/include/dfhack/DFProcess.h index 84468d71a..686d7cc40 100644 --- a/library/include/dfhack/DFProcess.h +++ b/library/include/dfhack/DFProcess.h @@ -33,7 +33,7 @@ namespace DFHack { class memory_info; class Process; - class DFWindow; + class Window; // structure describing a memory range struct DFHACK_EXPORT t_memrange @@ -122,8 +122,6 @@ namespace DFHack // get the flattened Memory.xml entry of this process virtual memory_info *getDescriptor() = 0; - // get the DF's window (first that can be found ~_~) - virtual DFWindow * getWindow() = 0; // get the DF Process ID virtual int getPID() = 0; // get module index by name and version. bool 1 = error @@ -195,7 +193,6 @@ namespace DFHack bool getThreadIDs(vector & threads ); void getMemRanges( vector & ranges ); memory_info *getDescriptor(); - DFWindow * getWindow(); int getPID(); // get module index by name and version. bool 1 = error bool getModuleIndex (const char * name, const uint32_t version, uint32_t & OUTPUT) { OUTPUT=0; return false;}; @@ -267,7 +264,6 @@ namespace DFHack bool getThreadIDs(vector & threads ); void getMemRanges( vector & ranges ); memory_info *getDescriptor(); - DFWindow * getWindow(); int getPID(); // get module index by name and version. bool 1 = error bool getModuleIndex (const char * name, const uint32_t version, uint32_t & OUTPUT); @@ -338,7 +334,6 @@ namespace DFHack bool getThreadIDs(vector & threads ); void getMemRanges( vector & ranges ); memory_info *getDescriptor(); - DFWindow * getWindow(); int getPID(); // get module index by name and version. bool 1 = error bool getModuleIndex (const char * name, const uint32_t version, uint32_t & OUTPUT) {OUTPUT=0; return false;}; diff --git a/library/include/dfhack/modules/Buildings.h b/library/include/dfhack/modules/Buildings.h index ab25239f9..a9dc04494 100644 --- a/library/include/dfhack/modules/Buildings.h +++ b/library/include/dfhack/modules/Buildings.h @@ -25,11 +25,11 @@ namespace DFHack // FIXME: not complete, we need building presence bitmaps for stuff like farm plots and stockpiles, orientation (N,E,S,W) and state (open/closed) }; - class DFContextPrivate; + class DFContextShared; class DFHACK_EXPORT Buildings { public: - Buildings(DFContextPrivate * d); + Buildings(DFContextShared * d); ~Buildings(); bool Start(uint32_t & numBuildings); // read one building at offset diff --git a/library/include/dfhack/modules/Constructions.h b/library/include/dfhack/modules/Constructions.h index f9fcd751e..e4f029591 100644 --- a/library/include/dfhack/modules/Constructions.h +++ b/library/include/dfhack/modules/Constructions.h @@ -39,11 +39,11 @@ namespace DFHack uint32_t origin; }; #pragma pack (pop) - class DFContextPrivate; + class DFContextShared; class DFHACK_EXPORT Constructions { public: - Constructions(DFContextPrivate * d); + Constructions(DFContextShared * d); ~Constructions(); bool Start(uint32_t & numConstructions); bool Read (const uint32_t index, t_construction & constr); diff --git a/library/include/dfhack/modules/Creatures.h b/library/include/dfhack/modules/Creatures.h index fad04f2fa..7e0d48cb5 100644 --- a/library/include/dfhack/modules/Creatures.h +++ b/library/include/dfhack/modules/Creatures.h @@ -353,12 +353,12 @@ namespace DFHack uint32_t birth_time; }; - class DFContextPrivate; + class DFContextShared; struct t_creature; class DFHACK_EXPORT Creatures { public: - Creatures(DFHack::DFContextPrivate * d); + Creatures(DFHack::DFContextShared * d); ~Creatures(); bool Start( uint32_t & numCreatures); bool Finish(); diff --git a/library/include/dfhack/modules/Gui.h b/library/include/dfhack/modules/Gui.h index fdc921060..abc33cff2 100644 --- a/library/include/dfhack/modules/Gui.h +++ b/library/include/dfhack/modules/Gui.h @@ -8,13 +8,13 @@ namespace DFHack { - class DFContextPrivate; + class DFContextShared; struct t_viewscreen; class DFHACK_EXPORT Gui { public: - Gui(DFHack::DFContextPrivate * d); + Gui(DFHack::DFContextShared * d); ~Gui(); bool Start(); bool Finish(); diff --git a/library/include/dfhack/modules/Items.h b/library/include/dfhack/modules/Items.h index 97fe736a9..90db2bbf6 100644 --- a/library/include/dfhack/modules/Items.h +++ b/library/include/dfhack/modules/Items.h @@ -8,7 +8,7 @@ namespace DFHack { class Context; -class DFContextPrivate; +class DFContextShared; enum accessor_type {ACCESSOR_CONSTANT, ACCESSOR_INDIRECT, ACCESSOR_DOUBLE_INDIRECT}; @@ -77,7 +77,7 @@ public: class DFHACK_EXPORT Items { public: - Items(DFContextPrivate * _d); + Items(DFContextShared * _d); ~Items(); std::string getItemDescription(uint32_t itemptr, Materials * Materials); std::string getItemClass(int32_t index); diff --git a/library/include/dfhack/modules/Maps.h b/library/include/dfhack/modules/Maps.h index 2a10b1705..cfdb31d43 100644 --- a/library/include/dfhack/modules/Maps.h +++ b/library/include/dfhack/modules/Maps.h @@ -255,13 +255,13 @@ namespace DFHack C L I E N T M O D U L E ***************************************************************************/ - class DFContextPrivate; + class DFContextShared; struct t_viewscreen; class DFHACK_EXPORT Maps { public: - Maps(DFHack::DFContextPrivate * d); + Maps(DFHack::DFContextShared * d); ~Maps(); bool Start(); bool Finish(); diff --git a/library/include/dfhack/modules/Materials.h b/library/include/dfhack/modules/Materials.h index 8e484568e..af2e16941 100644 --- a/library/include/dfhack/modules/Materials.h +++ b/library/include/dfhack/modules/Materials.h @@ -6,7 +6,7 @@ #include "dfhack/DFExport.h" namespace DFHack { - class DFContextPrivate; + class DFContextShared; struct t_matgloss { @@ -119,7 +119,7 @@ namespace DFHack class DFHACK_EXPORT Materials { public: - Materials(DFHack::DFContextPrivate * _d); + Materials(DFHack::DFContextShared * _d); ~Materials(); std::vector inorganic; diff --git a/library/include/dfhack/modules/Position.h b/library/include/dfhack/modules/Position.h index 6e55b82e6..b70387e66 100644 --- a/library/include/dfhack/modules/Position.h +++ b/library/include/dfhack/modules/Position.h @@ -16,12 +16,12 @@ namespace DFHack int32_t z; }; - class DFContextPrivate; + class DFContextShared; class DFHACK_EXPORT Position { public: - Position(DFContextPrivate * d); + Position(DFContextShared * d); ~Position(); /* * Cursor and window coords diff --git a/library/include/dfhack/modules/Translation.h b/library/include/dfhack/modules/Translation.h index 2b70d4df0..a7e186990 100644 --- a/library/include/dfhack/modules/Translation.h +++ b/library/include/dfhack/modules/Translation.h @@ -6,7 +6,7 @@ #include "dfhack/DFExport.h" namespace DFHack { - class DFContextPrivate; + class DFContextShared; typedef std::vector< std::vector > DFDict; typedef struct { @@ -17,7 +17,7 @@ namespace DFHack class DFHACK_EXPORT Translation { public: - Translation(DFContextPrivate * d); + Translation(DFContextShared * d); ~Translation(); bool Start(); bool Finish(); diff --git a/library/include/dfhack/modules/Vegetation.h b/library/include/dfhack/modules/Vegetation.h index 3f647b752..b81bb81c1 100644 --- a/library/include/dfhack/modules/Vegetation.h +++ b/library/include/dfhack/modules/Vegetation.h @@ -27,11 +27,11 @@ namespace DFHack uint32_t address; }; - class DFContextPrivate; + class DFContextShared; class DFHACK_EXPORT Vegetation { public: - Vegetation(DFContextPrivate * d); + Vegetation(DFContextShared * d); ~Vegetation(); bool Start(uint32_t & numTrees); bool Read (const uint32_t index, t_tree & shrubbery); diff --git a/library/include/dfhack/DFWindow.h b/library/include/dfhack/modules/WindowIO.h similarity index 91% rename from library/include/dfhack/DFWindow.h rename to library/include/dfhack/modules/WindowIO.h index d24f7297c..146029ca0 100644 --- a/library/include/dfhack/DFWindow.h +++ b/library/include/dfhack/modules/WindowIO.h @@ -25,8 +25,8 @@ distribution. #ifndef KEYS_H_INCLUDED #define KEYS_H_INCLUDED -#include "DFPragma.h" -#include "DFExport.h" +#include "dfhack/DFPragma.h" +#include "dfhack/DFExport.h" namespace DFHack { @@ -87,15 +87,15 @@ enum t_special KEYPAD_DECIMAL_POINT, NUM_SPECIALS }; - -class DFHACK_EXPORT DFWindow +class DFContextShared; +class DFHACK_EXPORT WindowIO { class Private; private: Private * d; public: - DFWindow(Process * p); - ~DFWindow(); + WindowIO(DFHack::DFContextShared * d); + ~WindowIO(); void TypeStr (const char *input, int delay = 0, bool useShift = false); void TypeSpecial (t_special command, int count = 1, int delay = 0); }; diff --git a/library/include/dfhack/modules/World.h b/library/include/dfhack/modules/World.h index a7ab7f979..21300bfd5 100644 --- a/library/include/dfhack/modules/World.h +++ b/library/include/dfhack/modules/World.h @@ -8,12 +8,12 @@ namespace DFHack { - class DFContextPrivate; + class DFContextShared; class DFHACK_EXPORT World { public: - World(DFHack::DFContextPrivate * d); + World(DFHack::DFContextShared * d); ~World(); bool Start(); bool Finish(); diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 3452ba220..5d55163b3 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -59,13 +59,13 @@ struct Buildings::Private uint32_t custom_workshop_name; int32_t custom_workshop_id; DfVector * p_bld; - DFContextPrivate *d; + DFContextShared *d; Process * owner; bool Inited; bool Started; }; -Buildings::Buildings(DFContextPrivate * d_) +Buildings::Buildings(DFContextShared * d_) { d = new Private; d->d = d_; diff --git a/library/modules/Buildings_C.cpp b/library/modules/Buildings_C.cpp index 5d0a8fb30..18bd77922 100644 --- a/library/modules/Buildings_C.cpp +++ b/library/modules/Buildings_C.cpp @@ -29,7 +29,7 @@ distribution. using namespace std; -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Buildings.h" #include "dfhack-c/modules/Buildings_C.h" diff --git a/library/modules/Constructions.cpp b/library/modules/Constructions.cpp index ff4230b5b..535098fc5 100644 --- a/library/modules/Constructions.cpp +++ b/library/modules/Constructions.cpp @@ -22,9 +22,9 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" -//#include "modules/Translation.h" +#include "Internal.h" +#include "ContextShared.h" + #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" #include "dfhack/DFVector.h" @@ -39,13 +39,13 @@ struct Constructions::Private // translation DfVector * p_cons; - DFContextPrivate *d; + DFContextShared *d; Process * owner; bool Inited; bool Started; }; -Constructions::Constructions(DFContextPrivate * d_) +Constructions::Constructions(DFContextShared * d_) { d = new Private; d->d = d_; diff --git a/library/modules/Constructions_C.cpp b/library/modules/Constructions_C.cpp index 3fdcca5a4..93afdae01 100644 --- a/library/modules/Constructions_C.cpp +++ b/library/modules/Constructions_C.cpp @@ -24,7 +24,7 @@ distribution. #include "dfhack/DFIntegers.h" -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Constructions.h" #include "dfhack-c/modules/Constructions_C.h" diff --git a/library/modules/Creatures.cpp b/library/modules/Creatures.cpp index 15b1f6b6b..b7e39a95f 100644 --- a/library/modules/Creatures.cpp +++ b/library/modules/Creatures.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -55,11 +55,11 @@ struct Creatures::Private uint32_t dwarf_race_index_addr; uint32_t dwarf_civ_id_addr; DfVector *p_cre; - DFContextPrivate *d; + DFContextShared *d; Process *owner; }; -Creatures::Creatures(DFContextPrivate* _d) +Creatures::Creatures(DFContextShared* _d) { d = new Private; d->d = _d; diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index c49e7a6eb..f017a04f3 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/modules/Gui.h" #include "dfhack/DFProcess.h" #include "dfhack/DFMemInfo.h" @@ -39,11 +39,11 @@ struct Gui::Private uint32_t view_screen_offset; uint32_t current_cursor_creature_offset; uint32_t current_menu_state_offset; - DFContextPrivate *d; + DFContextShared *d; Process * owner; }; -Gui::Gui(DFContextPrivate * _d) +Gui::Gui(DFContextShared * _d) { d = new Private; diff --git a/library/modules/Gui_C.cpp b/library/modules/Gui_C.cpp index efb66ffcf..586eb1dd0 100644 --- a/library/modules/Gui_C.cpp +++ b/library/modules/Gui_C.cpp @@ -27,7 +27,7 @@ distribution. #include "dfhack-c/modules/Gui_C.h" #include "dfhack/DFIntegers.h" -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/modules/Gui.h" using namespace DFHack; @@ -68,7 +68,7 @@ int Gui_ReadPauseState(DFHackObject* gui) int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen) { - int result; + //int result; if(gui != NULL) { diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 6fc0d9b2c..66e2720ac 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/DFTypes.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -36,7 +36,7 @@ using namespace DFHack; class Items::Private { public: - DFContextPrivate *d; + DFContextShared *d; Process * owner; /* bool Inited; @@ -44,7 +44,7 @@ class Items::Private */ }; -Items::Items(DFContextPrivate * d_) +Items::Items(DFContextShared * d_) { d = new Private; d->d = d_; diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp index 474de769a..af0a8be9b 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -22,11 +22,11 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include #include #include -#include "../private/APIPrivate.h" +#include "ContextShared.h" #include "dfhack/modules/Maps.h" #include "dfhack/DFError.h" #include "dfhack/DFMemInfo.h" @@ -50,7 +50,7 @@ struct Maps::Private uint32_t maps_module; Server::Maps::maps_offsets offsets; - DFContextPrivate *d; + DFContextShared *d; Process * owner; bool Inited; bool Started; @@ -61,7 +61,7 @@ struct Maps::Private vector v_geology[eBiomeCount]; }; -Maps::Maps(DFContextPrivate* _d) +Maps::Maps(DFContextShared* _d) { d = new Private; d->d = _d; diff --git a/library/modules/Maps_C.cpp b/library/modules/Maps_C.cpp index effc188b5..ccac26447 100644 --- a/library/modules/Maps_C.cpp +++ b/library/modules/Maps_C.cpp @@ -29,7 +29,7 @@ distribution. using namespace std; -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Maps.h" #include "dfhack-c/modules/Maps_C.h" diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index f73beac37..3567bb0d0 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Materials.h" #include "dfhack/DFMemInfo.h" @@ -35,7 +35,7 @@ using namespace DFHack; class Materials::Private { public: - DFContextPrivate *d; + DFContextShared *d; Process * owner; /* bool Inited; @@ -43,7 +43,7 @@ class Materials::Private */ }; -Materials::Materials(DFContextPrivate * d_) +Materials::Materials(DFContextShared * d_) { d = new Private; d->d = d_; diff --git a/library/modules/Materials_C.cpp b/library/modules/Materials_C.cpp index 135878276..dee99fbaa 100644 --- a/library/modules/Materials_C.cpp +++ b/library/modules/Materials_C.cpp @@ -29,7 +29,7 @@ distribution. using namespace std; -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Materials.h" #include "dfhack-c/DFTypes_C.h" diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index 4ecf8dd56..0d3ae1819 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/modules/Position.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -42,14 +42,14 @@ struct Position::Private uint32_t hotkey_xyz_offset; uint32_t hotkey_size; - DFContextPrivate *d; + DFContextShared *d; Process * owner; bool Inited; bool Started; bool StartedHotkeys; }; -Position::Position(DFContextPrivate * d_) +Position::Position(DFContextShared * d_) { d = new Private; d->d = d_; diff --git a/library/modules/Position_C.cpp b/library/modules/Position_C.cpp index 04f76fbde..72405d9b7 100644 --- a/library/modules/Position_C.cpp +++ b/library/modules/Position_C.cpp @@ -27,7 +27,7 @@ distribution. #include "dfhack-c/modules/Position_C.h" #include "dfhack/DFIntegers.h" -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/modules/Position.h" using namespace DFHack; diff --git a/library/modules/Translation.cpp b/library/modules/Translation.cpp index 6528d1c5c..80412c690 100644 --- a/library/modules/Translation.cpp +++ b/library/modules/Translation.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/modules/Translation.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -42,12 +42,12 @@ struct Translation::Private // translation Dicts dicts; - DFContextPrivate *d; + DFContextShared *d; bool Inited; bool Started; }; -Translation::Translation(DFContextPrivate * d_) +Translation::Translation(DFContextShared * d_) { d = new Private; d->d = d_; diff --git a/library/modules/Translation_C.cpp b/library/modules/Translation_C.cpp index 50dd51411..e84e04c2a 100644 --- a/library/modules/Translation_C.cpp +++ b/library/modules/Translation_C.cpp @@ -27,7 +27,7 @@ distribution. using namespace std; -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Translation.h" #include "dfhack-c/modules/Translation_C.h" diff --git a/library/modules/Vegetation.cpp b/library/modules/Vegetation.cpp index f5f20794f..6038e4d53 100644 --- a/library/modules/Vegetation.cpp +++ b/library/modules/Vegetation.cpp @@ -22,8 +22,8 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFProcess.h" @@ -41,13 +41,13 @@ struct Vegetation::Private // translation DfVector * p_veg; - DFContextPrivate *d; + DFContextShared *d; Process * owner; bool Inited; bool Started; }; -Vegetation::Vegetation(DFContextPrivate * d_) +Vegetation::Vegetation(DFContextShared * d_) { d = new Private; d->owner = d_->p; diff --git a/library/modules/Vegetation_C.cpp b/library/modules/Vegetation_C.cpp index 0153e1a7e..0a919c070 100644 --- a/library/modules/Vegetation_C.cpp +++ b/library/modules/Vegetation_C.cpp @@ -23,7 +23,7 @@ distribution. */ #include "dfhack/DFIntegers.h" -#include "dfhack/DFCommonInternal.h" +#include "Internal.h" #include "dfhack/DFTypes.h" #include "dfhack/modules/Vegetation.h" #include "dfhack-c/modules/Vegetation_C.h" diff --git a/library/DFWindow-linux.cpp b/library/modules/WindowIO-linux.cpp similarity index 93% rename from library/DFWindow-linux.cpp rename to library/modules/WindowIO-linux.cpp index 23a769724..b8ff0cd13 100644 --- a/library/DFWindow-linux.cpp +++ b/library/modules/WindowIO-linux.cpp @@ -21,11 +21,12 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "dfhack/DFWindow.h" +#include "Internal.h" +#include "dfhack/modules/WindowIO.h" #include //need for X11 functions #include +#include using namespace DFHack; @@ -84,7 +85,7 @@ const static KeySym ksTable[NUM_SPECIALS]= XK_KP_Decimal }; -class DFWindow::Private +class WindowIO::Private { public: Private(Process * _p) @@ -111,18 +112,18 @@ class DFWindow::Private }; // ctor -DFWindow::DFWindow (Process * p) +WindowIO::WindowIO (DFContextShared * csh) { - d = new Private(p); + d = new Private(csh->p); } // dtor -DFWindow::~DFWindow () +WindowIO::~WindowIO () { delete d; } -Window DFWindow::Private::EnumerateWindows (Display *display, Window rootWindow, const char *searchString) +Window WindowIO::Private::EnumerateWindows (Display *display, Window rootWindow, const char *searchString) { Window parent; Window *children; @@ -161,7 +162,7 @@ Window DFWindow::Private::EnumerateWindows (Display *display, Window rootWindow, return retWindow; } -bool DFWindow::Private::getDFWindow (Display *dpy, Window& dfWindow, Window & rootWindow) +bool WindowIO::Private::getDFWindow (Display *dpy, Window& dfWindow, Window & rootWindow) { // int numScreeens = ScreenCount(dpy); for (int i = 0;i < ScreenCount (dpy);i++) @@ -177,7 +178,7 @@ bool DFWindow::Private::getDFWindow (Display *dpy, Window& dfWindow, Window & ro return false; } -void DFWindow::Private::send_xkeyevent(Display *display, Window dfW,Window rootW, int keycode, int modstate, int is_press, useconds_t delay) +void WindowIO::Private::send_xkeyevent(Display *display, Window dfW,Window rootW, int keycode, int modstate, int is_press, useconds_t delay) { XKeyEvent event; @@ -199,7 +200,7 @@ void DFWindow::Private::send_xkeyevent(Display *display, Window dfW,Window rootW usleep(delay); } -void DFWindow::TypeStr (const char *input, int delay, bool useShift) +void WindowIO::TypeStr (const char *input, int delay, bool useShift) { Display *dpy = XOpenDisplay (NULL); // null opens the display in $DISPLAY Window dfWin; @@ -234,7 +235,7 @@ void DFWindow::TypeStr (const char *input, int delay, bool useShift) } } -void DFWindow::TypeSpecial (t_special command, int count, int delay) +void WindowIO::TypeSpecial (t_special command, int count, int delay) { if (command != WAIT) { diff --git a/library/DFWindow-windows.cpp b/library/modules/WindowIO-windows.cpp similarity index 93% rename from library/DFWindow-windows.cpp rename to library/modules/WindowIO-windows.cpp index f7164fa64..37c5eb08c 100644 --- a/library/DFWindow-windows.cpp +++ b/library/modules/WindowIO-windows.cpp @@ -22,8 +22,9 @@ must not be misrepresented as being the original software. distribution. */ -#include "dfhack/DFCommonInternal.h" -#include "dfhack/DFWindow.h" +#include "Internal.h" +#include "ContextShared.h" +#include "dfhack/modules/WindowIO.h" #include "dfhack/DFProcess.h" using namespace DFHack; @@ -101,7 +102,7 @@ BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam) return TRUE; } -class DFWindow::Private +class WindowIO::Private { public: Private(Process * _p) @@ -114,19 +115,19 @@ class DFWindow::Private }; // ctor -DFWindow::DFWindow (Process * p) +WindowIO::WindowIO (DFContextShared * schr) { - d = new Private(p); + d = new Private(schr->p); } // dtor -DFWindow::~DFWindow () +WindowIO::~WindowIO () { delete d; } // TODO: also investigate possible problems with UIPI on Vista and 7 -void DFWindow::TypeStr (const char *input, int delay, bool useShift) +void WindowIO::TypeStr (const char *input, int delay, bool useShift) { //sendmessage needs a window handle HWND, so have to get that from the process HANDLE HWND currentWindow = GetForegroundWindow(); @@ -163,7 +164,7 @@ void DFWindow::TypeStr (const char *input, int delay, bool useShift) Sleep (delay); } -void DFWindow::TypeSpecial (t_special command, int count, int delay) +void WindowIO::TypeSpecial (t_special command, int count, int delay) { if (command != WAIT) { diff --git a/library/modules/World.cpp b/library/modules/World.cpp index 00aa67a6a..47f4d200d 100644 --- a/library/modules/World.cpp +++ b/library/modules/World.cpp @@ -34,8 +34,8 @@ FIXME: Japa said that he had to do this with the time stuff he got from here currentTickRel = (currentTick+9)-(((((currentMonth*28)+currentDay)*24)+currentHour)*50); */ -#include "dfhack/DFCommonInternal.h" -#include "../private/APIPrivate.h" +#include "Internal.h" +#include "ContextShared.h" #include "dfhack/modules/World.h" #include "dfhack/DFProcess.h" #include "dfhack/DFMemInfo.h" @@ -49,11 +49,11 @@ struct World::Private bool Started; uint32_t year_offset; uint32_t tick_offset; - DFContextPrivate *d; + DFContextShared *d; Process * owner; }; -World::World(DFContextPrivate * _d) +World::World(DFContextShared * _d) { d = new Private; diff --git a/library/private/APIPrivate.h b/library/private/ContextShared.h similarity index 95% rename from library/private/APIPrivate.h rename to library/private/ContextShared.h index 49de782f4..f3c506880 100644 --- a/library/private/APIPrivate.h +++ b/library/private/ContextShared.h @@ -42,15 +42,16 @@ namespace DFHack class Buildings; class ProcessEnumerator; class Process; + class WindowIO; class Vegetation; class Constructions; class memory_info; struct t_name; - class DFContextPrivate + class DFContextShared { public: - DFContextPrivate(); - ~DFContextPrivate(); + DFContextShared(); + ~DFContextShared(); // names, used by a few other modules. void readName(t_name & name, uint32_t address); @@ -79,6 +80,7 @@ namespace DFHack Vegetation * vegetation; Buildings * buildings; Constructions * constructions; + WindowIO * windowio; /* uint32_t item_material_offset; diff --git a/library/include/dfhack/DFCommonInternal.h b/library/private/Internal.h similarity index 96% rename from library/include/dfhack/DFCommonInternal.h rename to library/private/Internal.h index 8cf157f48..3f5d561fa 100644 --- a/library/include/dfhack/DFCommonInternal.h +++ b/library/private/Internal.h @@ -41,10 +41,10 @@ distribution. #endif // one file for globals -#include "DFGlobal.h" +#include "dfhack/DFGlobal.h" // one file for telling the MSVC compiler where it can shove its pointless warnings -#include "DFPragma.h" +#include "dfhack/DFPragma.h" // basic stl containers and IO stuff #include @@ -55,7 +55,7 @@ distribution. using namespace std; // C99 integer types -#include "DFIntegers.h" +#include "dfhack/DFIntegers.h" // C includes #include #include diff --git a/library/shm/CMakeLists.txt b/library/shm/CMakeLists.txt deleted file mode 100644 index 83c3235f9..000000000 --- a/library/shm/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/tools/examples/veinlook.cpp b/tools/examples/veinlook.cpp index 7f4bcd13a..63ad703bf 100644 --- a/tools/examples/veinlook.cpp +++ b/tools/examples/veinlook.cpp @@ -16,6 +16,8 @@ using namespace std; #include #include +#include + using namespace DFHack; diff --git a/tools/playground/digger.cpp b/tools/playground/digger.cpp index 54983aa27..380e1e8c3 100644 --- a/tools/playground/digger.cpp +++ b/tools/playground/digger.cpp @@ -13,6 +13,7 @@ using namespace std; #include +#include #include // counts the occurances of a certain element in a vector diff --git a/tools/playground/digger2.cpp b/tools/playground/digger2.cpp index 27b0ce2a6..91507bcc1 100644 --- a/tools/playground/digger2.cpp +++ b/tools/playground/digger2.cpp @@ -20,8 +20,10 @@ #include #include using namespace std; + #include #include +#include #define BLOCK_SIZE 16 diff --git a/tools/supported/liquids.cpp b/tools/supported/liquids.cpp index 39344b4c1..d125c7ad1 100644 --- a/tools/supported/liquids.cpp +++ b/tools/supported/liquids.cpp @@ -7,6 +7,7 @@ using namespace std; #include +#include int main (void) { diff --git a/tools/supported/probe.cpp b/tools/supported/probe.cpp index 9d6e89365..4353d48ba 100644 --- a/tools/supported/probe.cpp +++ b/tools/supported/probe.cpp @@ -10,6 +10,7 @@ using namespace std; #include +#include using namespace DFHack; int main (int numargs, const char ** args) diff --git a/tools/supported/prospector.cpp b/tools/supported/prospector.cpp index 5438d113f..514be1e3e 100644 --- a/tools/supported/prospector.cpp +++ b/tools/supported/prospector.cpp @@ -16,6 +16,7 @@ using namespace std; #include +#include int main (int argc, const char* argv[]) { diff --git a/tools/supported/vdig.cpp b/tools/supported/vdig.cpp index ca70cc400..80cab23e7 100644 --- a/tools/supported/vdig.cpp +++ b/tools/supported/vdig.cpp @@ -9,6 +9,7 @@ using namespace std; #include +#include #include #define MAX_DIM 0x300