Merge branch 'master' into export-plugin

develop
Espen Wiborg 2012-01-02 12:49:23 +01:00
commit 5918cb773d
203 changed files with 3146 additions and 11596 deletions

3
.gitmodules vendored

@ -4,3 +4,6 @@
[submodule "plugins/df2mc"] [submodule "plugins/df2mc"]
path = plugins/df2mc path = plugins/df2mc
url = git://github.com/peterix/DF2MC.git url = git://github.com/peterix/DF2MC.git
[submodule "library/xml"]
path = library/xml
url = git://github.com/peterix/df-structures.git

@ -19,8 +19,8 @@ a 64-bit distribution like Arch, you'll need the multilib development tools and
Before you can build anything, you'll also need ``cmake``. It is advisable to also get Before you can build anything, you'll also need ``cmake``. It is advisable to also get
``ccmake`` on distributions that split the cmake package into multiple parts. ``ccmake`` on distributions that split the cmake package into multiple parts.
For the code generation parts, you need perl and the XML::LibXML perl package. For the code generation parts, you need perl and the XML::LibXML and XML::LibXSLT perl packages.
You should be able to find them in your distro repositories (on Arch linux 'perl-xml-libxml'). You should be able to find them in your distro repositories (on Arch linux 'perl-xml-libxml' and 'perl-xml-libxslt').
Build Build
===== =====
@ -58,9 +58,11 @@ You'll need a copy of Microsoft Visual C++ 2010. The Express version is sufficie
Grab it from Microsoft's site. Grab it from Microsoft's site.
For the code generation parts, you'll need perl and XML::LibXML. You can install them like this: For the code generation parts, you'll need perl and XML::LibXML. You can install them like this:
* download and install strawberry perl from http://strawberryperl.com/ * download and install strawberry perl from http://strawberryperl.com/
* reboot so that the system can pick up the new binary path * reboot so that the system can pick up the new binary path
* open a cmd.exe window and run "cpan XML::LibXML" (obviously without the quotes). This can take a while to complete. * open a cmd.exe window and run "cpan XML::LibXML" (obviously without the quotes). This can take a while to complete.
* Same with "cpan XML::LibXSLT".
Build Build
===== =====

@ -351,8 +351,8 @@ ul.auto-toc {
a 64-bit distribution like Arch, you'll need the multilib development tools and libraries.</p> a 64-bit distribution like Arch, you'll need the multilib development tools and libraries.</p>
<p>Before you can build anything, you'll also need <tt class="docutils literal">cmake</tt>. It is advisable to also get <p>Before you can build anything, you'll also need <tt class="docutils literal">cmake</tt>. It is advisable to also get
<tt class="docutils literal">ccmake</tt> on distributions that split the cmake package into multiple parts.</p> <tt class="docutils literal">ccmake</tt> on distributions that split the cmake package into multiple parts.</p>
<p>For the code generation parts, you need perl and the XML::LibXML perl package. <p>For the code generation parts, you need perl and the XML::LibXML and XML::LibXSLT perl packages.
You should be able to find them in your distro repositories (on Arch linux 'perl-xml-libxml').</p> You should be able to find them in your distro repositories (on Arch linux 'perl-xml-libxml' and 'perl-xml-libxslt').</p>
</div> </div>
<div class="section" id="build"> <div class="section" id="build">
<h2><a class="toc-backref" href="#id4">Build</a></h2> <h2><a class="toc-backref" href="#id4">Build</a></h2>
@ -384,10 +384,13 @@ site: <a class="reference external" href="http://www.cmake.org/cmake/resources/s
to your binary search PATH so the tool can be later run from anywhere.</p> to your binary search PATH so the tool can be later run from anywhere.</p>
<p>You'll need a copy of Microsoft Visual C++ 2010. The Express version is sufficient. <p>You'll need a copy of Microsoft Visual C++ 2010. The Express version is sufficient.
Grab it from Microsoft's site.</p> Grab it from Microsoft's site.</p>
<p>For the code generation parts, you'll need perl and XML::LibXML. You can install them like this: <p>For the code generation parts, you'll need perl and XML::LibXML. You can install them like this:</p>
* download and install strawberry perl from http://strawberryperl.com/ <ul class="simple">
* reboot so that the system can pick up the new binary path <li>download and install strawberry perl from <a class="reference external" href="http://strawberryperl.com/">http://strawberryperl.com/</a></li>
* open a cmd.exe window and run &quot;cpan XML::LibXML&quot; (obviously without the quotes). This can take a while to complete.</p> <li>reboot so that the system can pick up the new binary path</li>
<li>open a cmd.exe window and run &quot;cpan XML::LibXML&quot; (obviously without the quotes). This can take a while to complete.</li>
<li>Same with &quot;cpan XML::LibXSLT&quot;.</li>
</ul>
<div class="section" id="id1"> <div class="section" id="id1">
<h2><a class="toc-backref" href="#id6">Build</a></h2> <h2><a class="toc-backref" href="#id6">Build</a></h2>
<p>Open the <tt class="docutils literal">build</tt> folder and double click the batch script there. This will eventually open <p>Open the <tt class="docutils literal">build</tt> folder and double click the batch script there. This will eventually open

@ -1078,12 +1078,21 @@
<Group name="Notes" description="In-game notes"> <Group name="Notes" description="In-game notes">
<Address name="vector"/> <Address name="vector"/>
</Group> </Group>
<Group name='vtable'>
</Group>
<Group name='global'> <Group name='global'>
<Address name='cursor'/>
<Address name='selection_rect'/>
<Address name='world'/> <Address name='world'/>
<Address name='ui'/> <Address name='ui'/>
<Address name='gview'/> <Address name='gview'/>
<Address name='init'/> <Address name='init'/>
<Address name='d_init'/> <Address name='d_init'/>
<Address name='ui_sidebar_menus'/>
<Address name='ui_build_selector'/>
<Address name='ui_look_list'/>
<Address name='ui_look_cursor'/>
<Address name='ui_workshop_job_cursor'/>
</Group> </Group>
</Offsets> </Offsets>
</Base> </Base>
@ -2316,12 +2325,24 @@
<Group name="World"> <Group name="World">
<Address name="save_folder" value="0x1847A40" /> <Address name="save_folder" value="0x1847A40" />
</Group> </Group>
<Group name='vtable'>
</Group>
<Group name='global'> <Group name='global'>
<!-- .data -->
<Address name='cursor' value='0xb347f0'/>
<Address name='selection_rect' value='0xb347fc'/>
<!-- .bss -->
<Address name='world' value='0x16b0a58'/> <Address name='world' value='0x16b0a58'/>
<Address name='ui' value='0x14ee7e0'/> <Address name='ui' value='0x14ee7e0'/>
<Address name='gview' value='0x14f6070'/> <Address name='gview' value='0x14f6070'/>
<Address name='init' value='0x184ae58'/> <Address name='init' value='0x184ae58'/>
<Address name='d_init' value='0x1848350'/> <Address name='d_init' value='0x1848350'/>
<Address name='ui_sidebar_menus' value='0x1848648'/>
<Address name='ui_build_selector' value='0x1849e88'/>
<Address name='ui_look_list' value='0x185c104'/>
<Address name='ui_look_cursor' value='0xedeb98'/>
<Address name='ui_workshop_job_cursor' value='0x14ec79c'/>
</Group> </Group>
</Offsets> </Offsets>
cmake cmake
@ -3188,12 +3209,24 @@
<Group name="Notes"> <Group name="Notes">
<Address name="vector" value="0x93f635c"/> <Address name="vector" value="0x93f635c"/>
</Group> </Group>
<Group name='vtable'>
</Group>
<Group name='global'> <Group name='global'>
<!-- .data -->
<Address name='cursor' value='0x8c3de60'/>
<Address name='selection_rect' value='0x8c3de70'/>
<!-- .bss -->
<Address name='world' value='0x93f77a0'/> <Address name='world' value='0x93f77a0'/>
<Address name='ui' value='0x93f0780'/> <Address name='ui' value='0x93f0780'/>
<Address name='gview' value='0x8c3e900'/> <Address name='gview' value='0x8c3e900'/>
<Address name='init' value='0x959c2a0'/> <Address name='init' value='0x959c2a0'/>
<Address name='d_init' value='0x959d340'/> <Address name='d_init' value='0x959d340'/>
<Address name='ui_sidebar_menus' value='0x958aa40'/>
<Address name='ui_build_selector' value='0x8df9b20'/>
<Address name='ui_look_list' value='0x961d840'/>
<!--<Address name='ui_look_cursor' value=''/>-->
<Address name='ui_workshop_job_cursor' value='0x93f0644'/>
</Group> </Group>
</Offsets> </Offsets>
</Version> </Version>

3
build/.gitignore vendored

@ -1 +1,2 @@
build-real VC2010
DF_PATH.txt

@ -0,0 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat"
cd VC2010
msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj
cd ..

@ -0,0 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat"
cd VC2010
msbuild /m /p:Platform=Win32 /p:Configuration=Release ALL_BUILD.vcxproj
cd ..

@ -1,5 +0,0 @@
mkdir VC2010
cd VC2010
echo Pre-generating a build folder
cmake ..\.. -G"Visual Studio 10"
cmake-gui .

@ -0,0 +1,6 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010
cd VC2010
echo generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX=%_DF_PATH% -DBUILD_DEVEL=1 -DBUILD_DEV_PLUGINS=1 -DBUILD_DF2MC=1 -DBUILD_DFUSION=1 -DBUILD_STONESENSE=1 -DBUILD_SERVER=1

@ -0,0 +1,7 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010
cd VC2010
echo Pre-generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX=%_DF_PATH%
cmake-gui .

@ -0,0 +1,6 @@
IF EXIST DF_PATH.txt SET /P _DF_PATH=<DF_PATH.txt
IF NOT EXIST DF_PATH.txt SET _DF_PATH=%CD%\DF
mkdir VC2010
cd VC2010
echo generating a build folder
cmake ..\.. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX=%_DF_PATH% -DBUILD_DEVEL=0 -DBUILD_DEV_PLUGINS=0 -DBUILD_DF2MC=0 -DBUILD_DFUSION=0 -DBUILD_STONESENSE=0 -DBUILD_SERVER=0

@ -0,0 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat"
cd VC2010
msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo INSTALL.vcxproj
cd ..

@ -0,0 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat"
cd VC2010
msbuild /m /p:Platform=Win32 /p:Configuration=Release INSTALL.vcxproj
cd ..

@ -0,0 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat"
cd VC2010
msbuild /m /p:Platform=Win32 /p:Configuration=RelWithDebInfo PACKAGE.vcxproj
cd ..

@ -0,0 +1,4 @@
call "%VS100COMNTOOLS%vsvars32.bat"
cd VC2010
msbuild /m /p:Platform=Win32 /p:Configuration=Release PACKAGE.vcxproj
cd ..

@ -0,0 +1,32 @@
Option Explicit
Const BIF_returnonlyfsdirs = &H0001
Dim wsh, objDlg, objF, fso, spoFile
Set objDlg = WScript.CreateObject("Shell.Application")
Set objF = objDlg.BrowseForFolder (&H0,"Select your DF folder", BIF_returnonlyfsdirs)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("DF_PATH.txt") Then
fso.DeleteFile "DF_PATH.txt", True
End If
If IsValue(objF) Then
If InStr(1, TypeName(objF), "Folder") > 0 Then
Set spoFile = fso.CreateTextFile("DF_PATH.txt", True)
spoFile.WriteLine(objF.Self.Path)
End If
End If
Function IsValue(obj)
' Check whether the value has been returned.
Dim tmp
On Error Resume Next
tmp = " " & obj
If Err <> 0 Then
IsValue = False
Else
IsValue = True
End If
On Error GoTo 0
End Function

@ -13,60 +13,60 @@ include_directories (include)
include_directories (depends/md5) include_directories (depends/md5)
include_directories (depends/tinyxml) include_directories (depends/tinyxml)
include_directories (depends/tthread) include_directories (depends/tthread)
include_directories (private)
execute_process(COMMAND perl xml/list.pl xml include/dfhack/df ";" execute_process(COMMAND perl xml/list.pl xml include/df ";"
WORKING_DIRECTORY ${dfapi_SOURCE_DIR} WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
OUTPUT_VARIABLE GENERATED_HDRS) OUTPUT_VARIABLE GENERATED_HDRS)
SET(PROJECT_HDRS_INTERNAL SET(PROJECT_HDRS_INTERNAL
private/ContextShared.h
private/Internal.h
private/wdirent.h
) )
SET(PROJECT_HDRS SET(PROJECT_HDRS
include/Internal.h
include/DFHack.h include/DFHack.h
include/dfhack/Console.h include/Console.h
include/dfhack/Core.h include/Core.h
include/dfhack/DataDefs.h include/DataDefs.h
include/dfhack/Error.h include/Error.h
include/dfhack/Export.h include/Export.h
include/dfhack/FakeSDL.h include/Hooks.h
include/dfhack/MiscUtils.h include/MiscUtils.h
include/dfhack/Module.h include/Module.h
include/dfhack/Pragma.h include/Pragma.h
include/dfhack/Process.h include/MemAccess.h
include/dfhack/TileTypes.h include/SDL_events.h
include/dfhack/Types.h include/SDL_keyboard.h
include/dfhack/Vector.h include/SDL_keysym.h
include/dfhack/VersionInfo.h include/TileTypes.h
include/dfhack/VersionInfoFactory.h include/Types.h
include/dfhack/Virtual.h include/Vector.h
include/dfhack/extra/MapExtras.h include/VersionInfo.h
include/dfhack/extra/stopwatch.h include/VersionInfoFactory.h
include/dfhack/extra/termutil.h include/Virtual.h
include/dfhack/modules/Buildings.h include/modules/Buildings.h
include/dfhack/modules/Constructions.h include/modules/Constructions.h
include/dfhack/modules/Units.h include/modules/Units.h
include/dfhack/modules/Engravings.h include/modules/Engravings.h
include/dfhack/modules/Gui.h include/modules/Gui.h
include/dfhack/modules/Items.h include/modules/Items.h
include/dfhack/modules/kitchen.h include/modules/kitchen.h
include/dfhack/modules/Maps.h include/modules/Maps.h
include/dfhack/modules/Materials.h include/modules/MapCache.h
include/dfhack/modules/Notes.h include/modules/Materials.h
include/dfhack/modules/Translation.h include/modules/Notes.h
include/dfhack/modules/Vegetation.h include/modules/Translation.h
include/dfhack/modules/Vermin.h include/modules/Vegetation.h
include/dfhack/modules/World.h include/modules/Vermin.h
include/dfhack/modules/Graphic.h include/modules/World.h
include/modules/Graphic.h
) )
SET(PROJECT_SRCS SET(PROJECT_SRCS
Core.cpp Core.cpp
DataDefs.cpp DataDefs.cpp
DataStatics.cpp DataStatics.cpp
DataStaticsCtor.cpp
MiscUtils.cpp
PluginManager.cpp PluginManager.cpp
TileTypes.cpp TileTypes.cpp
VersionInfo.cpp VersionInfo.cpp
@ -104,17 +104,18 @@ SET(PROJECT_HDRS_LINUX
) )
SET(PROJECT_HDRS_WINDOWS SET(PROJECT_HDRS_WINDOWS
include/wdirent.h
) )
SET(PROJECT_SRCS_LINUX SET(PROJECT_SRCS_LINUX
Console-linux.cpp Console-linux.cpp
FakeSDL-linux.cpp Hooks-linux.cpp
Process-linux.cpp Process-linux.cpp
) )
SET(PROJECT_SRCS_WINDOWS SET(PROJECT_SRCS_WINDOWS
Console-windows.cpp Console-windows.cpp
FakeSDL-windows.cpp Hooks-windows.cpp
Process-windows.cpp Process-windows.cpp
) )
@ -134,17 +135,18 @@ LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
SET_SOURCE_FILES_PROPERTIES(${GENERATED_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE GENERATED TRUE) SET_SOURCE_FILES_PROPERTIES(${GENERATED_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE GENERATED TRUE)
FILE(GLOB GENERATE_INPUT_SCRIPTS ${dfapi_SOURCE_DIR}/xml/*.pm ${dfapi_SOURCE_DIR}/xml/*.xslt)
FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/*.xml) FILE(GLOB GENERATE_INPUT_XMLS ${dfapi_SOURCE_DIR}/xml/*.xml)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${dfapi_SOURCE_DIR}/include/dfhack/df/static.inc OUTPUT ${dfapi_SOURCE_DIR}/include/df/static.inc
COMMAND perl xml/codegen.pl xml include/dfhack/df COMMAND perl xml/codegen.pl xml include/df
WORKING_DIRECTORY ${dfapi_SOURCE_DIR} WORKING_DIRECTORY ${dfapi_SOURCE_DIR}
MAIN_DEPENDENCY ${dfapi_SOURCE_DIR}/xml/codegen.pl MAIN_DEPENDENCY ${dfapi_SOURCE_DIR}/xml/codegen.pl
DEPENDS ${GENERATE_INPUT_XMLS} DEPENDS ${GENERATE_INPUT_XMLS} ${GENERATE_INPUT_SCRIPTS}
) )
ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/dfhack/df/static.inc) ADD_CUSTOM_TARGET(generate_headers DEPENDS ${dfapi_SOURCE_DIR}/include/df/static.inc)
# Compilation # Compilation

@ -61,8 +61,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <errno.h> #include <errno.h>
#include <deque> #include <deque>
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
using namespace DFHack; using namespace DFHack;
#include "tinythread.h" #include "tinythread.h"

@ -50,8 +50,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <istream> #include <istream>
#include <string> #include <string>
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <sstream>

@ -34,30 +34,37 @@ distribution.
#include <sstream> #include <sstream>
using namespace std; using namespace std;
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/DataDefs.h" #include "DataDefs.h"
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/PluginManager.h" #include "PluginManager.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/modules/Gui.h" #include "modules/Gui.h"
#include "dfhack/modules/World.h" #include "modules/World.h"
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
using namespace DFHack; using namespace DFHack;
#include "dfhack/SDL_fakes/events.h" #include "SDL_events.h"
#include "df/ui.h"
#include "df/world.h"
#include "df/world_data.h"
#include "df/interface.h"
#include "df/viewscreen_dwarfmodest.h"
#include <stdio.h> #include <stdio.h>
#include <iomanip> #include <iomanip>
#include <stdlib.h> #include <stdlib.h>
#include <fstream> #include <fstream>
#include "tinythread.h" #include "tinythread.h"
using namespace tthread;
using namespace tthread;
using namespace df::enums;
struct Core::Cond struct Core::Cond
{ {
@ -91,9 +98,35 @@ struct Core::Cond
void cheap_tokenise(string const& input, vector<string> &output) void cheap_tokenise(string const& input, vector<string> &output)
{ {
istringstream str(input); string *cur = NULL;
istream_iterator<string> cur(str), end;
output.assign(cur, end); for (unsigned i = 0; i < input.size(); i++) {
char c = input[i];
if (isspace(c)) {
cur = NULL;
} else {
if (!cur) {
output.push_back("");
cur = &output.back();
}
if (c == '"') {
for (i++; i < input.size(); i++) {
c = input[i];
if (c == '"')
break;
else if (c == '\\') {
if (++i < input.size())
cur->push_back(input[i]);
}
else
cur->push_back(c);
}
} else {
cur->push_back(c);
}
}
}
} }
struct IODATA struct IODATA
@ -119,8 +152,17 @@ void fHKthread(void * iodata)
std::string stuff = core->getHotkeyCmd(); // waits on mutex! std::string stuff = core->getHotkeyCmd(); // waits on mutex!
if(!stuff.empty()) if(!stuff.empty())
{ {
vector <string> crap; vector <string> args;
command_result cr = plug_mgr->InvokeCommand(stuff, crap, false); cheap_tokenise(stuff, args);
if (args.empty()) {
core->con.printerr("Empty hotkey command.\n");
continue;
}
string first = args[0];
args.erase(args.begin());
command_result cr = plug_mgr->InvokeCommand(first, args, false);
if(cr == CR_WOULD_BREAK) if(cr == CR_WOULD_BREAK)
{ {
core->con.printerr("It isn't possible to run an interactive command outside the console.\n"); core->con.printerr("It isn't possible to run an interactive command outside the console.\n");
@ -129,53 +171,25 @@ void fHKthread(void * iodata)
} }
} }
// A thread function... for the interactive console. static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clueless_counter, const string &command)
void fIOthread(void * iodata)
{ {
IODATA * iod = ((IODATA*) iodata);
Core * core = iod->core;
PluginManager * plug_mgr = ((IODATA*) iodata)->plug_mgr;
CommandHistory main_history;
main_history.load("dfhack.history");
Console & con = core->con; Console & con = core->con;
if(plug_mgr == 0 || core == 0)
{ if (!command.empty())
con.printerr("Something horrible happened in Core's constructor...\n");
return;
}
con.print("DFHack is ready. Have a nice day!\n"
"Type in '?' or 'help' for general help, 'ls' to see all commands.\n");
int clueless_counter = 0;
while (true)
{
string command = "";
int ret = con.lineedit("[DFHack]# ",command, main_history);
if(ret == -2)
{
cerr << "Console is shutting down properly." << endl;
return;
}
else if(ret == -1)
{
cerr << "Console caught an unspecified error." << endl;
continue;
}
else if(ret)
{ {
// a proper, non-empty command was entered
main_history.add(command);
main_history.save("dfhack.history");
}
// cut the input into parts // cut the input into parts
vector <string> parts; vector <string> parts;
cheap_tokenise(command,parts); cheap_tokenise(command,parts);
if(parts.size() == 0) if(parts.size() == 0)
{ {
clueless_counter ++; clueless_counter ++;
continue; return;
} }
string first = parts[0]; string first = parts[0];
parts.erase(parts.begin()); parts.erase(parts.begin());
if (first[0] == '#') return;
cerr << "Invoking: " << command << endl; cerr << "Invoking: " << command << endl;
// let's see what we actually got // let's see what we actually got
@ -194,6 +208,7 @@ void fIOthread(void * iodata)
" cls - Clear the console.\n" " cls - Clear the console.\n"
" fpause - Force DF to pause.\n" " fpause - Force DF to pause.\n"
" die - Force DF to close immediately\n" " die - Force DF to close immediately\n"
" keybinding - Modify bindings of commands to keys\n"
"Plugin management (useful for developers):\n" "Plugin management (useful for developers):\n"
//" belongs COMMAND - Tell which plugin a command belongs to.\n" //" belongs COMMAND - Tell which plugin a command belongs to.\n"
" plug [PLUGIN|v] - List plugin state and description.\n" " plug [PLUGIN|v] - List plugin state and description.\n"
@ -202,6 +217,27 @@ void fIOthread(void * iodata)
" reload PLUGIN|all - Reload a plugin or all loaded plugins.\n" " reload PLUGIN|all - Reload a plugin or all loaded plugins.\n"
); );
} }
else if (parts.size() == 1)
{
Plugin *plug = plug_mgr->getPluginByCommand(parts[0]);
if (plug) {
for (int j = 0; j < plug->size();j++)
{
const PluginCommand & pcmd = (plug->operator[](j));
if (pcmd.name != parts[0])
continue;
if (pcmd.isHotkeyCommand())
con.color(Console::COLOR_CYAN);
con.print("%s: %s\n",pcmd.name.c_str(), pcmd.description.c_str());
con.reset_color();
if (!pcmd.usage.empty())
con << "Usage:\n" << pcmd.usage << flush;
return;
}
}
con.printerr("Unknown command: %s\n", parts[0].c_str());
}
else else
{ {
con.printerr("not implemented yet\n"); con.printerr("not implemented yet\n");
@ -301,7 +337,10 @@ void fIOthread(void * iodata)
else for (int j = 0; j < plug->size();j++) else for (int j = 0; j < plug->size();j++)
{ {
const PluginCommand & pcmd = (plug->operator[](j)); const PluginCommand & pcmd = (plug->operator[](j));
if (pcmd.isHotkeyCommand())
con.color(Console::COLOR_CYAN);
con.print(" %-22s - %s\n",pcmd.name.c_str(), pcmd.description.c_str()); con.print(" %-22s - %s\n",pcmd.name.c_str(), pcmd.description.c_str());
con.reset_color();
} }
} }
else else
@ -329,7 +368,10 @@ void fIOthread(void * iodata)
for (int j = 0; j < plug->size();j++) for (int j = 0; j < plug->size();j++)
{ {
const PluginCommand & pcmd = (plug->operator[](j)); const PluginCommand & pcmd = (plug->operator[](j));
if (pcmd.isHotkeyCommand())
con.color(Console::COLOR_CYAN);
con.print(" %-22s- %s\n",pcmd.name.c_str(), pcmd.description.c_str()); con.print(" %-22s- %s\n",pcmd.name.c_str(), pcmd.description.c_str());
con.reset_color();
} }
} }
} }
@ -344,6 +386,49 @@ void fIOthread(void * iodata)
con.print("%s\n", plug->getName().c_str()); con.print("%s\n", plug->getName().c_str());
} }
} }
else if(first == "keybinding")
{
if (parts.size() >= 3 && (parts[0] == "set" || parts[0] == "add"))
{
std::string keystr = parts[1];
if (parts[0] == "set")
core->ClearKeyBindings(keystr);
for (int i = parts.size()-1; i >= 2; i--)
{
if (!core->AddKeyBinding(keystr, parts[i])) {
con.printerr("Invalid key spec: %s\n", keystr.c_str());
break;
}
}
}
else if (parts.size() >= 2 && parts[0] == "clear")
{
for (unsigned i = 1; i < parts.size(); i++)
{
if (!core->ClearKeyBindings(parts[i])) {
con.printerr("Invalid key spec: %s\n", parts[i].c_str());
break;
}
}
}
else if (parts.size() == 2 && parts[0] == "list")
{
std::vector<std::string> list = core->ListKeyBindings(parts[1]);
if (list.empty())
con << "No bindings." << endl;
for (unsigned i = 0; i < list.size(); i++)
con << " " << list[i] << endl;
}
else
{
con << "Usage:" << endl
<< " keybinding list <key>" << endl
<< " keybinding clear <key> <key>..." << endl
<< " keybinding set <key> \"cmdline\" \"cmdline\"..." << endl
<< " keybinding add <key> \"cmdline\" \"cmdline\"..." << endl
<< "Later adds, and earlier items within one command have priority." << endl;
}
}
else if(first == "fpause") else if(first == "fpause")
{ {
World * w = core->getWorld(); World * w = core->getWorld();
@ -384,6 +469,70 @@ void fIOthread(void * iodata)
*/ */
} }
} }
}
}
static void loadInitFile(Core *core, PluginManager *plug_mgr, string fname)
{
ifstream init(fname);
if (init.bad())
return;
int tmp = 0;
string command;
while (getline(init, command))
{
if (!command.empty())
runInteractiveCommand(core, plug_mgr, tmp, command);
}
}
// A thread function... for the interactive console.
void fIOthread(void * iodata)
{
IODATA * iod = ((IODATA*) iodata);
Core * core = iod->core;
PluginManager * plug_mgr = ((IODATA*) iodata)->plug_mgr;
CommandHistory main_history;
main_history.load("dfhack.history");
Console & con = core->con;
if(plug_mgr == 0 || core == 0)
{
con.printerr("Something horrible happened in Core's constructor...\n");
return;
}
loadInitFile(core, plug_mgr, "dfhack.init");
con.print("DFHack is ready. Have a nice day!\n"
"Type in '?' or 'help' for general help, 'ls' to see all commands.\n");
int clueless_counter = 0;
while (true)
{
string command = "";
int ret = con.lineedit("[DFHack]# ",command, main_history);
if(ret == -2)
{
cerr << "Console is shutting down properly." << endl;
return;
}
else if(ret == -1)
{
cerr << "Console caught an unspecified error." << endl;
continue;
}
else if(ret)
{
// a proper, non-empty command was entered
main_history.add(command);
main_history.save("dfhack.history");
}
runInteractiveCommand(core, plug_mgr, clueless_counter, command);
if(clueless_counter == 3) if(clueless_counter == 3)
{ {
con.print("Do 'help' or '?' for the list of available commands.\n"); con.print("Do 'help' or '?' for the list of available commands.\n");
@ -408,11 +557,12 @@ Core::Core()
StackMutex = 0; StackMutex = 0;
core_cond = 0; core_cond = 0;
// set up hotkey capture // set up hotkey capture
memset(hotkey_states,0,sizeof(hotkey_states));
hotkey_set = false; hotkey_set = false;
HotkeyMutex = 0; HotkeyMutex = 0;
HotkeyCond = 0; HotkeyCond = 0;
misc_data_mutex=0; misc_data_mutex=0;
last_world_data_ptr = NULL;
top_viewscreen = NULL;
}; };
void Core::fatal (std::string output, bool deactivate) void Core::fatal (std::string output, bool deactivate)
@ -497,7 +647,7 @@ bool Core::Init()
} }
// initialize data defs // initialize data defs
virtual_identity::Init(); virtual_identity::Init(this);
InitDataDefGlobals(this); InitDataDefGlobals(this);
// create mutex for syncing with interactive tasks // create mutex for syncing with interactive tasks
@ -605,8 +755,36 @@ int Core::Update()
if(errorstate) if(errorstate)
return -1; return -1;
// detect if the game was loaded or unloaded in the meantime
void *new_wdata = NULL;
if (df::global::world) {
df::world_data *wdata = df::global::world->world_data;
// when the game is unloaded, world_data isn't deleted, but its contents are
if (wdata && !wdata->sites.empty())
new_wdata = wdata;
}
if (new_wdata != last_world_data_ptr) {
last_world_data_ptr = new_wdata;
plug_mgr->OnStateChange(new_wdata ? SC_GAME_LOADED : SC_GAME_UNLOADED);
}
// detect if the viewscreen changed
if (df::global::gview)
{
df::viewscreen *screen = &df::global::gview->view;
while (screen->child)
screen = screen->child;
if (screen != top_viewscreen)
{
top_viewscreen = screen;
plug_mgr->OnStateChange(SC_VIEWSCREEN_CHANGED);
}
}
// notify all the plugins that a game tick is finished // notify all the plugins that a game tick is finished
plug_mgr->OnUpdate(); plug_mgr->OnUpdate();
// wake waiting tools // wake waiting tools
// do not allow more tools to join in while we process stuff here // do not allow more tools to join in while we process stuff here
StackMutex->lock(); StackMutex->lock();
@ -695,37 +873,166 @@ int Core::SDL_Event(SDL::Event* ev, int orig_return)
if(ev && ev->type == SDL::ET_KEYDOWN || ev->type == SDL::ET_KEYUP) if(ev && ev->type == SDL::ET_KEYDOWN || ev->type == SDL::ET_KEYUP)
{ {
SDL::KeyboardEvent * ke = (SDL::KeyboardEvent *)ev; SDL::KeyboardEvent * ke = (SDL::KeyboardEvent *)ev;
bool shift = ke->ksym.mod & SDL::KMOD_SHIFT;
// consuming F1 .. F8 if(ke->state == SDL::BTN_PRESSED && !hotkey_states[ke->ksym.sym])
int idx = ke->ksym.sym - SDL::K_F1;
if(idx < 0 || idx > 7)
return orig_return;
idx += 8*shift;
// now we have the real index...
if(ke->state == SDL::BTN_PRESSED && !hotkey_states[idx])
{ {
hotkey_states[idx] = 1; hotkey_states[ke->ksym.sym] = true;
Gui * g = getGui();
if(g->hotkeys && g->df_interface && g->df_menu_state) int mod = 0;
if (ke->ksym.mod & SDL::KMOD_SHIFT) mod |= 1;
if (ke->ksym.mod & SDL::KMOD_CTRL) mod |= 2;
if (ke->ksym.mod & SDL::KMOD_ALT) mod |= 4;
SelectHotkey(ke->ksym.sym, mod);
}
else if(ke->state == SDL::BTN_RELEASED)
{ {
t_viewscreen * ws = g->GetCurrentScreen(); hotkey_states[ke->ksym.sym] = false;
// FIXME: put hardcoded values into memory.xml }
if(ws->getClassName() == "viewscreen_dwarfmodest" && *g->df_menu_state == 0x23) }
return orig_return; return orig_return;
// do stuff with the events...
}
bool Core::SelectHotkey(int sym, int modifiers)
{
// Find the topmost viewscreen
if (!df::global::gview || !df::global::ui)
return false;
df::viewscreen *screen = &df::global::gview->view;
while (screen->child)
screen = screen->child;
std::string cmd;
{
tthread::lock_guard<tthread::mutex> lock(*HotkeyMutex);
// Check the internal keybindings
std::vector<KeyBinding> &bindings = key_bindings[sym];
for (int i = bindings.size()-1; i >= 0; --i) {
if (bindings[i].modifiers != modifiers)
continue;
if (!plug_mgr->CanInvokeHotkey(bindings[i].command[0], screen))
continue;
cmd = bindings[i].cmdline;
break;
}
if (cmd.empty()) {
// Check the hotkey keybindings
int idx = sym - SDL::K_F1;
if(idx >= 0 && idx < 8)
{
if (modifiers & 1)
idx += 8;
if (strict_virtual_cast<df::viewscreen_dwarfmodest>(screen) &&
df::global::ui->main.mode != ui_sidebar_mode::Hotkeys)
{
cmd = df::global::ui->main.hotkeys[idx].name;
}
}
}
}
if (!cmd.empty()) {
setHotkeyCmd(cmd);
return true;
}
else else
return false;
}
static bool parseKeySpec(std::string keyspec, int *psym, int *pmod)
{ {
t_hotkey & hotkey = (*g->hotkeys)[idx]; *pmod = 0;
setHotkeyCmd(hotkey.name);
// ugh, ugly
for (;;) {
if (keyspec.size() > 6 && keyspec.substr(0, 6) == "Shift-") {
*pmod |= 1;
keyspec = keyspec.substr(6);
} else if (keyspec.size() > 5 && keyspec.substr(0, 5) == "Ctrl-") {
*pmod |= 2;
keyspec = keyspec.substr(5);
} else if (keyspec.size() > 4 && keyspec.substr(0, 4) == "Alt-") {
*pmod |= 4;
keyspec = keyspec.substr(4);
} else
break;
}
if (keyspec.size() == 1 && keyspec[0] >= 'A' && keyspec[0] <= 'Z') {
*psym = SDL::K_a + (keyspec[0]-'A');
return true;
} else if (keyspec.size() == 2 && keyspec[0] == 'F' && keyspec[1] >= '1' && keyspec[1] <= '9') {
*psym = SDL::K_F1 + (keyspec[1]-'1');
return true;
} else
return false;
} }
bool Core::ClearKeyBindings(std::string keyspec)
{
int sym, mod;
if (!parseKeySpec(keyspec, &sym, &mod))
return false;
tthread::lock_guard<tthread::mutex> lock(*HotkeyMutex);
std::vector<KeyBinding> &bindings = key_bindings[sym];
for (int i = bindings.size()-1; i >= 0; --i) {
if (bindings[i].modifiers == mod)
bindings.erase(bindings.begin()+i);
} }
return true;
} }
else if(ke->state == SDL::BTN_RELEASED)
bool Core::AddKeyBinding(std::string keyspec, std::string cmdline)
{ {
hotkey_states[idx] = 0; int sym;
KeyBinding binding;
if (!parseKeySpec(keyspec, &sym, &binding.modifiers))
return false;
cheap_tokenise(cmdline, binding.command);
if (binding.command.empty())
return false;
tthread::lock_guard<tthread::mutex> lock(*HotkeyMutex);
// Don't add duplicates
std::vector<KeyBinding> &bindings = key_bindings[sym];
for (int i = bindings.size()-1; i >= 0; --i) {
if (bindings[i].modifiers == binding.modifiers &&
bindings[i].cmdline == cmdline)
return true;
} }
binding.cmdline = cmdline;
bindings.push_back(binding);
return true;
} }
return orig_return;
// do stuff with the events... std::vector<std::string> Core::ListKeyBindings(std::string keyspec)
{
int sym, mod;
std::vector<std::string> rv;
if (!parseKeySpec(keyspec, &sym, &mod))
return rv;
tthread::lock_guard<tthread::mutex> lock(*HotkeyMutex);
std::vector<KeyBinding> &bindings = key_bindings[sym];
for (int i = bindings.size()-1; i >= 0; --i) {
if (bindings[i].modifiers == mod)
rv.push_back(bindings[i].cmdline);
}
return rv;
} }
//////////////// ////////////////

