diff --git a/CMake/Modules/CMakeVS10FindMake.cmake b/CMake/Modules/CMakeVS10FindMake.cmake
new file mode 100644
index 000000000..460de25e5
--- /dev/null
+++ b/CMake/Modules/CMakeVS10FindMake.cmake
@@ -0,0 +1,28 @@
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+# We use MSBuild as the build tool for VS 10
+FIND_PROGRAM(CMAKE_MAKE_PROGRAM
+ NAMES MSBuild
+ HINTS
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;ProductDir]
+ "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/"
+ "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/"
+ "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0;CLR Version]/"
+ )
+
+MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)
+SET(MSVC10 1)
+SET(MSVC_VERSION 1600)
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e4dc7ab5e..a03f7d6cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@
PROJECT (dfhack)
cmake_minimum_required(VERSION 2.6)
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
+SET ( DFHACK_VERSION "0.4.1.0-dev" )
# disable warning, autosearch
if(COMMAND cmake_policy)
@@ -18,6 +19,13 @@ 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" )
+SET( DATA_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/output CACHE PATH "Output directory for the dfhack data (offset files)" )
+
+OPTION(BUILD_DFHACK_DOCUMENTATION "Create doxygen documentation for developers" OFF)
+OPTION(BUILD_DFHACK_EXAMPLES "Build example tools" OFF)
+OPTION(BUILD_DFHACK_PLAYGROUND "Build tools from the playground folder" OFF)
+OPTION(BUILD_DFHACK_C_BINDIGS "Build the C portion of the library" ON)
+OPTION(BUILD_OFFSET_EDITOR "Build the Offset GUI editor (not ready for use)." OFF)
include_directories (${CMAKE_SOURCE_DIR}/library/include/)
include_directories (${CMAKE_SOURCE_DIR}/library/shm/)
@@ -26,7 +34,13 @@ include_directories (${CMAKE_SOURCE_DIR}/library/depends/tinyxml/)
include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/)
add_subdirectory (library)
-#add_subdirectory (dfhack/python)
+
+IF(BUILD_OFFSET_EDITOR)
+ add_subdirectory (offsetedit)
+ENDIF(BUILD_OFFSET_EDITOR)
+
+add_subdirectory (library/shm)
add_subdirectory (tools/examples)
add_subdirectory (tools/playground)
add_subdirectory (tools/supported)
+add_subdirectory (doc)
\ No newline at end of file
diff --git a/COMPILE b/COMPILE
deleted file mode 100644
index a4da697ba..000000000
--- a/COMPILE
+++ /dev/null
@@ -1,159 +0,0 @@
-Here's how you build dfhack!
-----------------------------
-
-Dependencies
-============
-
-You'll need cmake and 'a' compiler for building the main lib and the various tools.
-(Linux only) Veinlook requires the wide-character ncurses library (libncursesw)
-
-Building on Linux:
---------------------
-
-* To run in the output folder (without installing):
-
-building the library is simple. Enter the build folder, run the tools. Like this:
-
-cd build
-cmake .. -DCMAKE_BUILD_TYPE:string=Release
-make
-
-This will build the library and its tools and place them in /output.
-You can also use a cmake-friendly IDE like KDevelop 4 or the cmake GUI program.
-
-* To be installed into the system or packaged
-
-cd build
-cmake -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/usr -DMEMXML_DATA_PATH:path=/usr/share/dfhack ..
-make
-make install
-
-With this dfhack installs:
-library to $CMAKE_INSTALL_PREFIX/lib
-executables to $CMAKE_INSTALL_PREFIX/bin
-The Memory.xml file to /usr/share/dfhack
-
-See the section on the shared memory hook library (SHM).
-
-Building on Windows:
---------------------
-
-You need cmake. Get the win32 installer version from the official site:
-http://www.cmake.org/cmake/resources/software.html
-It has the usual installer wizard thing.
-
-
-* Using mingw:
-
-You also need a compiler. I build dfhack using mingw. You can get it from the mingw site:
-Get the automated installer, it will download newest version of mingw and set things up nicely.
-You'll have to add C:\MinGW\ to your PATH variable.
-
- - Building:
- open up cmd and navigate to the dfhack\build folder, run cmake and the mingw version of make:
- cd build
- cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE:string=Release
- mingw32-make
-
-
-* Using MSVC
-
-open up cmd and navigate to the dfhack\build folder, run cmake:
-cd build
-cmake ..
-
-This will generate MSVC solution and project files.
-Note that: you are working in the /build folder. Files added to projects will
- end up there! (and that's wrong). Any changes to the build system should
-be done by changing cmake configs and running cmake on them!
-
-Alo, you'll have to copy the Memory.xml file to the build output folders
-MSVC generates. For example from 'output/' to 'output/Release/'
-
-
-* Using some other compiler:
-
-I'm afraid you are on your own. dfhack wasn't tested with any other compiler.
-Try using a different cmake generator that's intended for your tools.
-
-Build targets
--------------
-
-dfhack has a few build targets.
-If you're only after the library run 'make dfhack'.
-'make' will build everything.
-'make expbench' will build the expbench testing program and the library.
-
-Build types
------------
-
-cmake allows you to pick a build type by changing this variable: CMAKE_BUILD_TYPE
-
-cmake .. -DCMAKE_BUILD_TYPE:string=BUILD_TYPE
-
-Without specifying a build type or 'None', cmake uses the CMAKE_CXX_FLAGS
-variable for building.
-Valid an useful build types include 'Release', 'Debug' and 'RelWithDebInfo'.
-There are others, but they aren't really that useful.
-
-Have fun.
-
---------------------------------------------------------------------------------
-**Deprecated*Deprecated*Deprecated*Deprecated*Deprecated*Deprecated*Deprecated**
---------------------------------------------------------------------------------
-
-Building the shared memory hook library (SHM)
----------------------------------------------
-
-Unlike the rest of DFHack, The SHM needs special treatment when it comes to
-compilation. Because it shares the memory space with DF itself, it has to be
-built with the same tools as DF and use the same C and C++/STL libraries.
-
-For DF 40d15 - 40d19_2 on Windows, use MSVC 2008. You can get the Express
-edition for free from Microsoft.
-
-Windows dependencies can be determined by a tool like depends.exe (google it).
-Both the fake SDL.dll and DF have to use the same version of the C runtime
-(MSVCRT).
-The SHM can only be debugged using a RelWithDebInfo build!
-
-Linux dependencies can be determined by setting the LD_DEBUG variable and
-running ./df:
-$export LD_DEBUG=versions
-$./df
-
-Example of (a part of a) relevant output from a working SHM installation:
- 24472: checking for version `GLIBC_2.0' in file /opt/lib32/lib/libpthread.so.0 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GCC_3.0' in file ./libs/libgcc_s.so.1 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.0' in file ./libs/libgcc_s.so.1 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.1' in file /opt/lib32/lib/libm.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.0' in file /opt/lib32/lib/libm.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.1.3' in file /opt/lib32/lib/libc.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.3.4' in file /opt/lib32/lib/libc.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.4' in file /opt/lib32/lib/libc.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBC_2.0' in file /opt/lib32/lib/libc.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBCXX_3.4.9' in file ./libs/libstdc++.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `CXXABI_1.3' in file ./libs/libstdc++.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `GLIBCXX_3.4' in file ./libs/libstdc++.so.6 [0] required by file ./dwarfort.exe [0]
- 24472: checking for version `CXXABI_1.3' in file ./libs/libstdc++.so.6 [0] required by file ./libs/libdfconnect.so [0]
- 24472: checking for version `GLIBCXX_3.4' in file ./libs/libstdc++.so.6 [0] required by file ./libs/libdfconnect.so [0]
- 24472: checking for version `GLIBC_2.1.3' in file /opt/lib32/lib/libc.so.6 [0] required by file ./libs/libdfconnect.so [0]
- 24472: checking for version `GLIBC_2.2' in file /opt/lib32/lib/libc.so.6 [0] required by file ./libs/libdfconnect.so [0]
- 24472: checking for version `GLIBC_2.3.4' in file /opt/lib32/lib/libc.so.6 [0] required by file ./libs/libdfconnect.so [0]
- 24472: checking for version `GLIBC_2.0' in file /opt/lib32/lib/libc.so.6 [0] required by file ./libs/libdfconnect.so [0]
-
-libdfconnect is the SHM. Both are compiled against the same C++ library and
-share the same CXXABI version.
-
-Precompiled SHM libraries are provided in binary releases.
-
-* Checking strings support
-
-Strings are one of the important C++ types and a great indicator that the SHM
-works. Tools like Dwarf Therapist depend on string support. Reading of strings
-can be checked by running any of the tools that deal with materials.
-
-String writing is best tested with a fresh throw-away fort and dfrenamer.
-Embark, give one dwarf a very long name using dfrenamer and save/exit.
-If DF crashes during the save sequence, your SHM is not compatible with DF and
-the throw-away fort is most probably lost.
diff --git a/COMPILE.rst b/COMPILE.rst
new file mode 100644
index 000000000..dc07456f0
--- /dev/null
+++ b/COMPILE.rst
@@ -0,0 +1,147 @@
+################
+Compiling DFHACK
+################
+
+============================
+Here's how you build dfhack!
+============================
+
+.. contents::
+
+
+Dependencies
+============
+* ``cmake``
+* A compiler for building the main lib and the various tools.
+* (Linux only) Veinlook requires the wide-character ncurses library (libncursesw)
+* (Linux only) You'll need X11 dev libraries.
+
+Building on Linux
+=================
+To run in the output folder (without installing) building the library
+is simple. Enter the build folder, run the tools. Like this::
+
+ cd build
+ cmake .. -DCMAKE_BUILD_TYPE:string=Release
+ make
+
+This will build the library and its tools and place them in ``/output``.
+You can also use a cmake-friendly IDE like KDevelop 4 or the cmake GUI
+program.
+
+To be installed into the system or packaged::
+
+ cd build
+ cmake -DCMAKE_BUILD_TYPE:string=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DMEMXML_DATA_PATH:path=/usr/share/dfhack ..
+ make
+ make install
+
+With this dfhack installs:
+
+* library to ``$CMAKE_INSTALL_PREFIX/lib``
+* executables to ``$CMAKE_INSTALL_PREFIX/bin``
+* The ``Memory.xml`` file to ``/usr/share/dfhack``
+
+See the section on the shared memory hook library (SHM).
+
+Building on Windows
+===================
+You need ``cmake``. Get the win32 installer version from the official
+site: http://www.cmake.org/cmake/resources/software.html
+
+It has the usual installer wizard thing.
+
+-----------
+Using mingw
+-----------
+You also need a compiler. I build dfhack using mingw. You can get it
+from the mingw site: http://www.mingw.org/
+
+Get the automated installer, it will download newest version of mingw
+and set things up nicely.
+
+You'll have to add ``C:\MinGW\`` to your PATH variable.
+
+Building
+--------
+open up cmd and navigate to the ``dfhack\build`` folder, run ``cmake``
+and the mingw version of make::
+
+ cd build
+ cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE:string=Release
+ mingw32-make
+
+----------
+Using MSVC
+----------
+open up ``cmd`` and navigate to the ``dfhack\build`` folder, run
+``cmake``::
+
+ cd build
+ cmake ..
+
+This will generate MSVC solution and project files.
+
+.. note::
+
+ You are working in the ``/build`` folder. Files added to
+ projects from within MSVC will end up there! (and that's
+ wrong). Any changes to the build system should be done
+ by changing cmake configs and running ``cmake`` on them!
+
+-------------------------
+Using some other compiler
+-------------------------
+I'm afraid you are on your own. dfhack wasn't tested with any other
+compiler.
+
+Try using a different cmake generator that's intended for your tools.
+
+Build targets
+=============
+dfhack has a few build targets:
+
+* If you're only after the library run ``make dfhack``.
+* ``make`` will build everything.
+* ``make expbench`` will build the expbench testing program and the
+ library.
+* Some of the utilities and the doxygen documentation won't be
+ normally built. You can enable them by specifying some extra
+ CMake variables::
+
+ BUILD_DFHACK_DOCUMENTATION - generate the documentation (really bad)
+ BUILD_DFHACK_EXAMPLES - build tools from tools/examples
+ BUILD_DFHACK_PLAYGROUND - build tools from tools/playground
+
+ Example::
+
+ cmake .. -DBUILD_DFHACK_EXAMPLES=ON
+
+Build types
+===========
+``cmake`` allows you to pick a build type by changing this
+variable: ``CMAKE_BUILD_TYPE``
+
+::
+
+ cmake .. -DCMAKE_BUILD_TYPE:string=BUILD_TYPE
+
+Without specifying a build type or 'None', cmake uses the
+``CMAKE_CXX_FLAGS`` variable for building.
+
+Valid an useful build types include 'Release', 'Debug' and
+'RelWithDebInfo'. There are others, but they aren't really that useful.
+
+Have fun.
+
+Building the shared memory hook library (SHM)
+=============================================
+Unlike the rest of DFHack, The SHM needs special treatment when it
+comes to compilation. Because it shares the memory space with DF
+itself, it has to be built with the same tools as DF and use the same C
+and C++/STL libraries.
+
+For DF 31.01 - 31.12 on Windows, use MSVC 2008. You can get the Express
+edition for free from Microsoft.
diff --git a/Compile.html b/Compile.html
new file mode 100644
index 000000000..d7bb44ce7
--- /dev/null
+++ b/Compile.html
@@ -0,0 +1,471 @@
+
+
+
+
open up cmd and navigate to the dfhack\build folder, run
+cmake:
+
+cd build
+cmake ..
+
+
This will generate MSVC solution and project files.
+
+
Note
+
You are working in the /build folder. Files added to
+projects from within MSVC will end up there! (and that's
+wrong). Any changes to the build system should be done
+by changing cmake configs and running cmake on them!
Unlike the rest of DFHack, The SHM needs special treatment when it
+comes to compilation. Because it shares the memory space with DF
+itself, it has to be built with the same tools as DF and use the same C
+and C++/STL libraries.
+
For DF 31.01 - 31.12 on Windows, use MSVC 2008. You can get the Express
+edition for free from Microsoft.
+
+
+
+
diff --git a/README b/README
deleted file mode 100644
index 56c5c4d7d..000000000
--- a/README
+++ /dev/null
@@ -1,174 +0,0 @@
-Introduction
-------------
-
-DFHack is a Dwarf Fortress memory access library and a set of basic tools using
-this library. The library is a work in progress, so things might change as more
-tools are written for it.
-
-It is an attempt to unite the various ways tools access DF memory and allow for
-easier development of new tools.
-
-Getting DFHack
-----------------
-The project is currently hosted on github, for both source and binaries:
- http://github.com/peterix/dfhack
-
-* Packages
-
-The library and tools are packaged for Archlinux and are available both in AUR
-and the arch-games repository.
-
-The package name is dfhack-git :)
-
-Compatibility
--------------
-
-DFHack works on Windows XP, Vista, 7 or any modern Linux distribution.
-
-Windows 2000 is currently *not supported* due to missing OS functionality.
-If you know how to easily suspend processes, you can fix it :)
-
-OSX is also not supported due to lack of developers with a Mac.
-
-Currently supported Dwarf Fortress versions:
-* Windows
- 0.31.01 - 0.31.03
-
-* Linux
- wine together with the Windows versions
-
-Using the library as a developer
---------------------------------
-
-The library is compilable under Linux with GCC and under Windows with MinGW32
-and MSVC compilers. It is using the cmake build system. See COMPILE for details.
-
-DFHack is using the zlib/libpng license. This makes it easy to link to it, use
-it in-source or add your own extensions. Contributing back to the dfhack
-repository is welcome and the right thing to do :)
-
-At the time of writing there's no API reference or documentation. The code does
-have a lot of comments though (and getting better all the time).
-
-Contributing to DFHack
-----------------------
-
-Several things should be kept in mind when contributing to DFHack.
-
-**** Coding style ****
-
-DFhack uses ANSI formatting and four spaces as indentation. Line endings are
-UNIX. The files use UTF-8 encoding. Code not following this won't make me happy,
-because I'll have to fix it. There's a good chance I'll make *you* fix it ;)
-
-**** How to get new code into DFHack ****
-
-You can send patches or make a clone of the github repo and ask me on the
-IRC channel to pull your code in. I'll review it and see if there are any
-problems. I'll fix them if they are minor.
-
-Fixes are higher in priority. If you want to work on something, but don't
-know what, check out http://github.com/peterix/dfhack/issues -- this is also
-a good place to dump new ideas and/or bugs that need fixing.
-
-**** Layout for tools ****
-
-Tools live in the tools/ folder. There, they are split into three categories:
-
-distributed: these tools get distributed with binary releases and are installed
- by doing 'make install' on linux. They are supposed to be stable
- and supported. Experimental, useless, buggy or untested stuff
- doesn't belong here.
-examples : examples are tools that aren't very useful, but show how DF
- and DFHack work. They should use only DFHack API functions.
- No actual hacking or 'magic offsets' are allowed.
-playground : This is a catch-all folder for tools that aren't ready to be
- examples or be distributed in binary releases. All new tools
- should start here. They can contain actual hacking, magic values
- and other nasty business.
-
-**** Modules - what are they? ****
-
-DFHack uses modules to partition sets of features into manageable chunks.
-A module can have both client and server side.
-
-Client side is the part that goes into the main library and is generally
-written in C++. It is exposed to the users of DFHack.
-
-Server side is used inside DF and serves to accelerate the client modules.
-This is written mostly in C style.
-
-There's a Core module that shouldn't be changed, because it defines
-the basic commands like reading and writing raw data. The client parts
-for the Core module are the various implementations of the Process
-interface.
-
-A good example of a module is Maps. Named the same in both client and
-server, it allows accelerating the reading of map blocks.
-
-Communication between modules happens by using shared memory. This is
-pretty fast, but needs quite a bit of care to not break.
-
-**** Dependencies ****
-
-Internal : either part of the codebase or statically linked.
-External : linked as dynamic loaded libraries (.dll, .so, etc.)
-
-If you want to add dependencies, think twice about it. All internal dependencies
-for core dfhack should be either public domain or require attribution at most.
-Internal dependencies for tools can be either that, or any Free Software
-licenses.
-
-** Current internal dependencies **
-
-tinyxml : used by core dfhack to read offset definitions from Memory.xml
-md5 : an implementation of the MD5 hash algorithm. Used for identifying
- DF binaries on Linux.
-argstream: Allows reading terminal application arguments. GPL!
-
-** Current external dependencies **
-
-wide-character ncurses : used for the veinlook tool on Linux.
-python 2.6 : required for building and using the python bindings.
-
-** Build-time dependencies **
-cmake: you need cmake to generate the build system and some configuration
- headers
-
-
-Tools
------
-All the DFHack tools are terminal programs. This might seem strange to Windows
-users, but these are meant mostly as examples for developers. Still, they can
-be useful and are cross-platform just like the library itself.
-
- - dfcleanmap : Cleans all the splatter that get scattered all over the map.
- Only exception is mud. It leaves mud alone.
- - dfexpbench : Just a simple benchmark of the data export speed.
- - dfliquids : A command prompt for liquid creation and manipulation
- (the Moses effect included!)
- Also allows painting obsidian walls directly.
- Note:
- Spawning and deleting liquids can F up pathing data and
- temperatures (creating heat traps). You've been warned.
- - dfposition : Prints the current DF window properties and cursor position.
- - dfprospector: Lists all available minerals on the map and how much
- of them there is.
- - dfreveal : Reveals the whole map, waits for input and hides it again.
- If you close the tool while it waits, the map remains revealed.
- - dfsuspend : Test of the process suspend/resume mechanism.
- - dfunstuck : Use if you prematurely close any of the tools and DF
- appears to be stuck.
- - dfvdig : Designates a whole vein for digging. Point the cursor at a vein
- and run this thing :)
-
- - Your tool here: Write one ;)
-
-
-Memory offset definitions
--------------------------
-
-The file with memory offset definitions used by dfhack can be found in the
-output folder.
-
-~ EOF ~
diff --git a/README.rst b/README.rst
new file mode 100644
index 000000000..1e479d107
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,260 @@
+============
+Introduction
+============
+
+DFHack is a Dwarf Fortress memory access library and a set of basic
+tools using this library. The library is a work in progress, so things
+might change as more tools are written for it.
+
+It is an attempt to unite the various ways tools access DF memory and
+allow for easier development of new tools.
+
+.. contents::
+
+
+==============
+Getting DFHack
+==============
+The project is currently hosted on github_, for both source and
+binaries at http://github.com/peterix/dfhack
+
+.. _github: http://www.github.com/
+
+Packages
+========
+The library and tools are packaged for Archlinux and are available both
+in AUR and the arch-games repository.
+
+The package name is dfhack-git :)
+
+=============
+Compatibility
+=============
+DFHack works on Windows XP, Vista, 7 or any modern Linux distribution.
+
+OSX is not supported due to lack of developers with a Mac.
+
+Currently supported Dwarf Fortress versions are Windows and Linux.
+
+Windows
+=======
+.. note::
+
+ Windows 2000 is currently *not supported* due to missing OS
+ functionality. If you know how to easily suspend processes, you can
+ fix it :)
+
+0.31.01 - 0.31.03 legacy
+0.31.04 - 0.31.12 SDL
+
+Linux
+=====
+0.31.05 - 0.31.12 native.
+There are missing offsets but Map tools should be OK. Linux support is
+a bit lacking, I'm working on it. All supported Windows versions
+running in wine can be used with native DFHack binaries.
+
+=====
+Tools
+=====
+All the DFHack tools are terminal programs. This might seem strange to Windows
+users, but these are meant mostly as examples for developers. Still, they can
+be useful and are cross-platform just like the library itself.
+
+dfcleanmap
+==========
+Cleans all the splatter that get scattered all over the map.
+Only exception is mud. It leaves mud alone.
+
+dfliquids
+=========
+A command prompt for liquid creation and manipulation (the Moses
+effect included!) Also allows painting obsidian walls directly.
+
+.. note::
+
+ Spawning and deleting liquids can F up pathing data and
+ temperatures (creating heat traps). You've been warned.
+
+dfposition
+==========
+Prints the current DF window properties and cursor position.
+
+dfprospector
+============
+Lists all available minerals on the map and how much of them there is.
+
+dfprobe
+============
+Can be used to determine tile properties.
+
+dfreveal
+========
+Reveals the whole map, waits for input and hides it again. If you close
+the tool while it waits, the map remains revealed.
+
+dfunstuck
+=========
+Use if you prematurely close any of the tools and DF appears to be
+stuck.
+
+dfvdig
+======
+Designates a whole vein for digging. Point the cursor at a vein and run
+this thing :)
+
+dfflows
+=======
+A tool for checking how many liquid tiles are actively checked for
+flows.
+
+dfattachtest
+============
+Test of the process attach/detach mechanism.
+
+dfsuspend
+=========
+Test of the process suspend/resume mechanism.
+
+dfexpbench
+==========
+Just a simple benchmark of the data export speed.
+
+dfdoffsets
+==========
+Dumps the offsets for the currently running DF version into the terminal.
+
+dfcleartask
+===========
+Solves the problem of unusable items after reclaim by clearing the 'in_job' bit of all items.
+
+Your tool here
+==============
+Write one ;)
+
+================================
+Using the library as a developer
+================================
+The library is compilable under Linux with GCC and under Windows with
+MinGW32 and MSVC compilers. It is using the cmake build system. See
+COMPILE for details.
+
+DFHack is using the zlib/libpng license. This makes it easy to link to
+it, use it in-source or add your own extensions. Contributing back to
+the dfhack repository is welcome and the right thing to do :)
+
+At the time of writing there's no API reference or documentation. The
+code does have a lot of comments though (and getting better all the
+time).
+
+Contributing to DFHack
+======================
+
+Several things should be kept in mind when contributing to DFHack.
+
+------------
+Coding style
+------------
+DFhack uses ANSI formatting and four spaces as indentation. Line
+endings are UNIX. The files use UTF-8 encoding. Code not following this
+won't make me happy, because I'll have to fix it. There's a good chance
+I'll make *you* fix it ;)
+
+-------------------------------
+How to get new code into DFHack
+-------------------------------
+You can send patches or make a clone of the github repo and ask me on
+the IRC channel to pull your code in. I'll review it and see if there
+are any problems. I'll fix them if they are minor.
+
+Fixes are higher in priority. If you want to work on something, but
+don't know what, check out http://github.com/peterix/dfhack/issues --
+this is also a good place to dump new ideas and/or bugs that need
+fixing.
+
+----------------
+Layout for tools
+----------------
+Tools live in the tools/ folder. There, they are split into three
+categories.
+
+distributed
+ these tools get distributed with binary releases and are installed
+ by doing 'make install' on linux. They are supposed to be stable
+ and supported. Experimental, useless, buggy or untested stuff
+ doesn't belong here.
+examples
+ examples are tools that aren't very useful, but show how DF and
+ DFHack work. They should use only DFHack API functions. No actual
+ hacking or 'magic offsets' are allowed.
+playground
+ This is a catch-all folder for tools that aren't ready to be
+ examples or be distributed in binary releases. All new tools should
+ start here. They can contain actual hacking, magic values and other
+ nasty business.
+
+------------------------
+Modules - what are they?
+------------------------
+DFHack uses modules to partition sets of features into manageable
+chunks. A module can have both client and server side.
+
+Client side is the part that goes into the main library and is
+generally written in C++. It is exposed to the users of DFHack.
+
+Server side is used inside DF and serves to accelerate the client
+modules. This is written mostly in C style.
+
+There's a Core module that shouldn't be changed, because it defines the
+basic commands like reading and writing raw data. The client parts for
+the Core module are the various implementations of the Process
+interface.
+
+A good example of a module is Maps. Named the same in both client and
+server, it allows accelerating the reading of map blocks.
+
+Communication between modules happens by using shared memory. This is
+pretty fast, but needs quite a bit of care to not break.
+
+------------
+Dependencies
+------------
+Internal
+ either part of the codebase or statically linked.
+External
+ linked as dynamic loaded libraries (.dll, .so, etc.)
+
+If you want to add dependencies, think twice about it. All internal
+dependencies for core dfhack should be either public domain or require
+attribution at most. External dependencies for tools can be either
+that, or any Free Software licenses.
+
+Current internal dependencies
+-----------------------------
+tinyxml
+ used by core dfhack to read offset definitions from Memory.xml
+md5
+ an implementation of the MD5 hash algorithm. Used for identifying
+ DF binaries on Linux.
+argstream
+ Allows reading terminal application arguments. GPL!
+
+Current external dependencies
+-----------------------------
+wide-character ncurses
+ used for the veinlook tool on Linux.
+x11 libraries
+ used for sending key events on linux
+
+Build-time dependencies
+-----------------------
+cmake
+ you need cmake to generate the build system and some configuration
+ headers
+
+=========================
+Memory offset definitions
+=========================
+The files with memory offset definitions used by dfhack can be found in the
+data folder.
+
diff --git a/Readme.html b/Readme.html
new file mode 100644
index 000000000..98eb64c8a
--- /dev/null
+++ b/Readme.html
@@ -0,0 +1,601 @@
+
+
+
+
+
+
+
+
+
+
+
DFHack is a Dwarf Fortress memory access library and a set of basic
+tools using this library. The library is a work in progress, so things
+might change as more tools are written for it.
+
It is an attempt to unite the various ways tools access DF memory and
+allow for easier development of new tools.
0.31.05 - 0.31.12 native.
+There are missing offsets but Map tools should be OK. Linux support is
+a bit lacking, I'm working on it. All supported Windows versions
+running in wine can be used with native DFHack binaries.
All the DFHack tools are terminal programs. This might seem strange to Windows
+users, but these are meant mostly as examples for developers. Still, they can
+be useful and are cross-platform just like the library itself.
The library is compilable under Linux with GCC and under Windows with
+MinGW32 and MSVC compilers. It is using the cmake build system. See
+COMPILE for details.
+
DFHack is using the zlib/libpng license. This makes it easy to link to
+it, use it in-source or add your own extensions. Contributing back to
+the dfhack repository is welcome and the right thing to do :)
+
At the time of writing there's no API reference or documentation. The
+code does have a lot of comments though (and getting better all the
+time).
DFhack uses ANSI formatting and four spaces as indentation. Line
+endings are UNIX. The files use UTF-8 encoding. Code not following this
+won't make me happy, because I'll have to fix it. There's a good chance
+I'll make you fix it ;)
You can send patches or make a clone of the github repo and ask me on
+the IRC channel to pull your code in. I'll review it and see if there
+are any problems. I'll fix them if they are minor.
+
Fixes are higher in priority. If you want to work on something, but
+don't know what, check out http://github.com/peterix/dfhack/issues --
+this is also a good place to dump new ideas and/or bugs that need
+fixing.
Tools live in the tools/ folder. There, they are split into three
+categories.
+
+
distributed
+
these tools get distributed with binary releases and are installed
+by doing 'make install' on linux. They are supposed to be stable
+and supported. Experimental, useless, buggy or untested stuff
+doesn't belong here.
+
examples
+
examples are tools that aren't very useful, but show how DF and
+DFHack work. They should use only DFHack API functions. No actual
+hacking or 'magic offsets' are allowed.
+
playground
+
This is a catch-all folder for tools that aren't ready to be
+examples or be distributed in binary releases. All new tools should
+start here. They can contain actual hacking, magic values and other
+nasty business.
DFHack uses modules to partition sets of features into manageable
+chunks. A module can have both client and server side.
+
Client side is the part that goes into the main library and is
+generally written in C++. It is exposed to the users of DFHack.
+
Server side is used inside DF and serves to accelerate the client
+modules. This is written mostly in C style.
+
There's a Core module that shouldn't be changed, because it defines the
+basic commands like reading and writing raw data. The client parts for
+the Core module are the various implementations of the Process
+interface.
+
A good example of a module is Maps. Named the same in both client and
+server, it allows accelerating the reading of map blocks.
+
Communication between modules happens by using shared memory. This is
+pretty fast, but needs quite a bit of care to not break.
linked as dynamic loaded libraries (.dll, .so, etc.)
+
+
If you want to add dependencies, think twice about it. All internal
+dependencies for core dfhack should be either public domain or require
+attribution at most. External dependencies for tools can be either
+that, or any Free Software licenses.
The files with memory offset definitions used by dfhack can be found in the
+data folder.
+
+
+
+
diff --git a/build/generate-MSVC-2002.bat b/build/generate-MSVC-2002.bat
deleted file mode 100644
index 4f6b68065..000000000
--- a/build/generate-MSVC-2002.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-mkdir build-real
-cd build-real
-cmake ..\.. -G"Visual Studio 7"
-pause
\ No newline at end of file
diff --git a/build/generate-MSVC-2003.bat b/build/generate-MSVC-2003.bat
deleted file mode 100644
index c45e02e4f..000000000
--- a/build/generate-MSVC-2003.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-mkdir build-real
-cd build-real
-cmake ..\.. -G"Visual Studio 7 .NET 2003"
-pause
\ No newline at end of file
diff --git a/output/Memory-40d.xml b/data/Memory-40d.xml
similarity index 100%
rename from output/Memory-40d.xml
rename to data/Memory-40d.xml
diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml
new file mode 100644
index 000000000..294886988
--- /dev/null
+++ b/data/Memory-ng.xml
@@ -0,0 +1,1665 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TODO: Parse this and turn it into Job tags
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .,:rsr,
+ :2;,;r2A@@5
+ @2::s5A#@@@ @r. .
+ sd;:riXA#@@ :@@@Gir;;AS9
+ Bs::sS3A#@2 @@#AhXirsS#;
+ iHrLr5d#@@@ .@#95sr;;rie
+ i*' `*@3 @@A2sr;:;r#5
+ :..:rll: @@A5sr::r3@
+ @Hr;iZ#@@@@ `:rr;;;;:
+ S@r.;i2#@@@ @s. ..
+ @2::ri2A@@# B@G2ir:...5i
+ :@r,r3X##@@ @G5sr:..,:A
+ .@Ar;;rSB@@# H#2sr;,..,is
+ .' `* ,@ASs;:..,:B
+ ;rr;:,..,:.
+ `'''
+ W I N D O W S
+ and
+ W I N E
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ vector
+ vector
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ the skill that will be increased at the end of the mood (or not)
+
+ seems to be indexes in the list of possible colors defined in the raws for each group
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Incrementaly assigned
+ seems to be just like the old occupations
+
+
+ like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ...
+ subsubtype ?
+ subtype ?
+ index of material (for example, 2 is for silver)
+ set only for shell / bone mood requirements ?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ WORLD: 0x0165c1d0 ?
+
+ Was 0x17f5ab8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ List of offsets in the VTable :
+
+
+
+
+
+
+
+
+
+ (in the vtable)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ BOGUS!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .-"""-.
+ ' \
+ |,. ,-. | _________________________
+ |()L( ()| | \ \
+ |,' `".| | /_ Argh !!! \
+ |.___.',| ` \________________________\
+ .j `--"' ` `.
+ / ' ' \
+ / / ` `.
+ / / ` .
+ / / l |
+ . , L I N U X | |
+ ,"`. .| |
+ _.' ``. | `..-'l
+ | `.`, | `.
+ | `. __.j )
+ |__ |--""___| ,-'
+ `"--...,+"""" `._,.-'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ vector
+ vector
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CHMOD
+ VERIFY!
+
+
+ chmod
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CHMOD
+
+
+
+
+ Incrementaly assigned
+ seems to be just like the old occupations
+
+
+ like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ...
+ subsubtype ?
+ subtype ?
+ index of material (for example, 2 is for silver)
+ set only for shell / bone mood requirements ?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VERIFIED
+
+ Creatures
+ =========
+ WORLD + 0x139E0
+ 0x92d79d4
+ 0x92d79e0 = real one? seems like it
+ 0x92d7a10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ VERIFIED
+ VERIFIED
+ VERIFIED
+ VERIFIED
+
+
+
+
+
+
+
+
diff --git a/output/Memory.xml b/data/Memory.xml
old mode 100755
new mode 100644
similarity index 78%
rename from output/Memory.xml
rename to data/Memory.xml
index fa97b261a..fd0072623
--- a/output/Memory.xml
+++ b/data/Memory.xml
@@ -4,6 +4,7 @@
0x0
+
====================================================================
T R A I T S
====================================================================
@@ -217,6 +218,17 @@
level_2="Often does the first thing that comes to mind"
level_1="Acts impulsively"
level_0="Always acts without considering alternatives or thinking through possibilities">29
+
+ ====================================================================
+ M O O D S
+ ====================================================================
+
+
+
+
+
+
+
====================================================================
P R O F E S S I O N S
====================================================================
@@ -322,6 +334,7 @@
888990
+
====================================================================
J O B S
====================================================================
@@ -792,7 +805,32 @@ size=212
626364
-
+
+ ====================================================================
+ L E V E L S
+ ====================================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TODO verify level 16 and up's existence in DF2010
+
+
+
+ -1 for no cap
+
====================================================================
L A B O R S
====================================================================
@@ -1427,6 +1465,8 @@ map_data_1b60_offset 0x1B9c
0x2880x2980x29C
+ 0x390
+ 0x394 the skill that will be increased at the end of the mood (or not)
0x464
- 0x390
- 0x394 the skill that will be increased at the end of the mood (or not)
0x6040x6D40x774
@@ -1447,20 +1485,23 @@ map_data_1b60_offset 0x1B9c
Castes
======
- 0x70
- 0x64
- 0x680x51C
- 0xACC0x654
+ 0xACC
- Body Parts
- ==========
- 0x0
- 0x1C
- 0x44
- 0x78
- 0x90
+ Color Mods
+ ==========
+ 0x70
+ 0x64
+ 0x68
+
+ Body Parts
+ ==========
+ 0x0
+ 0x1C
+ 0x44
+ 0x78
+ 0x90
Materials
=========
@@ -1597,7 +1638,90 @@ map_data_1b60_offset 0x1B9c
0x0 Why do i have to redefine this ???
-
+
+ 394ff63fc00fedd5df0b36e4beb589bc
+ 0x4c091569
+ 0x014abee4 CHMOD
+ 0x1471FB0 BOGUS!
+ 0x180b10c LOOKS O.K.
+ 0xe6c0dc VERIFIED
+ 0xe9a1b0 VERIFIED
+ 0xe9a18c VERIFIED
+ 0xaf12cc VERIFIED
+ 0xE80780 LOOKS O.K.
+ 0xEB2878 LOOKS O.K.
+ 0x0 Why do i have to redefine this ???
+ ... what?
+
+
+ c4b7e37dafa2716e31d29110968ac64e
+ 0x4c0f83d5
+ 0xaf12d0
+
+
+ 1c0b5254af1b8ff9a34b51c3f6609da3
+ 0x4c1cbe4b
+ 0xaf32d80xaf12d0
+ 0x180d11c 0x180b10c
+ 0xe6e0ec
+ 0xe9c1c0
+ 0xe9c19c
+ map size X: 0x16c4b10
+ map size Y: 0x16c4b14
+
+
+ a83e6b21307cf41fb54c315fa40dec86
+ 0x4c1d69fe
+ 0x14acee8
+
+
+ rebase="0xD030"
+
+
+ 1a85839ab03df082974dc5629d3fbc26
+ 0x4C3897C0
+ 0xaff2d8
+ 0x16D33CC
+ 0x16D33FC
+ 0x4c
+
+ Creatures
+ =========
+ 0x168E73C
+ 0x014b9f1c
+ 0X1F4
+ 0x4AC
+ 0x64c
+ 0x71c
+ 0x7Bc
+ 0x0788
+ 0x07A0
+ 0x87c
+
+
+ 349d1ad6eda7b6c5e87f8e4726a0999a
+ 0x4C398089
+
+
+ 552cfa417fd131204ebfee66aefc4adb
+ 0x4C496D93
+ 0xB062D8
+ 0xe81114 VERIFIED
+ 0xeAF1E8 VERIFIED
+ 0xeAF1C4 VERIFIED
+
+
+ f0459165a426a9f2dd8d957e9fa7f01d
+ 0x4C4C32E7
+
.-"""-.
' \
|,. ,-. | _________________________
@@ -1615,185 +1739,229 @@ map_data_1b60_offset 0x1B9c
| `.`, | `.
| `. __.j )
|__ |--""___| ,-'
- `"--...,+"""" `._,.-'
-
-
+ `"--...,+"""" `._,.-'
+
-
- 1d759a11af258263ef5c139d6d9a3e15
+
Basic things
============
- 0xC
- 0x0
- 0x4
-
+ 0xC VERIFIED
+ 0x0 VERIFIED
+ 0x4 VERIFIED
+
+ MAP BLOCK OFFSETS
+ =================
+ 0x08 VERIFIED
+ 0x20 VERIFIED
+ 0x24 VERIFIED
+ 0x006A VERIFIED
+ 0x026C VERIFIED
+ 0x066c VERIFIED
+ 0x156c VERIFIED
+ 0x176c VERIFIED
+ 0x1D6C VERIFIED
+ 0x0D6c VERIFIED
+
+ MAP FEATURE OFFSETS
+ ===================
+ 0x94 VERIFIED
+ 0x28 VERIFIED
+ 0x2C VERIFIED
+
+ 0x24 VERIFIED
+ 0x28 VERIFIED
+
+ values for the region structure
+ ===============================
+ 0x58 VERIFIED
+ 0x54 VERIFIED
+ geoblock offsets
+ ================
+ 0x4 VERIFIED
+ 0x4 VERIFIED
+ Name struct
+ ===========
+ 0x0 VERIFIED
+ 0x4 VERIFIED
+ 0x8 VERIFIED
+
+ Creature offsets
+ ================
+ 0x0 VERIFIED
+ 0x3c CHMOD
+ 0x40 CHMOD
+ 0x44 CHMOD
+ 0x90 BAD!!
+ 0x8C CHMOD
+ 0x90 CHMOD
+ 0xA4 VERIFY
+ 0xA6 CHMOD
+ 0xA8 CHMOD
+ 0xB4 VERIFY!
+ 0X144 CHMOD
+ 0x18C VERIFY!
+ 0x19C VERIFY!
+ 0x1A0 VERIFY!
+ 0x464 BAD!
+ 0x258 CHMOD
+ 0x394 VERIFY!
+ the skill that will be increased at the end of the mood (or not)
+ 0x604 BAD!
+ 0x6D4 BAD!
+ 0x51C CHMOD
+ 0x0500 CHMOD
+ 0x0758 BAD!
+ 0x5AC CHMOD
+
+ Souls
+ =====
+ 0x0
+ 0x1C4 CHMOD
+ 0x1DC CHMOD
+ 0x88 BAD!
+
+ Body Parts
+ ==========
+ 0x0
+ 0x1C
+ 0x44
+ 0x78
+ 0x90
+
+ Job structure
+ =============
+ 0x0 Incrementaly assigned
+ 0x8 seems to be just like the old occupations
+ 0xa4
+
+ Job materials
+ =============
+ 0x0 like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ...
+ 0x2 subsubtype ?
+ 0x4 subtype ?
+ 0x8 index of material (for example, 2 is for silver)
+ 0x18 set only for shell / bone mood requirements ?
+
+ Creature type offsets
+ =====================
+ 0x60 VERIFIED
+ from 0.31.08
+ Toad: 0xaf75b68
+ Toad: rawname = 0x0
+ Toad: character (not reliable) = 0x20
+ Toad: caste vector = 0x60
+ Toad: extract? vector = 0x18f4
+ Toad: colors = 0x36
+ 0x18f4 VERIFIED
+ 0x20 VERIFIED
+ 0x36 LOOKS OK
+
+ Castes
+ ======
+ 0x70
+ 0x64
+ 0x68
+ 0x51C
+ 0xACC
+ 0x654
+
+
+
+ Color descriptors
+ =================
+ 0x0 VERIFIED
+ 0x1C VERIFIED
+ 0x24 VERIFIED
+ 0x28 VERIFIED
+ 0x2C VERIFIED
+
+ Language tables
+ ===============
+ 0x1C VERIFIED
+
+ Constructions
+ =============
+ 0x14
+
+
+
+ 1d759a11af258263ef5c139d6d9a3e15
- 0x92D00C0 0x0165B188
+ 0x92D00C0
Position and window dimensions
==============================
- 0x8cd3b18 0xe32798
- 0x8cd3b1c 0xe60838
- 0x8cd3b20 0xe60814
- 0x8b17370 0xae82cc
+ 0x8cd3b18
+ 0x8cd3b1c
+ 0x8cd3b20
+ 0x8b17370
+ 0x9464d6c
- 0x9464d6c 0x17f5ab8
GUI State
=========
- 0x92c971c 0x146e45f
-
- Map stuff
+ Map data
=========
0x9322d20 WORLD + 0x52C60
- 0x08
- 0x20
- 0x24
- 0x006A
- 0x026C
- 0x066c
- 0x156c
- 0x176c
- 0x1D6C
- 0x0D6c
Map Features
============
WORLD + 0x5487C
0x932493C
- 0x94
- 0x28
- 0x2C
WORLD + 0x548F4
0x93249B4
- 0x24
- 0x28
* map size in blocks *
- 0x9322d34 0x016ad738
- 0x9322d380x016ad73C
- 0x9322d3C0x016ad740
+ 0x9322d34
+ 0x9322d38
+ 0x9322d3C
* map size in tiles *
- 0x9322d40 0x016ad744
- 0x9322d44 0x016ad748
- 0x9322d48 0x016ad74C
+ 0x9322d40
+ 0x9322d44
+ 0x9322d48
* region coords *
WORLD + 0x525C8
- 0x9322d4C 0x016ad750
+ 0x9322d4C
WORLD + 0x525CC
- 0x9322d50 0x016ad754
+ 0x9322d50
WORLD + 0x525D0
- 0x9322d54 0x016ad758
+ 0x9322d54
* World size * (WORDs)
WORLD + 0x542E0
- 0x93243A0 0x016AEDD4
+ 0x93243A0
WORLD + 0x542E2
- 0x93243A2 0x016AEDD6
+ 0x93243A2
WORLD + 0x54894
- 0x9324954 FIX 0x16AF52C
+ 0x9324954
WORLD + 0x548B8
- 0x9324978 FIX 0x16AF574
-
- values for the region structure
- ===============================
- 0x58 0x64 FIX
- 0x54 0x60 FIX
- geoblock offsets
- ================
- 0x4 vector
- 0x4 vector
-
- Name struct
- ===========
- 0x0
- 0x4
- 0x8
+ 0x9324978
Creatures
=========
0x092E3AA0
0x092CB608
0x092CB5FC
- 0x0
- 0x6c
- 0x3c *
- 0x44 *
- 0x90
- 0x8C *
- 0x90 *
- 0x110
- 0xA6 *
- 0x114
- 0XB4 *
- 0X1F4
- 0X21C
-
- 0x18C *
- 0x19C *
- 0x1A0 *
- 0x464
- 0x390 from chmod
- 0x394 the skill that will be increased at the end of the mood (or not)
- 0x604
- 0x6D4
- 0x774
- 0x0740
- 0x0758
- 0x834
-
- Souls
- =====
- 0x0
- 0x1F4
- 0x224
- 0x88
-
- Castes
- ======
- 0x70
- 0x64
- 0x68
- 0x51C
- 0xACC
- 0x654
-
- Body Parts
- ==========
- 0x0
- 0x1C
- 0x44
- 0x78
- 0x90
-
- Job structure
- =============
- 0x0 Incrementaly assigned
- 0x8 seems to be just like the old occupations
- 0xa4
-
- Job materials
- =============
- 0x0 like mood materials, 0=bars, 4=stone, 5=wood, 57=cloth, 54=leather ...
- 0x2 subsubtype ?
- 0x4 subtype ?
- 0x8 index of material (for example, 2 is for silver)
- 0x18 set only for shell / bone mood requirements ?
Materials
=========
@@ -1812,32 +1980,29 @@ map_data_1b60_offset 0x1B9c
creature types actually used for creatures,
0x09324F14
- 0x138
- 0x1A14
- 0xE0
- 0xF6
+
+ Color descriptors
+ =================
+ 0x9329378 VERIFIED
+ 0x9329390 VERIFIED
Translations
============
WORLD + 0x54E50
- 23
+ 0x9324fd4
WORLD + 0x54E80
- 24
- 0x4C
+ 0x9324fec
Constructions
=============
WORLD + 0x84
0x92D0144 0x165b290
- 0x14
+
+ Time
+ ====
+ 0x92C9680
+ 0x92C9688
+
+
+ fea3801a26538b1741f3cc9294139fca
+
+ 0x92C60E0 MOST PROBABLY BOGUS!
+
+ Position and window dimensions
+ ==============================
+ 0x8cc9b38 VERIFIED
+ 0x8cc9b3c VERIFIED
+ 0x8cc9b40 VERIFIED
+ 0x8b0d36c VERIFIED
+ 0x945ad8c VERIFIED
+ GUI State
+ =========
+ 0x92bf73c VERIFIED
+
+ Map data
+ ========
+ WORLD + 0x52C60?
+ 0x9318D40 VERIFIED
+
+ Map Features
+ ============
+ WORLD + 0x5487C?
+ 0x931A95C VERIFIED
+ WORLD + 0x548F4?
+ 0x931A9D4 VERIFIED
+
+ * map size in blocks *
+ 0x9318D54 VERIFIED
+ 0x9318D58 VERIFIED
+ 0x9318D5C VERIFIED
+
+ * map size in tiles *
+ 0x9318D60 VERIFIED
+ 0x9318D64 VERIFIED
+ 0x9318D68 VERIFIED
+
+ * region coords *
+ WORLD + 0x525C8
+ 0x9318D6C VERIFIED
+ WORLD + 0x525CC
+ 0x9318D70 VERIFIED
+ WORLD + 0x525D0
+ 0x9318D74 VERIFIED (old = 0x9322d54)
+
+ * World size * (WORDs)
+ WORLD + 0x542E0
+ 0x931A3C0 VERIFIED
+ WORLD + 0x542E2
+ 0x931A3C2 VERIFIED
+ WORLD + 0x54894
+ 0x931A974 VERIFIED
+ WORLD + 0x548B8
+ 0x931A998 VERIFIED
+
+ Materials
+ =========
+ soil, stone, metal
+ inorganics vector
+ 0x931ae88 VERIFIED
+
+ wood and plant matter
+ 0x931ae94 VERIFIED
+
+ plant matter
+ 0x931aea0 VERIFIED
+
+ just wood
+ 0x931aeb8 VERIFIED
+
+ creature types actually used for creatures,
+ 0x931af34 VERIFIED
+
+ Color descriptors
+ =================
+ 0x931f398 VERIFIED
+ 0x931f3b0 VERIFIED
+
+ Translations
+ ============
+ WORLD + 0x54E50
+ 0x931aff4
+ WORLD + 0x54E80
+ 0x931b00c
+
+ Creatures
+ =========
+ 0x92D9AC0
+ 0x92C16280x092CB608
+ 0x92C161C0x092CB5FC
+
Time
====
- 0x92C9688
- 0x92C9680
+ 0x92BF6A0
+ 0x92BF6A8
+ YEAR 0x92BF6A0, WORLD - 0x6A40
+ TICKS 0x92BF6A8, WORLD - 0x6A40 + 0x08
+
+
+
+ 13a1c19e8f59b74e307e094e2a0f28c3
+ 0x8b0b328 VERIFIED
+ WORLD = 0x92C4000
+ Creatures
+ =========
+ WORLD + 0x139E0
+ 0x92d79d4
+ 0x92d79e0 = real one? seems like it
+ 0x92d7a10
+
+
+ b31979551782e89c049b11db8d2d86d7
+
+
+ e37750890350d7b9d8203879aff8fa5c
+
+
+
+
+ 4f1f988bc1b425d4193d3d8b7b0579a5
+ stealing memory...
+ looking for vectors...
+ -------------------
+ !!LANGUAGE TABLES!!
+ -------------------
+ translation vector: 0x932bf2c
+ lang vector: 0x932bf14
+ word table offset: 0x1c
+ -------------
+ !!MATERIALS!!
+ -------------
+ inorganics:
+ 0x932bda8
+ organics:
+ 0x932bdb4
+ trees:
+ 0x932bdd8
+ plants:
+ 0x932bdc0
+ color descriptors:
+ 0x93302b8
+ Amber color:0xaf842e0
+ all descriptors:
+ 0x93302d0
+ toad-first creature types:
+ 0x932be54
+ all creature types:
+ 0x932be2c
+ 0x932be54
+ Toad: 0xb076f88
+ Toad: rawname = 0x0
+ Toad: character (not reliable) = 0x20
+ Toad: caste vector = 0x60
+ Toad: extract? vector = 0x18f4
+ Toad: colors = 0x36
+
+
+ 3e7bea269018a6fb88ef53715685aa64
+ -------------------
+ !!LANGUAGE TABLES!!
+ -------------------
+ translation vector: 0x932bf2c
+ lang vector: 0x932bf14
+ word table offset: 0x1c
+ -------------
+ !!MATERIALS!!
+ -------------
+ inorganics:
+ 0x932bda8
+ organics:
+ 0x932bdb4
+ trees:
+ 0x932bdd8
+ plants:
+ 0x932bdc0
+ color descriptors:
+ 0x93302b8
+ Amber color:0xcc3a770
+ all descriptors:
+ 0x93302d0
+ toad-first creature types:
+ 0x932be54
+ elephant-first creature types:
+ all creature types:
+ 0x932be2c
+ 0x932be54
+ Toad: 0xc77d798
+ Toad: rawname = 0x0
+ Toad: character (not reliable) = 0x20
+ Toad: caste vector = 0x60
+ Toad: extract? vector = 0x18f4
+ Toad: colors = 0x36
+
+ Buildings
+ =========
+ 0x92eb068
+ 0xE0
+
+ 0x93302e8
+ 0x4
+ 0x8
+
+
+
+
+
+
+
+
+
+ 7b04ad536b8b657588ac209a7f95e1d1
+ 0x8cf7a58 VERIFIED
+ 0x8cf7a5C VERIFIED
+ 0x8cf7a60 VERIFIED
+ 0x8b3b328 VERIFIED
+ -------------------
+ !!LANGUAGE TABLES!!
+ -------------------
+ translation vector: 0x9348f4c
+ lang vector: 0x9348f34
+ word table offset: 0x1c
+ -------------
+ !!MATERIALS!!
+ -------------
+ inorganics:
+ 0x9348dc8
+ organics:
+ 0x9348dd4
+ trees:
+ 0x9348df8
+ plants:
+ 0x9348de0
+ color descriptors:
+ 0x934d2d8
+ Amber color:0xac014c0
+ all descriptors:
+ 0x934d2f0
+ toad-first creature types:
+ 0x9348e74
+ all creature types:
+ 0x9348e4c
+ 0x9348e74
+ Toad: 0xadae390
+ Toad: rawname = 0x0
+ Toad: character (not reliable) = 0x20
+ Toad: caste vector = 0x60
+ Toad: extract? vector = 0x18f4
+ Toad: colors = 0x36
+
+
+ e79cead03187ecb692961b316b7cdcd4
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 000000000..1ced1fd7b
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,68 @@
+# repurposed from libnoise: http://github.com/qknight/libnoise/tree/master/doc/
+# following code and comments is by the original author, with some changes by
+# me (peterix)
+# ------------------------------------------------------------------------------
+#
+# many thanks go to Philippe Poilbarbe for writing the code this file is based on
+# http://www.cmake.org/pipermail/cmake/2006-August/010794.html
+#
+# much later i also found this:
+# http://tobias.rautenkranz.ch/cmake/doxygen/
+# but it is hard to understand...
+
+IF (BUILD_DFHACK_DOCUMENTATION)
+
+FIND_PACKAGE(Doxygen)
+
+IF(DOXYGEN_FOUND)
+ SET(DOXYGEN_LANGUAGE "English" CACHE STRING "Language used by doxygen")
+ MARK_AS_ADVANCED(DOXYGEN_LANGUAGE)
+
+ # you could also set the version with this, see Doxygen.in
+ # there you will find a line like this:
+ # PROJECT_NUMBER = @DFHACK_VERSION@
+ # @DFHACK_VERSION@ is then replaced by our global DFHACK_VERSION
+ #
+ # for instance you could uncomment the next 3 lines and change the version for testing
+ # SET(DFHACK_VERSION
+ # "1.2.3-foo500"
+ # )
+
+ # doxygen can reference external images with IMAGE_PATH, this is how we set it dynamically
+ SET( CMAKE_DOXYGEN_IMAGE_PATH
+ "${CMAKE_CURRENT_SOURCE_DIR}/img"
+ )
+
+ # doxygen searches for source code (defined in FILE_PATTERNS, for example: *.cpp *.h)
+ # with DOXYGEN_SOURCE_DIR we fill a list of directories and later we write it into
+ # the Doxyfile with a REGEX REPLACE (see below)
+ SET( DOXYGEN_SOURCE_DIR
+ # "${CMAKE_SOURCE_DIR}/library"
+ "${CMAKE_SOURCE_DIR}/doc/index.dxgen"
+ "${CMAKE_SOURCE_DIR}/library/include"
+ "${CMAKE_SOURCE_DIR}/library/include/dfhack"
+ "${CMAKE_SOURCE_DIR}/library/include/dfhack/modules"
+ "${CMAKE_SOURCE_DIR}/library/include/dfhack-c"
+ "${CMAKE_SOURCE_DIR}/library/include/dfhack-c/modules"
+# "${CMAKE_SOURCE_DIR}/library/modules"
+# "${CMAKE_SOURCE_DIR}/library/shm"
+# "${CMAKE_SOURCE_DIR}/library/private"
+ )
+
+ SET(DOXYGEN_OUTPUT_DIR html)
+ STRING(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${DOXYGEN_SOURCE_DIR}")
+
+ CONFIGURE_FILE(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+ SET(HTML_TARGET "html" )
+
+ ADD_CUSTOM_TARGET(${HTML_TARGET} ALL
+ /usr/bin/doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+
+ INSTALL( DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" DESTINATION "/usr/share/doc/dfhack-${DFHACK_VERSION}" )
+
+ELSE(DOXYGEN_FOUND)
+ MESSAGE (FATAL_ERROR "doxygen binary couldn't be found")
+ENDIF(DOXYGEN_FOUND)
+
+ENDIF (BUILD_DFHACK_DOCUMENTATION)
\ No newline at end of file
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
new file mode 100644
index 000000000..7c4302fa2
--- /dev/null
+++ b/doc/Doxyfile.in
@@ -0,0 +1,212 @@
+# Doxyfile 1.3.9.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = dfhack
+PROJECT_NUMBER = @DFHACK_VERSION@
+OUTPUT_DIRECTORY = .
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF =
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = YES
+INHERIT_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 4
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+SUBGROUPING = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = NO
+EXTRACT_LOCAL_METHODS = NO
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = @CMAKE_DOXYGEN_INPUT_LIST@
+FILE_PATTERNS = *.cpp *.h *.dxgen
+RECURSIVE = NO
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH = @CMAKE_DOXYGEN_IMAGE_PATH@
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 8
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = NO
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = YES
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = YES
+GRAPHICAL_HIERARCHY = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 0
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
diff --git a/doc/img/.dot b/doc/img/.dot
new file mode 100644
index 000000000..e69de29bb
diff --git a/doc/index.dxgen b/doc/index.dxgen
new file mode 100644
index 000000000..d356131f6
--- /dev/null
+++ b/doc/index.dxgen
@@ -0,0 +1,73 @@
+/*******************************************************************************
+www.sourceforge.net/projects/dfhack
+Copyright (c) 2009 Petr Mrázek (peterix)
+
+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.
+*/
+
+/*! \page index
+
+\htmlonly
+
DFHack
+
+\endhtmlonly
+
+
+
Introduction
+DFHack is a Dwarf Fortress memory access library and a set of basic tools using
+this library. The library is a work in progress, so things might change as more
+tools are written for it.
+
+It is an attempt to unite the various ways tools access DF memory and allow for
+easier development of new tools. In general, you can use it to move memory
+objects in and out of Dwarf Fortress really fast, regardless of DF version or OS.
+
+First part of the manual deals with the basic of using DFHack as a library:
+
+PLACEHOLDER TERRITORY!
+
+
Section \ref blah discusses some weird stuff
+ this is a link
+
Section \ref starting tells you how to cromulate at a distance!
+
+
+Second part has some details on DFHack development:
+
+
+
Section \ref starting tells you how to cromulate at a distance!
+
+
+The third part describes how to use the supported DFHack utilities
+
+
+
Section \ref dfattachtest shows how to use the \c dfattachtest program
+
Section \ref dfcleanmap shows how to use the \c dfcleanmap program
+
Section \ref dfexpbench shows how to use the \c dfexpbench program
+
Section \ref dfflows shows how to use the \c dfflows program
+
Section \ref dfliquids shows how to use the \c dfliquids program
+
Section \ref dfprobe shows how to use the \c dfprobe program
+
Section \ref dfprospector shows how to use the \c dfprospector program
+
Section \ref dfreveal shows how to use the \c dfreveal program
+
Section \ref dfsuspend shows how to use the \c dfsuspend program
+
Section \ref dfunstuck shows how to use the \c dfunstuck program
+
Section \ref dfvdig shows how to use the \c dfvdig program
+
+*/
+
diff --git a/fixTexts.sh b/fixTexts.sh
new file mode 100755
index 000000000..30ee0c52c
--- /dev/null
+++ b/fixTexts.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+rst2html README.rst > Readme.html
+rst2html COMPILE.rst > Compile.html
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index ce44079cf..8e09a2203 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -27,9 +27,11 @@ include_directories (${CMAKE_SOURCE_DIR}/library/depends/argstream/)
include_directories (${CMAKE_SOURCE_DIR}/library/private/)
SET(PROJECT_HDRS
+private/DFMemInfoManager.h
+private/ContextShared.h
+private/Internal.h
include/dfhack/DFError.h
include/dfhack/DFMemInfo.h
-include/dfhack/DFMemInfoManager.h
include/dfhack/DFProcessEnumerator.h
include/dfhack/DFProcess.h
include/dfhack/DFTileTypes.h
@@ -52,14 +54,18 @@ include/dfhack/modules/WindowIO.h
include/dfhack/modules/World.h
)
+SET(PROJECT_C_HDRS
+include/dfhack-c/DFTypes_C.h
+include/dfhack-c/DFContext_C.h
+)
+
SET(PROJECT_SRCS
DFMemInfo.cpp
DFMemInfoManager.cpp
DFContextManager.cpp
DFContext.cpp
+DFProcessEnumerator.cpp
ContextShared.cpp
-DFContext_C.cpp
-DFTypes_C.cpp
depends/md5/md5.cpp
depends/md5/md5wrapper.cpp
@@ -80,6 +86,11 @@ modules/Position.cpp
modules/Translation.cpp
modules/Vegetation.cpp
modules/World.cpp
+)
+
+SET(PROJECT_C_SRCS
+DFContext_C.cpp
+DFTypes_C.cpp
modules/Buildings_C.cpp
modules/Constructions_C.cpp
@@ -91,6 +102,8 @@ modules/Position_C.cpp
modules/Materials_C.cpp
modules/Translation_C.cpp
modules/Vegetation_C.cpp
+modules/WindowIO_C.cpp
+modules/World_C.cpp
)
SET(PROJECT_HDRS_LINUX
@@ -105,14 +118,12 @@ 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)
@@ -123,6 +134,11 @@ ELSE(UNIX)
LIST(APPEND PROJECT_SRCS ${PROJECT_SRCS_WINDOWS})
ENDIF(UNIX)
+IF(BUILD_DFHACK_C_BINDIGS)
+ LIST(APPEND PROJECT_HDRS ${PROJECT_C_HDRS})
+ LIST(APPEND PROJECT_SRCS ${PROJECT_C_SRCS})
+ENDIF(BUILD_DFHACK_C_BINDIGS)
+
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE )
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
@@ -161,65 +177,29 @@ SET_TARGET_PROPERTIES(dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
TARGET_LINK_LIBRARIES(dfhack ${PROJECT_LIBS})
+if(MSVC)
+ # This is a MSVC hack used for copying files into the target directory
+ # of build target set in MSVC.
+ # It exploits the fact that MSVC has some variables in .vcproj files, much like cmake does here.
+ #
+ # So, $(TargetDir) is ignored by cmake, and replaced with the actual output directory by MSVC
+ ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/data/Memory.xml $(TargetDir)/Memory.xml
+ )
+ ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Compile.html $(TargetDir)/Compile.html
+ )
+ ADD_CUSTOM_COMMAND(TARGET dfhack POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/Readme.html $(TargetDir)/Readme.html
+ )
+else(MSVC)
+ # Just put the file in the output directory on Linux and Mac
+ configure_file(${CMAKE_SOURCE_DIR}/data/Memory.xml ${DATA_OUTPUT_PATH}/Memory.xml COPYONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/Compile.html ${DATA_OUTPUT_PATH}/Compile.html COPYONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/Readme.html ${DATA_OUTPUT_PATH}/Readme.html COPYONLY)
+endif(MSVC)
+
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)
-
diff --git a/library/ContextShared.cpp b/library/ContextShared.cpp
index 7798cc85f..cf49a489b 100644
--- a/library/ContextShared.cpp
+++ b/library/ContextShared.cpp
@@ -24,33 +24,18 @@ using namespace DFHack;
DFContextShared::DFContextShared()
{
// init modules
- creatures = 0;
- maps = 0;
- position = 0;
- gui = 0;
- world = 0;
- materials = 0;
- translation = 0;
- vegetation = 0;
- buildings = 0;
- constructions = 0;
- items = 0;
- windowio = 0;
+ allModules.clear();
+ memset(&(s_mods), 0, sizeof(s_mods));
}
DFContextShared::~DFContextShared()
{
- if(creatures) delete creatures;
- if(maps) delete maps;
- if(position) delete position;
- if(gui) delete gui;
- if(materials) delete materials;
- if(translation) delete translation;
- if(vegetation) delete vegetation;
- if(buildings) delete buildings;
- if(constructions) delete constructions;
- if(world) delete world;
- if(windowio) delete windowio;
+ // invalidate all modules
+ for(int i = 0 ; i < allModules.size(); i++)
+ {
+ delete allModules[i];
+ }
+ allModules.clear();
}
bool DFContextShared::InitReadNames()
diff --git a/library/DFContext.cpp b/library/DFContext.cpp
index fe2d5002e..d46302426 100644
--- a/library/DFContext.cpp
+++ b/library/DFContext.cpp
@@ -27,7 +27,6 @@ distribution.
#include "dfhack/DFProcess.h"
#include "dfhack/DFProcessEnumerator.h"
#include "dfhack/DFContext.h"
-#include "dfhack/DFContext.h"
#include "dfhack/DFError.h"
#include
@@ -89,10 +88,18 @@ bool Context::Detach()
{
if (!d->p->detach())
{
+ cerr << "Context::Detach failed!" << endl;
return false;
}
d->shm_start = 0;
// invalidate all modules
+ for(int i = 0 ; i < d->allModules.size(); i++)
+ {
+ delete d->allModules[i];
+ }
+ d->allModules.clear();
+ memset(&(d->s_mods), 0, sizeof(d->s_mods));
+ /*
if(d->creatures)
{
delete d->creatures;
@@ -147,7 +154,7 @@ bool Context::Detach()
{
delete d->translation;
d->translation = 0;
- }
+ }*/
return true;
}
@@ -167,6 +174,10 @@ bool Context::AsyncSuspend()
bool Context::Resume()
{
+ for(int i = 0 ; i < d->allModules.size(); i++)
+ {
+ d->allModules[i]->OnResume();
+ }
return d->p->resume();
}
bool Context::ForceResume()
@@ -201,13 +212,39 @@ Process * Context::getProcess()
/*******************************************************************************
M O D U L E S
*******************************************************************************/
+
+#define MODULE_GETTER(TYPE) \
+TYPE * Context::get##TYPE() \
+{ \
+ if(!d->s_mods.p##TYPE)\
+ {\
+ d->s_mods.p##TYPE = new TYPE(d);\
+ d->allModules.push_back(d->s_mods.p##TYPE);\
+ }\
+ return d->s_mods.p##TYPE;\
+}
+
+MODULE_GETTER(Creatures);
+MODULE_GETTER(Maps);
+MODULE_GETTER(Gui);
+MODULE_GETTER(WindowIO);
+MODULE_GETTER(World);
+MODULE_GETTER(Position);
+MODULE_GETTER(Materials);
+MODULE_GETTER(Items);
+MODULE_GETTER(Translation);
+MODULE_GETTER(Vegetation);
+MODULE_GETTER(Buildings);
+MODULE_GETTER(Constructions);
+/*
Creatures * Context::getCreatures()
{
if(!d->creatures)
d->creatures = new Creatures(d);
return d->creatures;
}
-
+*/
+/*
Maps * Context::getMaps()
{
if(!d->maps)
@@ -284,7 +321,7 @@ Constructions * Context::getConstructions()
d->constructions = new Constructions(d);
return d->constructions;
}
-
+*/
/*
// returns number of buildings, expects v_buildingtypes that will later map t_building.type to its name
diff --git a/library/DFContextManager.cpp b/library/DFContextManager.cpp
index 636325bdc..46814d90e 100644
--- a/library/DFContextManager.cpp
+++ b/library/DFContextManager.cpp
@@ -23,10 +23,10 @@ distribution.
*/
#include "Internal.h"
+#include "DFMemInfoManager.h"
#include "dfhack/DFProcess.h"
#include "dfhack/DFProcessEnumerator.h"
-#include "dfhack/DFMemInfoManager.h"
#include "dfhack/DFError.h"
#include "dfhack/DFContext.h"
@@ -41,61 +41,186 @@ distribution.
using namespace DFHack;
namespace DFHack
{
- class DFContextMgrPrivate
+ class ContextManager::Private
{
public:
- DFContextMgrPrivate(){};
- ~DFContextMgrPrivate(){};
+ Private(){};
+ ~Private(){};
string xml; // path to xml
vector contexts;
ProcessEnumerator * pEnum;
};
}
+class DFHack::BadContexts::Private
+{
+ public:
+ Private(){};
+ vector bad;
+};
+
+
+BadContexts::BadContexts():d(new Private()){}
+
+BadContexts::~BadContexts()
+{
+ clear();
+ delete d;
+}
+
+bool BadContexts::Contains(Process* p)
+{
+ for(int i = 0; i < d->bad.size(); i++)
+ {
+ if((d->bad[i])->getProcess() == p)
+ return true;
+ }
+ return false;
+}
-ContextManager::ContextManager (const string path_to_xml) : d (new DFContextMgrPrivate())
+bool BadContexts::Contains(Context* c)
+{
+ for(int i = 0; i < d->bad.size(); i++)
+ {
+ if(d->bad[i] == c)
+ return true;
+ }
+ return false;
+}
+
+uint32_t BadContexts::size()
+{
+ return d->bad.size();
+}
+
+void BadContexts::clear()
+{
+ for(int i = 0; i < d->bad.size(); i++)
+ {
+ // delete both Process and Context!
+ // process has to be deleted after context, because Context does some
+ // cleanup on delete (detach, etc.)
+ Process * to_kill = d->bad[i]->getProcess();
+ delete d->bad[i];
+ delete to_kill;
+ }
+ d->bad.clear();
+}
+
+void BadContexts::push_back(Context* c)
+{
+ if(c)
+ d->bad.push_back(c);
+}
+
+Context * BadContexts::operator[](uint32_t index)
+{
+ if(index < d->bad.size())
+ return d->bad[index];
+ return 0;
+}
+
+ContextManager::ContextManager (const string path_to_xml) : d (new Private())
{
- d->pEnum = 0;
d->xml = QUOT (MEMXML_DATA_PATH);
d->xml += "/";
d->xml += path_to_xml;
+ d->pEnum = new ProcessEnumerator(d->xml);
}
ContextManager::~ContextManager()
{
purge();
+ // 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;
+ }
delete d;
}
-uint32_t ContextManager::Refresh()
+uint32_t ContextManager::Refresh( BadContexts* bad_contexts )
{
- purge();
- if(d->pEnum != 0)
- d->pEnum = new ProcessEnumerator(d->xml);
- else
+ // handle expired processes, remove stale Contexts
{
- delete d->pEnum;
- d->pEnum = new ProcessEnumerator(d->xml);
+ BadProcesses expired;
+ // get new list od living and expired Process objects
+ d->pEnum->Refresh(&expired);
+
+ // scan expired, kill contexts if necessary
+ vector ::iterator it = d->contexts.begin();;
+ while(it != d->contexts.end())
+ {
+ Process * test = (*it)->getProcess();
+ if(expired.Contains(test))
+ {
+ // ok. we have an expired context here.
+ if(!bad_contexts)
+ {
+ // with nowhere to put the context, we have to destroy it
+ delete *it;
+ // stop tracking it and advance the iterator
+ it = d->contexts.erase(it);
+ continue;
+ }
+ else
+ {
+ // we stuff the context into bad_contexts
+ bad_contexts->push_back(*it);
+ // stop tracking it and advance the iterator
+ it = d->contexts.erase(it);
+ // remove process from the 'expired' container, it is tracked by bad_contexts now
+ // (which is responsible for freeing it).
+ expired.excise(test);
+ continue;
+ }
+ }
+ else it++; // not expired, just advance to next one
+ }
+ // no expired contexts are in the d->contexts vector now
+ // all processes remaining in 'expired' are now destroyed along with it
}
- d->pEnum->purge();
- d->pEnum->findProcessess();
int numProcesses = d->pEnum->size();
+ int numContexts = d->contexts.size();
+ vector newContexts;
+ // enumerate valid processes
for(int i = 0; i < numProcesses; i++)
{
- Context * c = new Context(d->pEnum->operator[](i));
- d->contexts.push_back(c);
+ Process * test = d->pEnum->operator[](i);
+ bool exists = false;
+ // scan context vector for this process
+ for(int j = 0; j < numContexts; j++)
+ {
+ if((d->contexts[j])->getProcess() == test)
+ {
+ // already have that one, skip
+ exists = true;
+ }
+ }
+ if(!exists)
+ {
+ // new process needs a new context
+ Context * c = new Context(d->pEnum->operator[](i));
+ newContexts.push_back(c);
+ }
}
+ d->contexts.insert(d->contexts.end(), newContexts.begin(), newContexts.end());
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())
@@ -111,16 +236,11 @@ Context * ContextManager::getSingleContext()
}
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;
- }
+ d->pEnum->purge();
}
\ No newline at end of file
diff --git a/library/DFContext_C.cpp b/library/DFContext_C.cpp
index 3de599df0..e6406c5be 100644
--- a/library/DFContext_C.cpp
+++ b/library/DFContext_C.cpp
@@ -240,7 +240,7 @@ DFHackObject* Context_getWindow(DFHackObject* context)
{
if(context != NULL)
{
- return (DFHackObject*)((DFHack::Context*)context)->getWindow();
+ return (DFHackObject*)((DFHack::Context*)context)->getWindowIO();
}
return NULL;
diff --git a/library/DFMemInfo.cpp b/library/DFMemInfo.cpp
index 8ac0a2c94..ca7c58d03 100644
--- a/library/DFMemInfo.cpp
+++ b/library/DFMemInfo.cpp
@@ -27,8 +27,60 @@ distribution.
#include "dfhack/DFError.h"
#include "dfhack/DFProcess.h"
+//Inital amount of space in levels vector (since we usually know the number, efficent!)
+#define NUM_RESERVE_LVLS 20
+#define NUM_RESERVE_MOODS 6
using namespace DFHack;
+/*
+* Common data types
+*/
+namespace DFHack
+{
+ struct t_type
+ {
+ t_type(uint32_t assign, uint32_t type, std::string classname)
+ :classname(classname),assign(assign),type(type){};
+ std::string classname;
+ uint32_t assign;
+ uint32_t type;
+ };
+
+ struct t_class
+ {
+ t_class(const t_class &old)
+ {
+ classname = old.classname;
+ vtable = old.vtable;
+ assign = old.assign;
+ type_offset = old.type_offset;
+ for(uint32_t i = 0; i < old.subs.size();i++)
+ {
+ t_type * t = new t_type (*old.subs[i]);
+ subs.push_back(t);
+ }
+ }
+ t_class ()
+ {
+ vtable = 0;
+ assign = 0;
+ type_offset = 0;
+ }
+ ~t_class()
+ {
+ for(uint32_t i = 0; i < subs.size();i++)
+ {
+ delete subs[i];
+ }
+ subs.clear();
+ }
+ std::string classname;
+ uint32_t vtable;
+ uint32_t assign;// index to typeclass array if multiclass. return value if not.
+ uint32_t type_offset; // offset of type data for multiclass
+ std::vector subs;
+ };
+}
/*
* Private data
*/
@@ -43,7 +95,9 @@ class memory_info::Private
vector professions;
vector jobs;
vector skills;
+ vector levels;
vector< vector > traits;
+ vector moods;
map labors;
// storage for class and multiclass
@@ -71,6 +125,8 @@ memory_info::memory_info()
d->base = 0;
d->p = 0;
d->classindex = 0;
+ d->levels.reserve(NUM_RESERVE_LVLS);
+ d->moods.reserve(NUM_RESERVE_MOODS);
}
// copy constructor
@@ -97,6 +153,8 @@ memory_info::memory_info(const memory_info &old)
d->skills = old.d->skills;
d->traits = old.d->traits;
d->labors = old.d->labors;
+ d->levels = old.d->levels;
+ d->moods = old.d->moods;
}
void memory_info::setParentProcess(Process * _p)
{
@@ -251,6 +309,30 @@ void memory_info::setSkill (const string & key, const string & value)
d->skills[keyInt] = value;
}
+void memory_info::setLevel(const std::string &nLevel,
+ const std::string &nName,
+ const std::string &nXp)
+{
+ uint32_t keyInt = strtol(nLevel.c_str(), NULL, 10);
+
+ if(d->levels.size() <= keyInt)
+ d->levels.resize(keyInt+1);
+
+ d->levels[keyInt].level = keyInt;
+ d->levels[keyInt].name = nName;
+ d->levels[keyInt].xpNxtLvl = strtol(nXp.c_str(), NULL, 10);
+}
+
+void memory_info::setMood(const std::string &id, const std::string &mood)
+{
+ uint32_t keyInt = strtol(id.c_str(), NULL, 10);
+
+ if(d->moods.size() <= keyInt)
+ d->moods.resize(keyInt+1);
+
+ d->moods[keyInt] = mood;
+}
+
void memory_info::setTrait(const string & key,
const string & value,
const string & zero,
@@ -564,6 +646,7 @@ string memory_info::getProfession (const uint32_t key) const
string memory_info::getJob (const uint32_t key) const
{
if(d->jobs.size() > key)
+
{
return d->jobs[key];
}
@@ -579,6 +662,15 @@ string memory_info::getSkill (const uint32_t key) const
throw Error::MissingMemoryDefinition("skill", key);
}
+DFHack::t_level memory_info::getLevelInfo(const uint32_t level) const
+{
+ if(d->levels.size() > level)
+ {
+ return d->levels[level];
+ }
+ throw Error::MissingMemoryDefinition("Level", level);
+}
+
// FIXME: ugly hack that needs to die
int absolute (int number)
{
@@ -621,6 +713,11 @@ string memory_info::getTraitName(const uint32_t traitIdx) const
throw Error::MissingMemoryDefinition("traitname", traitIdx);
}
+std::vector< std::vector > const& memory_info::getAllTraits()
+{
+ return d->traits;
+}
+
string memory_info::getLabor (const uint32_t laborIdx)
{
if(d->labors.count(laborIdx))
@@ -630,3 +727,52 @@ string memory_info::getLabor (const uint32_t laborIdx)
throw Error::MissingMemoryDefinition("labor", laborIdx);
}
+std::string memory_info::getMood(const uint32_t moodID)
+{
+ if(d->moods.size() > moodID)
+ {
+ return d->moods[moodID];
+ }
+ throw Error::MissingMemoryDefinition("Mood", moodID);
+}
+
+std::string memory_info::PrintOffsets()
+{
+ ostringstream ss;
+ ss << "" << endl;
+ switch (getOS())
+ {
+ case OS_LINUX:
+ ss << "" << endl;
+ break;
+ case OS_WINDOWS:
+ ss << "" << endl;
+ ss << "" << endl;
+ break;
+ default:
+ ss << " UNKNOWN" << endl;
+ }
+ ss << "" << endl;
+ map::const_iterator iter;
+ for(iter = d->addresses.begin(); iter != d->addresses.end(); iter++)
+ {
+ ss << " " << endl;
+ }
+ map::const_iterator iter2;
+ for(iter2 = d->offsets.begin(); iter2 != d->offsets.end(); iter2++)
+ {
+ ss << " " << endl;
+ }
+ for(iter = d->hexvals.begin(); iter != d->hexvals.end(); iter++)
+ {
+ ss << " " << endl;
+ }
+ map::const_iterator iter3;
+ for(iter3 = d->strings.begin(); iter3 != d->strings.end(); iter3++)
+ {
+ ss << " " << endl;
+ }
+ ss << "" << endl;
+ ss << "" << endl;
+ return ss.str();
+}
\ No newline at end of file
diff --git a/library/DFMemInfoManager.cpp b/library/DFMemInfoManager.cpp
index 4b7f537e0..cc4c5de4a 100644
--- a/library/DFMemInfoManager.cpp
+++ b/library/DFMemInfoManager.cpp
@@ -23,8 +23,9 @@ distribution.
*/
#include "Internal.h"
+#include "DFMemInfoManager.h"
+
#include "dfhack/DFMemInfo.h"
-#include "dfhack/DFMemInfoManager.h"
#include "dfhack/DFError.h"
using namespace DFHack;
@@ -151,8 +152,12 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map Value();
- const char *cstr_name = pMemEntry->Attribute("name");
+ const char *cstr_name = pMemEntry->Attribute("name");
const char *cstr_value = pMemEntry->GetText();
+
+ if(!cstr_value)
+ cstr_value = pMemEntry->Attribute("id");
+
// check for missing parts
string type, name, value;
type = cstr_type;
@@ -203,6 +208,14 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map setLabor(value,name);
}
+ else if (type == "Level")
+ {
+ mem->setLevel(value, name, pMemEntry->Attribute("xpNxtLvl"));
+ }
+ else if (type == "Mood")
+ {
+ mem->setMood(value, name);
+ }
else
{
throw Error::MemoryXmlUnknownType(type.c_str());
diff --git a/library/DFProcess-linux-SHM.cpp b/library/DFProcess-linux-SHM.cpp
index d4f90db93..acf519ecf 100644
--- a/library/DFProcess-linux-SHM.cpp
+++ b/library/DFProcess-linux-SHM.cpp
@@ -569,10 +569,7 @@ bool SHMProcess::attach()
bool SHMProcess::detach()
{
- if(!d->attached)
- {
- return false;
- }
+ if(!d->attached) return true;
if(d->locked)
{
resume();
@@ -714,7 +711,7 @@ float SHMProcess::readFloat (const uint32_t offset)
D_SHMHDR->address = offset;
gcc_barrier
d->SetAndWait(CORE_READ_DWORD);
- return D_SHMHDR->value;
+ return reinterpret_cast (D_SHMHDR->value);
}
void SHMProcess::readFloat (const uint32_t offset, float &val)
{
@@ -723,7 +720,7 @@ void SHMProcess::readFloat (const uint32_t offset, float &val)
D_SHMHDR->address = offset;
gcc_barrier
d->SetAndWait(CORE_READ_DWORD);
- val = D_SHMHDR->value;
+ val = reinterpret_cast (D_SHMHDR->value);
}
/*
diff --git a/library/DFProcess-linux-wine.cpp b/library/DFProcess-linux-wine.cpp
index b9ef2339b..b71e2266f 100644
--- a/library/DFProcess-linux-wine.cpp
+++ b/library/DFProcess-linux-wine.cpp
@@ -331,7 +331,7 @@ bool WineProcess::attach()
bool WineProcess::detach()
{
- if(!d->attached) return false;
+ if(!d->attached) return true;
if(!d->suspended) suspend();
int result = 0;
// close /proc/PID/mem
@@ -367,9 +367,11 @@ void WineProcess::read (const uint32_t offset, const uint32_t size, uint8_t *tar
if(size == 0) return;
ssize_t result;
- result = pread(d->memFileHandle, target,size,offset);
- if(result != size)
+ ssize_t total = 0;
+ ssize_t remaining = size;
+ while (total != size)
{
+ result = pread(d->memFileHandle, target + total ,remaining,offset + total);
if(result == -1)
{
cerr << "pread failed: can't read " << size << " bytes at addres " << offset << endl;
@@ -379,7 +381,8 @@ void WineProcess::read (const uint32_t offset, const uint32_t size, uint8_t *tar
}
else
{
- read(offset + result, size - result, target + result);
+ total += result;
+ remaining -= result;
}
}
}
diff --git a/library/DFProcess-linux.cpp b/library/DFProcess-linux.cpp
index 343985a3d..25dfa0d8c 100644
--- a/library/DFProcess-linux.cpp
+++ b/library/DFProcess-linux.cpp
@@ -86,7 +86,7 @@ NormalProcess::NormalProcess(uint32_t pid, vector< memory_info* >& known_version
target_name[target_result] = 0;
// is this the regular linux DF?
- if (strstr(target_name, "dwarfort.exe") != NULL)
+ if (strstr(target_name, "dwarfort.exe") != 0 || strstr(target_name,"Dwarf_Fortress") != 0)
{
// create linux process, add it to the vector
d->identified = d->validate(target_name,pid,mem_name,known_versions );
@@ -318,7 +318,7 @@ bool NormalProcess::attach()
bool NormalProcess::detach()
{
- if(!d->attached) return false;
+ if(!d->attached) return true;
if(!d->suspended) suspend();
int result = 0;
// close /proc/PID/mem
diff --git a/library/DFProcess-windows-SHM.cpp b/library/DFProcess-windows-SHM.cpp
index 9a8bd8d4f..5bb100e34 100644
--- a/library/DFProcess-windows-SHM.cpp
+++ b/library/DFProcess-windows-SHM.cpp
@@ -632,10 +632,7 @@ bool SHMProcess::attach()
bool SHMProcess::detach()
{
- if(!d->attached)
- {
- return false;
- }
+ if(!d->attached) return true;
//cerr << "detach" << endl;// FIXME: throw
if(d->locked)
{
@@ -756,7 +753,7 @@ float SHMProcess::readFloat (const uint32_t offset)
D_SHMHDR->address = offset;
full_barrier
d->SetAndWait(CORE_READ_DWORD);
- return (float) D_SHMHDR->value;
+ return reinterpret_cast (D_SHMHDR->value);
}
void SHMProcess::readFloat (const uint32_t offset, float &val)
{
@@ -765,7 +762,7 @@ void SHMProcess::readFloat (const uint32_t offset, float &val)
D_SHMHDR->address = offset;
full_barrier
d->SetAndWait(CORE_READ_DWORD);
- val = (float) D_SHMHDR->value;
+ val = reinterpret_cast (D_SHMHDR->value);
}
uint64_t SHMProcess::readQuad (const uint32_t offset)
{
diff --git a/library/DFProcess-windows.cpp b/library/DFProcess-windows.cpp
index da44a0f32..dad67b135 100644
--- a/library/DFProcess-windows.cpp
+++ b/library/DFProcess-windows.cpp
@@ -249,10 +249,7 @@ bool NormalProcess::attach()
bool NormalProcess::detach()
{
- if(!d->attached)
- {
- return false;
- }
+ if(!d->attached) return true;
resume();
d->attached = false;
return true;
diff --git a/library/DFProcessEnumerator-linux.cpp b/library/DFProcessEnumerator-linux.cpp
deleted file mode 100644
index 3ee14ef80..000000000
--- a/library/DFProcessEnumerator-linux.cpp
+++ /dev/null
@@ -1,135 +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 "Internal.h"
-#include "dfhack/DFProcessEnumerator.h"
-#include "dfhack/DFProcess.h"
-#include "dfhack/DFMemInfo.h"
-#include "dfhack/DFMemInfoManager.h"
-#include
-#include
-#include
-#include
-#include "shms.h"
-
-using namespace DFHack;
-
-class DFHack::ProcessEnumerator::Private
-{
- public:
- Private(){};
- MemInfoManager *meminfo;
- std::vector processes;
-};
-
-bool ProcessEnumerator::findProcessess()
-{
- DIR *dir_p;
- struct dirent *dir_entry_p;
- // Open /proc/ directory
- dir_p = opendir("/proc/");
- // Reading /proc/ entries
- while(NULL != (dir_entry_p = readdir(dir_p)))
- {
- // Only PID folders (numbers)
- if (strspn(dir_entry_p->d_name, "0123456789") != strlen(dir_entry_p->d_name))
- {
- continue;
- }
- Process *p1 = new SHMProcess(atoi(dir_entry_p->d_name),d->meminfo->meminfo);
- if(p1->isIdentified())
- {
- d->processes.push_back(p1);
- continue;
- }
- else
- {
- delete p1;
- }
- Process *p2 = new NormalProcess(atoi(dir_entry_p->d_name),d->meminfo->meminfo);
- if(p2->isIdentified())
- {
- d->processes.push_back(p2);
- continue;
- }
- else
- {
- delete p2;
- }
- Process *p3 = new WineProcess(atoi(dir_entry_p->d_name),d->meminfo->meminfo);
- if(p3->isIdentified())
- {
- d->processes.push_back(p3);
- continue;
- }
- else
- {
- delete p3;
- }
-
- }
- closedir(dir_p);
- // return value depends on if we found some DF processes
- if(d->processes.size())
- {
- return true;
- }
- return false;
-}
-
-uint32_t ProcessEnumerator::size()
-{
- return d->processes.size();
-}
-
-
-Process * ProcessEnumerator::operator[](uint32_t index)
-{
- assert(index < d->processes.size());
- return d->processes[index];
-}
-
-
-ProcessEnumerator::ProcessEnumerator( string path_to_xml )
-: d(new Private())
-{
- d->meminfo = new MemInfoManager(path_to_xml);
-}
-
-void ProcessEnumerator::purge()
-{
- for(uint32_t i = 0;i < d->processes.size();i++)
- {
- delete d->processes[i];
- }
- d->processes.clear();
-}
-
-ProcessEnumerator::~ProcessEnumerator()
-{
- // delete all processes
- purge();
- delete d->meminfo;
- delete d;
-}
diff --git a/library/DFProcessEnumerator-windows.cpp b/library/DFProcessEnumerator-windows.cpp
deleted file mode 100644
index bec67361d..000000000
--- a/library/DFProcessEnumerator-windows.cpp
+++ /dev/null
@@ -1,147 +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 "Internal.h"
-#include "dfhack/DFProcessEnumerator.h"
-#include "dfhack/DFProcess.h"
-#include "dfhack/DFMemInfo.h"
-#include "dfhack/DFMemInfoManager.h"
-using namespace DFHack;
-
-class DFHack::ProcessEnumerator::Private
-{
- public:
- Private(){};
- MemInfoManager *meminfo;
- std::vector processes;
-};
-
-// some magic - will come in handy when we start doing debugger stuff on Windows
-bool EnableDebugPriv()
-{
- bool bRET = FALSE;
- TOKEN_PRIVILEGES tp;
- HANDLE hToken;
-
- if (LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid))
- {
- if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
- {
- if (hToken != INVALID_HANDLE_VALUE)
- {
- tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- tp.PrivilegeCount = 1;
- if (AdjustTokenPrivileges(hToken, FALSE, &tp, 0, 0, 0))
- {
- bRET = TRUE;
- }
- CloseHandle(hToken);
- }
- }
- }
- return bRET;
-}
-
-// WINDOWS version of the process finder
-bool ProcessEnumerator::findProcessess()
-{
- // Get the list of process identifiers.
- DWORD ProcArray[2048], memoryNeeded, numProccesses;
- //EnableDebugPriv();
- if ( !EnumProcesses( ProcArray, sizeof(ProcArray), &memoryNeeded ) )
- {
- cout << "EnumProcesses fail'd" << endl;
- return false;
- }
-
- // Calculate how many process identifiers were returned.
- numProccesses = memoryNeeded / sizeof(DWORD);
- EnableDebugPriv();
-
- // iterate through processes
- for ( int i = 0; i < (int)numProccesses; i++ )
- {
- Process *p = new SHMProcess(ProcArray[i],d->meminfo->meminfo);
- if(p->isIdentified())
- {
- d->processes.push_back(p);
- continue;
- }
- else
- {
- delete p;
- p = 0;
- }
- p = new NormalProcess(ProcArray[i],d->meminfo->meminfo);
- if(p->isIdentified())
- {
- d->processes.push_back(p);
- continue;
- }
- else
- {
- delete p;
- p = 0;
- }
- }
- if(d->processes.size())
- return true;
- return false;
-}
-
-uint32_t ProcessEnumerator::size()
-{
- return d->processes.size();
-};
-
-
-Process * ProcessEnumerator::operator[](uint32_t index)
-{
- assert(index < d->processes.size());
- return d->processes[index];
-};
-
-
-ProcessEnumerator::ProcessEnumerator( string path_to_xml )
-: d(new Private())
-{
- d->meminfo = new MemInfoManager(path_to_xml);
-}
-
-void ProcessEnumerator::purge()
-{
- for(uint32_t i = 0;i < d->processes.size();i++)
- {
- delete d->processes[i];
- }
- d->processes.clear();
-}
-
-ProcessEnumerator::~ProcessEnumerator()
-{
- // delete all processes
- purge();
- delete d->meminfo;
- delete d;
-}
diff --git a/library/DFProcessEnumerator.cpp b/library/DFProcessEnumerator.cpp
new file mode 100644
index 000000000..c060d2182
--- /dev/null
+++ b/library/DFProcessEnumerator.cpp
@@ -0,0 +1,380 @@
+/*
+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 "DFMemInfoManager.h"
+
+#include "dfhack/DFProcessEnumerator.h"
+#include "dfhack/DFProcess.h"
+#include "dfhack/DFMemInfo.h"
+
+
+using namespace DFHack;
+
+typedef std::vector PROC_V;
+typedef std::map PID2PROC;
+
+class DFHack::ProcessEnumerator::Private
+{
+ public:
+ Private(){};
+ MemInfoManager *meminfo;
+ PROC_V Processes;
+ PID2PROC ProcMap;
+ Process *GetProcessObject(ProcessID ID);
+ void EnumPIDs (vector &PIDs);
+};
+
+class DFHack::BadProcesses::Private
+{
+ public:
+ Private(){};
+ PROC_V bad;
+};
+
+BadProcesses::BadProcesses():d(new Private()){}
+
+BadProcesses::~BadProcesses()
+{
+ clear();
+ delete d;
+}
+
+bool BadProcesses::Contains(Process* p)
+{
+ for(int i = 0; i < d->bad.size(); i++)
+ {
+ if(d->bad[i] == p)
+ return true;
+ }
+ return false;
+}
+
+bool BadProcesses::excise(Process* p)
+{
+ vector::iterator it = d->bad.begin();
+ while(it != d->bad.end())
+ {
+ if((*it) == p)
+ {
+ d->bad.erase(it);
+ return true;
+ }
+ else
+ {
+ it++;
+ }
+ }
+ return false;
+}
+
+uint32_t BadProcesses::size()
+{
+ return d->bad.size();
+}
+
+void BadProcesses::clear()
+{
+ for(int i = 0; i < d->bad.size(); i++)
+ {
+ delete d->bad[i];
+ }
+ d->bad.clear();
+}
+
+void BadProcesses::push_back(Process* p)
+{
+ if(p)
+ d->bad.push_back(p);
+}
+
+Process * BadProcesses::operator[](uint32_t index)
+{
+ if(index < d->bad.size())
+ return d->bad[index];
+ return 0;
+}
+
+//FIXME: wasteful
+Process *ProcessEnumerator::Private::GetProcessObject(ProcessID ID)
+{
+
+ Process *p1 = new SHMProcess(ID.pid,meminfo->meminfo);
+ if(p1->isIdentified())
+ return p1;
+ else
+ delete p1;
+
+ Process *p2 = new NormalProcess(ID.pid,meminfo->meminfo);
+ if(p2->isIdentified())
+ return p2;
+ else
+ delete p2;
+#ifdef LINUX_BUILD
+ Process *p3 = new WineProcess(ID.pid,meminfo->meminfo);
+ if(p3->isIdentified())
+ return p3;
+ else
+ delete p3;
+#endif
+ return 0;
+}
+
+#ifdef LINUX_BUILD
+void ProcessEnumerator::Private::EnumPIDs (vector &PIDs)
+{
+ DIR *dir_p;
+ struct dirent *dir_entry_p;
+ struct stat st;
+ char fullname[512];
+ fullname[0] = 0;
+ PIDs.clear(); // make sure the vector is clear
+
+ // Open /proc/ directory
+ dir_p = opendir("/proc/");
+ // Reading /proc/ entries
+ while(NULL != (dir_entry_p = readdir(dir_p)))
+ {
+ // Only PID folders (numbers)
+ if (strspn(dir_entry_p->d_name, "0123456789") != strlen(dir_entry_p->d_name))
+ {
+ continue;
+ }
+ sprintf(fullname, "/proc/%s", dir_entry_p->d_name);
+ int ierr = stat (fullname, &st);
+ if (ierr != 0)
+ {
+ printf("Cannot stat %s: ierr= %d\n", fullname, ierr);
+ continue;
+ }
+ uint64_t Pnum = atoi(dir_entry_p->d_name);
+ uint64_t ctime = st.st_ctime;
+ PIDs.push_back(ProcessID(ctime,Pnum));
+ }
+ closedir(dir_p);
+}
+#endif
+
+#ifndef LINUX_BUILD
+// some magic - will come in handy when we start doing debugger stuff on Windows
+bool EnableDebugPriv()
+{
+ bool bRET = FALSE;
+ TOKEN_PRIVILEGES tp;
+ HANDLE hToken;
+
+ if (LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tp.Privileges[0].Luid))
+ {
+ if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
+ {
+ if (hToken != INVALID_HANDLE_VALUE)
+ {
+ tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+ tp.PrivilegeCount = 1;
+ if (AdjustTokenPrivileges(hToken, FALSE, &tp, 0, 0, 0))
+ {
+ bRET = TRUE;
+ }
+ CloseHandle(hToken);
+ }
+ }
+ }
+ return bRET;
+}
+
+typedef union
+{
+ struct
+ {
+ uint32_t LowDword;
+ uint32_t HighDword;
+ };
+ uint64_t Quad;
+} TWO_DWORDS;
+
+// Convert Windows FileTime structs to POSIX timestamp
+// from http://frenk.wordpress.com/2009/12/14/convert-filetime-to-unix-timestamp/
+uint64_t FileTime_to_POSIX(FILETIME ft)
+{
+ // takes the last modified date
+ TWO_DWORDS date, adjust;
+ date.HighDword = ft.dwHighDateTime;
+ date.LowDword = ft.dwLowDateTime;
+
+ // 100-nanoseconds = milliseconds * 10000
+ adjust.Quad = 11644473600000LL * 10000LL;
+
+ // removes the diff between 1970 and 1601
+ date.Quad -= adjust.Quad;
+
+ // converts back from 100-nanoseconds to seconds
+ return date.Quad / 10000000LL;
+}
+
+void ProcessEnumerator::Private::EnumPIDs (vector &PIDs)
+{
+ FILETIME ftCreate, ftExit, ftKernel, ftUser;
+
+ PIDs.clear(); // make sure the vector is clear
+
+ // Get the list of process identifiers.
+ DWORD ProcArray[2048], memoryNeeded, numProccesses;
+ //EnableDebugPriv();
+ if ( !EnumProcesses( ProcArray, sizeof(ProcArray), &memoryNeeded ) )
+ {
+ cout << "EnumProcesses fail'd" << endl;
+ return;
+ }
+ // Calculate how many process identifiers were returned.
+ numProccesses = memoryNeeded / sizeof(DWORD);
+ EnableDebugPriv();
+ // iterate through processes
+ for ( int i = 0; i < (int)numProccesses; i++ )
+ {
+ HANDLE proc = OpenProcess (PROCESS_QUERY_INFORMATION, false, ProcArray[i]);
+ if(!proc)
+ continue;
+ if(GetProcessTimes(proc, &ftCreate, &ftExit, &ftKernel, &ftUser))
+ {
+ uint64_t ctime = FileTime_to_POSIX(ftCreate);
+ uint64_t Pnum = ProcArray[i];
+ PIDs.push_back(ProcessID(ctime,Pnum));
+ }
+ CloseHandle(proc);
+ }
+}
+#endif
+
+bool ProcessEnumerator::Refresh( BadProcesses* invalidated_processes )
+{
+ // PIDs to process
+ vector PIDs;
+ // this will be the new process map
+ PID2PROC temporary;
+ // clear the vector
+ d->Processes.clear();
+ if(invalidated_processes)
+ invalidated_processes->clear();
+
+ d->EnumPIDs(PIDs);
+
+ for(uint64_t i = 0; i < PIDs.size();i++)
+ {
+ ProcessID & PID = PIDs[i];
+ // check if we know about the OS process already
+ PID2PROC::iterator found= d->ProcMap.find(PID);
+ if( found != d->ProcMap.end())
+ {
+ // we do
+ // check if it does have a DFHack Process object associated with it
+ Process * p = (*found).second;
+ if(p)
+ {
+ // add it back to the vector we export
+ d->Processes.push_back(p);
+ }
+ // remove the OS Process from ProcMap
+ d->ProcMap.erase(found);
+ // add the OS Process to what will be the new ProcMap
+ temporary[PID] = p;
+ }
+ else
+ {
+ // an OS process we don't know yet!
+ // try to make a DFHack Process object for it
+ if(Process*p = d->GetProcessObject(PID))
+ {
+ // allright. this is something that can be used
+ d->Processes.push_back(p);
+ temporary[PID] = p;
+ }
+ else
+ {
+ // just a process. we track it anyway. Why not.
+ temporary[PID] = 0;
+ }
+ }
+ }
+ // now the vector we export is filled again and a temporary map with valid processes is created.
+ // we iterate over the old Process map and destroy all the processes that are dead.
+ for(PID2PROC::const_iterator idx = d->ProcMap.begin(); idx != d->ProcMap.end();++idx)
+ {
+ Process * p = (*idx).second;
+ if(p)
+ {
+ if(invalidated_processes)
+ {
+ invalidated_processes->push_back(p);
+ }
+ else
+ {
+ delete p;
+ }
+ }
+ }
+ d->ProcMap.swap(temporary);
+ // return value depends on if we found some DF processes
+ if(d->Processes.size())
+ {
+ return true;
+ }
+ return false;
+}
+
+uint32_t ProcessEnumerator::size()
+{
+ return d->Processes.size();
+}
+
+
+Process * ProcessEnumerator::operator[](uint32_t index)
+{
+ assert(index < d->Processes.size());
+ return d->Processes[index];
+}
+
+
+ProcessEnumerator::ProcessEnumerator( string path_to_xml )
+: d(new Private())
+{
+ d->meminfo = new MemInfoManager(path_to_xml);
+}
+
+void ProcessEnumerator::purge()
+{
+ for(uint32_t i = 0;i < d->Processes.size();i++)
+ {
+ delete d->Processes[i];
+ }
+ d->ProcMap.clear();
+ d->Processes.clear();
+}
+
+ProcessEnumerator::~ProcessEnumerator()
+{
+ // delete all processes
+ purge();
+ delete d->meminfo;
+ delete d;
+}
diff --git a/library/DFTypes_C.cpp b/library/DFTypes_C.cpp
index 2a27ad292..dc7d946aa 100644
--- a/library/DFTypes_C.cpp
+++ b/library/DFTypes_C.cpp
@@ -23,6 +23,7 @@ distribution.
*/
#include "dfhack/DFIntegers.h"
+#include "dfhack/DFTileTypes.h"
#include
#include "string.h"
#include
@@ -41,31 +42,65 @@ using namespace DFHack;
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;
+int (*alloc_byte_buffer_callback)(int8_t*, uint32_t) = NULL;
+int (*alloc_short_buffer_callback)(int16_t*, uint32_t) = NULL;
+int (*alloc_int_buffer_callback)(int32_t*, 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;
+int (*alloc_ubyte_buffer_callback)(uint8_t*, uint32_t) = NULL;
+int (*alloc_ushort_buffer_callback)(uint16_t*, uint32_t) = NULL;
+int (*alloc_uint_buffer_callback)(uint32_t*, uint32_t) = NULL;
-char* (*alloc_char_buffer_callback)(uint32_t) = NULL;
+int (*alloc_char_buffer_callback)(char*, 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;
+int (*alloc_matgloss_buffer_callback)(t_matgloss*, uint32_t) = NULL;
+int (*alloc_descriptor_buffer_callback)(t_descriptor_color*, uint32_t) = NULL;
+int (*alloc_matgloss_other_buffer_callback)(t_matglossOther*, uint32_t) = 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;
+int (*alloc_empty_colormodifier_callback)(c_colormodifier*) = NULL;
+int (*alloc_colormodifier_callback)(c_colormodifier*, const char*, uint32_t) = NULL;
+int (*alloc_colormodifier_buffer_callback)(c_colormodifier*, 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;
+int (*alloc_empty_creaturecaste_callback)(c_creaturecaste*)= NULL;
+int (*alloc_creaturecaste_callback)(c_creaturecaste*, const char*, const char*, const char*, const char*, uint32_t, uint32_t) = NULL;
+int (*alloc_creaturecaste_buffer_callback)(c_creaturecaste*, 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;
+int (*alloc_empty_creaturetype_callback)(c_creaturetype*) = NULL;
+int (*alloc_creaturetype_callback)(c_creaturetype*, const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t) = NULL;
+int (*alloc_creaturetype_buffer_callback)(c_creaturetype*, uint32_t) = NULL;
+
+int (*alloc_vein_buffer_callback)(t_vein*, uint32_t) = NULL;
+int (*alloc_frozenliquidvein_buffer_callback)(t_frozenliquidvein*, uint32_t) = NULL;
+int (*alloc_spattervein_buffer_callback)(t_spattervein*, uint32_t) = NULL;
+
+int DFHack_isWallTerrain(int in)
+{
+ return DFHack::isWallTerrain(in);
+}
+
+int DFHack_isFloorTerrain(int in)
+{
+ return DFHack::isFloorTerrain(in);
+}
+
+int DFHack_isRampTerrain(int in)
+{
+ return DFHack::isRampTerrain(in);
+}
+
+int DFHack_isStairTerrain(int in)
+{
+ return DFHack::isStairTerrain(in);
+}
+
+int DFHack_isOpenTerrain(int in)
+{
+ return DFHack::isOpenTerrain(in);
+}
+
+int DFHack_getVegetationType(int in)
+{
+ return DFHack::getVegetationType(in);
+}
#ifdef __cplusplus
}
@@ -76,7 +111,7 @@ int ColorListConvert(t_colormodifier* src, c_colormodifier* dest)
if(src == NULL)
return -1;
- dest = ((*alloc_colormodifier_callback)(src->part, src->colorlist.size()));
+ ((*alloc_colormodifier_callback)(dest, src->part, src->colorlist.size()));
copy(src->colorlist.begin(), src->colorlist.end(), dest->colorlist);
@@ -88,7 +123,7 @@ 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()));
+ ((*alloc_creaturecaste_callback)(dest, 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]);
@@ -103,7 +138,7 @@ 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));
+ ((*alloc_creaturetype_callback)(dest, 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]);
diff --git a/library/include/DFHack.h b/library/include/DFHack.h
index 22a332522..3ccaf0b83 100644
--- a/library/include/DFHack.h
+++ b/library/include/DFHack.h
@@ -1,6 +1,17 @@
#ifndef DFHACK_API_H
#define DFHACK_API_H
+// Defines
+#ifdef __GNUC__
+#define DEPRECATED(func) func __attribute__ ((deprecated))
+#elif defined(_MSC_VER)
+#define DEPRECATED(func) __declspec(deprecated) func
+#else
+#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
+#define DEPRECATED(func) func
+#endif
+
+// DFHack core classes and types
#include "dfhack/DFIntegers.h"
#include "dfhack/DFGlobal.h"
#include "dfhack/DFError.h"
@@ -10,7 +21,7 @@
#include "dfhack/DFProcess.h"
#include "dfhack/DFTypes.h"
-
+// DFHack modules
#include "dfhack/modules/Buildings.h"
#include "dfhack/modules/Materials.h"
#include "dfhack/modules/Position.h"
@@ -22,5 +33,16 @@
#include "dfhack/modules/Vegetation.h"
#include "dfhack/modules/Maps.h"
-#include "dfhack/DFMiscUtils.h"
-#endif
\ No newline at end of file
+/*
+ * This is a header full of ugly, volatile things.
+ * Only for use of official DFHack tools!
+ */
+#ifdef DFHACK_WANT_MISCUTILS
+ #include "dfhack/DFMiscUtils.h"
+#endif
+
+// define this to get the static tiletype->properties mapping
+#ifdef DFHACK_WANT_TILETYPES
+ #include "dfhack/DFTileTypes.h"
+#endif
+#endif
diff --git a/library/include/DFHack_C.h b/library/include/DFHack_C.h
index 8eb381595..6c5dd004f 100644
--- a/library/include/DFHack_C.h
+++ b/library/include/DFHack_C.h
@@ -25,12 +25,20 @@ distribution.
#ifndef DFHACK_C_API
#define DFHACK_C_API
-typedef void DFHackObject;
+#include
+#include
+#include
+#include