Merge branch 'master' of git://github.com/peterix/dfhack

develop
Warmist 2011-09-21 22:53:40 +03:00
commit 986a3e0f56
21 changed files with 1002 additions and 643 deletions

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "plugins/stonesense"]
path = plugins/stonesense
url = git://github.com/peterix/stonesense.git

@ -1,5 +1,10 @@
# main project file. use it from a build sub-folder, see COMPILE for details
## setting the build type.
IF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release RelWithDebInfo.")
ENDIF()
## some generic CMake magic
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(dfhack)
@ -14,11 +19,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not allowed.")
endif()
## setting the build type.
IF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release RelWithDebInfo.")
ENDIF()
# set up versioning.
set(DF_VERSION_MAJOR "0")
set(DF_VERSION_MINOR "31")

@ -280,14 +280,28 @@ Examples:
digcircle
=========
A command for easy designation of filled and hollow circles.
It has several types of options.
Options:
Shape:
--------
:hollow: Set the circle to hollow (default)
:filled: Set the circle to filled
:#: Diameter in tiles (default = 0, does nothing)
Action:
-------
:set: Set designation (default)
:unset: Unset current designation
:#: Radius in tiles (default = 0)
:invert: Invert designations already present
Designation types:
------------------
:dig: Normal digging designation (default)
:ramp: Ramp digging
:ustair: Staircase up
:dstair: Staircase down
:xstair: Staircase up/down
:chan: Dig channel
After you have set the options, the command called with no options
repeats with the last selected parameters.