@ -28,12 +28,12 @@ distribution.
#include <vector> #include <vector>
#include <map> #include <map>
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "tinythread.h" #include "tinythread.h"
// must be last due to MS stupidity // must be last due to MS stupidity
#include "dfhack/DataDefs.h" #include "DataDefs.h"
using namespace DFHack; using namespace DFHack;
@ -78,31 +78,62 @@ virtual_identity *virtual_identity::get(virtual_ptr instance_ptr)
for (virtual_identity *p = list; p; p = p->next) { for (virtual_identity *p = list; p; p = p->next) {
if (strcmp(name.c_str(), p->getOriginalName()) != 0) continue; if (strcmp(name.c_str(), p->getOriginalName()) != 0) continue;
if (p->vtable_ptr && p->vtable_ptr != vtable) {
std::cerr << "Conflicting vtable ptr for class '" << p->getName()
<< "': found 0x" << std::hex << unsigned(vtable)
<< ", previous 0x" << unsigned(p->vtable_ptr) << std::dec << std::endl;
abort();
} else if (!p->vtable_ptr) {
std::cerr << "class '" << p->getName() << "': vtable = 0x"
<< std::hex << unsigned(vtable) << std::dec << std::endl;
}
known[vtable] = p; known[vtable] = p;
p->vtable_ptr = vtable; p->vtable_ptr = vtable;
return p; return p;
} }
std::cerr << "UNKNOWN CLASS '" << name << "': vtable = 0x"
<< std::hex << unsigned(vtable) << std::dec << std::endl;
known[vtable] = NULL; known[vtable] = NULL;
return NULL; return NULL;
} }
bool virtual_identity::check_instance(virtual_ptr instance_ptr, bool allow_subclasses) bool virtual_identity::is_subclass(virtual_identity *actual)
{ {
virtual_identity *actual = get(instance_ptr); for (; actual; actual = actual->parent)
if (actual == this) return true; if (actual == this) return true;
if (!allow_subclasses || !actual) return false;
do {
actual = actual->parent;
if (actual == this) return true;
} while (actual);
return false; return false;
} }
void virtual_identity::Init() void virtual_identity::adjust_vtable(virtual_ptr obj, virtual_identity *main)
{
if (vtable_ptr) {
*(void**)obj = vtable_ptr;
return;
}
if (main && main != this && is_subclass(main))
return;
std::cerr << "Attempt to create class '" << getName() << "' without known vtable." << std::endl;
abort();
}
virtual_ptr virtual_identity::clone(virtual_ptr obj)
{
virtual_identity *id = get(obj);
if (!id) return NULL;
virtual_ptr copy = id->instantiate();
if (!copy) return NULL;
id->do_copy(copy, obj);
return copy;
}
void virtual_identity::Init(Core *core)
{ {
if (!known_mutex) if (!known_mutex)
known_mutex = new tthread::mutex(); known_mutex = new tthread::mutex();
@ -119,19 +150,31 @@ void virtual_identity::Init()
p->parent->has_children = true; p->parent->has_children = true;
} }
} }
// Read pre-filled vtable ptrs
OffsetGroup *ptr_table = core->vinfo->getGroup("vtable");
for (virtual_identity *p = list; p; p = p->next) {
uint32_t tmp;
if (ptr_table->getSafeAddress(p->getName(),tmp))
p->vtable_ptr = (void*)tmp;
}
} }
#define GLOBAL(name,tname) \ #define SIMPLE_GLOBAL(name,tname) \
df::tname *df::global::name = NULL; tname *df::global::name = NULL;
#define GLOBAL(name,tname) SIMPLE_GLOBAL(name,df::tname)
DF_KNOWN_GLOBALS DF_KNOWN_GLOBALS
#undef GLOBAL #undef GLOBAL
#undef SIMPLE_GLOBAL
void DFHack::InitDataDefGlobals(Core *core) { void DFHack::InitDataDefGlobals(Core *core) {
OffsetGroup *global_table = core->vinfo->getGroup("global"); OffsetGroup *global_table = core->vinfo->getGroup("global");
uint32_t tmp; uint32_t tmp;
#define GLOBAL(name,tname) \ #define SIMPLE_GLOBAL(name,tname) \
if (global_table->getSafeAddress(#name,tmp)) df::global::name = (df::tname*)tmp; if (global_table->getSafeAddress(#name,tmp)) df::global::name = (tname*)tmp;
#define GLOBAL(name,tname) SIMPLE_GLOBAL(name,df::tname)
DF_KNOWN_GLOBALS DF_KNOWN_GLOBALS
#undef GLOBAL #undef GLOBAL
#undef SIMPLE_GLOBAL
} }

@ -1,10 +1,10 @@
#include "Internal.h" #include "Internal.h"
#include "dfhack/DataDefs.h" #include "DataDefs.h"
#include "dfhack/MiscUtils.h" #include "MiscUtils.h"
#include "dfhack/df/world.h" #include "df/world.h"
#include "dfhack/df/world_data.h" #include "df/world_data.h"
#include "dfhack/df/ui.h" #include "df/ui.h"
namespace { namespace {
template<class T> template<class T>
@ -14,4 +14,5 @@ namespace {
} }
// Instantiate all the static objects // Instantiate all the static objects
#include "dfhack/df/static.inc" #include "df/static.inc"
#include "df/static.enums.inc"

@ -0,0 +1,6 @@
#include "Internal.h"
#include "DataDefs.h"
#include "MiscUtils.h"
// Object constructors
#include "df/static.ctors.inc"

@ -39,8 +39,8 @@ distribution.
#include <map> #include <map>
#include "DFHack.h" #include "DFHack.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <iostream> #include <iostream>
/* /*

@ -28,12 +28,12 @@ distribution.
#include <stdint.h> #include <stdint.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <stdio.h> #include <stdio.h>
#include "tinythread.h" #include "tinythread.h"
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
/* /*
* Plugin loading functions * Plugin loading functions

@ -1,6 +1,33 @@
// Returns the amount of milliseconds elapsed since the UNIX epoch. /*
// Works on both windows and linux. https://github.com/peterix/dfhack
// source: http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
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 "Export.h"
#include "Core.h"
#include "MiscUtils.h"
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
#include <Windows.h> #include <Windows.h>

@ -23,10 +23,13 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/PluginManager.h" #include "PluginManager.h"
#include "dfhack/Console.h" #include "Console.h"
#include "DataDefs.h"
using namespace DFHack; using namespace DFHack;
#include <string> #include <string>
@ -135,6 +138,7 @@ Plugin::Plugin(Core * core, const std::string & filepath, const std::string & _f
plugin_shutdown = 0; plugin_shutdown = 0;
plugin_status = 0; plugin_status = 0;
plugin_onupdate = 0; plugin_onupdate = 0;
plugin_onstatechange = 0;
state = PS_UNLOADED; state = PS_UNLOADED;
access = new RefLock(); access = new RefLock();
} }
@ -192,6 +196,7 @@ bool Plugin::load()
plugin_status = (command_result (*)(Core *, std::string &)) LookupPlugin(plug, "plugin_status"); plugin_status = (command_result (*)(Core *, std::string &)) LookupPlugin(plug, "plugin_status");
plugin_onupdate = (command_result (*)(Core *)) LookupPlugin(plug, "plugin_onupdate"); plugin_onupdate = (command_result (*)(Core *)) LookupPlugin(plug, "plugin_onupdate");
plugin_shutdown = (command_result (*)(Core *)) LookupPlugin(plug, "plugin_shutdown"); plugin_shutdown = (command_result (*)(Core *)) LookupPlugin(plug, "plugin_shutdown");
plugin_onstatechange = (command_result (*)(Core *, state_change_event)) LookupPlugin(plug, "plugin_onstatechange");
//name = _PlugName(); //name = _PlugName();
plugin_lib = plug; plugin_lib = plug;
if(plugin_init(&c,commands) == CR_OK) if(plugin_init(&c,commands) == CR_OK)
@ -232,7 +237,7 @@ bool Plugin::unload()
ClosePlugin(plugin_lib); ClosePlugin(plugin_lib);
state = PS_UNLOADED; state = PS_UNLOADED;
access->unlock(); access->unlock();
return false; return true;
} }
else else
{ {
@ -271,13 +276,63 @@ command_result Plugin::invoke( std::string & command, std::vector <std::string>
{ {
for (int i = 0; i < commands.size();i++) for (int i = 0; i < commands.size();i++)
{ {
if(commands[i].name == command) PluginCommand &cmd = commands[i];
if(cmd.name == command)
{ {
// running interactive things from some other source than the console would break it // running interactive things from some other source than the console would break it
if(!interactive_ && commands[i].interactive) if(!interactive_ && cmd.interactive)
cr = CR_WOULD_BREAK; cr = CR_WOULD_BREAK;
else if (cmd.guard)
{
// Execute hotkey commands in a way where they can
// expect their guard conditions to be matched,
// so as to avoid duplicating checks.
// This means suspending the core beforehand.
CoreSuspender suspend(&c);
df::viewscreen *top = c.getTopViewscreen();
if (!cmd.guard(&c, top))
{
c.con.printerr("Could not invoke %s: unsuitable UI state.\n", command.c_str());
cr = CR_WRONG_USAGE;
}
else
{
cr = cmd.function(&c, parameters);
}
}
else
{
cr = cmd.function(&c, parameters);
}
if (cr == CR_WRONG_USAGE && !cmd.usage.empty())
c.con << "Usage:\n" << cmd.usage << flush;
break;
}
}
}
access->lock_sub();
return cr;
}
bool Plugin::can_invoke_hotkey( std::string & command, df::viewscreen *top )
{
Core & c = Core::getInstance();
bool cr = false;
access->lock_add();
if(state == PS_LOADED)
{
for (int i = 0; i < commands.size();i++)
{
PluginCommand &cmd = commands[i];
if(cmd.name == command)
{
if (cmd.interactive)
cr = false;
else if (cmd.guard)
cr = cmd.guard(&c, top);
else else
cr = commands[i].function(&c, parameters); cr = default_hotkey(&c, top);
break; break;
} }
} }
@ -299,6 +354,19 @@ command_result Plugin::on_update()
return cr; return cr;
} }
command_result Plugin::on_state_change(state_change_event event)
{
Core & c = Core::getInstance();
command_result cr = CR_NOT_IMPLEMENTED;
access->lock_add();
if(state == PS_LOADED && plugin_onstatechange)
{
cr = plugin_onstatechange(&c, event);
}
access->lock_sub();
return cr;
}
Plugin::plugin_state Plugin::getState() const Plugin::plugin_state Plugin::getState() const
{ {
return state; return state;
@ -348,19 +416,27 @@ Plugin *PluginManager::getPluginByName (const std::string & name)
return 0; return 0;
} }
// FIXME: handle name collisions... Plugin *PluginManager::getPluginByCommand(const std::string &command)
command_result PluginManager::InvokeCommand( std::string & command, std::vector <std::string> & parameters, bool interactive)
{ {
command_result cr = CR_NOT_IMPLEMENTED; tthread::lock_guard<tthread::mutex> lock(*cmdlist_mutex);
Core * c = &Core::getInstance();
cmdlist_mutex->lock();
map <string, Plugin *>::iterator iter = belongs.find(command); map <string, Plugin *>::iterator iter = belongs.find(command);
if (iter != belongs.end()) if (iter != belongs.end())
return iter->second;
else
return NULL;
}
// FIXME: handle name collisions...
command_result PluginManager::InvokeCommand( std::string & command, std::vector <std::string> & parameters, bool interactive)
{ {
cr = iter->second->invoke(command, parameters, interactive); Plugin *plugin = getPluginByCommand(command);
return plugin ? plugin->invoke(command, parameters, interactive) : CR_NOT_IMPLEMENTED;
} }
cmdlist_mutex->unlock();
return cr; bool PluginManager::CanInvokeHotkey(std::string &command, df::viewscreen *top)
{
Plugin *plugin = getPluginByCommand(command);
return plugin ? plugin->can_invoke_hotkey(command, top) : false;
} }
void PluginManager::OnUpdate( void ) void PluginManager::OnUpdate( void )
@ -370,6 +446,15 @@ void PluginManager::OnUpdate( void )
all_plugins[i]->on_update(); all_plugins[i]->on_update();
} }
} }
void PluginManager::OnStateChange( state_change_event event )
{
for(int i = 0; i < all_plugins.size(); i++)
{
all_plugins[i]->on_state_change(event);
}
}
// FIXME: doesn't check name collisions! // FIXME: doesn't check name collisions!
void PluginManager::registerCommands( Plugin * p ) void PluginManager::registerCommands( Plugin * p )
{ {

@ -36,10 +36,10 @@ distribution.
using namespace std; using namespace std;
#include <md5wrapper.h> #include <md5wrapper.h>
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Error.h" #include "Error.h"
#include <string.h> #include <string.h>
using namespace DFHack; using namespace DFHack;

@ -91,10 +91,10 @@ extern "C" __declspec(dllimport) NTSTATUS __stdcall RtlDestroyQueryDebugBuffer(
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
using namespace DFHack; using namespace DFHack;
namespace DFHack namespace DFHack
{ {

@ -23,8 +23,8 @@ distribution.
*/ */
#include "Internal.h" #include "Internal.h"
#include "dfhack/TileTypes.h" #include "TileTypes.h"
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {

@ -31,9 +31,9 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
using namespace DFHack; using namespace DFHack;
//Inital amount of space in levels vector (since we usually know the number, efficient!) //Inital amount of space in levels vector (since we usually know the number, efficient!)
@ -598,7 +598,48 @@ void OffsetGroup::setInvalid(INVAL_TYPE invalidity)
(*iter4).second->setInvalid(invalidity); (*iter4).second->setInvalid(invalidity);
} }
} }
std::vector<OffsetKey> OffsetGroup::getKeys() const
{
std::vector<OffsetKey> ret;
OffsetKey K;
K.keytype=IS_ADDRESS;
for(uint32_Iter iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_OFFSET;
for(int32_Iter iter = OGd->offsets.begin(); iter != OGd->offsets.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_HEX_VAL;
for(uint32_Iter iter = OGd->hexvals.begin(); iter != OGd->hexvals.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_STRING;
for(strings_Iter iter = OGd->strings.begin(); iter != OGd->strings.end(); iter++)
{
K.key=iter->first;
K.inval=iter->second.first;
ret.push_back(K);
}
K.keytype=IS_GROUP;
K.inval=IS_VALID;
for(groups_Iter iter = OGd->groups.begin(); iter != OGd->groups.end(); iter++)
{
K.key=iter->first;
ret.push_back(K);
}
return ret;
}
/* /*
* Private data * Private data
*/ */

@ -31,9 +31,9 @@ distribution.
#include <iostream> #include <iostream>
using namespace std; using namespace std;
#include "dfhack/VersionInfoFactory.h" #include "VersionInfoFactory.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Error.h" #include "Error.h"
using namespace DFHack; using namespace DFHack;
#include <tinyxml.h> #include <tinyxml.h>

@ -4,9 +4,9 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/Virtual.h" #include "Virtual.h"
using namespace DFHack; using namespace DFHack;
std::string t_virtual::getClassName() const std::string t_virtual::getClassName() const

@ -23,8 +23,8 @@ distribution.
*/ */
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <sstream> #include <sstream>

@ -23,8 +23,8 @@ distribution.
*/ */
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <deque> #include <deque>
#include <fstream> #include <fstream>
#include <assert.h> #include <assert.h>

@ -24,15 +24,15 @@ distribution.
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/FakeSDL.h" #include "Hooks.h"
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <map> #include <map>
#include <stdint.h> #include <stdint.h>
#include "dfhack/Console.h" #include "Console.h"
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
struct WINDOW; struct WINDOW;
@ -43,6 +43,11 @@ namespace tthread
class thread; class thread;
} }
namespace df
{
struct viewscreen;
}
namespace DFHack namespace DFHack
{ {
class Process; class Process;
@ -134,6 +139,13 @@ namespace DFHack
/// returns a named pointer. /// returns a named pointer.
void *GetData(std::string key); void *GetData(std::string key);
bool ClearKeyBindings(std::string keyspec);
bool AddKeyBinding(std::string keyspec, std::string cmdline);
std::vector<std::string> ListKeyBindings(std::string keyspec);
bool isWorldLoaded() { return (last_world_data_ptr != NULL); }
df::viewscreen *getTopViewscreen() { return top_viewscreen; }
DFHack::Process * p; DFHack::Process * p;
DFHack::VersionInfo * vinfo; DFHack::VersionInfo * vinfo;
DFHack::Console con; DFHack::Console con;
@ -178,12 +190,25 @@ namespace DFHack
} s_mods; } s_mods;
std::vector <Module *> allModules; std::vector <Module *> allModules;
DFHack::PluginManager * plug_mgr; DFHack::PluginManager * plug_mgr;
// hotkey-related stuff // hotkey-related stuff
int hotkey_states[16]; struct KeyBinding {
int modifiers;
std::vector<std::string> command;
std::string cmdline;
};
std::map<int, std::vector<KeyBinding> > key_bindings;
std::map<int, bool> hotkey_states;
std::string hotkey_cmd; std::string hotkey_cmd;
bool hotkey_set; bool hotkey_set;
tthread::mutex * HotkeyMutex; tthread::mutex * HotkeyMutex;
tthread::condition_variable * HotkeyCond; tthread::condition_variable * HotkeyCond;
bool SelectHotkey(int key, int modifiers);
void *last_world_data_ptr; // for state change tracking
df::viewscreen *top_viewscreen;
// Very important! // Very important!
bool started; bool started;

@ -47,34 +47,34 @@ distribution.
#include <stdint.h> #include <stdint.h>
// DFHack core classes and types // DFHack core classes and types
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Types.h" #include "Types.h"
// DFHack modules // DFHack modules
#include "dfhack/modules/Buildings.h" #include "modules/Buildings.h"
#include "dfhack/modules/Engravings.h" #include "modules/Engravings.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Constructions.h" #include "modules/Constructions.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "dfhack/modules/World.h" #include "modules/World.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include "dfhack/modules/Vegetation.h" #include "modules/Vegetation.h"
#include "dfhack/modules/Maps.h" #include "modules/Maps.h"
#include "dfhack/modules/Gui.h" #include "modules/Gui.h"
/* /*
* This is a header full of ugly, volatile things. * This is a header full of ugly, volatile things.
* Only for use of official DFHack tools! * Only for use of official DFHack tools!
*/ */
#ifdef DFHACK_WANT_MISCUTILS #ifdef DFHACK_WANT_MISCUTILS
#include "dfhack/MiscUtils.h" #include "MiscUtils.h"
#endif #endif
// define this to get the static tiletype->properties mapping // define this to get the static tiletype->properties mapping
#ifdef DFHACK_WANT_TILETYPES #ifdef DFHACK_WANT_TILETYPES
#include "dfhack/TileTypes.h" #include "TileTypes.h"
#endif #endif
#endif #endif

@ -28,8 +28,8 @@ distribution.
#include <vector> #include <vector>
#include <map> #include <map>
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
// Stop some MS stupidity // Stop some MS stupidity
#ifdef interface #ifdef interface
@ -62,8 +62,6 @@ namespace DFHack
protected: protected:
virtual_identity(const char *dfhack_name, const char *original_name, virtual_identity *parent); virtual_identity(const char *dfhack_name, const char *original_name, virtual_identity *parent);
bool check_instance(virtual_ptr instance_ptr, bool allow_subclasses);
static void *get_vtable(virtual_ptr instance_ptr) { return *(void**)instance_ptr; } static void *get_vtable(virtual_ptr instance_ptr) { return *(void**)instance_ptr; }
public: public:
@ -73,8 +71,10 @@ namespace DFHack
virtual_identity *getParent() { return parent; } virtual_identity *getParent() { return parent; }
const std::vector<virtual_identity*> &getChildren() { return children; } const std::vector<virtual_identity*> &getChildren() { return children; }
public:
static virtual_identity *get(virtual_ptr instance_ptr); static virtual_identity *get(virtual_ptr instance_ptr);
bool is_subclass(virtual_identity *subtype);
bool is_instance(virtual_ptr instance_ptr) { bool is_instance(virtual_ptr instance_ptr) {
if (!instance_ptr) return false; if (!instance_ptr) return false;
if (vtable_ptr) { if (vtable_ptr) {
@ -82,16 +82,28 @@ namespace DFHack
if (vtable == vtable_ptr) return true; if (vtable == vtable_ptr) return true;
if (!has_children) return false; if (!has_children) return false;
} }
return check_instance(instance_ptr, true); return is_subclass(get(instance_ptr));
} }
bool is_direct_instance(virtual_ptr instance_ptr) { bool is_direct_instance(virtual_ptr instance_ptr) {
if (!instance_ptr) return false; if (!instance_ptr) return false;
return vtable_ptr ? (vtable_ptr == get_vtable(instance_ptr)) return vtable_ptr ? (vtable_ptr == get_vtable(instance_ptr))
: check_instance(instance_ptr, false); : (this == get(instance_ptr));
} }
static void Init(); public:
bool can_instantiate() { return (vtable_ptr != NULL); }
virtual_ptr instantiate() { return can_instantiate() ? do_instantiate() : NULL; }
static virtual_ptr clone(virtual_ptr obj);
protected:
virtual virtual_ptr do_instantiate() = 0;
virtual void do_copy(virtual_ptr tgt, virtual_ptr src) = 0;
public:
static void Init(Core *core);
// Strictly for use in virtual class constructors
void adjust_vtable(virtual_ptr obj, virtual_identity *main);
}; };
template<class T> template<class T>
@ -112,14 +124,23 @@ namespace DFHack
namespace df namespace df
{ {
using DFHack::virtual_ptr;
using DFHack::virtual_identity;
using DFHack::virtual_class; using DFHack::virtual_class;
using DFHack::BitArray; using DFHack::BitArray;
template<class T> template<class T>
class class_virtual_identity : public DFHack::virtual_identity { class class_virtual_identity : public virtual_identity {
public: public:
class_virtual_identity(const char *dfhack_name, const char *original_name, virtual_identity *parent) class_virtual_identity(const char *dfhack_name, const char *original_name, virtual_identity *parent)
: virtual_identity(dfhack_name, original_name, parent) {}; : virtual_identity(dfhack_name, original_name, parent) {};
T *instantiate() { return static_cast<T*>(virtual_identity::instantiate()); }
T *clone(T* obj) { return static_cast<T*>(virtual_identity::clone(obj)); }
protected:
virtual virtual_ptr do_instantiate() { return new T(); }
virtual void do_copy(virtual_ptr tgt, virtual_ptr src) { *static_cast<T*>(tgt) = *static_cast<T*>(src); }
}; };
template<class EnumType, class IntType = int32_t> template<class EnumType, class IntType = int32_t>
@ -148,15 +169,24 @@ namespace df
namespace df { namespace df {
#define DF_KNOWN_GLOBALS \ #define DF_KNOWN_GLOBALS \
GLOBAL(cursor,cursor) \
GLOBAL(selection_rect,selection_rect) \
GLOBAL(world,world) \ GLOBAL(world,world) \
GLOBAL(ui,ui) \ GLOBAL(ui,ui) \
GLOBAL(gview,interface) \ GLOBAL(gview,interface) \
GLOBAL(init,init) \ GLOBAL(init,init) \
GLOBAL(d_init,d_init) GLOBAL(d_init,d_init) \
SIMPLE_GLOBAL(ui_look_cursor,int) \
#define GLOBAL(name,tname) \ SIMPLE_GLOBAL(ui_workshop_job_cursor,int) \
struct tname; \ GLOBAL(ui_sidebar_menus,ui_sidebar_menus) \
GLOBAL(ui_build_selector,ui_build_selector) \
GLOBAL(ui_look_list,ui_look_list)
#define SIMPLE_GLOBAL(name,tname) \
namespace global { extern DFHACK_EXPORT tname *name; } namespace global { extern DFHACK_EXPORT tname *name; }
#define GLOBAL(name,tname) \
struct tname; SIMPLE_GLOBAL(name,tname)
DF_KNOWN_GLOBALS DF_KNOWN_GLOBALS
#undef GLOBAL #undef GLOBAL
#undef SIMPLE_GLOBAL
} }

@ -27,8 +27,8 @@ distribution.
#ifndef ERROR_H_INCLUDED #ifndef ERROR_H_INCLUDED
#define ERROR_H_INCLUDED #define ERROR_H_INCLUDED
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Pragma.h" #include "Pragma.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <exception> #include <exception>

@ -28,39 +28,20 @@ distribution.
* Some much needed SDL fakery. * Some much needed SDL fakery.
*/ */
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <string> #include <string>
#include <stdint.h> #include <stdint.h>
// function and variable pointer... we don't try to understand what SDL does here // function and variable pointer... we don't try to understand what SDL does here
typedef void * fPtr; typedef void * fPtr;
typedef void * vPtr; typedef void * vPtr;
struct WINDOW; struct WINDOW;
namespace SDL namespace SDL
{ {
union Event; union Event;
//struct Thread;
//struct Mutex;
//struct Cond;
//struct Library;
} }
/*
// mutex stuff
DFhackCExport SDL::Mutex * SDL_CreateMutex(void);
DFhackCExport int SDL_mutexP(SDL::Mutex *);
DFhackCExport int SDL_mutexV(SDL::Mutex *);
DFhackCExport void SDL_DestroyMutex(SDL::Mutex *);
// thread stuff
DFhackCExport SDL::Thread *SDL_CreateThread(int (*fn)(void *), void *data);
DFhackCExport uint32_t SDL_ThreadID();
// condition variables
DFhackCExport SDL::Cond *SDL_CreateCond(void);
DFhackCExport void SDL_DestroyCond(SDL::Cond *cond);
DFhackCExport int SDL_CondSignal(SDL::Cond *cond);
DFhackCExport int SDL_CondWait(SDL::Cond *cond, SDL::Mutex * mut);
*/
// these functions are here because they call into DFHack::Core and therefore need to // these functions are here because they call into DFHack::Core and therefore need to
// be declared as friend functions/known // be declared as friend functions/known
DFhackCExport int SDL_NumJoysticks(void); DFhackCExport int SDL_NumJoysticks(void);
@ -69,4 +50,3 @@ DFhackCExport int SDL_PollEvent(SDL::Event* event);
DFhackCExport int SDL_Init(uint32_t flags); DFhackCExport int SDL_Init(uint32_t flags);
DFhackCExport int wgetch(WINDOW * win); DFhackCExport int wgetch(WINDOW * win);
// Other crud is in the OS-specific core files.

@ -24,9 +24,6 @@ distribution.
#pragma once #pragma once
#ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED
// this makes everything that includes this file export symbols when using DFHACK_EXPORT (see DFExport.h) // this makes everything that includes this file export symbols when using DFHACK_EXPORT (see DFExport.h)
#ifndef BUILD_DFHACK_LIB #ifndef BUILD_DFHACK_LIB
#define BUILD_DFHACK_LIB #define BUILD_DFHACK_LIB
@ -38,10 +35,7 @@ distribution.
#endif #endif
// one file for telling the MSVC compiler where it can shove its pointless warnings // one file for telling the MSVC compiler where it can shove its pointless warnings
#include "dfhack/Pragma.h" #include "Pragma.h"
// C99 integer types // C99 integer types
#include <stdint.h> #include <stdint.h>
#endif // DFCOMMONINTERNAL_H_INCLUDED

@ -28,8 +28,8 @@ distribution.
#ifndef PROCESS_H_INCLUDED #ifndef PROCESS_H_INCLUDED
#define PROCESS_H_INCLUDED #define PROCESS_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <map> #include <map>

@ -0,0 +1,104 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
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.
*/
#pragma once
#include "Export.h"
#include <iostream>
#include <iomanip>
#include <climits>
#include <stdint.h>
#include <vector>
#include <sstream>
#include <cstdio>
using namespace std;
template <typename T>
void print_bits ( T val, DFHack::Console& out )
{
stringstream strs;
T n_bits = sizeof ( val ) * CHAR_BIT;
int cnt;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i/10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i%10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs << "--";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs<< !!( val & 1 ) << " ";
val >>= 1;
}
strs << endl;
out.print(strs.str().c_str());
}
//FIXME: Error 8 error C4519: default template arguments are only allowed on a class template
template <typename CT, typename FT, typename AT/* = FT*/>
CT *binsearch_in_vector(std::vector<CT*> &vec, FT CT::*field, AT value)
{
int min = -1, max = (int)vec.size();
CT **p = vec.data();
FT key = (FT)value;
for (;;)
{
int mid = (min + max)>>1;
if (mid == min)
{
return NULL;
}
FT midv = p[mid]->*field;
if (midv == key)
{
return p[mid];
}
else if (midv < key)
{
min = mid;
}
else
{
max = mid;
}
}
}
/**
* Returns the amount of milliseconds elapsed since the UNIX epoch.
* Works on both windows and linux.
* source: http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c
*/
DFHACK_EXPORT uint64_t GetTimeMs64();

@ -27,7 +27,7 @@ distribution.
#ifndef MODULE_H_INCLUDED #ifndef MODULE_H_INCLUDED
#define MODULE_H_INCLUDED #define MODULE_H_INCLUDED
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {
/** /**

@ -24,55 +24,80 @@ distribution.
#pragma once #pragma once
#include "dfhack/Export.h" #include "Export.h"
#include "Hooks.h"
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "FakeSDL.h"
struct DFLibrary; struct DFLibrary;
namespace tthread namespace tthread
{ {
class mutex; class mutex;
class condition_variable; class condition_variable;
} }
namespace df
{
struct viewscreen;
}
namespace DFHack namespace DFHack
{ {
class Core; class Core;
class PluginManager; class PluginManager;
struct virtual_identity;
enum command_result enum command_result
{ {
CR_WOULD_BREAK = -2, CR_WOULD_BREAK = -2,
CR_NOT_IMPLEMENTED = -1, CR_NOT_IMPLEMENTED = -1,
CR_FAILURE = 0, CR_FAILURE = 0,
CR_OK = 1 CR_OK = 1,
CR_WRONG_USAGE = 2
}; };
struct PluginCommand enum state_change_event
{ {
SC_GAME_LOADED,
SC_GAME_UNLOADED,
SC_VIEWSCREEN_CHANGED
};
struct DFHACK_EXPORT PluginCommand
{
typedef command_result (*command_function)(Core *, std::vector <std::string> &);
typedef bool (*command_hotkey_guard)(Core *, df::viewscreen *);
/// create a command with a name, description, function pointer to its code /// create a command with a name, description, function pointer to its code
/// and saying if it needs an interactive terminal /// and saying if it needs an interactive terminal
/// Most commands shouldn't require an interactive terminal! /// Most commands shouldn't require an interactive terminal!
PluginCommand(const char * _name, PluginCommand(const char * _name,
const char * _description, const char * _description,
command_result (*function_)(Core *, std::vector <std::string> &), command_function function_,
bool interactive_ = false bool interactive_ = false,
const char * usage_ = ""
) )
: name(_name), description(_description),
function(function_), interactive(interactive_),
guard(NULL), usage(usage_)
{ {
name = _name;
description = _description;
function = function_;
interactive = interactive_;
} }
PluginCommand (const PluginCommand & rhs)
PluginCommand(const char * _name,
const char * _description,
command_function function_,
command_hotkey_guard guard_,
const char * usage_ = "")
: name(_name), description(_description),
function(function_), interactive(false),
guard(guard_), usage(usage_)
{ {
name = rhs.name;
description = rhs.description;
function = rhs.function;
interactive = rhs.interactive;
} }
bool isHotkeyCommand() const { return guard != NULL; }
std::string name; std::string name;
std::string description; std::string description;
command_result (*function)(Core *, std::vector <std::string> &); command_function function;
bool interactive; bool interactive;
command_hotkey_guard guard;
std::string usage;
}; };
class Plugin class Plugin
{ {
@ -87,11 +112,13 @@ namespace DFHack
Plugin(DFHack::Core* core, const std::string& filepath, const std::string& filename, PluginManager * pm); Plugin(DFHack::Core* core, const std::string& filepath, const std::string& filename, PluginManager * pm);
~Plugin(); ~Plugin();
command_result on_update(); command_result on_update();
command_result on_state_change(state_change_event event);
public: public:
bool load(); bool load();
bool unload(); bool unload();
bool reload(); bool reload();
command_result invoke( std::string & command, std::vector <std::string> & parameters, bool interactive ); command_result invoke( std::string & command, std::vector <std::string> & parameters, bool interactive );
bool can_invoke_hotkey( std::string & command, df::viewscreen *top );
plugin_state getState () const; plugin_state getState () const;
const PluginCommand& operator[] (std::size_t index) const const PluginCommand& operator[] (std::size_t index) const
{ {
@ -117,6 +144,7 @@ namespace DFHack
command_result (*plugin_status)(Core *, std::string &); command_result (*plugin_status)(Core *, std::string &);
command_result (*plugin_shutdown)(Core *); command_result (*plugin_shutdown)(Core *);
command_result (*plugin_onupdate)(Core *); command_result (*plugin_onupdate)(Core *);
command_result (*plugin_onstatechange)(Core *, state_change_event);
}; };
class DFHACK_EXPORT PluginManager class DFHACK_EXPORT PluginManager
{ {
@ -126,12 +154,15 @@ namespace DFHack
PluginManager(Core * core); PluginManager(Core * core);
~PluginManager(); ~PluginManager();
void OnUpdate( void ); void OnUpdate( void );
void OnStateChange( state_change_event event );
void registerCommands( Plugin * p ); void registerCommands( Plugin * p );
void unregisterCommands( Plugin * p ); void unregisterCommands( Plugin * p );
// PUBLIC METHODS // PUBLIC METHODS
public: public:
Plugin *getPluginByName (const std::string & name); Plugin *getPluginByName (const std::string & name);
Plugin *getPluginByCommand (const std::string &command);
command_result InvokeCommand( std::string & command, std::vector <std::string> & parameters, bool interactive = true ); command_result InvokeCommand( std::string & command, std::vector <std::string> & parameters, bool interactive = true );
bool CanInvokeHotkey(std::string &command, df::viewscreen *top);
Plugin* operator[] (std::size_t index) Plugin* operator[] (std::size_t index)
{ {
if(index >= all_plugins.size()) if(index >= all_plugins.size())
@ -149,5 +180,10 @@ namespace DFHack
std::vector <Plugin *> all_plugins; std::vector <Plugin *> all_plugins;
std::string plugin_path; std::string plugin_path;
}; };
// Predefined hotkey guards
DFHACK_EXPORT bool default_hotkey(Core *, df::viewscreen *);
DFHACK_EXPORT bool dwarfmode_hotkey(Core *, df::viewscreen *);
DFHACK_EXPORT bool cursor_hotkey(Core *, df::viewscreen *);
} }

@ -24,7 +24,7 @@
// Needed for processing its event types without polluting our namespaces with C garbage // Needed for processing its event types without polluting our namespaces with C garbage
#pragma once #pragma once
#include "keyboard.h" #include "SDL_keyboard.h"
namespace SDL namespace SDL
{ {

@ -24,7 +24,7 @@
// Needed for processing its event types without polluting our namespaces with C garbage // Needed for processing its event types without polluting our namespaces with C garbage
#pragma once #pragma once
#include "keysym.h" #include "SDL_keysym.h"
#include <stdint.h> #include <stdint.h>
namespace SDL namespace SDL

@ -27,8 +27,8 @@ distribution.
#ifndef TILETYPES_H_INCLUDED #ifndef TILETYPES_H_INCLUDED
#define TILETYPES_H_INCLUDED #define TILETYPES_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {

@ -25,8 +25,8 @@ distribution.
#pragma once #pragma once
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
namespace DFHack namespace DFHack
{ {

@ -28,10 +28,10 @@ distribution.
#ifndef DFVECTOR_H_INCLUDED #ifndef DFVECTOR_H_INCLUDED
#define DFVECTOR_H_INCLUDED #define DFVECTOR_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include <string.h> #include <string.h>
#include <vector> #include <vector>

@ -28,9 +28,9 @@ distribution.
#ifndef MEMINFO_H_INCLUDED #ifndef MEMINFO_H_INCLUDED
#define MEMINFO_H_INCLUDED #define MEMINFO_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Types.h" #include "Types.h"
#include <map> #include <map>
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>
@ -52,7 +52,20 @@ namespace DFHack
IS_INVALID, IS_INVALID,
IS_VALID IS_VALID
}; };
enum KEY_TYPE
{
IS_OFFSET,
IS_ADDRESS,
IS_HEX_VAL,
IS_STRING,
IS_GROUP
};
struct OffsetKey
{
std::string key;
INVAL_TYPE inval;
KEY_TYPE keytype;
};
/* /*
* Offset Group * Offset Group
*/ */
@ -96,6 +109,8 @@ namespace DFHack
std::string getFullName(); std::string getFullName();
OffsetGroup * getParent(); OffsetGroup * getParent();
void setInvalid(INVAL_TYPE arg1); void setInvalid(INVAL_TYPE arg1);
std::vector<OffsetKey> getKeys() const;
}; };
/* /*

@ -28,8 +28,8 @@ distribution.
#ifndef MEMINFO_MANAGER_H_INCLUDED #ifndef MEMINFO_MANAGER_H_INCLUDED
#define MEMINFO_MANAGER_H_INCLUDED #define MEMINFO_MANAGER_H_INCLUDED
#include "dfhack/Pragma.h" #include "Pragma.h"
#include "dfhack/Export.h" #include "Export.h"
class TiXmlElement; class TiXmlElement;
namespace DFHack namespace DFHack

@ -1,269 +0,0 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
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.
*/
#pragma once
#include <iostream>
#include <iomanip>
#include <climits>
#include <stdint.h>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
/*
#include <dfhack/Process.h>
#include <dfhack/VersionInfo.h>
#include <dfhack/Vector.h>
void DumpObjStr0Vector (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector <uint32_t> vect(p,addr);
for(uint32_t i = 0; i < vect.size();i++)
{
uint32_t addr = vect[i];
cout << p->readSTLString(addr) << endl;
}
cout << endl;
}
void DumpObjVtables (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector <uint32_t> vect(p,addr);
for(uint32_t i = 0; i < vect.size();i++)
{
uint32_t addr = vect[i];
uint32_t vptr = p->readDWord(addr);
cout << p->readClassName(vptr) << endl;
}
cout << endl;
}
void DumpDWordVector (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector <uint32_t> vect(p,addr);
for(uint32_t i = 0; i < vect.size();i++)
{
uint32_t number = vect[i];
cout << number << endl;
}
cout << endl;
}
*/
/*
address = absolute address of dump start
length = length in lines. 1 line = 16 bytes
*/
/*
void hexdump (DFHack::Context *DF, uint32_t address, uint32_t length)
{
char *buf = new char[length];
DF->ReadRaw(address, length, (uint8_t *) buf);
uint32_t i = 0;
while (i < length)
{
// leading offset
if(i%16 == 0)
cout << "0x" << hex << setw(8) << address + i << "| ";
// bytes
for(int k = 0; k < 4; k++)
{
cout << hex << setw(2) << int(static_cast<unsigned char>(buf[i])) << " ";
i++;
if(i == length) break;
}
if(i%16 == 0 || i>= length)
{
cout << endl;
}
else if(i%4 == 0)
{
cout << " ";
}
}
delete buf;
}
void interleave_hex (DFHack::Context* DF, vector < uint32_t > & addresses, uint32_t length)
{
vector <char * > bufs;
for(uint32_t counter = 0; counter < addresses.size(); counter ++)
{
char * buf = new char[length * 16];
DF->ReadRaw(addresses[counter], length * 16, (uint8_t *) buf);
bufs.push_back(buf);
}
cout << setfill('0');
// output a header
cout << "line offset ";
for (uint32_t obj = 0; obj < addresses.size(); obj++)
{
cout << "0x" << hex << setw(9) << addresses[obj] << " ";
}
cout << endl;
for(uint32_t offs = 0 ; offs < length * 16; offs += 4)
{
if((!(offs % 16)) && offs != 0)
{
cout << endl;
}
cout << setfill(' ');
cout << dec << setw(4) << offs/4 << " ";
cout << setfill('0');
cout << "0x" << hex << setw(4) << offs << " ";
for (uint32_t object = 0; object < bufs.size(); object++)
{
// bytes
for(int k = 0; k < 4; k++)
{
uint8_t data = bufs[object][offs + k];
cout << hex << setw(2) << int(static_cast<unsigned char>(data)) << " ";
}
cout << " ";
}
cout << endl;
}
for(uint32_t counter = 0; counter < addresses.size(); counter ++)
{
delete bufs[counter];
}
}
*/
template <typename T>
void print_bits ( T val, DFHack::Console& out )
{
stringstream strs;
T n_bits = sizeof ( val ) * CHAR_BIT;
int cnt;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i/10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
cnt = i%10;
strs << cnt << " ";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs << "--";
}
strs << endl;
for ( unsigned i = 0; i < n_bits; ++i )
{
strs<< !!( val & 1 ) << " ";
val >>= 1;
}
strs << endl;
out.print(strs.str().c_str());
}
/*
// this is probably completely bogus
std::string PrintSplatterType (int16_t mat1, int32_t mat2, vector<DFHack::t_matgloss> &creature_types)
{
std::string ret;
switch (mat1)
{
case 0:
return "Rock";
case 1:
return "Amber";
case 2:
return "Coral";
case 3:
return "Green Glass";
case 4:
return "Clear Glass";
case 5:
return "Crystal Glass";
case 6:
return "Water";
case 7:
return "Coal";
case 8:
return "Potash";
case 9:
return "Ash";
case 10:
return "Pearlash";
case 11:
return "Lye";
case 12:
return "Mud";
case 13:
return "Vomit";
case 14:
return "Salt";
case 15:
return "Filth";
case 16:
return "Frozen? Filth";
case 18:
return "Grime";
case 0xF2:
return "Very Specific Blood (references a named creature)";
case 0x2A:
case 0x2B:
if(mat2 != -1)
{
ret += creature_types[mat2].id;
ret += " ";
}
ret += "Blood";
return ret;
default:
return "Unknown";
}
}
*/
//FIXME: Error 8 error C4519: default template arguments are only allowed on a class template
template <typename CT, typename FT, typename AT/* = FT*/>
CT *binsearch_in_vector(std::vector<CT*> &vec, FT CT::*field, AT value) {
int min = -1, max = (int)vec.size();
CT **p = vec.data();
FT key = (FT)value;
for (;;) {
int mid = (min + max)>>1;
if (mid == min)
return NULL;
FT midv = p[mid]->*field;
if (midv == key)
return p[mid];
else if (midv < key)
min = mid;
else
max = mid;
}
}

@ -1,54 +0,0 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
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.
*/
#pragma once
#ifndef TERMUTIL_H
#define TERMUTIL_H
#ifdef LINUX_BUILD
// FIXME: is this ever true?
bool TemporaryTerminal ()
{
return false;
}
#else
#include <windows.h>
#include <stdio.h>
#include <conio.h>
bool TemporaryTerminal ()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hStdOutput;
hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
if (!GetConsoleScreenBufferInfo(hStdOutput, &csbi))
{
printf("GetConsoleScreenBufferInfo failed: %d\n", GetLastError());
return false;
}
return ((!csbi.dwCursorPosition.X) && (!csbi.dwCursorPosition.Y));
};
#endif // LINUX_BUILD
#endif

@ -29,8 +29,8 @@ distribution.
* \defgroup grp_buildings Building module parts - also includes zones and stockpiles * \defgroup grp_buildings Building module parts - also includes zones and stockpiles
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#ifdef __cplusplus #ifdef __cplusplus
namespace DFHack namespace DFHack

@ -28,8 +28,8 @@ distribution.
/* /*
* DF constructions * DF constructions
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
/** /**
* \defgroup grp_constructions Construction module parts * \defgroup grp_constructions Construction module parts

@ -28,8 +28,8 @@ distribution.
/* /*
* DF engravings * DF engravings
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
/** /**
* \defgroup grp_engraving Engraving module parts * \defgroup grp_engraving Engraving module parts

@ -1,6 +1,6 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2011 Petr Mr<EFBFBD>zek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
@ -31,8 +31,8 @@ distribution.
#define CL_MOD_GRAPHIC #define CL_MOD_GRAPHIC
#include <stdint.h> #include <stdint.h>
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
namespace DFHack namespace DFHack
{ {

@ -26,10 +26,10 @@ distribution.
#ifndef CL_MOD_GUI #ifndef CL_MOD_GUI
#define CL_MOD_GUI #define CL_MOD_GUI
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Virtual.h" #include "Virtual.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
#include <string> #include <string>
/** /**

@ -26,12 +26,12 @@ distribution.
/* /*
* Items! * Items!
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Virtual.h" #include "Virtual.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/Process.h" #include "MemAccess.h"
/** /**
* \defgroup grp_items Items module and its types * \defgroup grp_items Items module and its types
* @ingroup grp_modules * @ingroup grp_modules

@ -26,8 +26,8 @@ distribution.
#ifndef MAPEXTRAS_H #ifndef MAPEXTRAS_H
#define MAPEXTRAS_H #define MAPEXTRAS_H
#include "dfhack/modules/Maps.h" #include "modules/Maps.h"
#include "dfhack/TileTypes.h" #include "TileTypes.h"
#include <stdint.h> #include <stdint.h>
#include <cstring> #include <cstring>
namespace MapExtras namespace MapExtras

@ -30,12 +30,12 @@ distribution.
#ifndef CL_MOD_MAPS #ifndef CL_MOD_MAPS
#define CL_MOD_MAPS #define CL_MOD_MAPS
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/modules/Vegetation.h" #include "modules/Vegetation.h"
#include <vector> #include <vector>
#include "dfhack/Virtual.h" #include "Virtual.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
#include "Materials.h" #include "Materials.h"
/** /**

@ -29,10 +29,10 @@ distribution.
* \defgroup grp_materials Materials module - used for reading raws mostly * \defgroup grp_materials Materials module - used for reading raws mostly
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/BitArray.h" #include "BitArray.h"
#include <vector> #include <vector>
#include <string> #include <string>

@ -5,8 +5,8 @@
* \defgroup grp_notes In game notes (and routes) * \defgroup grp_notes In game notes (and routes)
* @ingroup grp_notes * @ingroup grp_notes
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include <vector> #include <vector>
#include <string> #include <string>

@ -30,9 +30,9 @@ distribution.
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
namespace DFHack namespace DFHack
{ {

@ -28,9 +28,9 @@ distribution.
/* /*
* Creatures * Creatures
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
/** /**
* \defgroup grp_units Unit module parts * \defgroup grp_units Unit module parts
* @ingroup grp_modules * @ingroup grp_modules

@ -30,9 +30,9 @@ distribution.
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
namespace DFHack namespace DFHack
{ {
/** /**

@ -5,8 +5,8 @@
* \defgroup grp_vermin Wild vermin (ants, bees, etc) * \defgroup grp_vermin Wild vermin (ants, bees, etc)
* @ingroup grp_vermin * @ingroup grp_vermin
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#ifdef __cplusplus #ifdef __cplusplus
namespace DFHack namespace DFHack

@ -31,8 +31,8 @@ distribution.
* @ingroup grp_modules * @ingroup grp_modules
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include <ostream> #include <ostream>
namespace DFHack namespace DFHack

@ -26,13 +26,13 @@ distribution.
/* /*
* kitchen settings * kitchen settings
*/ */
#include "dfhack/Export.h" #include "Export.h"
#include "dfhack/Module.h" #include "Module.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include <dfhack/Core.h> #include "Core.h"
/** /**
* \defgroup grp_kitchen Kitchen settings * \defgroup grp_kitchen Kitchen settings
* @ingroup grp_modules * @ingroup grp_modules

@ -30,14 +30,14 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/modules/Buildings.h" #include "modules/Buildings.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;
//raw //raw

@ -31,13 +31,13 @@ distribution.
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Constructions.h" #include "modules/Constructions.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -30,13 +30,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" //#include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Engravings.h" #include "modules/Engravings.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -1,6 +1,6 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2011 Petr Mr<EFBFBD>zek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
@ -33,13 +33,13 @@ distribution.
#include <cstdlib> #include <cstdlib>
using namespace std; using namespace std;
#include "dfhack/modules/Graphic.h" #include "modules/Graphic.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -30,15 +30,51 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/modules/Gui.h" #include "modules/Gui.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
#include "PluginManager.h"
using namespace DFHack; using namespace DFHack;
#include "DataDefs.h"
#include "df/cursor.h"
#include "df/viewscreen_dwarfmodest.h"
// Predefined common guard functions
bool DFHack::default_hotkey(Core *, df::viewscreen *top)
{
// Default hotkey guard function
for (;top ;top = top->parent)
if (strict_virtual_cast<df::viewscreen_dwarfmodest>(top))
return true;
return false;
}
bool DFHack::dwarfmode_hotkey(Core *, df::viewscreen *top)
{
// Require the main dwarf mode screen
return !!strict_virtual_cast<df::viewscreen_dwarfmodest>(top);
}
bool DFHack::cursor_hotkey(Core *c, df::viewscreen *top)
{
if (!dwarfmode_hotkey(c, top))
return false;
// Also require the cursor.
if (!df::global::cursor || df::global::cursor->x == -30000)
return false;
return true;
}
//
Module* DFHack::createGui() Module* DFHack::createGui()
{ {
return new Gui(); return new Gui();

@ -33,16 +33,16 @@ distribution.
#include <set> #include <set>
using namespace std; using namespace std;
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Virtual.h> #include "Virtual.h"
using namespace DFHack; using namespace DFHack;

@ -33,13 +33,13 @@ distribution.
#include <cstdlib> #include <cstdlib>
using namespace std; using namespace std;
#include "dfhack/modules/Maps.h" #include "modules/Maps.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
#define MAPS_GUARD if(!d->Started) throw DFHack::Error::ModuleNotInitialized(); #define MAPS_GUARD if(!d->Started) throw DFHack::Error::ModuleNotInitialized();

@ -31,14 +31,14 @@ distribution.
#include <cstring> #include <cstring>
using namespace std; using namespace std;
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include <dfhack/Error.h> #include "Error.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -29,13 +29,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
#include "dfhack/modules/Notes.h" #include "modules/Notes.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createNotes() Module* DFHack::createNotes()

@ -30,13 +30,13 @@ distribution.
#include <cassert> #include <cassert>
using namespace std; using namespace std;
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createTranslation() Module* DFHack::createTranslation()

@ -34,18 +34,18 @@ distribution.
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Types.h" #include "Types.h"
// we connect to those // we connect to those
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -30,14 +30,14 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/modules/Vegetation.h" #include "modules/Vegetation.h"
#include "dfhack/modules/Translation.h" #include "modules/Translation.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createVegetation() Module* DFHack::createVegetation()

@ -29,13 +29,13 @@ distribution.
#include <map> #include <map>
using namespace std; using namespace std;
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/modules/Vermin.h" #include "modules/Vermin.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "dfhack/Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;
struct Vermin::Private struct Vermin::Private
@ -106,7 +106,6 @@ SpawnPoints* Vermin::getSpawnPoints()
cerr << "Couldn't get spawn points: Vermin module not inited" << endl; cerr << "Couldn't get spawn points: Vermin module not inited" << endl;
return NULL; return NULL;
} }
return new SpawnPoints(this); return new SpawnPoints(this);
} }
@ -120,15 +119,11 @@ SpawnPoints::SpawnPoints(Vermin* v_)
cerr << "Couldn't get spawn points: Vermin module not inited" << endl; cerr << "Couldn't get spawn points: Vermin module not inited" << endl;
return; return;
} }
//p_sp = new DfVector <uint32_t> (v->d->spawn_points_vector);
//p_sp = new vector <void*> (v->d->spawn_points_vector);
p_sp = (vector <void*>*) (v->d->spawn_points_vector); p_sp = (vector <void*>*) (v->d->spawn_points_vector);
} }
SpawnPoints::~SpawnPoints() SpawnPoints::~SpawnPoints()
{ {
// Do NOT delete p_sp; it's a pointer to memory the game owns.
} }
size_t SpawnPoints::size() size_t SpawnPoints::size()

@ -30,13 +30,13 @@ distribution.
#include <cstring> #include <cstring>
using namespace std; using namespace std;
#include "dfhack/modules/World.h" #include "modules/World.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/Error.h" #include "Error.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
using namespace DFHack; using namespace DFHack;

@ -9,17 +9,17 @@
#include <set> #include <set>
using namespace std; using namespace std;
#include "dfhack/Types.h" #include "Types.h"
#include "dfhack/VersionInfo.h" #include "VersionInfo.h"
#include "dfhack/Process.h" #include "MemAccess.h"
#include "dfhack/Vector.h" #include "Vector.h"
#include "dfhack/modules/Materials.h" #include "modules/Materials.h"
#include "dfhack/modules/Items.h" #include "modules/Items.h"
#include "dfhack/modules/Units.h" #include "modules/Units.h"
#include "dfhack/modules/kitchen.h" #include "modules/kitchen.h"
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include <dfhack/Core.h> #include "Core.h"
#include <dfhack/Virtual.h> #include "Virtual.h"
namespace DFHack namespace DFHack
{ {

@ -0,0 +1 @@
Subproject commit 7a730830c515fea701ff73b33cb604f48a4531fc

@ -1,944 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
my $input_dir = $ARGV[0] || '.';
my $output_dir = $ARGV[1] || 'codegen';
my $main_namespace = $ARGV[2] || 'df';
my $export_prefix = 'DFHACK_EXPORT ';
my %types;
my %type_files;
# Misc XML analysis
our $typename;
our $filename;
sub parse_address($;$) {
my ($str,$in_bits) = @_;
return undef unless defined $str;
# Parse the format used by offset attributes in xml
$str =~ /^0x([0-9a-f]+)(?:\.([0-7]))?$/
or die "Invalid address syntax: $str\n";
my ($full, $bv) = ($1, $2);
die "Bits not allowed: $str\n" unless $in_bits;
return $in_bits ? (hex($full)*8 + ($bv||0)) : hex($full);
}
sub check_bad_attrs($;$$) {
my ($tag, $allow_size, $allow_align) = @_;
die "Cannot use size, alignment or offset for ".$tag->nodeName."\n"
if ((!$allow_size && defined $tag->getAttribute('size')) ||
defined $tag->getAttribute('offset') ||
(!$allow_align && defined $tag->getAttribute('alignment')));
}
sub check_name($) {
my ($name) = @_;
$name =~ /^[_a-zA-Z][_a-zA-Z0-9]*$/
or die "Invalid identifier: $name\n";
return $name;
}
sub is_attr_true($$) {
my ($tag, $name) = @_;
return ($tag->getAttribute($name)||'') eq 'true';
}
sub type_header_def($) {
my ($name) = @_;
return uc($main_namespace).'_'.uc($name).'_H';
}
sub translate_lookup($) {
my ($str) = @_;
return undef unless $str && $str =~ /^\$global((\.[_a-zA-Z0-9]+)+)$/;
my @fields = split /\./, substr($1,1);
my $expr = "df::global::".shift(@fields);
for my $fn (@fields) {
$expr = "_toref($expr).$fn";
}
return $expr;
}
# Text generation with indentation
our @lines;
our $indentation = 0;
sub with_emit(&;$) {
# Executes the code block, and returns emitted lines
my ($blk, $start_indent) = @_;
local @lines;
local $indentation = ($start_indent||0);
$blk->();
return @lines;
}
sub emit(@) {
# Emit an indented line to be returned from with_emit
my $line = join('',map { defined($_) ? $_ : '' } @_);
$line = (' 'x$indentation).$line unless length($line) == 0;
push @lines, $line;
}
sub indent(&) {
# Indent lines emitted from the block by one step
my ($blk) = @_;
local $indentation = $indentation+2;
$blk->();
}
sub outdent(&) {
# Unindent lines emitted from the block by one step
my ($blk) = @_;
local $indentation = ($indentation >= 2 ? $indentation-2 : 0);
$blk->();
}
sub emit_block(&;$$) {
# Emit a full {...} block with indentation
my ($blk, $prefix, $suffix) = @_;
$prefix ||= '';
$suffix ||= '';
emit $prefix,'{';
&indent($blk);
emit '}',$suffix;
}
# Static file output
my @static_lines;
my %static_includes;
sub with_emit_static(&) {
my ($blk) = @_;
$static_includes{$typename}++;
push @static_lines, &with_emit($blk,2);
}
# Anonymous variable names
our $anon_id = 0;
our $anon_prefix;
sub ensure_name($) {
# If the name is empty, assign an auto-generated one
my ($name) = @_;
unless ($name) {
$name = $anon_prefix.(($anon_id == 0) ? '' : '_'.$anon_id);
$anon_id++;
}
return check_name($name);
}
sub with_anon(&;$) {
# Establish a new anonymous namespace
my ($blk,$stem) = @_;
local $anon_id = $stem ? 0 : 1;
local $anon_prefix = ($stem||'anon');
$blk->();
}
# Primitive types
my @primitive_type_list =
qw(int8_t uint8_t int16_t uint16_t
int32_t uint32_t int64_t uint64_t
s-float
bool ptr-string stl-string flag-bit
pointer);
my %primitive_aliases = (
'stl-string' => 'std::string',
'ptr-string' => 'char*',
'flag-bit' => 'void',
'pointer' => 'void*',
's-float' => 'float',
);
my %primitive_types;
$primitive_types{$_}++ for @primitive_type_list;
sub primitive_type_name($) {
my ($tag_name) = @_;
$primitive_types{$tag_name}
or die "Not primitive: $tag_name\n";
return $primitive_aliases{$tag_name} || $tag_name;
}
# Type references
our %weak_refs;
our %strong_refs;
sub register_ref($;$) {
# Register a reference to another type.
# Strong ones require the type to be included.
my ($ref, $is_strong) = @_;
if ($ref) {
my $type = $types{$ref}
or die "Unknown type $ref referenced.\n";
if ($is_strong) {
$strong_refs{$ref}++;
} else {
$weak_refs{$ref}++;
}
}
}
# Determines if referenced other types should be included or forward-declared
our $is_strong_ref = 1;
sub with_struct_block(&$;$%) {
my ($blk, $tag, $name, %flags) = @_;
my $kwd = (is_attr_true($tag,'is-union') ? "union" : "struct");
my $exp = $flags{-export} ? $export_prefix : '';
my $prefix = $kwd.' '.$exp.($name ? $name.' ' : '');
emit_block {
local $_;
local $is_strong_ref = 1; # reset the state
if ($flags{-no_anon}) {
$blk->();
} else {
&with_anon($blk);
}
} $prefix, ";";
}
sub decode_type_name_ref($;%) {
# Interpret the type-name field of a tag
my ($tag,%flags) = @_;
my $force_type = $flags{-force_type};
my $force_strong = $flags{-force_strong};
my $tname = $tag->getAttribute($flags{-attr_name} || 'type-name')
or return undef;
if ($primitive_types{$tname}) {
die "Cannot use type $tname as type-name of ".$tag->nodeName."\n"
if ($force_type && $force_type ne 'primitive');
return primitive_type_name($tname);
} else {
register_ref $tname, ($force_strong||$is_strong_ref);
die "Cannot use type $tname as type-name of ".$tag->nodeName."\n"
if ($force_type && $force_type ne $types{$tname}->nodeName);
return $main_namespace.'::'.$tname;
}
}
# CONDITIONALS
sub is_conditional($) {
my ($tag) = @_;
return $tag->nodeName =~ /^(cond-if|cond-elseif)$/;
}
sub translate_if_cond($) {
my ($tag) = @_;
my @rules;
if (my $defvar = $tag->getAttribute('defined')) {
push @rules, "defined($defvar)";
}
if (my $cmpvar = $tag->getAttribute('var')) {
if (my $cmpval = $tag->getAttribute('lt')) {
push @rules, "($cmpvar < $cmpval)";
}
if (my $cmpval = $tag->getAttribute('le')) {
push @rules, "($cmpvar <= $cmpval)";
}
if (my $cmpval = $tag->getAttribute('eq')) {
push @rules, "($cmpvar == $cmpval)";
}
if (my $cmpval = $tag->getAttribute('ge')) {
push @rules, "($cmpvar >= $cmpval)";
}
if (my $cmpval = $tag->getAttribute('gt')) {
push @rules, "($cmpvar > $cmpval)";
}
if (my $cmpval = $tag->getAttribute('ne')) {
push @rules, "($cmpvar != $cmpval)";
}
}
return '('.(join(' && ',@rules) || '1').')';
}
our $in_cond = 0;
sub render_cond_if($$$;@) {
my ($tag, $in_elseif, $render_cb, @tail) = @_;
local $in_cond = 1;
{
local $indentation = 0;
my $op = ($in_elseif && $in_elseif >= 2) ? '#elif' : '#if';
emit $op, ' ', translate_if_cond($tag);
}
for my $child ($tag->findnodes('child::*')) {
&render_cond($child, $render_cb, @tail);
}
unless ($in_elseif) {
local $indentation = 0;
emit "#endif";
}
}
sub render_cond($$;@) {
my ($tag, $render_cb, @tail) = @_;
my $tag_name = $tag->nodeName;
if ($tag_name eq 'cond-if') {
render_cond_if($tag, 0, $render_cb, @tail);
} elsif ($tag_name eq 'cond-elseif') {
my $idx = 1;
for my $child ($tag->findnodes('child::*')) {
($child->nodeName eq 'cond-if')
or die "Only cond-if tags may be inside a cond-switch: ".$child->nodeName."\n";
render_cond_if($child, $idx++, $render_cb, @tail);
}
{
local $indentation = 0;
emit "#endif";
}
} else {
local $_ = $tag;
$render_cb->($tag, @tail);
}
}
# ENUM
sub render_enum_core($$) {
my ($name,$tag) = @_;
my $base = 0;
emit_block {
my @items = $tag->findnodes('child::*');
my $idx = 0;
for my $item (@items) {
render_cond $item, sub {
my $tag = $_->nodeName;
return if $tag eq 'enum-attr';
($tag eq 'enum-item')
or die "Invalid enum member: ".$item->nodeName."\n";
my $name = ensure_name $_->getAttribute('name');
my $value = $_->getAttribute('value');
$base = ($idx == 0 && !$in_cond) ? $value : undef if defined $value;
$idx++;
emit $name, (defined($value) ? ' = '.$value : ''), ',';
};
}
emit "_last_item_of_$name";
} "enum $name ", ";";
return $base;
}
sub render_enum_tables($$$) {
my ($name,$tag,$base) = @_;
# Enumerate enum attributes
my %aidx = ('key' => 0);
my @anames = ('key');
my @avals = ('NULL');
my @atypes = ('const char*');
my @atnames = (undef);
for my $attr ($tag->findnodes('child::enum-attr')) {
my $name = $attr->getAttribute('name') or die "Unnamed enum-attr.\n";
my $type = $attr->getAttribute('type-name');
my $def = $attr->getAttribute('default-value');
die "Duplicate attribute $name.\n" if exists $aidx{$name};
check_name $name;
$aidx{$name} = scalar @anames;
push @anames, $name;
push @atnames, $type;
if ($type) {
push @atypes, $type;
push @avals, (defined $def ? $def : "($type)0");
} else {
push @atypes, 'const char*';
push @avals, (defined $def ? "\"$def\"" : 'NULL');
}
}
# Emit accessor function prototypes
emit "const $name _first_item_of_$name = ($name)$base;";
emit_block {
emit "return (value >= _first_item_of_$name && value < _last_item_of_$name);";
} "inline bool is_valid($name value) ";
for (my $i = 0; $i < @anames; $i++) {
emit "${export_prefix}$atypes[$i] get_$anames[$i]($name value);";
}
# Emit implementation
with_emit_static {
emit_block {
emit_block {
# Emit the entry type
emit_block {
for (my $i = 0; $i < @anames; $i++) {
emit "$atypes[$i] $anames[$i];";
}
} "struct _info_entry ", ";";
# Emit the info table
emit_block {
for my $item ($tag->findnodes('child::*')) {
render_cond $item, sub {
my $tag = $_->nodeName;
return if $tag eq 'enum-attr';
# Assemble item-specific attr values
my @evals = @avals;
my $name = $_->getAttribute('name');
$evals[0] = "\"$name\"" if $name;
for my $attr ($_->findnodes('child::item-attr')) {
my $name = $attr->getAttribute('name') or die "Unnamed item-attr.\n";
my $value = $attr->getAttribute('value') or die "No-value item-attr.\n";
my $idx = $aidx{$name} or die "Unknown item-attr: $name\n";
if ($atnames[$idx]) {
$evals[$idx] = $value;
} else {
$evals[$idx] = "\"$value\"";
}
}
emit "{ ",join(', ',@evals)," },";
};
}
emit "{ ",join(', ',@avals)," }";
} "static const _info_entry _info[] = ", ";";
for (my $i = 0; $i < @anames; $i++) {
emit_block {
emit "return is_valid(value) ? _info[value - $base].$anames[$i] : $avals[$i];";
} "$atypes[$i] get_$anames[$i]($name value) ";
}
} "namespace $name ";
} "namespace enums ";
};
}
sub render_enum_type {
my ($tag) = @_;
emit_block {
emit_block {
my $base = render_enum_core($typename,$tag);
if (defined $base) {
render_enum_tables($typename,$tag,$base);
} else {
print STDERR "Warning: complex enum: $typename\n";
}
} "namespace $typename ";
} "namespace enums ";
emit "using enums::",$typename,"::",$typename,";";
}
# BITFIELD
sub get_primitive_base($;$) {
my ($tag, $default) = @_;
my $base = $tag->getAttribute('base-type') || $default || 'uint32_t';
$primitive_types{$base} or die "Must be primitive: $base\n";
return $base;
}
sub render_bitfield_core {
my ($name, $tag) = @_;
emit_block {
emit get_primitive_base($tag), ' whole;';
emit_block {
for my $item ($tag->findnodes('child::*')) {
render_cond $item, sub {
my ($item) = @_;
($item->nodeName eq 'flag-bit')
or die "Invalid bitfield member:".$item->nodeName."\n";
check_bad_attrs($item);
my $name = ensure_name $item->getAttribute('name');
my $size = $item->getAttribute('count') || 1;
emit "unsigned ", $name, " : ", $size, ";";
};
}
} "struct ", " bits;";
} "union $name ", ";";
}
sub render_bitfield_type {
my ($tag) = @_;
render_bitfield_core($typename,$tag);
}
# STRUCT
my %struct_field_handlers;
sub get_struct_fields($) {
# Retrieve subtags that are actual struct fields
my ($struct_tag) = @_;
local $_;
return grep {
my $tag = $_->nodeName;
die "Unknown field tag: $tag\n"
unless exists $struct_field_handlers{$tag};
$struct_field_handlers{$tag};
} $struct_tag->findnodes('child::*');
}
sub get_struct_field_type($) {
# Dispatch on the tag name, and retrieve the type prefix & suffix
my ($tag) = @_;
my $handler = $struct_field_handlers{$tag->nodeName}
or die "Unexpected tag: ".$tag->nodeName;
return $handler->($tag);
}
sub do_render_struct_field($) {
my ($tag) = @_;
my $tag_name = $tag->nodeName;
my $field_name = $tag->getAttribute('name');
# Special case: anonymous compounds.
if ($tag_name eq 'compound' && !defined $field_name &&
!defined $tag->getAttribute('type-name'))
{
check_bad_attrs($tag);
with_struct_block {
render_struct_field($_) for get_struct_fields($tag);
} $tag, undef, -no_anon => 1;
return;
}
# Otherwise, create the name if necessary, and render
my $name = ensure_name $field_name;
with_anon {
my ($prefix, $postfix) = get_struct_field_type($tag);
emit $prefix, ' ', $name, $postfix, ';';
} "T_$name";
}
sub render_struct_field($) {
my ($tag) = @_;
render_cond $tag, \&do_render_struct_field;
}
sub emit_typedef($$) {
# Convert a prefix/postfix pair into a single name
my ($pre, $post) = @_;
my $name = ensure_name undef;
emit 'typedef ', $pre, ' ', $name, $post, ';';
return $name;
}
sub get_container_item_type($$;$) {
# Interpret the type-name and nested fields for a generic container type
my ($tag,$strong_ref,$allow_void) = @_;
check_bad_attrs($tag);
my $prefix;
my $postfix = '';
local $is_strong_ref = $strong_ref;
unless ($prefix = decode_type_name_ref($tag)) {
my @fields = get_struct_fields($tag);
if (scalar(@fields) == 1 && !is_conditional($fields[0])) {
($prefix, $postfix) = get_struct_field_type($fields[0]);
} elsif (scalar(@fields) == 0) {
$allow_void or die "Empty container: ".$tag->nodeName."\n";
$prefix = $allow_void;
} else {
$prefix = ensure_name undef;
with_struct_block {
render_struct_field($_) for @fields;
} $tag, $prefix;
}
}
return ($prefix,$postfix) if wantarray;
return emit_typedef($prefix, $postfix) if $postfix;
return $prefix;
}
sub get_primitive_field_type {
# Primitive type handler
my ($tag,$fname) = @_;
check_bad_attrs($tag);
my $name = $tag->nodeName;
return (primitive_type_name($name), "");
}
sub get_static_string_type {
# Static string handler
my ($tag, $fname) = @_;
check_bad_attrs($tag, 1);
my $count = $tag->getAttribute('size') || 0;
return ('char', "[$count]");
}
sub get_padding_type {
# Padding handler. Supports limited alignment.
my ($tag, $fname) = @_;
check_bad_attrs($tag, 1, 1);
my $count = $tag->getAttribute('size') || 0;
my $align = $tag->getAttribute('alignment') || 1;
if ($align == 1) {
return ('char', "[$count]");
} elsif ($align == 2) {
($count % 2 == 0) or die "Size not aligned in padding: $count at $align\n";
return ('short', "[".($count/2)."]");
} elsif ($align == 4) {
($count % 4 == 0) or die "Size not aligned in padding: $count at $align\n";
return ('int', "[".($count/4)."]");
} else {
die "Bad padding alignment $align in $typename in $filename\n";
}
}
sub get_static_array_type {
# static-array handler
my ($tag, $fname) = @_;
my ($pre, $post) = get_container_item_type($tag, 1);
my $count = $tag->getAttribute('count')
or die "Count is mandatory for static-array in $typename in $filename\n";
return ($pre, "[$count]".$post);
}
sub get_pointer_type($) {
# pointer handler
my ($tag) = @_;
my $item = get_container_item_type($tag, 0, 'void');
return ($item.'*', '');
}
sub get_compound_type($) {
# compound (nested struct) handler
my ($tag) = @_;
check_bad_attrs($tag);
my $tname = decode_type_name_ref($tag);
unless ($tname) {
$tname = ensure_name undef;
with_struct_block {
render_struct_field($_) for get_struct_fields($tag);
} $tag, $tname;
}
return ($tname,'');
}
sub get_bitfield_type($) {
# nested bitfield handler
my ($tag) = @_;
check_bad_attrs($tag);
my $tname = decode_type_name_ref($tag, -force_type => 'bitfield-type');
unless ($tname) {
$tname = ensure_name undef;
with_anon {
render_bitfield_core($tname, $tag);
};
}
return ($tname,'');
}
sub get_enum_type($) {
# nested enum handler
my ($tag) = @_;
check_bad_attrs($tag);
my $tname = decode_type_name_ref($tag, -force_type => 'enum-type', -force_strong => 1);
my $base = get_primitive_base($tag, 'int32_t');
unless ($tname) {
$tname = ensure_name undef;
with_anon {
render_enum_core($tname,$tag);
};
}
return ("enum_field<$tname,$base>", '');
}
sub get_stl_vector_type($) {
# STL vector
my ($tag) = @_;
my $item = get_container_item_type($tag,1,'void*');
$item = 'char' if $item eq 'bool';
return ("std::vector<$item>", '');
}
sub get_stl_bit_vector_type($) {
# STL bit vector
my ($tag) = @_;
check_bad_attrs($tag);
return ("std::vector<bool>", '');
}
sub get_df_flagarray_type($) {
# DF flag array
my ($tag) = @_;
check_bad_attrs($tag);
my $type = decode_type_name_ref($tag, -attr_name => 'index-enum', -force_type => 'enum-type', -force_strong => 1) || 'int';
return ("BitArray<$type>", '');
}
# Struct dispatch table and core
%struct_field_handlers = (
'comment' => undef, # skip
'code-helper' => undef, # skip
'cond-if' => sub { die "cond handling error"; },
'cond-elseif' => sub { die "cond handling error"; },
'static-string' => \&get_static_string_type,
'padding' => \&get_padding_type,
'static-array' => \&get_static_array_type,
'pointer' => \&get_pointer_type,
'compound' => \&get_compound_type,
'bitfield' => \&get_bitfield_type,
'enum' => \&get_enum_type,
'stl-vector' => \&get_stl_vector_type,
'stl-bit-vector' => \&get_stl_bit_vector_type,
'df-flagarray' => \&get_df_flagarray_type,
);
$struct_field_handlers{$_} ||= \&get_primitive_field_type for @primitive_type_list;
sub emit_find_instance {
my ($tag) = @_;
my $instance_vector = translate_lookup $tag->getAttribute('instance-vector');
if ($instance_vector) {
emit "static std::vector<$typename*> &get_vector();";
emit "static $typename *find(int id);";
with_emit_static {
emit_block {
emit "return ", $instance_vector, ";";
} "std::vector<$typename*>& ${typename}::get_vector() ";
emit_block {
emit "std::vector<$typename*> &vec_ = get_vector();";
if (my $id = $tag->getAttribute('key-field')) {
emit "return binsearch_in_vector(vec_, &${typename}::$id, id_);";
} else {
emit "return (id_ >= 0 && id_ < vec_.size()) ? vec_[id_] : NULL;";
}
} "$typename *${typename}::find(int id_) ";
}
}
}
sub render_struct_type {
my ($tag) = @_;
my $tag_name = $tag->nodeName;
my $is_class = ($tag_name eq 'class-type');
my $has_methods = $is_class || is_attr_true($tag, 'has-methods');
my $inherits = $tag->getAttribute('inherits-from');
my $original_name = $tag->getAttribute('original-name');
my $ispec = '';
if ($inherits) {
register_ref $inherits, 1;
$ispec = ' : '.$inherits;
} elsif ($is_class) {
$ispec = ' : virtual_class';
}
with_struct_block {
render_struct_field($_) for get_struct_fields($tag);
emit_find_instance($tag);
if ($has_methods) {
if ($is_class) {
emit "static class_virtual_identity<$typename> _identity;";
with_emit_static {
emit "class_virtual_identity<$typename> ${typename}::_identity(",
"\"$typename\",",
($original_name ? "\"$original_name\"" : 'NULL'), ',',
($inherits ? "&${inherits}::_identity" : 'NULL'),
");";
}
}
outdent {
emit "protected:";
};
if ($is_class) {
emit "virtual ~",$typename,"() {}";
} else {
emit "~",$typename,"() {}";
}
}
} $tag, "$typename$ispec", -export => 1;
}
# MAIN BODY
# Collect all type definitions from XML files
sub add_type_to_hash($) {
my ($type) = @_;
my $name = $type->getAttribute('type-name')
or die "Type without a name in $filename\n";
die "Duplicate definition of $name in $filename\n" if $types{$name};
local $typename = $name;
check_bad_attrs $type;
$types{$name} = $type;
$type_files{$name} = $filename;
}
for my $fn (glob "$input_dir/*.xml") {
local $filename = $fn;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($filename);
add_type_to_hash $_ foreach $doc->findnodes('/data-definition/enum-type');
add_type_to_hash $_ foreach $doc->findnodes('/data-definition/bitfield-type');
add_type_to_hash $_ foreach $doc->findnodes('/data-definition/struct-type');
add_type_to_hash $_ foreach $doc->findnodes('/data-definition/class-type');
}
# Generate text representations
my %type_handlers = (
'enum-type' => \&render_enum_type,
'bitfield-type' => \&render_bitfield_type,
'class-type' => \&render_struct_type,
'struct-type' => \&render_struct_type,
);
my %type_data;
for my $name (sort { $a cmp $b } keys %types) {
local $typename = $name;
local $filename = $type_files{$typename};
local %weak_refs;
local %strong_refs;
eval {
my $type = $types{$typename};
# Emit the actual type definition
my @code = with_emit {
with_anon {
$type_handlers{$type->nodeName}->($type);
};
} 2;
delete $weak_refs{$name};
delete $strong_refs{$name};
# Add wrapping
my @all = with_emit {
my $def = type_header_def($typename);
emit "#ifndef $def";
emit "#define $def";
for my $strong (sort { $a cmp $b } keys %strong_refs) {
my $sdef = type_header_def($strong);
emit "#ifndef $sdef";
emit "#include \"$strong.h\"";
emit "#endif";
}
emit_block {
for my $weak (sort { $a cmp $b } keys %weak_refs) {
next if $strong_refs{$weak};
my $ttype = $types{$weak};
my $tstr = 'struct';
$tstr = 'enum' if $ttype->nodeName eq 'enum-type';
$tstr = 'union' if $ttype->nodeName eq 'bitfield-type';
$tstr = 'union' if ($ttype->nodeName eq 'struct-type' && is_attr_true($ttype,'is-union'));
emit $tstr, ' ', $weak, ';';
}
push @lines, @code;
} "namespace $main_namespace ";
emit "#endif";
};
$type_data{$typename} = \@all;
};
if ($@) {
print 'Error: '.$@."Type $typename in $filename ignored\n";
}
}
# Write output files
mkdir $output_dir;
{
# Delete the old files
for my $name (glob "$output_dir/*.h") {
unlink $name;
}
# Write out the headers
local $, = "\n";
local $\ = "\n";
for my $name (keys %type_data) {
open FH, ">$output_dir/$name.h";
print FH "/* THIS FILE WAS GENERATED. DO NOT EDIT. */";
print FH @{$type_data{$name}};
close FH;
}
# Write out the static file
open FH, ">$output_dir/static.inc";
print FH "/* THIS FILE WAS GENERATED. DO NOT EDIT. */";
for my $name (sort { $a cmp $b } keys %static_includes) {
print FH "#include \"$name.h\"";
}
print FH "namespace $main_namespace {";
print FH @static_lines;
print FH '}';
close FH;
}