@ -318,7 +318,7 @@ ul.auto-toc {
<div class="section" id="introduction">
<h1><a class="toc-backref" href="#id8">Introduction</a></h1>
<h1><a class="toc-backref" href="#id7">Introduction</a></h1>
<p>DFHack is a Dwarf Fortress memory access library and a set of basic
tools that use it. Tools come in the form of plugins or (not yet)
external tools. It is an attempt to unite the various ways tools
@ -326,68 +326,70 @@ access DF memory and allow for easier development of new tools.</p>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id8">Introduction</a></li>
<li><a class="reference internal" href="#getting-dfhack" id="id9">Getting DFHack</a></li>
<li><a class="reference internal" href="#compatibility" id="id10">Compatibility</a></li>
<li><a class="reference internal" href="#installation-removal" id="id11">Installation/Removal</a></li>
<li><a class="reference internal" href="#using-dfhack" id="id12">Using DFHack</a></li>
<li><a class="reference internal" href="#something-doesn-t-work-help" id="id13">Something doesn't work, help!</a></li>
<li><a class="reference internal" href="#commands" id="id14">Commands</a><ul>
<li><a class="reference internal" href="#autodump" id="id15">autodump</a><ul>
<li><a class="reference internal" href="#options" id="id16">Options</a></li>
<li><a class="reference internal" href="#introduction" id="id7">Introduction</a></li>
<li><a class="reference internal" href="#getting-dfhack" id="id8">Getting DFHack</a></li>
<li><a class="reference internal" href="#compatibility" id="id9">Compatibility</a></li>
<li><a class="reference internal" href="#installation-removal" id="id10">Installation/Removal</a></li>
<li><a class="reference internal" href="#using-dfhack" id="id11">Using DFHack</a></li>
<li><a class="reference internal" href="#something-doesn-t-work-help" id="id12">Something doesn't work, help!</a></li>
<li><a class="reference internal" href="#commands" id="id13">Commands</a><ul>
<li><a class="reference internal" href="#autodump" id="id14">autodump</a><ul>
<li><a class="reference internal" href="#options" id="id15">Options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#cleanmap" id="id17">cleanmap</a></li>
<li><a class="reference internal" href="#cleanowned" id="id18">cleanowned</a><ul>
<li><a class="reference internal" href="#id1" id="id19">Options</a></li>
<li><a class="reference internal" href="#cleanmap" id="id16">cleanmap</a></li>
<li><a class="reference internal" href="#cleanowned" id="id17">cleanowned</a><ul>
<li><a class="reference internal" href="#id1" id="id18">Options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#colonies" id="id20">colonies</a><ul>
<li><a class="reference internal" href="#id2" id="id21">Options</a></li>
<li><a class="reference internal" href="#colonies" id="id19">colonies</a><ul>
<li><a class="reference internal" href="#id2" id="id20">Options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#deramp-by-zilpin" id="id22">deramp (by zilpin)</a></li>
<li><a class="reference internal" href="#dfusion" id="id23">dfusion</a><ul>
<li><a class="reference internal" href="#confirmed-working-dfusion-plugins" id="id24">Confirmed working DFusion plugins:</a></li>
<li><a class="reference internal" href="#deramp-by-zilpin" id="id21">deramp (by zilpin)</a></li>
<li><a class="reference internal" href="#dfusion" id="id22">dfusion</a><ul>
<li><a class="reference internal" href="#confirmed-working-dfusion-plugins" id="id23">Confirmed working DFusion plugins:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#flows" id="id25">flows</a></li>
<li><a class="reference internal" href="#grow" id="id26">grow</a></li>
<li><a class="reference internal" href="#extirpate" id="id27">extirpate</a><ul>
<li><a class="reference internal" href="#id3" id="id28">Options</a></li>
<li><a class="reference internal" href="#flows" id="id24">flows</a></li>
<li><a class="reference internal" href="#grow" id="id25">grow</a></li>
<li><a class="reference internal" href="#extirpate" id="id26">extirpate</a><ul>
<li><a class="reference internal" href="#id3" id="id27">Options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#immolate" id="id29">immolate</a></li>
<li><a class="reference internal" href="#liquids" id="id30">liquids</a></li>
<li><a class="reference internal" href="#mode" id="id31">mode</a></li>
<li><a class="reference internal" href="#forcepause" id="id32">forcepause</a></li>
<li><a class="reference internal" href="#die" id="id33">die</a></li>
<li><a class="reference internal" href="#probe" id="id34">probe</a></li>
<li><a class="reference internal" href="#prospector" id="id35">prospector</a><ul>
<li><a class="reference internal" href="#id4" id="id36">Options</a></li>
<li><a class="reference internal" href="#immolate" id="id28">immolate</a></li>
<li><a class="reference internal" href="#liquids" id="id29">liquids</a></li>
<li><a class="reference internal" href="#mode" id="id30">mode</a></li>
<li><a class="reference internal" href="#forcepause" id="id31">forcepause</a></li>
<li><a class="reference internal" href="#die" id="id32">die</a></li>
<li><a class="reference internal" href="#probe" id="id33">probe</a></li>
<li><a class="reference internal" href="#prospector" id="id34">prospector</a><ul>
<li><a class="reference internal" href="#id4" id="id35">Options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#reveal" id="id37">reveal</a></li>
<li><a class="reference internal" href="#unreveal" id="id38">unreveal</a></li>
<li><a class="reference internal" href="#revtoggle" id="id39">revtoggle</a></li>
<li><a class="reference internal" href="#revflood" id="id40">revflood</a></li>
<li><a class="reference internal" href="#ssense-stonesense" id="id41">ssense / stonesense</a></li>
<li><a class="reference internal" href="#tubefill" id="id42">tubefill</a></li>
<li><a class="reference internal" href="#vdig" id="id43">vdig</a></li>
<li><a class="reference internal" href="#vdigx" id="id44">vdigx</a></li>
<li><a class="reference internal" href="#expdig" id="id45">expdig</a><ul>
<li><a class="reference internal" href="#patterns" id="id46">Patterns:</a></li>
<li><a class="reference internal" href="#filters" id="id47">Filters:</a></li>
<li><a class="reference internal" href="#examples" id="id48">Examples:</a></li>
<li><a class="reference internal" href="#reveal" id="id36">reveal</a></li>
<li><a class="reference internal" href="#unreveal" id="id37">unreveal</a></li>
<li><a class="reference internal" href="#revtoggle" id="id38">revtoggle</a></li>
<li><a class="reference internal" href="#revflood" id="id39">revflood</a></li>
<li><a class="reference internal" href="#ssense-stonesense" id="id40">ssense / stonesense</a></li>
<li><a class="reference internal" href="#tubefill" id="id41">tubefill</a></li>
<li><a class="reference internal" href="#vdig" id="id42">vdig</a></li>
<li><a class="reference internal" href="#vdigx" id="id43">vdigx</a></li>
<li><a class="reference internal" href="#expdig" id="id44">expdig</a><ul>
<li><a class="reference internal" href="#patterns" id="id45">Patterns:</a></li>
<li><a class="reference internal" href="#filters" id="id46">Filters:</a></li>
<li><a class="reference internal" href="#examples" id="id47">Examples:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#digcircle" id="id49">digcircle</a><ul>
<li><a class="reference internal" href="#id5" id="id50">Options:</a></li>
<li><a class="reference internal" href="#id6" id="id51">Examples:</a></li>
<li><a class="reference internal" href="#digcircle" id="id48">digcircle</a><ul>
<li><a class="reference internal" href="#shape" id="id49">Shape:</a></li>
<li><a class="reference internal" href="#action" id="id50">Action:</a></li>
<li><a class="reference internal" href="#designation-types" id="id51">Designation types:</a></li>
<li><a class="reference internal" href="#id5" id="id52">Examples:</a></li>
</ul>
</li>
<li><a class="reference internal" href="#weather" id="id52">weather</a><ul>
<li><a class="reference internal" href="#id7" id="id53">Options:</a></li>
<li><a class="reference internal" href="#weather" id="id53">weather</a><ul>
<li><a class="reference internal" href="#id6" id="id54">Options:</a></li>
</ul>
</li>
</ul>
@ -396,14 +398,14 @@ access DF memory and allow for easier development of new tools.</p>
</div>
</div>
<div class="section" id="getting-dfhack">
<h1><a class="toc-backref" href="#id9">Getting DFHack</a></h1>
<h1><a class="toc-backref" href="#id8">Getting DFHack</a></h1>
<p>The project is currently hosted on <a class="reference external" href="http://www.github.com/">github</a>, for both source and
binaries at <a class="reference external" href="http://github.com/peterix/dfhack">http://github.com/peterix/dfhack</a></p>
<p>Releases can be downloaded from here: <a class="reference external" href="https://github.com/peterix/dfhack/downloads">https://github.com/peterix/dfhack/downloads</a></p>
<p>All new releases are announced in the bay12 thread: <a class="reference external" href="http://tinyurl.com/dfhack-ng">http://tinyurl.com/dfhack-ng</a></p>
</div>
<div class="section" id="compatibility">
<h1><a class="toc-backref" href="#id10">Compatibility</a></h1>
<h1><a class="toc-backref" href="#id9">Compatibility</a></h1>
<p>DFHack works on Windows XP, Vista, 7 or any modern Linux distribution.
OSX is not supported due to lack of developers with a Mac.</p>
<p>Currently, only the 31.25 version is supported. If you need DFHack
@ -412,7 +414,7 @@ for older versions, look for older releases.</p>
<p>It is possible to use the Windows DFHack under wine/OSX.</p>
</div>
<div class="section" id="installation-removal">
<h1><a class="toc-backref" href="#id11">Installation/Removal</a></h1>
<h1><a class="toc-backref" href="#id10">Installation/Removal</a></h1>
<p>Installing DFhack involves copying files into your DF folder.
Copy the files from a release archive so that:</p>
<blockquote>
@ -438,7 +440,7 @@ Copy the files from a release archive so that:</p>
<p>If it refuses to load, check the stderr.log file created in your DF folder.</p>
</div>
<div class="section" id="using-dfhack">
<h1><a class="toc-backref" href="#id12">Using DFHack</a></h1>
<h1><a class="toc-backref" href="#id11">Using DFHack</a></h1>
<p>DFHack basically extends what DF can do with something similar to a quake console. On Windows, this is a separate command line window. On linux, the terminal used to launch the dfhack script is taken over (so, make sure you start from a terminal).
Basic interaction with dfhack involves entering commands into the console. For some basic instroduction, use the 'help' command. To list all possible commands, use the 'ls' command.
Many commands have their own help or detailed description. You can use 'command help' or 'command ?' to show that.</p>
@ -448,21 +450,21 @@ Some commands can't be used from hotkeys - this includes interactive commands li
<p>Most of the commands come from plugins. Those reside in 'DF/plugins/'.</p>
</div>
<div class="section" id="something-doesn-t-work-help">
<h1><a class="toc-backref" href="#id13">Something doesn't work, help!</a></h1>
<h1><a class="toc-backref" href="#id12">Something doesn't work, help!</a></h1>
<p>First, don't panic :) Second, dfhack keeps a few log files in DF's folder - stderr.log and stdout.log. You can look at those and possibly find out what's happening.
If you found a bug, you can either report it in the bay12 DFHack thread, the issues tracker on github, contact me (<a class="reference external" href="mailto:peterix&#64;gmail.com">peterix&#64;gmail.com</a>) or visit the #dfhack IRC channel on freenode.</p>
</div>
<div class="section" id="commands">
<h1><a class="toc-backref" href="#id14">Commands</a></h1>
<h1><a class="toc-backref" href="#id13">Commands</a></h1>
<p>Almost all the commands have a 'help'/'?' option that will give you further help without having to look at this document.</p>
<div class="section" id="autodump">
<h2><a class="toc-backref" href="#id15">autodump</a></h2>
<h2><a class="toc-backref" href="#id14">autodump</a></h2>
<p>Automated item dumping tool. All loose items on the floor marked
for dumping are insta-dumped to the position of the in-game cursor.</p>
<p>Cursor must be placed on a floor tile. Instadumped items may not
show up in the cursor description list until you save/reload.</p>
<div class="section" id="options">
<h3><a class="toc-backref" href="#id16">Options</a></h3>
<h3><a class="toc-backref" href="#id15">Options</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -474,16 +476,16 @@ show up in the cursor description list until you save/reload.</p>
</div>
</div>
<div class="section" id="cleanmap">
<h2><a class="toc-backref" href="#id17">cleanmap</a></h2>
<h2><a class="toc-backref" href="#id16">cleanmap</a></h2>
<p>Cleans all the splatter that get scattered all over the map.
By default, it leaves mud and snow alone.</p>
</div>
<div class="section" id="cleanowned">
<h2><a class="toc-backref" href="#id18">cleanowned</a></h2>
<h2><a class="toc-backref" href="#id17">cleanowned</a></h2>
<p>Confiscates items owned by dwarfs.
By default, owned food on the floor and rotten items are confistacted and dumped.</p>
<div class="section" id="id1">
<h3><a class="toc-backref" href="#id19">Options</a></h3>
<h3><a class="toc-backref" href="#id18">Options</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -503,10 +505,10 @@ By default, owned food on the floor and rotten items are confistacted and dumped
</div>
</div>
<div class="section" id="colonies">
<h2><a class="toc-backref" href="#id20">colonies</a></h2>
<h2><a class="toc-backref" href="#id19">colonies</a></h2>
<p>Allows listing all the vermin colonies on the map and optionally turning them into honey bee colonies.</p>
<div class="section" id="id2">
<h3><a class="toc-backref" href="#id21">Options</a></h3>
<h3><a class="toc-backref" href="#id20">Options</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -518,16 +520,16 @@ By default, owned food on the floor and rotten items are confistacted and dumped
</div>
</div>
<div class="section" id="deramp-by-zilpin">
<h2><a class="toc-backref" href="#id22">deramp (by zilpin)</a></h2>
<h2><a class="toc-backref" href="#id21">deramp (by zilpin)</a></h2>
<p>Removes all ramps designated for removal from the map. This is useful for replicating the old channel digging designation.
It also removes any and all 'down ramps' that can remain after a cave-in (you don't have to designate anything for that to happen).</p>
</div>
<div class="section" id="dfusion">
<h2><a class="toc-backref" href="#id23">dfusion</a></h2>
<h2><a class="toc-backref" href="#id22">dfusion</a></h2>
<p>This is the DFusion lua plugin system by warmist/darius, running as a DFHack plugin.</p>
<p>See the bay12 thread for details: <a class="reference external" href="http://www.bay12forums.com/smf/index.php?topic=69682.15">http://www.bay12forums.com/smf/index.php?topic=69682.15</a></p>
<div class="section" id="confirmed-working-dfusion-plugins">
<h3><a class="toc-backref" href="#id24">Confirmed working DFusion plugins:</a></h3>
<h3><a class="toc-backref" href="#id23">Confirmed working DFusion plugins:</a></h3>
<p>:simple_embark:allows changing the number of dwarves available on embark.</p>
<div class="note">
<p class="first admonition-title">Note</p>
@ -540,19 +542,19 @@ It also removes any and all 'down ramps' that can remain after a cave-in (you do
</div>
</div>
<div class="section" id="flows">
<h2><a class="toc-backref" href="#id25">flows</a></h2>
<h2><a class="toc-backref" href="#id24">flows</a></h2>
<p>A tool for checking how many tiles contain flowing liquids. If you suspect that your magma sea leaks into HFS, you can use this tool to be sure without revealing the map.</p>
</div>
<div class="section" id="grow">
<h2><a class="toc-backref" href="#id26">grow</a></h2>
<h2><a class="toc-backref" href="#id25">grow</a></h2>
<p>Makes all saplings present on the map grow into trees (almost) instantly.</p>
</div>
<div class="section" id="extirpate">
<h2><a class="toc-backref" href="#id27">extirpate</a></h2>
<h2><a class="toc-backref" href="#id26">extirpate</a></h2>
<p>A tool for getting rid of trees and shrubs. By default, it only kills a tree/shrub under the cursor.
The plants are turned into ashes instantly.</p>
<div class="section" id="id3">
<h3><a class="toc-backref" href="#id28">Options</a></h3>
<h3><a class="toc-backref" href="#id27">Options</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -568,11 +570,11 @@ The plants are turned into ashes instantly.</p>
</div>
</div>
<div class="section" id="immolate">
<h2><a class="toc-backref" href="#id29">immolate</a></h2>
<h2><a class="toc-backref" href="#id28">immolate</a></h2>
<p>Very similar to extirpate, but additionally sets the plants on fire. The fires can and <em>will</em> spread ;)</p>
</div>
<div class="section" id="liquids">
<h2><a class="toc-backref" href="#id30">liquids</a></h2>
<h2><a class="toc-backref" href="#id29">liquids</a></h2>
<p>Allows adding magma, water and obsidian to the game. It replaces the normal dfhack command line and can't be used from a hotkey.
For more information, refer to the command's internal help.</p>
<div class="note">
@ -582,7 +584,7 @@ temperatures (creating heat traps). You've been warned.</p>
</div>
</div>
<div class="section" id="mode">
<h2><a class="toc-backref" href="#id31">mode</a></h2>
<h2><a class="toc-backref" href="#id30">mode</a></h2>
<p>This command lets you see and change the game mode directly. Not all combinations are good for every situation and most of them will produce undesirable results.
There are a few good ones though.</p>
<div class="admonition-example admonition">
@ -594,22 +596,22 @@ You just lost a fortress and gained an adventurer.</p>
<p>I take no responsibility of anything that happens as a result of using this tool :P</p>
</div>
<div class="section" id="forcepause">
<h2><a class="toc-backref" href="#id32">forcepause</a></h2>
<h2><a class="toc-backref" href="#id31">forcepause</a></h2>
<p>Forces DF to pause. This is useful when your FPS drops below 1 and you lose control of the game.</p>
</div>
<div class="section" id="die">
<h2><a class="toc-backref" href="#id33">die</a></h2>
<h2><a class="toc-backref" href="#id32">die</a></h2>
<p>Instantly kills DF without saving.</p>
</div>
<div class="section" id="probe">
<h2><a class="toc-backref" href="#id34">probe</a></h2>
<h2><a class="toc-backref" href="#id33">probe</a></h2>
<p>Can be used to determine tile properties like temperature.</p>
</div>
<div class="section" id="prospector">
<h2><a class="toc-backref" href="#id35">prospector</a></h2>
<h2><a class="toc-backref" href="#id34">prospector</a></h2>
<p>Lists all available minerals on the map and how much of them there is. By default, only processes the already discovered part of the map.</p>
<div class="section" id="id4">
<h3><a class="toc-backref" href="#id36">Options</a></h3>
<h3><a class="toc-backref" href="#id35">Options</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -621,23 +623,23 @@ You just lost a fortress and gained an adventurer.</p>
</div>
</div>
<div class="section" id="reveal">
<h2><a class="toc-backref" href="#id37">reveal</a></h2>
<h2><a class="toc-backref" href="#id36">reveal</a></h2>
<p>This reveals the map. By default, HFS will remain hidden so that the demons don't spawn. You can use 'reveal hell' to reveal everything. With hell revealed, you won't be able to unpause until you hide the map again.</p>
</div>
<div class="section" id="unreveal">
<h2><a class="toc-backref" href="#id38">unreveal</a></h2>
<h2><a class="toc-backref" href="#id37">unreveal</a></h2>
<p>Reverts the effects of 'reveal'.</p>
</div>
<div class="section" id="revtoggle">
<h2><a class="toc-backref" href="#id39">revtoggle</a></h2>
<h2><a class="toc-backref" href="#id38">revtoggle</a></h2>
<p>Switches between 'reveal' and 'unreveal'.</p>
</div>
<div class="section" id="revflood">
<h2><a class="toc-backref" href="#id40">revflood</a></h2>
<h2><a class="toc-backref" href="#id39">revflood</a></h2>
<p>This command will hide the whole map and then reveal all the tiles that have a path to the in-game cursor.</p>
</div>
<div class="section" id="ssense-stonesense">
<h2><a class="toc-backref" href="#id41">ssense / stonesense</a></h2>
<h2><a class="toc-backref" href="#id40">ssense / stonesense</a></h2>
<p>An isometric visualizer that runs in a second window. This requires working graphics acceleration and at least a dual core CPU (otherwise it will slow down DF).</p>
<p>Unfortunately currently fails to run on Windows XP and most Linux distributions.</p>
<p>All the data resides in the 'stonesense' directory.</p>
@ -647,24 +649,24 @@ You just lost a fortress and gained an adventurer.</p>
<a class="reference external" href="http://df.magmawiki.com/index.php/Utility:Stonesense/Content_repository">http://df.magmawiki.com/index.php/Utility:Stonesense/Content_repository</a></p>
</div>
<div class="section" id="tubefill">
<h2><a class="toc-backref" href="#id42">tubefill</a></h2>
<h2><a class="toc-backref" href="#id41">tubefill</a></h2>
<p>Fills all the adamantine veins again. Veins that were empty will be filled in too, but might still trigger a demon invasion (this is a known bug).</p>
</div>
<div class="section" id="vdig">
<h2><a class="toc-backref" href="#id43">vdig</a></h2>
<h2><a class="toc-backref" href="#id42">vdig</a></h2>
<p>Designates a whole vein for digging. Requires an active in-game cursor placed over a vein tile. With the 'x' option, it will traverse z-levels (putting stairs between the same-material tiles).</p>
</div>
<div class="section" id="vdigx">
<h2><a class="toc-backref" href="#id44">vdigx</a></h2>
<h2><a class="toc-backref" href="#id43">vdigx</a></h2>
<p>A permanent alias for 'vdig x'.</p>
</div>
<div class="section" id="expdig">
<h2><a class="toc-backref" href="#id45">expdig</a></h2>
<h2><a class="toc-backref" href="#id44">expdig</a></h2>
<p>This command can be used for exploratory mining.</p>
<p>See: <a class="reference external" href="http://df.magmawiki.com/index.php/DF2010:Exploratory_mining">http://df.magmawiki.com/index.php/DF2010:Exploratory_mining</a></p>
<p>There are two variables that can be set: pattern and filter.</p>
<div class="section" id="patterns">
<h3><a class="toc-backref" href="#id46">Patterns:</a></h3>
<h3><a class="toc-backref" href="#id45">Patterns:</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -681,7 +683,7 @@ You just lost a fortress and gained an adventurer.</p>
</table>
</div>
<div class="section" id="filters">
<h3><a class="toc-backref" href="#id47">Filters:</a></h3>
<h3><a class="toc-backref" href="#id46">Filters:</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -697,7 +699,7 @@ You just lost a fortress and gained an adventurer.</p>
<p>After you have a pattern set, you can use 'expdig' to apply it again.</p>
</div>
<div class="section" id="examples">
<h3><a class="toc-backref" href="#id48">Examples:</a></h3>
<h3><a class="toc-backref" href="#id47">Examples:</a></h3>
<ul class="simple">
<li>'expdig diag5 hidden' = designate the diagonal 5 patter over all hidden tiles.</li>
<li>'expdig' = apply last used pattern and filter.</li>
@ -706,10 +708,11 @@ You just lost a fortress and gained an adventurer.</p>
</div>
</div>
<div class="section" id="digcircle">
<h2><a class="toc-backref" href="#id49">digcircle</a></h2>
<p>A command for easy designation of filled and hollow circles.</p>
<div class="section" id="id5">
<h3><a class="toc-backref" href="#id50">Options:</a></h3>
<h2><a class="toc-backref" href="#id48">digcircle</a></h2>
<p>A command for easy designation of filled and hollow circles.
It has several types of options.</p>
<div class="section" id="shape">
<h3><a class="toc-backref" href="#id49">Shape:</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
@ -718,19 +721,51 @@ You just lost a fortress and gained an adventurer.</p>
</tr>
<tr class="field"><th class="field-name">filled:</th><td class="field-body">Set the circle to filled</td>
</tr>
<tr class="field"><th class="field-name">#:</th><td class="field-body">Diameter in tiles (default = 0, does nothing)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="action">
<h3><a class="toc-backref" href="#id50">Action:</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">set:</th><td class="field-body">Set designation (default)</td>
</tr>
<tr class="field"><th class="field-name">unset:</th><td class="field-body">Unset current designation</td>
</tr>
<tr class="field"><th class="field-name">#:</th><td class="field-body">Radius in tiles (default = 0)</td>
<tr class="field"><th class="field-name">invert:</th><td class="field-body">Invert designations already present</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="designation-types">
<h3><a class="toc-backref" href="#id51">Designation types:</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">dig:</th><td class="field-body">Normal digging designation (default)</td>
</tr>
<tr class="field"><th class="field-name">ramp:</th><td class="field-body">Ramp digging</td>
</tr>
<tr class="field"><th class="field-name">ustair:</th><td class="field-body">Staircase up</td>
</tr>
<tr class="field"><th class="field-name">dstair:</th><td class="field-body">Staircase down</td>
</tr>
<tr class="field"><th class="field-name">xstair:</th><td class="field-body">Staircase up/down</td>
</tr>
<tr class="field"><th class="field-name">chan:</th><td class="field-body">Dig channel</td>
</tr>
</tbody>
</table>
<p>After you have set the options, the command called with no options
repeats with the last selected parameters.</p>
</div>
<div class="section" id="id6">
<h3><a class="toc-backref" href="#id51">Examples:</a></h3>
<div class="section" id="id5">
<h3><a class="toc-backref" href="#id52">Examples:</a></h3>
<ul class="simple">
<li>'digcircle filled 3' = Dig a filled circle with radius = 3.</li>
<li>'digcircle' = Do it again.</li>
@ -738,11 +773,11 @@ repeats with the last selected parameters.</p>
</div>
</div>
<div class="section" id="weather">
<h2><a class="toc-backref" href="#id52">weather</a></h2>
<h2><a class="toc-backref" href="#id53">weather</a></h2>
<p>Prints the current weather map by default.</p>
<p>Also lets you change the current weather to 'clear sky', 'rainy' or 'snowing'.</p>
<div class="section" id="id7">
<h3><a class="toc-backref" href="#id53">Options:</a></h3>
<div class="section" id="id6">
<h3><a class="toc-backref" href="#id54">Options:</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />

@ -186,7 +186,7 @@ void fIOthread(void * iodata)
"by clicking on the program icon in the top bar of the window.\n\n"
"Basic commands:\n"
" help|? - This text.\n"
" ls|dir [PLUGIN] - List available commands. Optionally for single plugin.\n"
" ls|dir [PLUGIN] - List available commands. Optionally for single plugin.\n"
" cls - Clear the console.\n"
" fpause - Force DF to pause.\n"
" die - Force DF to close immediately\n"

@ -27,7 +27,6 @@ distribution.
#include "dfhack/Export.h"
#include <deque>
#include <fstream>
#include <llimits.h>
#include <assert.h>
#include <iostream>
#include <string>

@ -260,6 +260,7 @@ namespace DFHack
/**
* \ingroup grp_creatures
*/
/*
struct t_like
{
int16_t type;
@ -268,25 +269,23 @@ namespace DFHack
t_matglossPair material;
bool active;
};
*/
// FIXME: THIS IS VERY, VERY BAD.
#define NUM_CREATURE_LABORS 96
#define NUM_CREATURE_TRAITS 30
#define NUM_CREATURE_LABORS 102
#define NUM_CREATURE_MENTAL_ATTRIBUTES 13
#define NUM_CREATURE_PHYSICAL_ATTRIBUTES 6
/**
* structure for holding a DF creature's soul
* structure for holding a copy of a creature's soul
* \ingroup grp_creatures
*/
struct t_soul
{
uint8_t numSkills;
t_skill skills[256];
/*
uint8_t numLikes;
t_like likes[32];
*/
//uint8_t numLikes;
//t_like likes[32];
uint16_t traits[NUM_CREATURE_TRAITS];
t_attrib analytical_ability;
t_attrib focus;
@ -302,15 +301,15 @@ namespace DFHack
t_attrib empathy;
t_attrib social_awareness;
};
#define MAX_COLORS 15
struct df_creature;
/**
* structure for holding a DF creature
* structure for holding a copy of a creature
* \ingroup grp_creatures
*/
struct t_creature
{
uint32_t origin;
df_creature * origin;
uint16_t x;
uint16_t y;
uint16_t z;
@ -328,7 +327,7 @@ namespace DFHack
t_name artifact_name;
uint8_t profession;
char custom_profession[128];
std::string custom_profession;
// enabled labors
uint8_t labors[NUM_CREATURE_LABORS];
@ -346,8 +345,8 @@ namespace DFHack
uint8_t sex;
uint16_t caste;
uint32_t pregnancy_timer; //Countdown timer to giving birth
bool has_default_soul;
t_soul defaultSoul;
//bool has_default_soul;
//t_soul defaultSoul;
uint32_t nbcolors;
uint32_t color[MAX_COLORS];
@ -355,7 +354,375 @@ namespace DFHack
uint32_t birth_time;
};
class DFContextShared;
/**
* Creature attribute descriptor
* \ingroup grp_creatures
*/
struct df_attrib
{
uint32_t unk_0;
uint32_t unk_4;
uint32_t unk_8;
uint32_t unk_c;
uint32_t unk_10;
uint32_t unk_14;
uint32_t unk_18;
};
/**
* Creature skil descriptor
* \ingroup grp_creatures
*/
struct df_skill
{
uint16_t id; // 0
int32_t rating; // 4
uint32_t experience; // 8
uint32_t unk_c;
uint32_t rusty; // 10
uint32_t unk_14;
uint32_t unk_18;
uint32_t unk_1c;
};
/**
* A creature's soul, as it appears in DF memory
* \ingroup grp_creatures
*/
struct df_soul
{
uint32_t unk_0;
df_name name; // 4
uint32_t unk_70;
uint16_t unk_74;
uint16_t unk_76;
int32_t unk_78;
int32_t unk_7c;
int32_t unk_80;
int32_t unk_84;
df_attrib mental[NUM_CREATURE_MENTAL_ATTRIBUTES]; // 88..1f3
std::vector<df_skill*> skills; // 1f4;
std::vector<void*> unk_204; // pointers to 14 0x14-byte structures ... likes?
uint16_t traits[NUM_CREATURE_TRAITS]; // 214
std::vector<int16_t*> unk_250; // 1 pointer to 2 shorts
uint32_t unk_260;
uint32_t unk_264;
uint32_t unk_268;
uint32_t unk_26c;
};
/**
* A creature job - what it's supposed to be doing.
* \ingroup grp_creatures
*/
struct df_job
{
};
/**
* A creature, as it appears in DF memory
* \ingroup grp_creatures
*/
struct df_creature
{
df_name name; // 0
std::string custom_profession; // 6c (MSVC)
uint8_t profession; // 88
uint32_t race; // 8c
uint16_t x; // 90
uint16_t y; // 92
uint16_t z; // 94
uint16_t unk_x96; // 96
uint16_t unk_y98; // 98
uint16_t unk_z9a; // 9a
uint32_t unk_9c;
uint16_t unk_a0;
int16_t unk_a2;
uint32_t unk_a4;
uint16_t dest_x; // a8
uint16_t dest_y; // aa
uint16_t dest_z; // ac
uint16_t unk_ae; // -1
std::vector<uint32_t> unk_b0; // b0->df (3*4 in MSVC) -> 68->8b (3*3 in glibc)
std::vector<uint32_t> unk_c0;
std::vector<uint32_t> unk_d0;
t_creaturflags1 flags1; // e0
t_creaturflags2 flags2; // e4
t_creaturflags3 flags3; // e8
void ** unk_ec;
int32_t unk_f0;
int16_t unk_f4;
int16_t unk_f6;
uint16_t caste; // f8
uint8_t sex; // fa
uint32_t id; // fc
uint16_t unk_100;
uint16_t unk_102;
int32_t unk_104;
uint32_t civ; // 108
uint32_t unk_10c;
int32_t unk_110;
std::vector<uint32_t> unk_114;
std::vector<uint32_t> unk_124;
std::vector<uint32_t> unk_134;
uint32_t unk_144;
std::vector<void*> unk_148;
std::vector<void*> unk_158;
int32_t unk_168;
int32_t unk_16c;
uint32_t unk_170;
uint32_t unk_174;
uint16_t unk_178;
std::vector<uint32_t> unk_17c;
std::vector<uint32_t> unk_18c;
std::vector<uint32_t> unk_19c;
std::vector<uint32_t> unk_1ac;
uint32_t pickup_equipment_bit; // 1bc
std::vector<uint32_t> unk_1c0;
std::vector<uint32_t> unk_1d0;
std::vector<uint32_t> unk_1e0;
int32_t unk_1f0;
int16_t unk_1f4;
int32_t unk_1f8;
int32_t unk_1fc;
int32_t unk_200;
int16_t unk_204;
uint32_t unk_208;
uint32_t unk_20c;
int16_t mood; // 210
uint32_t pregnancy_timer; // 214
void* pregnancy_ptr; // 218
int32_t unk_21c;
uint32_t unk_220;
uint32_t birth_year; // 224
uint32_t birth_time; // 228
uint32_t unk_22c;
uint32_t unk_230;
df_creature * unk_234; // suspiciously close to the pregnancy/birth stuff. Mother?
uint32_t unk_238;
int32_t unk_23c;
int32_t unk_240;
int32_t unk_244;
int32_t unk_248;
int32_t unk_24c;
int32_t unk_250;
int32_t unk_254;
int32_t unk_258;
int32_t unk_25c;
int32_t unk_260;
int16_t unk_264;
int32_t unk_268;
int32_t unk_26c;
int16_t unk_270;
int32_t unk_274;
int32_t unk_278;
int32_t unk_27c;
int16_t unk_280;
int32_t unk_284;
std::vector<t_item *> inventory; // 288 - vector of item pointers
std::vector<int32_t> owned_items; // 298 - vector of item IDs
std::vector<uint32_t> unk_2a8;
std::vector<uint32_t> unk_2b8;
std::vector<uint32_t> unk_2c8;
uint32_t unk_2d8;
uint32_t unk_2dc;
uint32_t unk_2e0;
uint32_t unk_2e4;
uint32_t unk_2e8;
uint32_t unk_2ec;
uint32_t unk_2f0;
df_job * current_job; // 2f4
uint32_t unk_2f8; // possibly current skill?
uint32_t unk_2fc;
uint32_t unk_300;
uint32_t unk_304;
std::vector<uint32_t> unk_308;
std::vector<uint32_t> unk_318;
std::vector<uint32_t> unk_328;
std::vector<uint32_t> unk_338;
std::vector<uint32_t> unk_348;
std::vector<uint32_t> unk_358;
std::vector<uint32_t> unk_368;
std::vector<uint32_t> unk_378;
std::vector<uint32_t> unk_388;
uint32_t unk_398;
int32_t unk_39c;
int32_t unk_3a0;
int32_t unk_3a4;
int32_t unk_3a8;
int32_t unk_3ac;
int32_t unk_3b0;
int32_t unk_3b4;
int32_t unk_3b8;
int32_t unk_3bc;
int32_t unk_3c0;
uint32_t unk_3c4;
uint32_t unk_3c8;
df_attrib physical[NUM_CREATURE_PHYSICAL_ATTRIBUTES]; // 3cc..473
uint32_t unk_474;
uint32_t unk_478;
uint32_t unk_47c;
uint32_t unk_480;
uint32_t unk_484;
uint32_t unk_488;
uint32_t unk_48c; // blood_max?
uint32_t blood_count; // 490
uint32_t unk_494;
std::vector<void*> unk_498;
std::vector<uint16_t> unk_4a8;
std::vector<uint16_t> unk_4b8;
uint32_t unk_4c8;
std::vector<int16_t> unk_4cc;
std::vector<int32_t> unk_4dc;
std::vector<int32_t> unk_4ec;
std::vector<int32_t> unk_4fc;
std::vector<uint16_t> unk_50c;
void* unk_51c;
uint16_t unk_520;
uint16_t unk_522;
uint16_t* unk_524;
uint16_t unk_528;
uint16_t unk_52a;
std::vector<uint32_t> appearance; // 52c
int16_t unk_53c;
int16_t unk_53e;
int16_t unk_540;
int16_t unk_542;
int16_t unk_544;
int16_t unk_546;
int16_t unk_548;
int16_t unk_54a;
int16_t unk_54c;
int16_t unk_54e;
int16_t unk_550;
int16_t unk_552;
int16_t unk_x554; // coords ? (-30.000x3)
int16_t unk_y556;
int16_t unk_z558;
int16_t unk_x55a; // coords again
int16_t unk_y55c;
int16_t unk_z55e;
int16_t unk_560;
int16_t unk_562;
uint32_t unk_564;
uint32_t unk_568;
uint32_t unk_56c;
uint32_t unk_570;
uint32_t unk_574;
uint32_t unk_578;
uint32_t unk_57c;
uint32_t unk_580;
uint32_t unk_584;
uint32_t unk_588;
uint32_t unk_58c;
uint32_t unk_590;
uint32_t unk_594;
uint32_t unk_598;
uint32_t unk_59c;
std::vector<void*> unk_5a0;
void* unk_5b0; // pointer to X (12?) vector<int16_t>
uint32_t unk_5b4; // 0x3e8 (1000)
uint32_t unk_5b8; // 0x3e8 (1000)
std::vector<uint32_t> unk_5bc;
std::vector<uint32_t> unk_5cc;
int16_t unk_5dc;
int16_t unk_5de;
df_name artifact_name; // 5e0
std::vector<df_soul*> souls; // 64c
df_soul* current_soul; // 65c
std::vector<uint32_t> unk_660;
uint8_t labors[NUM_CREATURE_LABORS]; // 670..6cf
std::vector<uint32_t> unk_6d0;
std::vector<uint32_t> unk_6e0;
std::vector<uint32_t> unk_6f0;
std::vector<uint32_t> unk_700;
uint32_t happiness; // 710
uint16_t unk_714;
uint16_t unk_716;
std::vector<void*> unk_718;
std::vector<void*> unk_728;
std::vector<void*> unk_738;
std::vector<void*> unk_748;
uint16_t unk_758;
uint16_t unk_x75a; // coords (-30000*3)
uint16_t unk_y75c;
uint16_t unk_z75e;
std::vector<uint16_t> unk_760;
std::vector<uint16_t> unk_770;
std::vector<uint16_t> unk_780;
uint32_t hist_figure_id; // 790
uint16_t able_stand; // 794
uint16_t able_stand_impair; // 796
uint16_t able_grasp; // 798
uint16_t able_grasp_impair; // 79a
uint32_t unk_79c; // able_fly/impair (maybe)
uint32_t unk_7a0; // able_fly/impair (maybe)
std::vector<void*> unk_7a4;
uint32_t unk_7b4;
uint32_t unk_7b8;
uint32_t unk_7bc;
int32_t unk_7c0;
std::vector<uint32_t> unk_7c4;
std::vector<uint32_t> unk_7d4;
std::vector<uint32_t> unk_7e4;
std::vector<uint32_t> unk_7f4;
std::vector<uint32_t> unk_804;
std::vector<uint32_t> unk_814;
uint32_t unk_824;
void* unk_828;
void* unk_82c;
uint32_t unk_830;
void* unk_834;
void* unk_838;
void* unk_83c;
std::vector<void*> unk_840;
std::vector<uint32_t> unk_850;
std::vector<uint32_t> unk_860;
uint32_t unk_870;
uint32_t unk_874;
std::vector<uint8_t> unk_878;
std::vector<uint8_t> unk_888;
std::vector<uint32_t> unk_898;
std::vector<uint8_t> unk_8a8;
std::vector<uint16_t> unk_8b8;
std::vector<uint16_t> unk_8c8;
std::vector<uint32_t> unk_8d8;
std::vector<uint32_t> unk_8e8;
std::vector<uint32_t> unk_8f8;
std::vector<uint32_t> unk_908;
int32_t unk_918;
uint16_t unk_91c;
uint16_t unk_91e;
uint16_t unk_920;
uint16_t unk_922;
uint32_t unk_924;
uint32_t unk_928;
std::vector<uint16_t> unk_92c;
uint32_t unk_93c;
};
/**
* The Creatures module - allows reading all non-vermin creatures and their properties
* \ingroup grp_modules
@ -363,6 +730,8 @@ namespace DFHack
*/
class DFHACK_EXPORT Creatures : public Module
{
public:
std::vector <df_creature *> * creatures;
public:
Creatures();
~Creatures();
@ -372,17 +741,19 @@ namespace DFHack
/* Read Functions */
// Read creatures in a box, starting with index. Returns -1 if no more creatures
// found. Call repeatedly do get all creatures in a specified box (uses tile coords)
int32_t ReadCreatureInBox(const int32_t index, t_creature & furball,
int32_t GetCreatureInBox(const int32_t index, df_creature ** furball,
const uint16_t x1, const uint16_t y1,const uint16_t z1,
const uint16_t x2, const uint16_t y2,const uint16_t z2);
bool ReadCreature(const int32_t index, t_creature & furball);
bool ReadJob(const t_creature * furball, std::vector<t_material> & mat);
df_creature * GetCreature(const int32_t index);
void CopyCreature(df_creature * source, t_creature & target);
bool ReadJob(const df_creature * unit, std::vector<t_material> & mat);
bool ReadInventoryIdx(const uint32_t index, std::vector<uint32_t> & item);
bool ReadInventoryPtr(const uint32_t index, std::vector<uint32_t> & item);
bool ReadInventoryByIdx(const uint32_t index, std::vector<t_item *> & item);
bool ReadInventoryByPtr(const df_creature * unit, std::vector<t_item *> & item);
bool ReadOwnedItemsIdx(const uint32_t index, std::vector<int32_t> & item);
bool ReadOwnedItemsPtr(const uint32_t index, std::vector<int32_t> & item);
bool ReadOwnedItemsByIdx(const uint32_t index, std::vector<int32_t> & item);
bool ReadOwnedItemsByPtr(const df_creature * unit, std::vector<int32_t> & item);
int32_t FindIndexById(int32_t id);
@ -391,27 +762,27 @@ namespace DFHack
int32_t GetDwarfCivId ( void );
/* Write Functions */
bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
bool WriteHappiness(const uint32_t index, const uint32_t happinessValue);
bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2);
bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2, uint32_t flags3);
bool WriteSkills(const uint32_t index, const t_soul &soul);
bool WriteAttributes(const uint32_t index, const t_creature &creature);
bool WriteSex(const uint32_t index, const uint8_t sex);
bool WriteTraits(const uint32_t index, const t_soul &soul);
bool WriteMood(const uint32_t index, const uint16_t mood);
bool WriteMoodSkill(const uint32_t index, const uint16_t moodSkill);
bool WriteJob(const t_creature * furball, std::vector<t_material> const& mat);
bool WritePos(const uint32_t index, const t_creature &creature);
bool WriteCiv(const uint32_t index, const int32_t civ);
bool WritePregnancy(const uint32_t index, const uint32_t pregTimer);
void CopyNameTo(t_creature &creature, uint32_t address);
//bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
//bool WriteHappiness(const uint32_t index, const uint32_t happinessValue);
//bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2);
//bool WriteFlags(const uint32_t index, const uint32_t flags1, const uint32_t flags2, uint32_t flags3);
//bool WriteSkills(const uint32_t index, const t_soul &soul);
//bool WriteAttributes(const uint32_t index, const t_creature &creature);
//bool WriteSex(const uint32_t index, const uint8_t sex);
//bool WriteTraits(const uint32_t index, const t_soul &soul);
//bool WriteMood(const uint32_t index, const uint16_t mood);
//bool WriteMoodSkill(const uint32_t index, const uint16_t moodSkill);
//bool WriteJob(const t_creature * furball, std::vector<t_material> const& mat);
//bool WritePos(const uint32_t index, const t_creature &creature);
//bool WriteCiv(const uint32_t index, const int32_t civ);
//bool WritePregnancy(const uint32_t index, const uint32_t pregTimer);
void CopyNameTo(df_creature *creature, df_name * target);
protected:
friend class Items;
bool RemoveOwnedItemIdx(const uint32_t index, int32_t id);
bool RemoveOwnedItemPtr(const uint32_t index, int32_t id);
bool RemoveOwnedItemByIdx(const uint32_t index, int32_t id);
bool RemoveOwnedItemByPtr(df_creature * unit, int32_t id);
private:
struct Private;

@ -73,7 +73,7 @@ union t_itemflags
unsigned int unk3 : 1; ///< 0000 0800 unknown, unseen, unusable
unsigned int unk4 : 1; ///< 0000 1000 unknown, unseen
unsigned int unk5 : 1; ///< 0000 2000 unknown, unseen
unsigned int murder : 1; ///< 0000 2000 Implies murder - used in fell moods
unsigned int foreign : 1; ///< 0000 4000 Item is imported
unsigned int trader : 1; ///< 0000 8000 Item ownwed by trader

@ -67,10 +67,10 @@ namespace DFHack
// names, used by a few other modules.
bool InitReadNames();
bool readName(t_name & name, uint32_t address);
bool copyName(uint32_t address, uint32_t target);
bool readName(t_name & name, df_name * address);
bool copyName(df_name * address, df_name * target);
// translate a name using the loaded dictionaries
std::string TranslateName(const DFHack::t_name& name, bool inEnglish = true);
std::string TranslateName(const DFHack::df_name * name, bool inEnglish = true);
private:
struct Private;

@ -30,6 +30,7 @@ distribution.
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
@ -52,71 +53,12 @@ struct Creatures::Private
{
bool Inited;
bool Started;
bool Ft_basic;
bool Ft_advanced;
bool Ft_jobs;
bool Ft_job_materials;
bool Ft_soul;
bool Ft_inventory;
bool Ft_owned_items;
struct t_offsets
{
// creature offsets
uint32_t vector;
uint32_t pos_offset;
uint32_t profession_offset;
uint32_t custom_profession_offset;
uint32_t race_offset;
int32_t civ_offset;
uint32_t flags1_offset;
uint32_t flags2_offset;
uint32_t flags3_offset;
uint32_t name_offset;
uint32_t sex_offset;
uint32_t caste_offset;
uint32_t id_offset;
uint32_t labors_offset;
uint32_t happiness_offset;
uint32_t artifact_name_offset;
uint32_t physical_offset;
uint32_t mood_offset;
uint32_t pregnancy_offset;
uint32_t pregnancy_ptr_offset;
uint32_t mood_skill_offset;
uint32_t pickup_equipment_bit;
uint32_t soul_vector_offset;
uint32_t default_soul_offset;
uint32_t current_job_offset;
// soul offsets
uint32_t soul_skills_vector_offset;
// name offsets (needed for reading creature names)
uint32_t name_firstname_offset;
uint32_t name_nickname_offset;
uint32_t name_words_offset;
uint32_t soul_mental_offset;
uint32_t soul_traits_offset;
uint32_t appearance_vector_offset;
uint32_t birth_year_offset;
uint32_t birth_time_offset;
uint32_t inventory_offset;
uint32_t owned_items_offset;
// creature job stuff
int32_t job_type_offset;
int32_t job_id_offset;
int32_t job_materials_vector;
int32_t job_material_itemtype_o;
int32_t job_material_subtype_o;
int32_t job_material_subindex_o;
int32_t job_material_index_o;
int32_t job_material_flags_o;
// creature job material stuff
} creatures;
uint32_t creature_module;
uint32_t dwarf_race_index_addr;
uint32_t dwarf_civ_id_addr;
bool IdMapReady;
std::map<int32_t, int32_t> IdMap;
DfVector <uint32_t> *p_cre;
Process *owner;
Translation * trans;
};
@ -135,101 +77,17 @@ Creatures::Creatures()
d->Inited = false;
d->Started = false;
d->IdMapReady = false;
d->p_cre = NULL;
d->trans = c.getTranslation();
d->trans->InitReadNames(); // throws on error
d->trans->InitReadNames(); // FIXME: throws on error
OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");
OffsetGroup *OG_creature = OG_Creatures->getGroup("creature");
OffsetGroup *OG_creature_ex = OG_creature->getGroup("advanced");
OffsetGroup *OG_soul = OG_Creatures->getGroup("soul");
OffsetGroup * OG_name = minfo->getGroup("name");
OffsetGroup * OG_jobs = OG_Creatures->getGroup("job");
OffsetGroup * OG_job_mats = OG_jobs->getGroup("material");
d->Ft_basic = d->Ft_advanced = d->Ft_jobs = d->Ft_soul = d->Ft_inventory = d->Ft_owned_items = d->Ft_job_materials = false;
Private::t_offsets &creatures = d->creatures;
creatures = 0;
try
{
// Creatures
creatures.vector = OG_Creatures->getAddress ("vector");
creatures = (vector <df_creature *> *) OG_Creatures->getAddress ("vector");
d->dwarf_race_index_addr = OG_Creatures->getAddress("current_race");
d->dwarf_civ_id_addr = OG_Creatures->getAddress("current_civ");
// Creatures/creature
creatures.name_offset = OG_creature->getOffset ("name");
creatures.custom_profession_offset = OG_creature->getOffset ("custom_profession");
creatures.profession_offset = OG_creature->getOffset ("profession");
creatures.race_offset = OG_creature->getOffset ("race");
creatures.pos_offset = OG_creature->getOffset ("position");
creatures.flags1_offset = OG_creature->getOffset ("flags1");
creatures.flags2_offset = OG_creature->getOffset ("flags2");
creatures.flags3_offset = OG_creature->getOffset ("flags3");
creatures.sex_offset = OG_creature->getOffset ("sex");
creatures.caste_offset = OG_creature->getOffset ("caste");
creatures.id_offset = OG_creature->getOffset ("id");
creatures.civ_offset = OG_creature->getOffset ("civ");
// name struct
creatures.name_firstname_offset = OG_name->getOffset("first");
creatures.name_nickname_offset = OG_name->getOffset("nick");
creatures.name_words_offset = OG_name->getOffset("second_words");
d->Ft_basic = true;
try
{
creatures.pickup_equipment_bit = OG_creature_ex->getOffset("pickup_equipment_bit");
creatures.mood_offset = OG_creature_ex->getOffset("mood");
creatures.pregnancy_offset = OG_creature_ex->getOffset("pregnancy");
creatures.pregnancy_ptr_offset = OG_creature_ex->getOffset("pregnancy_ptr");
creatures.birth_year_offset = OG_creature_ex->getOffset("birth_year");
creatures.birth_time_offset = OG_creature_ex->getOffset("birth_time");
creatures.current_job_offset = OG_creature_ex->getOffset("current_job");
creatures.mood_skill_offset = OG_creature_ex->getOffset("current_job_skill");
creatures.physical_offset = OG_creature_ex->getOffset("physical");
creatures.appearance_vector_offset = OG_creature_ex->getOffset("appearance_vector");
creatures.artifact_name_offset = OG_creature_ex->getOffset("artifact_name");
creatures.labors_offset = OG_creature_ex->getOffset ("labors");
creatures.happiness_offset = OG_creature_ex->getOffset ("happiness");
d->Ft_advanced = true;
}catch(Error::All&){};
try
{
creatures.inventory_offset = OG_creature_ex->getOffset("inventory_vector");
d->Ft_inventory = true;
}
catch(Error::All&){};
try
{
creatures.owned_items_offset = OG_creature_ex->getOffset("owned_items_vector");
d->Ft_owned_items = true;
}
catch(Error::All&){};
try
{
creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector");
creatures.default_soul_offset = OG_creature_ex->getOffset("current_soul");
creatures.soul_mental_offset = OG_soul->getOffset("mental");
creatures.soul_skills_vector_offset = OG_soul->getOffset("skills_vector");
creatures.soul_traits_offset = OG_soul->getOffset("traits");
d->Ft_soul = true;
}
catch(Error::All&){};
try
{
creatures.job_type_offset = OG_jobs->getOffset("type");
creatures.job_id_offset = OG_jobs->getOffset("id");
d->Ft_jobs = true;
try
{
creatures.job_materials_vector = OG_jobs->getOffset("materials_vector");
creatures.job_material_itemtype_o = OG_job_mats->getOffset("maintype");
creatures.job_material_subtype_o = OG_job_mats->getOffset("sectype1");
creatures.job_material_subindex_o = OG_job_mats->getOffset("sectype2");
creatures.job_material_index_o = OG_job_mats->getOffset("sectype3");
creatures.job_material_flags_o = OG_job_mats->getOffset("flags");
d->Ft_job_materials = true;
}
catch(Error::All&){};
}
catch(Error::All&){};
}
catch(Error::All&){};
d->Inited = true;
@ -243,11 +101,11 @@ Creatures::~Creatures()
bool Creatures::Start( uint32_t &numcreatures )
{
if(d->Ft_basic)
if(creatures)
{
d->p_cre = new DfVector <uint32_t> (d->creatures.vector);
d->Started = true;
numcreatures = d->p_cre->size();
numcreatures = creatures->size();
d->IdMap.clear();
d->IdMapReady = false;
return true;
}
@ -256,96 +114,116 @@ bool Creatures::Start( uint32_t &numcreatures )
bool Creatures::Finish()
{
if(d->p_cre)
{
delete d->p_cre;
d->p_cre = 0;
}
d->Started = false;
return true;
}
bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
df_creature * Creatures::GetCreature (const int32_t index)
{
if(!d->Started) return false;
memset(&furball, 0, sizeof(t_creature));
// SHM fast path
Process * p = d->owner;
if(!d->Started) return nullptr;
// read pointer from vector at position
uint32_t addr_cr = d->p_cre->at (index);
furball.origin = addr_cr;
Private::t_offsets &offs = d->creatures;
if(index > creatures->size())
return nullptr;
return creatures->at(index);
}
//read creature from memory
if(d->Ft_basic)
{
// name
d->trans->readName(furball.name,addr_cr + offs.name_offset);
// basic stuff
p->readDWord (addr_cr + offs.id_offset, furball.id);
p->read (addr_cr + offs.pos_offset, 3 * sizeof (uint16_t), (uint8_t *) & (furball.x)); // xyz really
p->readDWord (addr_cr + offs.race_offset, furball.race);
furball.civ = p->readDWord (addr_cr + offs.civ_offset);
p->readByte (addr_cr + offs.sex_offset, furball.sex);
p->readWord (addr_cr + offs.caste_offset, furball.caste);
p->readDWord (addr_cr + offs.flags1_offset, furball.flags1.whole);
p->readDWord (addr_cr + offs.flags2_offset, furball.flags2.whole);
p->readDWord (addr_cr + offs.flags3_offset, furball.flags3.whole);
// custom profession
p->readSTLString(addr_cr + offs.custom_profession_offset, furball.custom_profession, sizeof(furball.custom_profession));
// profession
furball.profession = p->readByte (addr_cr + offs.profession_offset);
}
if(d->Ft_advanced)
// returns index of creature actually read or -1 if no creature can be found
int32_t Creatures::GetCreatureInBox (int32_t index, df_creature ** furball,
const uint16_t x1, const uint16_t y1, const uint16_t z1,
const uint16_t x2, const uint16_t y2, const uint16_t z2)
{
if (!d->Started)
return -1;
Process *p = d->owner;
uint16_t coords[3];
uint32_t size = creatures->size();
while (uint32_t(index) < size)
{
// happiness
p->readDWord (addr_cr + offs.happiness_offset, furball.happiness);
// physical attributes
p->read(addr_cr + offs.physical_offset,
sizeof(t_attrib) * NUM_CREATURE_PHYSICAL_ATTRIBUTES,
(uint8_t *)&furball.strength);
// mood stuff
furball.mood = (int16_t) p->readWord (addr_cr + offs.mood_offset);
furball.mood_skill = p->readWord (addr_cr + offs.mood_skill_offset);
d->trans->readName(furball.artifact_name, addr_cr + offs.artifact_name_offset);
// labors
p->read (addr_cr + offs.labors_offset, NUM_CREATURE_LABORS, furball.labors);
furball.birth_year = p->readDWord (addr_cr + offs.birth_year_offset );
furball.birth_time = p->readDWord (addr_cr + offs.birth_time_offset );
furball.pregnancy_timer = p->readDWord (addr_cr + offs.pregnancy_offset );
// appearance
DfVector <uint32_t> app(addr_cr + offs.appearance_vector_offset);
furball.nbcolors = app.size();
if(furball.nbcolors>MAX_COLORS)
furball.nbcolors = MAX_COLORS;
for(uint32_t i = 0; i < furball.nbcolors; i++)
// read pointer from vector at position
df_creature * temp = creatures->at(index);
if (temp->x >= x1 && temp->x < x2)
{
furball.color[i] = app[i];
if (temp->y >= y1 && temp->y < y2)
{
if (temp->z >= z1 && temp->z < z2)
{
*furball = temp;
return index;
}
}
}
index++;
}
*furball = nullptr;
return -1;
}
//likes
/*
DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset);
furball.numLikes = likes.getSize();
for(uint32_t i = 0;i<furball.numLikes;i++)
{
uint32_t temp2 = *(uint32_t *) likes[i];
p->read(temp2,sizeof(t_like),(uint8_t *) &furball.likes[i]);
}*/
void Creatures::CopyCreature(df_creature * source, t_creature & furball)
{
if(!d->Started) return;
// read pointer from vector at position
furball.origin = source;
//read creature from memory
// name
d->trans->readName(furball.name,&source->name);
// basic stuff
furball.id = source->id;
furball.x = source->x;
furball.y = source->y;
furball.z = source->z;
furball.race = source->race;
furball.civ = source->civ;
furball.sex = source->sex;
furball.caste = source->caste;
furball.flags1.whole = source->flags1.whole;
furball.flags2.whole = source->flags2.whole;
furball.flags3.whole = source->flags3.whole;
// custom profession
furball.custom_profession = source->custom_profession;
// profession
furball.profession = source->profession;
// happiness
furball.happiness = source->happiness;
// physical attributes
memcpy(&furball.strength, source->physical, sizeof(source->physical));
// mood stuff
furball.mood = source->mood;
furball.mood_skill = source->unk_2f8; // FIXME: really? More like currently used skill anyway.
d->trans->readName(furball.artifact_name, &source->artifact_name);
// labors
memcpy(&furball.labors, &source->labors, sizeof(furball.labors));
furball.birth_year = source->birth_year;
furball.birth_time = source->birth_time;
furball.pregnancy_timer = source->pregnancy_timer;
// appearance
furball.nbcolors = source->appearance.size();
if(furball.nbcolors>MAX_COLORS)
furball.nbcolors = MAX_COLORS;
for(uint32_t i = 0; i < furball.nbcolors; i++)
{
furball.color[i] = source->appearance[i];
}
//likes. FIXME: where do they fit in now? The soul?
/*
DfVector <uint32_t> likes(d->p, temp + offs.creature_likes_offset);
furball.numLikes = likes.getSize();
for(uint32_t i = 0;i<furball.numLikes;i++)
{
uint32_t temp2 = *(uint32_t *) likes[i];
p->read(temp2,sizeof(t_like),(uint8_t *) &furball.likes[i]);
}
*/
/*
if(d->Ft_soul)
{
/*
// enum soul pointer vector
DfVector <uint32_t> souls(p,temp + offs.creature_soul_vector_offset);
*/
uint32_t soul = p->readDWord(addr_cr + offs.default_soul_offset);
furball.has_default_soul = false;
@ -378,76 +256,39 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
(uint8_t *) &furball.defaultSoul.traits);
}
}
if(d->Ft_jobs)
*/
/*
furball.current_job.occupationPtr = p->readDWord (addr_cr + offs.current_job_offset);
if(furball.current_job.occupationPtr)
{
furball.current_job.occupationPtr = p->readDWord (addr_cr + offs.current_job_offset);
if(furball.current_job.occupationPtr)
{
furball.current_job.active = true;
furball.current_job.jobType = p->readByte (furball.current_job.occupationPtr + offs.job_type_offset );
furball.current_job.jobId = p->readWord (furball.current_job.occupationPtr + offs.job_id_offset);
}
else
{
furball.current_job.active = false;
}
furball.current_job.active = true;
furball.current_job.jobType = p->readByte (furball.current_job.occupationPtr + offs.job_type_offset );
furball.current_job.jobId = p->readWord (furball.current_job.occupationPtr + offs.job_id_offset);
}
else
{
furball.current_job.active = false;
}
return true;
}
// returns index of creature actually read or -1 if no creature can be found
int32_t Creatures::ReadCreatureInBox (int32_t index, t_creature & furball,
const uint16_t x1, const uint16_t y1, const uint16_t z1,
const uint16_t x2, const uint16_t y2, const uint16_t z2)
{
if (!d->Started)
return -1;
Process *p = d->owner;
uint16_t coords[3];
uint32_t size = d->p_cre->size();
while (uint32_t(index) < size)
*/
// no jobs for now...
{
// read pointer from vector at position
uint32_t temp = d->p_cre->at(index);
p->read (temp + d->creatures.pos_offset, 3 * sizeof (uint16_t), (uint8_t *) &coords);
if (coords[0] >= x1 && coords[0] < x2)
{
if (coords[1] >= y1 && coords[1] < y2)
{
if (coords[2] >= z1 && coords[2] < z2)
{
ReadCreature (index, furball);
return index;
}
}
}
index++;
furball.current_job.active = false;
}
return -1;
}
int32_t Creatures::FindIndexById(int32_t creature_id)
{
if (!d->Started || !d->Ft_basic)
if (!d->Started)
return -1;
if (!d->IdMapReady)
{
d->IdMap.clear();
Process * p = d->owner;
Private::t_offsets &offs = d->creatures;
uint32_t size = d->p_cre->size();
uint32_t size = creatures->size();
for (uint32_t index = 0; index < size; index++)
{
uint32_t temp = d->p_cre->at(index);
int32_t id = p->readDWord (temp + offs.id_offset);
df_creature * temp = creatures->at(index);
int32_t id = temp->id;
d->IdMap[id] = index;
}
}
@ -459,7 +300,7 @@ int32_t Creatures::FindIndexById(int32_t creature_id)
else
return it->second;
}
/*
bool Creatures::WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS])
{
if(!d->Started || !d->Ft_advanced) return false;
@ -665,7 +506,7 @@ bool Creatures::WritePregnancy(const uint32_t index, const uint32_t pregTimer)
p->writeDWord(temp + d->creatures.pregnancy_offset, pregTimer);
return true;
}
*/
uint32_t Creatures::GetDwarfRaceIndex()
{
if(!d->Inited) return 0;
@ -688,7 +529,7 @@ bool Creatures::getCurrentCursorCreature(uint32_t & creature_index)
return true;
}
*/
/*
bool Creatures::ReadJob(const t_creature * furball, vector<t_material> & mat)
{
unsigned int i;
@ -709,67 +550,56 @@ bool Creatures::ReadJob(const t_creature * furball, vector<t_material> & mat)
}
return true;
}
bool Creatures::ReadInventoryIdx(const uint32_t index, std::vector<uint32_t> & item)
*/
bool Creatures::ReadInventoryByIdx(const uint32_t index, std::vector<t_item *> & item)
{
if(!d->Started || !d->Ft_inventory) return false;
uint32_t temp = d->p_cre->at (index);
return this->ReadInventoryPtr(temp, item);
if(!d->Started) return false;
if(index >= creatures->size()) return false;
df_creature * temp = creatures->at(index);
return this->ReadInventoryByPtr(temp, item);
}
bool Creatures::ReadInventoryPtr(const uint32_t temp, std::vector<uint32_t> & item)
bool Creatures::ReadInventoryByPtr(const df_creature * temp, std::vector<t_item *> & items)
{
unsigned int i;
if(!d->Started || !d->Ft_inventory) return false;
Process * p = d->owner;
DfVector <uint32_t> citem(temp + d->creatures.inventory_offset);
if(citem.size() == 0)
return false;
item.resize(citem.size());
for(i=0;i<citem.size();i++)
item[i] = p->readDWord(citem[i]);
if(!d->Started) return false;
items = temp->inventory;
return true;
}
bool Creatures::ReadOwnedItemsIdx(const uint32_t index, std::vector<int32_t> & item)
bool Creatures::ReadOwnedItemsByIdx(const uint32_t index, std::vector<int32_t> & item)
{
if(!d->Started || !d->Ft_owned_items) return false;
uint32_t temp = d->p_cre->at (index);
return this->ReadOwnedItemsPtr(temp, item);
if(!d->Started ) return false;
if(index >= creatures->size()) return false;
df_creature * temp = creatures->at(index);
return this->ReadOwnedItemsByPtr(temp, item);
}
bool Creatures::ReadOwnedItemsPtr(const uint32_t temp, std::vector<int32_t> & item)
bool Creatures::ReadOwnedItemsByPtr(const df_creature * temp, std::vector<int32_t> & items)
{
unsigned int i;
if(!d->Started || !d->Ft_owned_items) return false;
Process * p = d->owner;
DfVector <int32_t> citem(temp + d->creatures.owned_items_offset);
if(citem.size() == 0)
return false;
item.resize(citem.size());
for(i=0;i<citem.size();i++)
item[i] = citem[i];
if(!d->Started) return false;
items = temp->owned_items;
return true;
}
bool Creatures::RemoveOwnedItemIdx(const uint32_t index, int32_t id)
bool Creatures::RemoveOwnedItemByIdx(const uint32_t index, int32_t id)
{
if(!d->Started || !d->Ft_owned_items)
if(!d->Started)
{
cerr << "!d->Started || !d->Ft_owned_items FAIL" << endl;
cerr << "!d->Started FAIL" << endl;
return false;
}
uint32_t temp = d->p_cre->at (index);
return this->RemoveOwnedItemPtr(temp, id);
df_creature * temp = creatures->at (index);
return this->RemoveOwnedItemByPtr(temp, id);
}
bool Creatures::RemoveOwnedItemPtr(const uint32_t temp, int32_t id)
bool Creatures::RemoveOwnedItemByPtr(df_creature * temp, int32_t id)
{
if(!d->Started || !d->Ft_owned_items) return false;
if(!d->Started) return false;
Process * p = d->owner;
vector <int32_t> & vec = temp->owned_items;
vec.erase(std::remove(vec.begin(), vec.end(), id), vec.end());
/*
DfVector <int32_t> citem(temp + d->creatures.owned_items_offset);
for (unsigned i = 0; i < citem.size(); i++) {
@ -778,15 +608,12 @@ bool Creatures::RemoveOwnedItemPtr(const uint32_t temp, int32_t id)
if (!citem.remove(i--))
return false;
}
*/
return true;
}
void Creatures::CopyNameTo(t_creature &creature, uint32_t address)
void Creatures::CopyNameTo(df_creature * creature, df_name * target)
{
Private::t_offsets &offs = d->creatures;
if(d->Ft_basic)
d->trans->copyName(creature.origin + offs.name_offset, address);
d->trans->copyName(&creature->name, target);
}

@ -655,7 +655,7 @@ bool Items::removeItemOwner(dfh_item &item, Creatures *creatures)
int32_t & oid = p_refs[i]->value;
int32_t ix = creatures->FindIndexById(oid);
if (ix < 0 || !creatures->RemoveOwnedItemIdx(ix, item.base->id))
if (ix < 0 || !creatures->RemoveOwnedItemByIdx(ix, item.base->id))
{
cerr << "RemoveOwnedItemIdx: CREATURE " << ix << " ID " << item.base->id << " FAILED!" << endl;
return false;

@ -168,7 +168,7 @@ bool Translation::InitReadNames()
return true;
}
bool Translation::readName(t_name & name, uint32_t address)
bool Translation::readName(t_name & name, df_name * source)
{
Core & c = Core::getInstance();
Process * p = c.p;
@ -180,36 +180,35 @@ bool Translation::readName(t_name & name, uint32_t address)
{
if(!InitReadNames()) return false;
}
p->readSTLString(address + d->name_firstname_offset , name.first_name, 128);
p->readSTLString(address + d->name_nickname_offset , name.nickname, 128);
p->read(address + d->name_words_offset, 7*4, (uint8_t *)name.words);
p->read(address + d->name_parts_offset, 7*2, (uint8_t *)name.parts_of_speech);
name.language = p->readDWord(address + d->name_language_offset);
name.has_name = p->readByte(address + d->name_set_offset);
strncpy(name.first_name,source->first_name.c_str(),127);
strncpy(name.nickname,source->nick_name.c_str(),127);
memcpy(&name.parts_of_speech, &source->parts_of_speech, sizeof (source->parts_of_speech));
memcpy(&name.words, &source->words, sizeof (source->words));
name.language = source->language;
name.has_name = source->has_name;
return true;
}
bool Translation::copyName(uint32_t address, uint32_t target)
bool Translation::copyName(df_name * source, df_name * target)
{
uint8_t buf[28];
if (address == target)
if (source == target)
return true;
Core & c = Core::getInstance();
Process * p = c.p;
p->copySTLString(address + d->name_firstname_offset, target + d->name_firstname_offset);
p->copySTLString(address + d->name_nickname_offset, target + d->name_nickname_offset);
p->read(address + d->name_words_offset, 7*4, buf);
p->write(target + d->name_words_offset, 7*4, buf);
p->read(address + d->name_parts_offset, 7*2, buf);
p->write(target + d->name_parts_offset, 7*2, buf);
p->writeDWord(target + d->name_language_offset, p->readDWord(address + d->name_language_offset));
p->writeByte(target + d->name_set_offset, p->readByte(address + d->name_set_offset));
target->first_name = source->first_name;
target->nick_name = source->nick_name;
target->has_name = source->has_name;
target->language = source->language;
memcpy(&target->parts_of_speech, &source->parts_of_speech, sizeof (source->parts_of_speech));
memcpy(&target->words, &source->words, sizeof (source->words));
target->unknown = source->unknown;
return true;
}
string Translation::TranslateName(const t_name &name, bool inEnglish)
string Translation::TranslateName(const df_name * name, bool inEnglish)
{
string out;
assert (d->Started);
@ -218,25 +217,25 @@ string Translation::TranslateName(const t_name &name, bool inEnglish)
if(!inEnglish)
{
if(name.words[0] >=0 || name.words[1] >=0)
if(name->words[0] >=0 || name->words[1] >=0)
{
if(name.words[0]>=0) out.append(d->dicts.foreign_languages[name.language][name.words[0]]);
if(name.words[1]>=0) out.append(d->dicts.foreign_languages[name.language][name.words[1]]);
if(name->words[0]>=0) out.append(d->dicts.foreign_languages[name->language][name->words[0]]);
if(name->words[1]>=0) out.append(d->dicts.foreign_languages[name->language][name->words[1]]);
out[0] = toupper(out[0]);
}
if(name.words[5] >=0)
if(name->words[5] >=0)
{
string word;
for(int i=2;i<=5;i++)
if(name.words[i]>=0) word.append(d->dicts.foreign_languages[name.language][name.words[i]]);
if(name->words[i]>=0) word.append(d->dicts.foreign_languages[name->language][name->words[i]]);
word[0] = toupper(word[0]);
if(out.length() > 0) out.append(" ");
out.append(word);
}
if(name.words[6] >=0)
if(name->words[6] >=0)
{
string word;
word.append(d->dicts.foreign_languages[name.language][name.words[6]]);
word.append(d->dicts.foreign_languages[name->language][name->words[6]]);
word[0] = toupper(word[0]);
if(out.length() > 0) out.append(" ");
out.append(word);
@ -244,13 +243,13 @@ string Translation::TranslateName(const t_name &name, bool inEnglish)
}
else
{
if(name.words[0] >=0 || name.words[1] >=0)
if(name->words[0] >=0 || name->words[1] >=0)
{
if(name.words[0]>=0) out.append(d->dicts.translations[name.parts_of_speech[0]+1][name.words[0]]);
if(name.words[1]>=0) out.append(d->dicts.translations[name.parts_of_speech[1]+1][name.words[1]]);
if(name->words[0]>=0) out.append(d->dicts.translations[name->parts_of_speech[0]+1][name->words[0]]);
if(name->words[1]>=0) out.append(d->dicts.translations[name->parts_of_speech[1]+1][name->words[1]]);
out[0] = toupper(out[0]);
}
if(name.words[5] >=0)
if(name->words[5] >=0)
{
if(out.length() > 0)
out.append(" the");
@ -259,22 +258,22 @@ string Translation::TranslateName(const t_name &name, bool inEnglish)
string word;
for(int i=2;i<=5;i++)
{
if(name.words[i]>=0)
if(name->words[i]>=0)
{
word = d->dicts.translations[name.parts_of_speech[i]+1][name.words[i]];
word = d->dicts.translations[name->parts_of_speech[i]+1][name->words[i]];
word[0] = toupper(word[0]);
out.append(" " + word);
}
}
}
if(name.words[6] >=0)
if(name->words[6] >=0)
{
if(out.length() > 0)
out.append(" of");
else
out.append("Of");
string word;
word.append(d->dicts.translations[name.parts_of_speech[6]+1][name.words[6]]);
word.append(d->dicts.translations[name->parts_of_speech[6]+1][name->words[6]]);
word[0] = toupper(word[0]);
out.append(" " + word);
}

@ -1,80 +1,4 @@
#FIXME: inherit all macros and stuff from the dfhack SDK
IF(UNIX)
add_definitions(-DLINUX_BUILD)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -m32 -std=c++0x")
SET(CMAKE_C_FLAGS "-fvisibility=hidden -m32")
ENDIF()
include_directories("${dfhack_SOURCE_DIR}/library/include")
include_directories("${dfhack_SOURCE_DIR}/library/depends/xgetopt")
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO(CAR)
MACRO(CDR var junk)
SET(${var} ${ARGN})
ENDMACRO(CDR)
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF (${value} STREQUAL ${value2})
ENDFOREACH (value2)
ENDMACRO(LIST_CONTAINS)
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name)
LIST_CONTAINS(is_option ${arg} ${option_names})
IF (is_option)
SET(${prefix}_${arg} TRUE)
ELSE (is_option)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option)
ENDIF (is_arg_name)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
MACRO(DFHACK_PLUGIN)
PARSE_ARGUMENTS(PLUGIN
"LINK_LIBRARIES;DEPENDS"
"SOME_OPT"
${ARGN}
)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll)
ENDIF()
install(TARGETS ${PLUGIN_NAME}
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION})
ENDMACRO(DFHACK_PLUGIN)
INCLUDE(Plugins.cmake)
# Dfusion plugin
IF(UNIX)