@ -1,58 +0,0 @@
<data-definition>
<class-type type-name='building_def' original-name='building_defst' key-field='code'>
<stl-string name="code"/>
<int32_t name="index"/>
<stl-string name="name"/>
<int32_t name='unk_40'/>
<int32_t name='unk_44'/>
<static-array name='name_color' count='3' type-name='int16_t'/>
<static-array name='tile' count='4'>
<static-array count='31'>
<static-array count='31' type-name='uint8_t'/>
</static-array>
</static-array>
<static-array name='tile_color' count='3'>
<static-array count='4'>
<static-array count='31'>
<static-array count='31' type-name='uint8_t'/>
</static-array>
</static-array>
</static-array>
<static-array name='tile_block' count='31'>
<static-array count='31' type-name='uint8_t'/>
</static-array>
<int32_t name='build_key'/>
<bool name='needs_magma'/>
<stl-vector name="build_items">
<pointer/>
</stl-vector>
<int32_t name="dim_x"/>
<int32_t name="dim_y"/>
<int32_t name="workloc_x"/>
<int32_t name="workloc_y"/>
<stl-vector name="build_labors">
<enum base-type='int32_t' type-name='unit_labor'/>
</stl-vector>
<stl-string name="labor_description"/>
<int32_t name="build_stages"/>
</class-type>
<class-type type-name='building_def_workshopst' inherits-from='building_def'/>
<class-type type-name='building_def_furnacest' inherits-from='building_def'/>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->

@ -1,403 +0,0 @@
<data-definition>
<bitfield-type type-name='building_flags'>
<flag-bit name='exists' comment='actually built, not just ordered'/>
<flag-bit/>
<flag-bit name='room_collision' comment='major intersection with another room?'/>
<flag-bit/>
<flag-bit name='justice'/>
</bitfield-type>
<class-type type-name='building' original-name='buildingst'
instance-vector='$global.world.buildings.all' key-field='id'>
<int32_t name='x1' comment='left'/>
<int32_t name='y1'/>
<int32_t name='x2' comment='work location'/>
<int32_t name='x3' comment='right'/>
<int32_t name='y3'/>
<int32_t name='y2'/>
<int32_t name='z'/>
<compound name='flags' type-name='building_flags'/>
<int16_t name='materialType' ref-target='material' aux-value='$$.materialIndex'/>
<int32_t name='materialIndex'/>
<compound name='room'>
<pointer name='extents' type-name='uint8_t'>
<comment>0 - not room; 1 in stockpile; 2 wall; 3 inner; 4 distance boundary.</comment>
</pointer>
<int32_t name='x'/>
<int32_t name='y'/>
<int32_t name='width'/>
<int32_t name='height'/>
</compound>
<int32_t name='age'/>
<int16_t name='race' ref-target='creature_raw'/>
<int32_t name='id'/>
<stl-vector name='jobs'>
<pointer type-name='job'/>
</stl-vector>
<stl-vector name='meetings'>
<pointer type-name='meeting_ref'/>
</stl-vector>
<stl-vector name='unk6' type-name='pointer'/>
<bool name='is_room'/>
<stl-vector name='children' comment='other buildings within this room'>
<pointer type-name='building'/>
</stl-vector>
<stl-vector name='parents' comment='rooms this building belongs to'>
<pointer type-name='building'/>
</stl-vector>
<pointer type-name='unit' name='owner'/>
<stl-vector name='unk7' type-name='pointer'/>
<stl-string name='name'/>
<stl-vector name='activities'>
<pointer>
<int32_t name='id' ref-target='activity_entry'/>
<int32_t name='is_group'/>
</pointer>
</stl-vector>
</class-type>
-- stockpile --
<class-type type-name='building_stockpilest' inherits-from='building'>
<compound type-name='stockpile_settings' name='settings'/>
<int16_t name='max_barrels'/>
<int16_t name='max_bins'/>
<stl-vector name='container_type'>
<enum base-type='int16_t' type-name='item_type'/>
</stl-vector>
<stl-vector name='container_item_id'>
<int32_t ref-target='item'/>
</stl-vector>
<stl-vector name='container_x' type-name='int16_t'/>
<stl-vector name='container_y' type-name='int16_t'/>
<pointer name='give_to' type-name='building_stockpilest'/>
<stl-vector name='take_from'>
<pointer type-name='building_stockpilest'/>
</stl-vector>
<int32_t name='stockpile_number'/>
</class-type>
-- zone --
<class-type type-name='building_civzonest' inherits-from='building'>
</class-type>
-- actual --
<class-type type-name='building_actual' inherits-from='building'
original-name='building_actualst'>
<int16_t name='construction_stage'
comment='0 not started, then 1 or 3 max depending on type'/>
<stl-vector name='contained_items'>
<pointer>
<pointer name='item' type-name='item'/>
<int16_t name='use_mode'/>
</pointer>
</stl-vector>
<pointer name='design' type-name='building_design'/>
</class-type>
<struct-type type-name='building_design'>
<int32_t name='architect' ref-target='historical_figure'/>
<int32_t name='unk2' comment='-1'/>
<int16_t name='unk3'/>
<int32_t name='builder1' ref-target='historical_figure'/>
<int32_t name='unk5' comment='-1'/>
<int16_t name='unk6'/>
<int16_t name='build_timer1' comment='+1 per 10 frames while building'/>
<int32_t name='builder2' ref-target='historical_figure'/>
<int16_t name='build_timer2'/>
<int16_t name='unk8b'/>
<int16_t name='unk9'/>
<bitfield name='flags' base-type='uint32_t'>
<flag-bit name='rough' comment='rough gabbro road'/>
<flag-bit name='built'/>
<flag-bit name='designed'/>
</bitfield>
<int32_t name='unk11'/>
<int32_t name='unk12'/>
<int32_t name='unk13'/>
</struct-type>
-- workshops --
<enum-type type-name='furnace_type'>
<enum-item name="WoodFurnace"/>
<enum-item name="Smelter"/>
<enum-item name="GlassFurnace"/>
<enum-item name="Kiln"/>
<enum-item name="MagmaSmelter"/>
<enum-item name="MagmaGlassFurnace"/>
<enum-item name="MagmaKiln"/>
<enum-item name="Custom"/>
</enum-type>
<class-type type-name='building_furnacest' inherits-from='building_actual'>
<stl-vector name='melt_remainder' type-name='int32_t'
index-refers-to='(material-by-id 0 $)'/>
<int16_t name="unk_108"/>
<enum base-type='int16_t' name="type" type-name='furnace_type'/>
<stl-vector name="permitted_workers">
<int32_t ref-target='unit'/>
</stl-vector>
<int32_t name="min_level"/>
<int32_t name="max_level"/>
<int32_t name="custom_type" refers-to='$global.world.raws.buildings.furnaces[$]'/>
</class-type>
<enum-type type-name='workshop_type'>
<enum-item name="Carpenters"/>
<enum-item name="Farmers"/>
<enum-item name="Masons"/>
<enum-item name="Craftdwarfs"/>
<enum-item name="Jewelers"/>
<enum-item name="MetalsmithsForge"/>
<enum-item name="MagmaForge"/>
<enum-item name="Bowyers"/>
<enum-item name="Mechanics"/>
<enum-item name="Siege"/>
<enum-item name="Butchers"/>
<enum-item name="Leatherworks"/>
<enum-item name="Tanners"/>
<enum-item name="Clothiers"/>
<enum-item name="Fishery"/>
<enum-item name="Still"/>
<enum-item name="Loom"/>
<enum-item name="Quern"/>
<enum-item name="Kennels"/>
<enum-item name="Kitchen"/>
<enum-item name="Ashery"/>
<enum-item name="Dyers"/>
<enum-item name="Millstone"/>
<enum-item name="Custom"/>
</enum-type>
<class-type type-name='building_workshopst' inherits-from='building_actual'>
<enum base-type='int16_t' name="type" type-name='workshop_type'/>
<stl-vector name="permitted_workers">
<int32_t ref-target='unit'/>
</stl-vector>
<int32_t name="min_level"/>
<int32_t name="max_level"/>
<int32_t name="machine_id" ref-target='machine'/>
<int32_t name="unk_118"/>
<int32_t name="custom_type" refers-to='$global.world.raws.buildings.workshops[$]'/>
</class-type>
-- misc --
<class-type type-name='building_animaltrapst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_archerytargetst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_armorstandst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_bars_verticalst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_bars_floorst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_bedst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_boxst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_bridgest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_cabinetst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_cagest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_chainst' inherits-from='building_actual'>
<pointer name='assigned' type-name='unit'/>
<pointer name='chained' type-name='unit'/>
<int16_t name='unk'/>
</class-type>
<class-type type-name='building_chairst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_coffinst' inherits-from='building_actual'>
<bitfield name='burial_mode' base-type='uint16_t'>
<flag-bit name='allow_burial'/>
<flag-bit name='no_citizens'/>
<flag-bit name='no_pets'/>
</bitfield>
</class-type>
<class-type type-name='building_constructionst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_doorst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_farmplotst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_floodgatest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_grate_floorst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_grate_wallst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_hatchst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_hivest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_nestst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_nest_boxst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_roadst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_road_dirtst' inherits-from='building_roadst'>
</class-type>
<class-type type-name='building_road_pavedst' inherits-from='building_roadst'>
</class-type>
<class-type type-name='building_shopst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_siegeenginest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_slabst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_statuest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_supportst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_tablest' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_traction_benchst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_tradedepotst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_trapst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_wagonst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_weaponst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_weaponrackst' inherits-from='building_actual'>
<int16_t name='unk_c0'/>
<stl-vector name='assignments'>
<pointer>
<int32_t name='squad_id' ref-target='squad'/>
<compound name='mode' type-name='squad_use_flags'/>
</pointer>
</stl-vector>
<int32_t name='unk_d0'/>
</class-type>
<class-type type-name='building_wellst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_windowst' inherits-from='building_actual'>
</class-type>
<class-type type-name='building_window_glassst' inherits-from='building_windowst'>
</class-type>
<class-type type-name='building_window_gemst' inherits-from='building_windowst'>
</class-type>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->