@ -0,0 +1,77 @@
IF(UNIX)
add_definitions(-DLINUX_BUILD)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall")
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -m32 -std=c++0x")
SET(CMAKE_C_FLAGS "-fvisibility=hidden -m32")
ENDIF()
include_directories("${dfhack_SOURCE_DIR}/library/include")
include_directories("${dfhack_SOURCE_DIR}/library/depends/xgetopt")
MACRO(CAR var)
SET(${var} ${ARGV1})
ENDMACRO()
MACRO(CDR var junk)
SET(${var} ${ARGN})
ENDMACRO()
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF()
ENDFOREACH()
ENDMACRO()
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH()
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH()
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
LIST_CONTAINS(is_arg_name ${arg} ${arg_names})
IF (is_arg_name)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE()
LIST_CONTAINS(is_option ${arg} ${option_names})
IF(is_option)
SET(${prefix}_${arg} TRUE)
ELSE()
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF()
ENDIF()
ENDFOREACH()
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO()
MACRO(DFHACK_PLUGIN)
PARSE_ARGUMENTS(PLUGIN
"LINK_LIBRARIES;DEPENDS"
"SOME_OPT"
${ARGN}
)
CAR(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
CDR(PLUGIN_SOURCES ${PLUGIN_DEFAULT_ARGS})
ADD_LIBRARY(${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} dfhack ${PLUGIN_LINK_LIBRARIES})
IF(UNIX)
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.so PREFIX "")
ELSE()
SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES SUFFIX .plug.dll)
ENDIF()
install(TARGETS ${PLUGIN_NAME}
LIBRARY DESTINATION ${DFHACK_PLUGIN_DESTINATION}
RUNTIME DESTINATION ${DFHACK_PLUGIN_DESTINATION})
ENDMACRO(DFHACK_PLUGIN)

@ -178,14 +178,12 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
if (owner_index >= 0)
{
DFHack::t_creature temp;
Creatures->ReadCreature(owner_index,temp);
temp.name.first_name[0] = toupper(temp.name.first_name[0]);
info = temp.name.first_name;
if (temp.name.nickname[0])
info += std::string(" '") + temp.name.nickname + "'";
DFHack::df_creature * temp = Creatures->GetCreature(owner_index);
info = temp->name.first_name;
if (!temp->name.nick_name.empty())
info += std::string(" '") + temp->name.nick_name + "'";
info += " ";
info += Tran->TranslateName(temp.name,false);
info += Tran->TranslateName(&temp->name,false);
c->con.print(", owner %s", info.c_str());
}

@ -67,7 +67,7 @@ public:
t_itemflags &f = itm->base->flags;
return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || f.unk5 ||
return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || /*f.unk5 ||*/
f.unk6 || f.unk7 ||
// f.unk8 || f.unk9 || /* Too common */
f.unk10 || f.unk11);
@ -100,7 +100,7 @@ public:
if (f.unk2) flags.push_back("unk2");
if (f.unk3) flags.push_back("unk3");
if (f.unk4) flags.push_back("unk4");
if (f.unk5) flags.push_back("unk5");
//if (f.unk5) flags.push_back("unk5");
if (f.unk6) flags.push_back("unk6");
if (f.unk7) flags.push_back("unk7");
if (f.unk8) flags.push_back("unk8");