@ -1,592 +0,0 @@
<data-definition>
<enum-type type-name='creature_raw_flags'>
<enum-item/>
<enum-item name='EQUIPMENT_WAGON'/>
<enum-item name='MUNDANE'/>
<enum-item name='VERMIN_EATER'/>
<enum-item name='VERMIN_GROUNDER'/>
<enum-item name='VERMIN_ROTTER'/>
<enum-item name='VERMIN_SOIL'/>
<enum-item name='VERMIN_SOIL_COLONY'/>
<enum-item name='LARGE_ROAMING'/>
<enum-item name='VERMIN_FISH'/>
<enum-item name='LOOSE_CLUSTERS'/>
<enum-item name='FANCIFUL'/>
<enum-item name='BIOME_MOUNTAIN'/>
<enum-item name='BIOME_GLACIER'/>
<enum-item name='BIOME_TUNDRA'/>
<enum-item name='BIOME_SWAMP_TEMPERATE_FRESHWATER'/>
<enum-item name='BIOME_SWAMP_TEMPERATE_SALTWATER'/>
<enum-item name='BIOME_MARSH_TEMPERATE_FRESHWATER'/>
<enum-item name='BIOME_MARSH_TEMPERATE_SALTWATER'/>
<enum-item name='BIOME_SWAMP_TROPICAL_FRESHWATER'/>
<enum-item name='BIOME_SWAMP_TROPICAL_SALTWATER'/>
<enum-item name='BIOME_SWAMP_MANGROVE'/>
<enum-item name='BIOME_MARSH_TROPICAL_FRESHWATER'/>
<enum-item name='BIOME_MARSH_TROPICAL_SALTWATER'/>
<enum-item name='BIOME_FOREST_TAIGA'/>
<enum-item name='BIOME_FOREST_TEMPERATE_CONIFER'/>
<enum-item name='BIOME_FOREST_TEMPERATE_BROADLEAF'/>
<enum-item name='BIOME_FOREST_TROPICAL_CONIFER'/>
<enum-item name='BIOME_FOREST_TROPICAL_DRY_BROADLEAF'/>
<enum-item name='BIOME_FOREST_TROPICAL_MOIST_BROADLEAF'/>
<enum-item name='BIOME_GRASSLAND_TEMPERATE'/>
<enum-item name='BIOME_SAVANNA_TEMPERATE'/>
<enum-item name='BIOME_SHRUBLAND_TEMPERATE'/>
<enum-item name='BIOME_GRASSLAND_TROPICAL'/>
<enum-item name='BIOME_SAVANNA_TROPICAL'/>
<enum-item name='BIOME_SHRUBLAND_TROPICAL'/>
<enum-item name='BIOME_DESERT_BADLAND'/>
<enum-item name='BIOME_DESERT_ROCK'/>
<enum-item name='BIOME_DESERT_SAND'/>
<enum-item name='BIOME_OCEAN_TROPICAL'/>
<enum-item name='BIOME_OCEAN_TEMPERATE'/>
<enum-item name='BIOME_OCEAN_ARCTIC'/>
<enum-item name='BIOME_SUBTERRANEAN_WATER'/>
<enum-item name='BIOME_SUBTERRANEAN_CHASM'/>
<enum-item name='BIOME_SUBTERRANEAN_LAVA'/>
<enum-item name='BIOME_POOL_TEMPERATE_FRESHWATER'/>
<enum-item name='BIOME_POOL_TEMPERATE_BRACKISHWATER'/>
<enum-item name='BIOME_POOL_TEMPERATE_SALTWATER'/>
<enum-item name='BIOME_POOL_TROPICAL_FRESHWATER'/>
<enum-item name='BIOME_POOL_TROPICAL_BRACKISHWATER'/>
<enum-item name='BIOME_POOL_TROPICAL_SALTWATER'/>
<enum-item name='BIOME_LAKE_TEMPERATE_FRESHWATER'/>
<enum-item name='BIOME_LAKE_TEMPERATE_BRACKISHWATER'/>
<enum-item name='BIOME_LAKE_TEMPERATE_SALTWATER'/>
<enum-item name='BIOME_LAKE_TROPICAL_FRESHWATER'/>
<enum-item name='BIOME_LAKE_TROPICAL_BRACKISHWATER'/>
<enum-item name='BIOME_LAKE_TROPICAL_SALTWATER'/>
<enum-item name='BIOME_RIVER_TEMPERATE_FRESHWATER'/>
<enum-item name='BIOME_RIVER_TEMPERATE_BRACKISHWATER'/>
<enum-item name='BIOME_RIVER_TEMPERATE_SALTWATER'/>
<enum-item name='BIOME_RIVER_TROPICAL_FRESHWATER'/>
<enum-item name='BIOME_RIVER_TROPICAL_BRACKISHWATER'/>
<enum-item name='BIOME_RIVER_TROPICAL_SALTWATER'/>
<enum-item name='GOOD'/>
<enum-item name='EVIL'/>
<enum-item name='SAVAGE'/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item name='GENERATED'/>
<enum-item/>
<enum-item/>
<enum-item name='DOES_NOT_EXIST'/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item name='ARTIFICIAL_HIVEABLE'/>
<enum-item name='UBIQUITOUS'/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
<enum-item/>
</enum-type>
<struct-type type-name='body_part_layer_raw' key-field='layer_name'>
<stl-string name='layer_name'/>
<int32_t name='tissue_id'/>
<df-flagarray name='flags'/>
<int32_t name='unk2'/>
<int32_t name='healing_rate'/>
<int32_t name='vascular'/>
<int32_t name='pain_receptors'/>
<int32_t name='unk6'/>
<int16_t name='unk7'/>
<stl-vector name='unk8'/>
<int32_t name='layer_id' comment='across all body parts'/>
<int32_t name='unk10'/>
<int32_t name='unk11'/>
<int32_t name='layer_depth' comment='-1 for skin and internal organs'/>
<int32_t name='unk13'/>
<int32_t name='unk14'/>
<int32_t name='unk15'/>
<int32_t name='unk16'/>
</struct-type>
<struct-type type-name='body_part_raw' key-field='part_name'>
<stl-string name='part_code'/>
<stl-string name='part_name'/>
<int16_t name='con_part_id'/>
<df-flagarray name='flags'/>
<stl-vector name='layers'>
<pointer type-name='body_part_layer_raw'/>
</stl-vector>
<int32_t name='unk2'/>
<int32_t name='unk3'/>
<int32_t name='unk4'/>
<int32_t name='unk5'/>
<int32_t name='relsize'/>
<int32_t name='unk7'/>
<int16_t name='unk7b'/>
<stl-vector name='name_singular'>
<pointer type-name='stl-string'/>
</stl-vector>
<stl-vector name='name_plural'>
<pointer type-name='stl-string'/>
</stl-vector>
<pointer name='bp_relation_part_id'>
<stl-vector type-name='int16_t'/>
</pointer>
<pointer name='bp_relation_code'>
<stl-vector type-name='int16_t'/> // 0 around of, 1 around by
</pointer>
<pointer name='bp_relation_coverage'>
<stl-vector type-name='int16_t'/>
</pointer>
<uint16_t name='min_temp'/>
<uint16_t name='max_temp'/>
<uint16_t name='temp_factor'/>
<int32_t name='unused'/>
<int32_t name='unk11'/>
<int16_t name='unk12'/>
</struct-type>
<struct-type type-name='caste_raw' key-field='caste_id'>
<stl-string name='caste_id'/>
<code-helper name='find-instance'>$global.world.raws.creatures.all[$$].caste[$]</code-helper>
<static-array type-name='stl-string' name='caste_name' count='3'/>
<stl-string name='vermin_bite_txt'/>
<stl-string name='gnawer_txt'/>
<static-array type-name='stl-string' name='baby_name' count='2'/>
<static-array type-name='stl-string' name='child_name' count='2'/>
<static-array type-name='stl-string' name='itemcorpse_str' count='5'/> // temporary
<static-array type-name='stl-string' name='remains' count='2'/>
<stl-string name='description'/>
<static-array type-name='stl-string' name='mannerisms' count='17'>
<comment>fingers[2], nose, ear, head, eyes, mouth, hair, knuckles, lips, cheek, nails, f eet, arms, hands, tongue, leg</comment>
</static-array>
<uint8_t name='caste_tile'/>
<uint8_t name='caste_soldier_tile'/>
<uint8_t name='caste_alttile'/>
<uint8_t name='caste_soldier_alttile'/>
<uint8_t name='caste_glowtile'/>
<uint16_t name='homeotherm'/>
<int16_t name='unk1_1'/>
<int16_t name='unk1_2'/>
<uint16_t name='fixed_temp'/>
<static-array type-name='int16_t' name='caste_color' count='3'/>
<compound name='misc'>
<int16_t name='litter_size_min'/>
<int16_t name='litter_size_max'/>
<int16_t name='penetratepower'/>
<int16_t name='vermin_bite_chance'/>
<int16_t name='grasstrample'/>
<int16_t name='buildingdestroyer'/>
<enum base-type='int16_t' name='itemcorpse_itemtype' type-name='item_type'/>
<int16_t name='itemcorpse_itemsubtype'/>
<int16_t name='itemcorpse_materialtype'
ref-target='material' aux-value='$$.itemcorpse_materialindex'/>
<int16_t name='itemcorpse_materialindex'/> // NOT 32-bit!
<int16_t name='itemcorpse_quality'/>
<static-array type-name='int16_t' name='remains_color' count='3'/>
<int16_t name='difficulty'/>
<static-array type-name='int16_t' name='caste_glowcolor' count='3'/>
<int16_t name='beach_frequency'/>
<int16_t name='clutch_size_min'/>
<int16_t name='clutch_size_max'/>
<int32_t name='speed'/>
<int32_t name='modvalue'/>
<int32_t name='petvalue'/>
<int32_t name='milkable'/>
<int32_t name='viewrange'/>
<int32_t name='maxage_min'/>
<int32_t name='maxage_max'/>
<static-array type-name='int32_t' name='unk3' count='2'/>
<int32_t name='swim_speed'/>
<int32_t name='trade_capacity'/>
<int32_t name='unk4'/>
<int32_t name='pop_ratio'/>
<int32_t name='adult_size'/>
<static-array type-name='int32_t' name='unk5' count='4'/>
<static-array type-name='int32_t' name='attack_trigger' count='3'/>
<int32_t name='egg_size'/>
<int32_t name='grazer'/>
<int32_t name='petvalue_divisor'/>
<int32_t name='prone_to_rage'/>
<static-array type-name='int32_t' name='unk6' count='29'/>
</compound>
<static-array name='personality' count='30'>
<int16_t name='a'/>
<int16_t name='b'/>
<int16_t name='c'/>
</static-array>
<df-flagarray name='flags'/>
<int32_t name='unk7'/>
<stl-vector name='body_parts'>
<pointer type-name='body_part_raw'/>
</stl-vector>
<stl-vector name='attacks'>
<pointer/>
</stl-vector>
<compound name='unknown1'>
<int32_t name='unk8'/>
<stl-vector type-name='int16_t' name='unk9a'/>
<stl-vector type-name='int16_t' name='unk9b'/>
<stl-vector name='unk10'/>
<stl-vector name='unk11'/>
<stl-vector name='unk12'/>
<stl-vector type-name='int16_t' name='unk13'/>
<stl-vector type-name='int32_t' name='unk14'/>
</compound>
<static-array type-name='int32_t' name='unk15' count='4'/>
<stl-vector name='caste_speech_1'/>
<stl-vector name='caste_speech_2'/>
<static-array name='skill_rates' count='116'>
<static-array type-name='int32_t' count='4'/>
</static-array>
<compound name='attributes'>
<static-array name='phys_att_range' count='7'>
<static-array type-name='int32_t' count='6'/>
</static-array>
<static-array name='ment_att_range' count='7'>
<static-array type-name='int32_t' count='13'/>
</static-array>
<static-array name='phys_att_rates' count='4'>
<static-array type-name='int32_t' count='6'/>
</static-array>
<static-array name='ment_att_rates' count='4'>
<static-array type-name='int32_t' count='13'/>
</static-array>
<static-array type-name='int32_t' name='phys_att_cap_perc' count='6'/>
<static-array type-name='int32_t' name='ment_att_cap_perc' count='13'/>
</compound>
<int8_t name='gender'/>
<stl-vector type-name='int32_t' name='body_size_1'/>
<stl-vector type-name='int32_t' name='body_size_2'/>
<static-array name='unk16' count='19'>
<stl-vector/>
</static-array>
<static-array type-name='int32_t' name='unk17' count='2'/>
<stl-vector type-name='int16_t' name='natural_skill_id'/>
<stl-vector type-name='int32_t' name='natural_skill_exp'/>
<stl-vector type-name='int32_t' name='natural_skill_lvl'/>
<static-array name='caste_profession_name' count='106'>
<stl-string name='singular'/>
<stl-string name='plural'/>
</static-array>
<compound name='extracts'>
<stl-vector type-name='int16_t' name='extract_mat'/>
<stl-vector type-name='int32_t' name='extract_matidx'/>
<static-array name='extract_str' count='3'>
<stl-vector>
<pointer type-name='stl-string'/>
</stl-vector>
</static-array>
<int16_t name='milkable_mat'/>
<int32_t name='milkable_matidx'/>
<static-array name='milkable_str' count='3'>
<stl-string/>
</static-array>
<int16_t name='webber_mat'/>
<int32_t name='webber_matidx'/>
<static-array name='webber_str' count='3'>
<stl-string/>
</static-array>
<int16_t name='vermin_bite_mat'/>
<int32_t name='vermin_bite_matidx'/>
<int16_t name='vermin_bite_chance'/>
<static-array name='vermin_bite_str' count='3'>
<stl-string/>
</static-array>
<int16_t name='tendons_mat'/>
<int32_t name='tendons_matidx'/>
<static-array name='tendons_str' count='3'>
<stl-string/>
</static-array>
<int32_t name='tendons_heal'/>
<int16_t name='ligaments_mat'/>
<int32_t name='ligaments_matidx'/>
<static-array name='ligaments_str' count='3'>
<stl-string/>
</static-array>
<int32_t name='ligaments_heal'/>
<int16_t name='blood_state'/>
<int16_t name='blood_mat'/>
<int32_t name='blood_matidx'/>
<static-array name='blood_str' count='3'>
<stl-string/>
</static-array>
<int16_t name='pus_state'/>
<int16_t name='pus_mat'/>
<int32_t name='pus_matidx'/>
<static-array name='pus_str' count='3'>
<stl-string/>
</static-array>
<stl-vector type-name='int16_t' name='material_breath_attack_mattype'/>
<stl-vector type-name='int32_t' name='material_breath_attack_matindex'/>
<static-array name='material_breath_attack_str' count='3'>
<stl-vector>
<pointer type-name='stl-string'/>
</stl-vector>
</static-array>
<stl-vector type-name='int16_t' name='material_breath_attack_type'/>
<stl-vector type-name='int16_t' name='egg_material_mattype'/>
<stl-vector type-name='int32_t' name='egg_material_matindex'/>
<static-array name='egg_material_str' count='3'>
<stl-vector>
<pointer type-name='stl-string'/>
</stl-vector>
</static-array>
<stl-vector name='lays_unusual_eggs_itemtype'>
<enum base-type='int16_t' type-name='item_type'/>
</stl-vector>
<stl-vector name='lays_unusual_eggs_itemsubtype'/>
<stl-vector type-name='int16_t' name='lays_unusual_eggs_mattype'/>
<stl-vector type-name='int32_t' name='lays_unusual_eggs_matindex'/>
<static-array name='lays_unusual_eggs_str' count='5'>
<stl-vector>
<pointer type-name='stl-string'/>
</stl-vector>
</static-array>
</compound>
<stl-vector name='unk22'/>
<stl-vector name='creature_class'>
<pointer type-name='stl-string'/>
</stl-vector>
<compound name='unknown2'>
<stl-vector name='unk23a'/>
<stl-vector name='unk23b'/>
<stl-vector name='unk23c'/>
<df-flagarray name='unk24_flags'/>
<df-flagarray name='unk25_flags'/>
<static-array type-name='int32_t' name='unk26' count='33'/>
<static-array name='unk27' count='5'><stl-vector/></static-array>
<static-array type-name='int32_t' name='unk28' count='2'/>
</compound>
<static-array type-name='int32_t' name='habit_num' count='2'/>
<static-array name='habit' count='2'><stl-vector/></static-array>
<static-array name='lair' count='2'><stl-vector/></static-array>
<static-array name='lair_characteristic' count='2'><stl-vector/></static-array>
<static-array name='lair_hunter_speech' count='2'><stl-vector/></static-array>
<static-array name='unk29' count='2'><stl-vector/></static-array>
<static-array name='specific_food' count='2'><stl-vector/></static-array>
<static-array name='unk30' count='3'><stl-vector/></static-array>
</struct-type>
<struct-type type-name='creature_raw' key-field='creature_id'>
<stl-string name='creature_id'/>
<code-helper name='find-instance'>$global.world.raws.creatures.all[$]</code-helper>
<static-array type-name='stl-string' name='name' count='3'/>
<static-array type-name='stl-string' name='general_baby_name' count='2'/>
<static-array type-name='stl-string' name='general_child_name' count='2'/>
<uint8_t name='creature_tile'/>
<uint8_t name='creature_soldier_tile'/>
<uint8_t name='alttile'/>
<uint8_t name='soldier_alttile'/>
<uint8_t name='glowtile'/>
<int16_t name='unk1'/>
<int16_t name='unk2'/>
<int16_t name='frequency'/>
<static-array type-name='int16_t' name='population_number' count='2'/>
<static-array type-name='int16_t' name='cluster_number' count='2'/>
<static-array type-name='int16_t' name='triggerable_group' count='2'/>
<static-array type-name='int16_t' name='color' count='3'/>
<static-array type-name='int16_t' name='glowcolor' count='3'/>
<int32_t name='adultsize'/>
<stl-vector name='prefstring'>
<pointer type-name='stl-string'/>
</stl-vector>
<stl-vector type-name='int16_t' name='sphere'/>
<stl-vector name='caste'>
<pointer type-name='caste_raw'/>
</stl-vector>
<stl-vector type-name='int32_t' name='pop_ratio'/>
<df-flagarray name='flags' index-enum='creature_raw_flags'/>
<compound name='stuff'>
<static-array name='stuff1' count='2'>
<static-array type-name='int32_t' count='7'/>
</static-array>
<static-array name='stuff2a' count='7'>
<static-array type-name='int32_t' count='12'/>
</static-array>
<static-array name='stuff2b' count='7'>
<static-array type-name='int32_t' count='12'/>
</static-array>
<static-array type-name='int32_t' name='unk3' count='84'/>
<static-array name='stuff3a' count='7'>
<static-array type-name='int32_t' count='106'/>
</static-array>
<static-array name='stuff3b' count='7'>
<static-array type-name='int32_t' count='106'/>
</static-array>
<static-array type-name='int8_t' name='stuff4' count='7'/>
<static-array name='stuff2c' count='7'>
<static-array type-name='int8_t' count='12'/>
</static-array>
<static-array type-name='int8_t' name='unk4' count='42'/>
<static-array name='stuff3c' count='7'>
<static-array type-name='int8_t' count='106'/>
</static-array>
</compound>
<stl-vector name='unk5'/>
<stl-vector name='speech1'/>
<stl-vector name='speech2'/>
<stl-vector name='speech3'/>
<stl-vector name='material'>
<pointer type-name='material'/>
</stl-vector>
<stl-vector type-name='pointer' name='tissue'/>
<static-array name='profession_name' count='106'>
<stl-string name='singular'/>
<stl-string name='plural'/>
</static-array>
<pointer name='unk6pa'/>
<pointer name='unk6pb'/>
<stl-vector type-name='int32_t' name='unk6'/>
<stl-vector type-name='int32_t' name='unk7'/>
<stl-vector type-name='int32_t' name='hive_product_0'/>
<stl-vector type-name='int32_t' name='hive_product_1'/>
<stl-vector type-name='int16_t' name='hive_product_2'/>
<stl-vector type-name='int16_t' name='hive_product_3'/>
<stl-vector type-name='int16_t' name='hive_product_4'/>
<stl-vector type-name='int32_t' name='hive_product_5'/>
<static-array name='hive_product_tmpstr' count='5'>
<stl-vector>
<pointer type-name='stl-string'/>
</stl-vector>
</static-array>
<int32_t name='unk8'/>
<stl-vector name='raws'>
<pointer type-name='stl-string'/>
</stl-vector>
</struct-type>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->