@ -25,6 +25,8 @@ DFhackCExport command_result ktimer (Core * c, vector <string> & parameters);
DFhackCExport command_result bflags (Core * c, vector <string> & parameters);
DFhackCExport command_result trackmenu (Core * c, vector <string> & parameters);
DFhackCExport command_result mapitems (Core * c, vector <string> & parameters);
DFhackCExport command_result test_creature_offsets (Core * c, vector <string> & parameters);
DFhackCExport command_result creat_job (Core * c, vector <string> & parameters);
DFhackCExport const char * plugin_name ( void )
{
@ -39,6 +41,8 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
commands.push_back(PluginCommand("blockflags","Look up block flags",bflags));
commands.push_back(PluginCommand("trackmenu","Track menu ID changes (toggle).",trackmenu));
commands.push_back(PluginCommand("mapitems","Check item ids under cursor against item ids in map block.",mapitems));
commands.push_back(PluginCommand("test_creature_offsets","Bleh.",test_creature_offsets));
commands.push_back(PluginCommand("creat_job","Bleh.",creat_job));
return CR_OK;
}
@ -287,3 +291,49 @@ DFhackCExport command_result kittens (Core * c, vector <string> & parameters)
color = Console::COLOR_BLUE;
}
}
#include "dfhack/modules/Creatures.h"
#include "dfhack/VersionInfo.h"
#include <stddef.h>
command_result test_creature_offsets(Core* c, vector< string >& parameters)
{
uint32_t off_vinfo = c->vinfo->getGroup("Creatures")->getGroup("creature")->/*getGroup("advanced")->*/getOffset("custom_profession");
uint32_t off_struct = offsetof(df_creature,custom_profession);
c->con.print("Struct 0x%x, vinfo 0x%x\n", off_struct, off_vinfo);
return CR_OK;
};
command_result creat_job (Core * c, vector< string >& parameters)
{
c->Suspend();
Creatures * cr = c->getCreatures();
Gui * g = c-> getGui();
uint32_t num_cr = 0;
int32_t cx,cy,cz;
g->getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
c->con.printerr("No cursor.\n");
c->Resume();
return CR_FAILURE;
}
if(!cr->Start(num_cr) || num_cr == 0)
{
c->con.printerr("No creatures.\n");
c->Resume();
return CR_FAILURE;
}
auto iter = cr->creatures->begin();
while (iter != cr->creatures->end())
{
df_creature * unit = *iter;
if(cx == unit->x && cy == unit->y && cz == unit->z)
{
c->con.print("%d:%s - address 0x%x - job 0x%x\n", unit->id, unit->name.first_name.c_str(), unit, uint32_t(unit) + offsetof(df_creature,current_job));
}
iter++;
}
c->Resume();
return CR_OK;
};

@ -206,6 +206,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
<< "of - make obsidian floors" << endl
<< "rs - make a river source" << endl
<< "f - flow bits only" << endl
<< "wclean - remove salt and stagnant flags from tiles" << endl
<< "Set-Modes (only for magma/water):" << endl
<< "s+ - only add" << endl
<< "s. - set" << endl
@ -254,6 +255,10 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
{
mode = "riversource";
}
else if(command == "wclean")
{
mode = "wclean";
}
else if(command == "point" || command == "p")
{
delete brush;
@ -423,6 +428,19 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters)
iter++;
}
}
else if(mode=="wclean")
{
coord_vec::iterator iter = all_tiles.begin();
while (iter != all_tiles.end())
{
DFHack::DFCoord current = *iter;
DFHack::t_designation des = mcache.designationAt(current);
des.bits.water_salt = false;
des.bits.water_stagnant = false;
mcache.setDesignationAt(current,des);
iter++;
}
}
else if(mode== "magma" || mode== "water" || mode == "flowbits")
{
set <Block *> seen_blocks;

@ -198,6 +198,10 @@ DFhackCExport command_result df_probe (Core * c, vector <string> & parameters)
con << "rained?" << std::endl;
if(des.smooth)
con << "smooth?" << std::endl;
if(des.water_salt)
con << "salty" << endl;
if(des.water_stagnant)
con << "stagnant" << endl;
#define PRINT_FLAG( X ) con.print("%-16s= %c\n", #X , ( des.X ? 'Y' : ' ' ) )
PRINT_FLAG( hidden );

@ -0,0 +1 @@
Subproject commit c140ed8d6dbe05854ee1499540814d5f358a960a

@ -9,7 +9,7 @@
#include <cstdio>
#include <stack>
#include <string>
#include <cmath>
using std::vector;
using std::string;
using std::stack;
@ -56,6 +56,7 @@ enum circle_what
{
circle_set,
circle_unset,
circle_invert,
};
DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
@ -63,8 +64,8 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
static bool filled = false;
static circle_what what = circle_set;
static e_designation type = designation_default;
static int r = 0;
auto saved_r = r;
static int diameter = 0;
auto saved_d = diameter;
bool force_help = false;
for(int i = 0; i < parameters.size();i++)
{
@ -88,6 +89,10 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
{
what = circle_unset;
}
else if(parameters[i] == "invert")
{
what = circle_invert;
}
else if(parameters[i] == "dig")
{
type = designation_default;
@ -112,14 +117,14 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
{
type = designation_channel;
}
else if (!from_string(r,parameters[i], std::dec))
else if (!from_string(diameter,parameters[i], std::dec))
{
r = saved_r;
diameter = saved_d;
}
}
if(r < 0)
r = -r;
if(force_help || r == 0)
if(diameter < 0)
diameter = -diameter;
if(force_help || diameter == 0)
{
c->con.print( "A command for easy designation of filled and hollow circles.\n"
"\n"
@ -129,6 +134,7 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
"\n"
" set = set designation\n"
" unset = unset current designation\n"
" invert = invert current designation\n"
"\n"
" dig = normal digging\n"
" ramp = ramp digging\n"
@ -137,7 +143,7 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
" xstair = staircase up/down\n"
" chan = dig channel\n"
"\n"
" # = radius in tiles (default = 0)\n"
" # = diameter in tiles (default = 0)\n"
"\n"
"After you have set the options, the command called with no options\n"
"repeats with the last selected parameters:\n"
@ -173,10 +179,16 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
auto b = MCache.BlockAt(at/16);
if(!b || !b->valid)
return false;
if(x == 0 || x == x_max - 1)
if(x == 0 || x == x_max * 16 - 1)
{
//c->con.print("not digging map border\n");
return false;
if(y == 0 || y == y_max - 1)
}
if(y == 0 || y == y_max * 16 - 1)
{
//c->con.print("not digging map border\n");
return false;
}
uint16_t tt = MCache.tiletypeAt(at);
t_designation des = MCache.designationAt(at);
// could be potentially used to locate hidden constructions?
@ -220,6 +232,15 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
{
des.bits.dig = designation_no;
}
case circle_invert:
if(des.bits.dig == designation_no)
{
des.bits.dig = type;
}
else
{
des.bits.dig = designation_no;
}
break;
}
std::cerr << "allowing tt" << tt << "\n";
@ -242,53 +263,71 @@ DFhackCExport command_result digcircle (Core * c, vector <string> & parameters)
}
return true;
};
int f = 1 - r;
int ddF_x = 1;
int ddF_y = -2 * r;
int x = 0;
int y = r;
if(!filled)
{
dig(cx, cy + r, cz);
dig(cx, cy - r, cz);
dig(cx + r, cy, cz);
dig(cx - r, cy, cz);
int r = diameter / 2;
int iter;
bool adjust;
if(diameter % 2)
{
// paint center
if(filled)
{
lineY(cx - r, cx + r, cy, cz);
}
else
{
dig(cx - r, cy, cz);
dig(cx + r, cy, cz);
}
adjust = false;
iter = 2;
}
else
{
lineX(cy-r, cy+r, cx, cz);
lineY(cx-r, cx+r, cy, cz);
adjust = true;
iter = 1;
}
while(x < y)
{
if(f >= 0)
{
y--;
ddF_y += 2;
f += ddF_y;
int lastwhole = r;
for(; iter <= diameter - 1; iter +=2)
{
// top, bottom coords
int top = cy - ((iter + 1) / 2) + adjust;
int bottom = cy + ((iter + 1) / 2);
// see where the current 'line' intersects the circle
double val = std::sqrt(double(diameter*diameter - iter*iter));
// adjust for circles with odd diameter
if(!adjust)
val -= 1;
// map the found value to the DF grid
double whole;
double fraction = std::modf(val / 2.0, & whole);
if (fraction > 0.5)
whole += 1.0;
int right = cx + whole;
int left = cx - whole + adjust;
int diff = lastwhole - whole;
// paint
if(filled || iter == diameter - 1)
{
lineY(left, right, top , cz);
lineY(left, right, bottom , cz);
}
x++;
ddF_x += 2;
f += ddF_x;
if(!filled)
else
{
dig(cx + x, cy + y, cz);
dig(cx - x, cy + y, cz);
dig(cx + x, cy - y, cz);
dig(cx - x, cy - y, cz);
dig(cx + y, cy + x, cz);
dig(cx - y, cy + x, cz);
dig(cx + y, cy - x, cz);
dig(cx - y, cy - x, cz);
dig(left, top, cz);
dig(left, bottom, cz);
dig(right, top, cz);
dig(right, bottom, cz);
}
else
if(!filled && diff > 1)
{
lineY(cx-x, cx+x, cy+y, cz);
lineY(cx-x, cx+x, cy-y, cz);
lineY(cx-y, cx+y, cy+x, cz);
lineY(cx-y, cx+y, cy-x, cz);
int lright = cx + lastwhole;
int lleft = cx - lastwhole + adjust;
lineY(lleft + 1, left - 1, top + 1 , cz);
lineY(right + 1, lright - 1, top + 1 , cz);
lineY(lleft + 1, left - 1, bottom - 1 , cz);
lineY(right + 1, lright - 1, bottom - 1 , cz);
}
lastwhole = whole;
}
MCache.WriteAll();
c->Resume();