@ -1,129 +0,0 @@
<data-definition>
<enum-type type-name='d_init_nickname'>
<enum-item name='REPLACE_FIRST'/>
<enum-item name='CENTRALIZE'/>
<enum-item name='REPLACE_ALL'/>
</enum-type>
<enum-type type-name='d_init_z_view'>
<enum-item name='OFF'/>
<enum-item name='UNHIDDEN'/>
<enum-item name='CREATURE'/>
<enum-item name='ON'/>
</enum-type>
<enum-type type-name='d_init_idlers'>
<enum-item name='OFF' value='-1'/>
<enum-item name='TOP'/>
<enum-item name='BOTTOM'/>
</enum-type>
<enum-type type-name='d_init_tunnel'>
<enum-item name='NO'/>
<enum-item name='FINDER'/>
<enum-item name='ALWAYS'/>
</enum-type>
<enum-type type-name='d_init_flags1'>
<enum-item name='VARIED_GROUND_TILES'/>
<enum-item name='ENGRAVINGS_START_OBSCURED'/>
<enum-item name='SHOW_IMP_QUALITY'/>
<enum-item name='SHOW_FLOW_AMOUNTS'/>
</enum-type>
<enum-type type-name='d_init_flags2'>
<enum-item name='MORE'/>
<enum-item name='ADVENTURER_TRAPS'/>
<enum-item name='ADVENTURER_ALWAYS_CENTER'/>
</enum-type>
<enum-type type-name='d_init_flags3'>
<enum-item name='COFFIN_NO_PETS_DEFAULT'/>
</enum-type>
<enum-type type-name='d_init_flags4'>
<enum-item name='TEMPERATURE'/>
<enum-item name='WEATHER'/>
<enum-item name='ECONOMY'/>
<enum-item name='ZERO_RENT'/>
<enum-item name='AUTOSAVE_SEASONAL'/>
<enum-item name='AUTOSAVE_YEARLY'/>
<enum-item name='AUTOSAVE_PAUSE'/>
<enum-item name='AUTOBACKUP'/>
<enum-item name='INITIAL_SAVE'/>
<enum-item name='INVADERS'/>
<enum-item name='CAVEINS'/>
<enum-item name='ARTIFACTS'/>
<enum-item name='LOG_MAP_REJECTS'/>
<enum-item name='PAUSE_ON_LOAD'/>
<enum-item name='EMBARK_WARNING_ALWAYS'/>
<enum-item name='SHOW_ALL_HISTORY_IN_DWARF_MODE'/>
<enum-item name='TESTING_ARENA'/>
<enum-item name='WALKING_SPREADS_SPATTER_DWF'/>
<enum-item name='WALKING_SPREADS_SPATTER_ADV'/>
</enum-type>
<struct-type type-name='d_init'>
<df-flagarray name='flags1' index-enum='d_init_flags1'/>
<enum name="nickname_dwarf" type-name='d_init_nickname'/>
<enum name="nickname_adventure" type-name='d_init_nickname'/>
<enum name="nickname_legends" type-name='d_init_nickname'/>
<enum name="nickname_dwarf2" type-name='d_init_nickname'/>
<int32_t name="unk_18"/>
<int32_t name="unk_1c"/>
<uint8_t name='sky_tile'/>
<static-array name='sky_color' type-name='int16_t' count='3'/>
<uint8_t name='chasm_tile'/>
<uint8_t name='pillar_tile'/>
<static-array name='chasm_color' type-name='int16_t' count='3'/>
<compound name='wound_color'>
<static-array name='none' type-name='int16_t' count='3'/>
<static-array name='minor' type-name='int16_t' count='3'/>
<static-array name='inhibited' type-name='int16_t' count='3'/>
<static-array name='function_loss' type-name='int16_t' count='3'/>
<static-array name='broken' type-name='int16_t' count='3'/>
<static-array name='missing' type-name='int16_t' count='3'/>
</compound>
<enum name="idlers" base-type='int16_t' type-name='d_init_idlers'/>
<enum name="show_embark_tunnel" base-type='int16_t' type-name='d_init_tunnel'/>
<df-flagarray name='flags2' index-enum='d_init_flags2'/>
<int32_t name="display_length"/>
<enum name="adventurer_z_view" type-name='d_init_z_view'/>
<int32_t name="adventurer_z_view_size"/>
<df-flagarray name='flags3' index-enum='d_init_flags3'/>
<int32_t name="population_cap"/>
<int32_t name="baby_cap_absolute"/>
<int32_t name="baby_cap_percent"/>
<static-array name='path_cost' type-name='int32_t' count='4'/>
<static-array name='embark_rect' type-name='int16_t' count='2'/>
<compound name='store_dist'>
<int16_t name='item_decrease'/>
<int16_t name='seed_combine'/>
<int16_t name='bucket_combine'/>
<int16_t name='barrel_combine'/>
<int16_t name='bin_combine'/>
</compound>
<df-flagarray name='flags4' index-enum='d_init_flags4'/>
85266c0
</struct-type>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->

@ -1,126 +0,0 @@
<data-definition>
<struct-type type-name='historical_figure' instance-vector='$global.world.history.figures' key-field='id'>
<enum base-type='int16_t' name='profession' type-name='profession'/>
<int16_t name='race' ref-target='creature_raw'/>
<int16_t name='caste' ref-target='caste_raw' aux-value='$$.race'/>
<int8_t name='sex'/>
<int32_t name='appeared_year'/>
<int32_t name='born_year'/>
<int32_t name='born_seconds'/>
<int32_t name='old_year'/>
<int32_t name='old_seconds'/>
<int32_t name='died_year'/>
<int32_t name='died_seconds'/>
<compound type-name='language_name' name='name'/>
<code-helper name='describe'>
(describe-obj $.name)
(awhen (find-creature $.race)
(fmt "~:(~A ~A~)" $it.caste[$.caste].caste_id $it.creature_id))
</code-helper>
<int32_t name='civ_id' ref-target='historical_entity'/>
<int32_t name='population_id' ref-target='entity_population'/>
<df-flagarray name='flags'/>
<int32_t name='unit_id' ref-target='unit'/>
<int32_t name='id'/>
<int32_t name='unk4'/>
<stl-vector name='entity_links'/>
<stl-vector name='site_links'/>
<stl-vector name='histfig_links'/>
<pointer name='unk6'/>
<static-array name='unk7' count='5' type-name='int32_t' comment='empty'/>
</struct-type>
<class-type type-name='history_event' original-name='history_eventst'
instance-vector='$global.world.history.events' key-field='id'>
<int32_t name='year'/>
<int32_t name='seconds'/>
<df-flagarray name='flags'/>
<int32_t name='id'/>
</class-type>
<class-type type-name='history_event_masterpiece_createdst' inherits-from='history_event'>
<int32_t name='maker' ref-target='historical_figure'/>
<int32_t name='maker_entity' ref-target='historical_entity'/>
<int32_t name='site' ref-target='world_site'/>
</class-type>
<class-type type-name='history_event_masterpiece_created_itemst'
inherits-from='history_event_masterpiece_createdst'>
<enum base-type='int32_t' name='skill_used' type-name='job_skill'/>
<enum base-type='int16_t' name='item_type' type-name='item_type'/>
<int16_t name='item_subtype' refers-to='(item-subtype-target $$._parent.item_type $)'/>
<int16_t name='mat_type' ref-target='material' aux-value='$$.mat_index'/>
<int16_t name='mat_index'/>
<int32_t name='item_id' ref-target='item'/>
</class-type>
<class-type type-name='history_event_masterpiece_created_foodst'
inherits-from='history_event_masterpiece_createdst'>
<int32_t name='unk1'/>
<int16_t name='item_subtype' refers-to='$global.world.raws.itemdefs.food[$]'/>
<int32_t name='item_id' ref-target='item'/>
</class-type>
<struct-type type-name='world_history'>
dtor 8532fa0
<stl-vector name='events'>
<pointer type-name='history_event'/>
</stl-vector>
<stl-vector name='events2'>
<pointer type-name='history_event'/>
</stl-vector>
<stl-vector name='figures'>
<pointer type-name='historical_figure'/>
</stl-vector>
<static-array name='other_events' count='9'>
<stl-vector>
<pointer type-name='history_event'/>
</stl-vector>
</static-array>
<stl-vector name='ages'>
<pointer/>
</stl-vector>
<stl-vector name='unk1' type-name='int32_t'/>
<stl-vector name='unk2' type-name='int16_t'/>
<int32_t/>
<int32_t/>
<int32_t/>
<int32_t/>
<stl-vector/>
<stl-vector/>
<stl-vector/>
<stl-vector/>
<stl-vector/>
<stl-vector/>
<bool/>
<stl-vector/>
<int32_t/>
<int32_t/>
<int32_t/>
</struct-type>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->

@ -1,138 +0,0 @@
<data-definition>
-- init.h
<enum-type type-name='init_display_flags'>
<enum-item name='USE_GRAPHICS'/>
<enum-item name='BLACK_SPACE'/>
<enum-item name='PARTIAL_PRINT'/>
<enum-item name='FRAME_BUFFER'/>
<enum-item name='SINGLE_BUFFER'/>
<enum-item name='ACCUM_BUFFER'/>
<enum-item name='VBO'/>
<enum-item name='RENDER_2D'/>
<enum-item name='RENDER_2DHW'/>
<enum-item name='RENDER_2DASYNC'/>
<enum-item name='UNUSED_01_08'/>
<enum-item name='TEXT'/>
<enum-item name='SHADER'/>
<enum-item name='NOT_RESIZABLE'/>
<enum-item name='ARB_SYNC'/>
</enum-type>
<struct-type type-name='init_display'>
<df-flagarray name='flag' index-enum='init_display_flags'/>
<enum name='windowed'>
<enum-item name='True'/>
<enum-item name='False'/>
<enum-item name='Prompt'/>
</enum>
<int32_t name='grid_x'/>
<int32_t name='grid_y'/>
<int32_t name='desired_fullscreen_width'/>
<int32_t name='desired_fullscreen_height'/>
<int32_t name='desired_windowed_width'/>
<int32_t name='desired_windowed_height'/>
<int8_t name='partial_print_count'/>
</struct-type>
<enum-type type-name='init_media_flags'>
<enum-item name='SOUND_OFF'/>
<enum-item name='INTRO_OFF'/>
<enum-item name='COMPRESS_SAVES'/>
</enum-type>
<struct-type type-name='init_media'>
<df-flagarray name='flag' index-enum='init_media_flags'/>
<int32_t name='volume'/>
</struct-type>
<enum-type type-name='init_input_flags'>
<enum-item name='MOUSE_OFF'/>
<enum-item name='MOUSE_PICTURE'/>
</enum-type>
<struct-type type-name='init_input'>
<int32_t name='hold_time'/>
<int32_t name='repeat_time'/>
<int32_t name='macro_time'/>
<int32_t name='pause_zoom_no_interface_ms'/>
<df-flagarray name='flag' index-enum='init_input_flags'/>
<int32_t name='zoom_speed'/>
<int32_t name='repeat_accel_start'/>
<int32_t name='repeat_accel_limit'/>
</struct-type>
<struct-type type-name='init_font'>
<static-array name='small_font_texpos' type-name='int32_t' count='256'/>
<static-array name='large_font_texpos' type-name='int32_t' count='256'/>
<static-array name='small_font_datapos' type-name='int32_t' count='256'/>
<static-array name='large_font_datapos' type-name='int32_t' count='256'/>
<s-float name='small_font_adjx'/>
<s-float name='small_font_adjy'/>
<s-float name='large_font_adjx'/>
<s-float name='large_font_adjy'/>
<int32_t name='small_font_dispx'/>
<int32_t name='small_font_dispy'/>
<int32_t name='large_font_dispx'/>
<int32_t name='large_font_dispy'/>
<bool name='use_ttf'/>
</struct-type>
<enum-type type-name='init_window_flags'>
<enum-item name='TOPMOST'/>
<enum-item name='VSYNC_ON'/>
<enum-item name='VSYNC_OFF'/>
<enum-item name='TEXTURE_LINEAR'/>
</enum-type>
<struct-type type-name='init_window'>
<df-flagarray name='flag' index-enum='init_window_flags'/>
</struct-type>
<struct-type type-name='init'>
<compound name='display' type-name='init_display'/>
<compound name='media' type-name='init_media'/>
<compound name='input' type-name='init_input'/>
<compound name='font' type-name='init_font'/>
<compound name='window' type-name='init_window'/>
</struct-type>
-- texture_handler.h
<struct-type type-name='tile_page'>
<stl-string name='token'/>
<stl-string name='filename'/>
<int16_t name='tile_dim_x'/>
<int16_t name='tile_dim_y'/>
<int16_t name='page_dim_x'/>
<int16_t name='page_dim_y'/>
<stl-vector name='texpos' type-name='int32_t'/>
<stl-vector name='datapos' type-name='int32_t'/>
<stl-vector name='texpos_gs' type-name='int32_t'/>
<stl-vector name='datapos_gs' type-name='int32_t'/>
<bool name='loaded'/>
</struct-type>
<struct-type type-name='texture_handler'>
<stl-vector name='page'>
<pointer type-name='tile_page'/>
</stl-vector>
<stl-vector name='texpos' type-name='int32_t'/>
<stl-vector name='datapos' type-name='int32_t'/>
</struct-type>
</data-definition>
<!--
Local Variables:
indent-tabs-mode: nil
nxml-child-indent: 4
End:
-->

Some files were not shown because too many files have changed in this diff Show More