Merge remote-tracking branch 'DFHack/develop' into remote_reader

develop
Japa 2018-03-14 16:18:03 +05:30
commit 4d74f66b64
27 changed files with 78 additions and 59 deletions

@ -1,10 +1,5 @@
# main project file. use it from a build sub-folder, see COMPILE for details
# prevent CMake warnings about INTERFACE_LINK_LIBRARIES vs LINK_INTERFACE_LIBRARIES
IF(CMAKE_VERSION VERSION_GREATER "2.8.12")
CMAKE_POLICY(SET CMP0022 OLD)
ENDIF()
# Set up build types
if(CMAKE_CONFIGURATION_TYPES)
SET(CMAKE_CONFIGURATION_TYPES Release RelWithDebInfo)
@ -18,7 +13,7 @@ endif(CMAKE_CONFIGURATION_TYPES)
OPTION(BUILD_DOCS "Choose whether to build the documentation (requires python and Sphinx)." OFF)
## some generic CMake magic
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
project(dfhack)
macro(CHECK_GCC COMPILER_PATH)
@ -140,12 +135,14 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac
endif()
# set up versioning.
set(DF_VERSION "0.44.05")
set(DFHACK_RELEASE "r2")
set(DFHACK_PRERELEASE FALSE)
set(DF_VERSION "0.44.07")
set(DFHACK_RELEASE "alpha1")
set(DFHACK_PRERELEASE TRUE)
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
set(DFHACK_ABI_VERSION 1)
## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here:
IF(UNIX)
@ -187,6 +184,7 @@ IF(UNIX)
# ensure compatibility with older CPUs
# enable C++11 features
add_definitions(-DLINUX_BUILD)
add_definitions(-D_GLIBCXX_USE_C99)
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -Wno-unused-variable")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -mtune=generic -std=c++0x")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -mtune=generic")

@ -3922,8 +3922,10 @@ Value& Path::make(Value& root) const {
#define isfinite finite
#else
#include <cmath>
#ifndef isfinite // fix isfinite on Ubuntu 18.04
#define isfinite std::isfinite
#endif
#endif
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
#define snprintf _snprintf

@ -1,10 +1,8 @@
PROJECT (dfapi)
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.12)
# prevent CMake warnings about INTERFACE_LINK_LIBRARIES vs LINK_INTERFACE_LIBRARIES
IF(CMAKE_VERSION VERSION_GREATER "2.8.12")
CMAKE_POLICY(SET CMP0022 OLD)
ENDIF()
CMAKE_POLICY(SET CMP0022 NEW)
## build options
OPTION(BUILD_DEVEL "Install/package files required for development (For SDK)." OFF)
@ -301,6 +299,7 @@ SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
DFHACK_VERSION="${DFHACK_VERSION}"
DF_VERSION="${DF_VERSION}"
DFHACK_RELEASE="${DFHACK_RELEASE}"
DFHACK_ABI_VERSION=${DFHACK_ABI_VERSION}
)
IF(DFHACK_PRERELEASE)
SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
@ -365,7 +364,7 @@ IF(APPLE)
ENDIF()
TARGET_LINK_LIBRARIES(dfhack protobuf-lite clsocket lua jsoncpp dfhack-version ${PROJECT_LIBS})
SET_TARGET_PROPERTIES(dfhack PROPERTIES LINK_INTERFACE_LIBRARIES "")
SET_TARGET_PROPERTIES(dfhack PROPERTIES INTERFACE_LINK_LIBRARIES "")
TARGET_LINK_LIBRARIES(dfhack-client protobuf-lite clsocket)
TARGET_LINK_LIBRARIES(dfhack-run dfhack-client)

@ -3,6 +3,10 @@
#include "git-describe.h"
namespace DFHack {
namespace Version {
int dfhack_abi_version()
{
return DFHACK_ABI_VERSION;
}
const char *dfhack_version()
{
return DFHACK_VERSION;

@ -36,6 +36,7 @@ distribution.
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <cstdlib>
#include <sstream>
#include <map>

@ -276,6 +276,7 @@ bool Plugin::load(color_ostream &con)
plugin_check_symbol("plugin_name")
plugin_check_symbol("plugin_version")
plugin_check_symbol("plugin_abi_version")
plugin_check_symbol("plugin_self")
plugin_check_symbol("plugin_init")
plugin_check_symbol("plugin_globals")
@ -287,11 +288,19 @@ bool Plugin::load(color_ostream &con)
return false;
}
const char ** plug_version =(const char ** ) LookupPlugin(plug, "plugin_version");
const int *plugin_abi_version = (int*) LookupPlugin(plug, "plugin_abi_version");
const char ** plug_git_desc_ptr = (const char**) LookupPlugin(plug, "plugin_git_description");
Plugin **plug_self = (Plugin**)LookupPlugin(plug, "plugin_self");
const char *dfhack_version = Version::dfhack_version();
const char *dfhack_git_desc = Version::git_description();
const char *plug_git_desc = plug_git_desc_ptr ? *plug_git_desc_ptr : "unknown";
if (*plugin_abi_version != Version::dfhack_abi_version())
{
con.printerr("Plugin %s: ABI version mismatch (Plugin: %i, DFHack: %i)\n",
*plug_name, *plugin_abi_version, Version::dfhack_abi_version());
plugin_abort_load;
return false;
}
if (strcmp(dfhack_version, *plug_version) != 0)
{
con.printerr("Plugin %s was not built for this version of DFHack.\n"

@ -7,7 +7,8 @@ set(git_describe_h ${dfhack_SOURCE_DIR}/library/include/git-describe.h)
if(EXISTS ${git_describe_tmp_h} AND
NOT(${dfhack_SOURCE_DIR}/.git/index IS_NEWER_THAN ${git_describe_tmp_h}) AND
NOT(${dfhack_SOURCE_DIR}/.git/modules/library/xml/index IS_NEWER_THAN ${git_describe_tmp_h}))
NOT(${dfhack_SOURCE_DIR}/.git/modules/library/xml/index IS_NEWER_THAN ${git_describe_tmp_h}) AND
NOT(${dfhack_SOURCE_DIR}/library/git-describe.cmake IS_NEWER_THAN ${git_describe_tmp_h}))
return()
endif()

@ -4,6 +4,7 @@ namespace DFHack {
const char *dfhack_version();
const char *df_version();
const char *dfhack_release();
int dfhack_abi_version();
const char *git_description();
const char *git_commit();
const char *git_xml_commit();
@ -18,6 +19,7 @@ namespace DFHack {
#define DF_VERSION (DFHack::Version::df_version())
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
#define DFHACK_VERSION (DFHack::Version::dfhack_version())
#define DFHACK_ABI_VERSION (DFHack::Version::dfhack_abi_version())
#define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description())
#define DFHACK_GIT_COMMIT (DFHack::Version::git_commit())
#define DFHACK_GIT_XML_COMMIT (DFHack::Version::git_xml_commit())

@ -61,6 +61,7 @@ namespace DFHack
namespace Version {
const char *dfhack_version();
const char *git_description();
int dfhack_abi_version();
}
// anon type, pretty much
@ -296,6 +297,7 @@ namespace DFHack
DFhackDataExport const char * plugin_name = m_plugin_name;\
DFhackDataExport const char * plugin_version = DFHack::Version::dfhack_version();\
DFhackDataExport const char * plugin_git_description = DFHack::Version::git_description();\
DFhackDataExport int plugin_abi_version = DFHack::Version::dfhack_abi_version();\
DFhackDataExport DFHack::Plugin *plugin_self = NULL;\
std::vector<std::string> _plugin_globals;\
DFhackDataExport std::vector<std::string>* plugin_globals = &_plugin_globals; \

@ -476,7 +476,7 @@ local function matchIds(bid1,wid1,cid1,bid2,wid2,cid2)
end
local function scanRawsReaction(buildingId,workshopId,customId)
local ret={}
for idx,reaction in ipairs(df.global.world.raws.reactions) do
for idx,reaction in ipairs(df.global.world.raws.reactions.reactions) do
for k,v in pairs(reaction.building.type) do
if matchIds(buildingId,workshopId,customId,v,reaction.building.subtype[k],reaction.building.custom[k]) then
table.insert(ret,reaction)
@ -575,4 +575,4 @@ function getJobs(buildingId,workshopId,customId)
--get jobs, add in from raws
return ret
end
return _ENV
return _ENV

@ -105,7 +105,7 @@ local function parse_inset(inset)
l = inset or 0
t,r,b = l,l,l
end
return l,r,t,b
return l,t,r,b
end
function inset_frame(rect, inset, gap)

@ -733,7 +733,7 @@ bool Materials::ReadOthers(void)
bool Materials::ReadDescriptorColors (void)
{
size_t size = world->raws.language.colors.size();
size_t size = world->raws.descriptors.colors.size();
color.clear();
if(size == 0)
@ -741,7 +741,7 @@ bool Materials::ReadDescriptorColors (void)
color.reserve(size);
for (size_t i = 0; i < size;i++)
{
df::descriptor_color *c = world->raws.language.colors[i];
df::descriptor_color *c = world->raws.descriptors.colors[i];
t_descriptor_color col;
col.id = c->id;
col.name = c->name;
@ -751,13 +751,13 @@ bool Materials::ReadDescriptorColors (void)
color.push_back(col);
}
size = world->raws.language.patterns.size();
size = world->raws.descriptors.patterns.size();
alldesc.clear();
alldesc.reserve(size);
for (size_t i = 0; i < size;i++)
{
t_matgloss mat;
mat.id = world->raws.language.patterns[i]->id;
mat.id = world->raws.descriptors.patterns[i]->id;
alldesc.push_back(mat);
}
return true;

@ -1 +1 @@
Subproject commit 5fea1ef62a040d24a9efa31a9a6dfd8eb1eea3f6
Subproject commit dd558ca1ea4645f14a7e5b83329d4f59d8414496

@ -356,7 +356,7 @@ static bool find_reactions(color_ostream &out)
reactions.clear();
products.clear();
auto &rlist = world->raws.reactions;
auto &rlist = df::reaction::get_vector();
for (size_t i = 0; i < rlist.size(); i++)
{

@ -59,10 +59,10 @@ command_result df_dumpmats (color_ostream &out, vector<string> &parameters)
{
def_color[matter_state::Liquid] = solid_color;
def_color[matter_state::Gas] = solid_color;
out.print("\t[STATE_COLOR:ALL:%s]\n", world->raws.language.colors[solid_color]->id.c_str());
out.print("\t[STATE_COLOR:ALL:%s]\n", world->raws.descriptors.colors[solid_color]->id.c_str());
}
else
out.print("\t[STATE_COLOR:ALL_SOLID:%s]\n", world->raws.language.colors[solid_color]->id.c_str());
out.print("\t[STATE_COLOR:ALL_SOLID:%s]\n", world->raws.descriptors.colors[solid_color]->id.c_str());
}
string solid_name = mat->state_name[matter_state::Solid];
@ -141,7 +141,7 @@ command_result df_dumpmats (color_ostream &out, vector<string> &parameters)
FOR_ENUM_ITEMS(matter_state, state)
{
if (mat->state_color[state] != -1 && mat->state_color[state] != def_color[state])
out.print("\t[STATE_COLOR:%s:%s]\n", state_names[state], world->raws.language.colors[mat->state_color[state]]->id.c_str());
out.print("\t[STATE_COLOR:%s:%s]\n", state_names[state], world->raws.descriptors.colors[mat->state_color[state]]->id.c_str());
if (mat->state_name[state] == mat->state_adj[state])
{
if (mat->state_name[state].size() && mat->state_name[state] != def_name[state] || mat->state_adj[state].size() && mat->state_adj[state] != def_adj[state])
@ -241,7 +241,7 @@ command_result df_dumpmats (color_ostream &out, vector<string> &parameters)
if (mat->hardens_with_water.mat_type != -1)
out.print("\t[HARDENS_WITH_WATER:%s:%s%s%s]\n", mat->hardens_with_water.str[0].c_str(), mat->hardens_with_water.str[1].c_str(), mat->hardens_with_water.str[2].size() ? ":" : "", mat->hardens_with_water.str[2].c_str());
if (mat->powder_dye != -1)
out.print("\t[POWDER_DYE:%s]\n", world->raws.language.colors[mat->powder_dye]->id.c_str());
out.print("\t[POWDER_DYE:%s]\n", world->raws.descriptors.colors[mat->powder_dye]->id.c_str());
if (mat->soap_level != -0)
out.print("\t[SOAP_LEVEL:%o]\n", mat->soap_level);
@ -262,4 +262,4 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
DFhackCExport command_result plugin_shutdown ( Core * c )
{
return CR_OK;
}
}

@ -1303,7 +1303,7 @@ struct preference_map
}
case (T_type::LikeShape):
label += "Shape :" + raws.language.shapes[pref.shape_id]->name_plural;
label += "Shape :" + raws.descriptors.shapes[pref.shape_id]->name_plural;
break;
case (T_type::LikeTree):
@ -1314,7 +1314,7 @@ struct preference_map
}
case (T_type::LikeColor):
label += "Color :" + raws.language.colors[pref.color_id]->name;
label += "Color :" + raws.descriptors.colors[pref.color_id]->name;
break;
case (T_type::LikePoeticForm):

@ -74,7 +74,7 @@ namespace embark_assist {
bool geo_survey(embark_assist::defs::geo_data *geo_summary) {
color_ostream_proxy out(Core::getInstance().getConsole());
df::world_data *world_data = world->world_data;
auto reactions = world->raws.reactions;
auto reactions = df::reaction::get_vector();
bool non_soil_found;
uint16_t size;

@ -397,7 +397,7 @@ static bool find_reactions(color_ostream &out)
{
reactions.clear();
auto &rlist = world->raws.reactions;
auto &rlist = df::reaction::get_vector();
for (size_t i = 0; i < rlist.size(); i++)
{

@ -1 +1 @@
Subproject commit 3ff3f05da53077dd9e67c1eef672427a2bfd95ea
Subproject commit fbbf9e46458e41707c27f2a4438452a579490db1

@ -583,11 +583,11 @@ class jlfunc_custom : public jlfunc
public:
df::unit_labor get_labor(df::job* j)
{
for (auto r = world->raws.reactions.begin(); r != world->raws.reactions.end(); r++)
for (auto r : df::reaction::get_vector())
{
if ((*r)->code == j->reaction_name)
if (r->code == j->reaction_name)
{
df::job_skill skill = (*r)->skill;
df::job_skill skill = r->skill;
df::unit_labor labor = ENUM_ATTR(job_skill, labor, skill);
return labor;
}
@ -894,11 +894,11 @@ df::unit_labor JobLaborMapper::find_job_labor(df::job* j)
{
if (j->job_type == df::job_type::CustomReaction)
{
for (auto r = world->raws.reactions.begin(); r != world->raws.reactions.end(); r++)
for (auto r : df::reaction::get_vector())
{
if ((*r)->code == j->reaction_name)
if (r->code == j->reaction_name)
{
df::job_skill skill = (*r)->skill;
df::job_skill skill = r->skill;
return ENUM_ATTR(job_skill, labor, skill);
}
}

@ -416,13 +416,13 @@ function collect_reactions()
end
for _, reaction_id in ipairs(entity.entity_raw.workshops.permitted_reaction_id) do
local reaction = df.global.world.raws.reactions[reaction_id]
local reaction = df.global.world.raws.reactions.reactions[reaction_id]
local name = string.gsub(reaction.name, "^.", string.upper)
reaction_entry(result, job_types.CustomReaction, {reaction_name = reaction.code}, name)
end
-- Reactions generated by the game.
for _, reaction in ipairs(df.global.world.raws.reactions) do
for _, reaction in ipairs(df.global.world.raws.reactions.reactions) do
if reaction.source_enid == entity.id then
local name = string.gsub(reaction.name, "^.", string.upper)
reaction_entry(result, job_types.CustomReaction, {reaction_name = reaction.code}, name)

@ -29,7 +29,7 @@ end
local function get_reaction(name)
if not reaction_id_cache then
reaction_id_cache = {}
for i,v in ipairs(df.global.world.raws.reactions) do
for i,v in ipairs(df.global.world.raws.reactions.reactions) do
reaction_id_cache[v.code] = i
end
end

@ -227,7 +227,7 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
case df::enums::item_type::STATUE:
{
VIRTUAL_CAST_VAR(statue, df::item_statuest, DfItem);
df::art_image_chunk * chunk = NULL;
GET_ART_IMAGE_CHUNK GetArtImageChunk = reinterpret_cast<GET_ART_IMAGE_CHUNK>(Core::getInstance().vinfo->getAddress("get_art_image_chunk"));
if (GetArtImageChunk)
@ -528,9 +528,9 @@ DFHack::command_result GetItemList(DFHack::color_ostream &stream, const DFHack::
case df::enums::item_type::GEM:
case df::enums::item_type::SMALLGEM:
{
for (int i = 0; i < world->raws.language.shapes.size(); i++)
for (int i = 0; i < world->raws.descriptors.shapes.size(); i++)
{
auto shape = world->raws.language.shapes[i];
auto shape = world->raws.descriptors.shapes[i];
if (shape->gems_use.whole == 0)
continue;
mat_def = out->add_material_list();

@ -388,7 +388,7 @@ void ConvertDfColor(int16_t in[3], RemoteFortressReader::ColorDefinition * out)
void ConvertDFColorDescriptor(int16_t index, RemoteFortressReader::ColorDefinition * out)
{
df::descriptor_color *color = world->raws.language.colors[index];
df::descriptor_color *color = world->raws.descriptors.colors[index];
out->set_red(color->red * 255);
out->set_green(color->green * 255);
out->set_blue(color->blue * 255);
@ -871,7 +871,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)] < raws->language.colors.size())
if (raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)] < raws->descriptors.colors.size())
{
ConvertDFColorDescriptor(raws->inorganics[i]->material.state_color[GetState(&raws->inorganics[i]->material)], mat_def->mutable_state_color());
}
@ -889,7 +889,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(j);
mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])] < raws->language.colors.size())
if (raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])] < raws->descriptors.colors.size())
{
ConvertDFColorDescriptor(raws->mat_table.builtin[i]->state_color[GetState(raws->mat_table.builtin[i])], mat_def->mutable_state_color());
}
@ -906,7 +906,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->language.colors.size())
if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->descriptors.colors.size())
{
ConvertDFColorDescriptor(creature->material[j]->state_color[GetState(creature->material[j])], mat_def->mutable_state_color());
}
@ -928,9 +928,9 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
// id << "HF" << i << mat.getToken();
// mat_def->set_id(id.str());
// mat_def->set_name(mat.toString()); //find the name at cave temperature;
// if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->language.colors.size())
// if (creature->material[j]->state_color[GetState(creature->material[j])] < raws->descriptors.colors.size())
// {
// df::descriptor_color *color = raws->language.colors[creature->material[j]->state_color[GetState(creature->material[j])]];
// df::descriptor_color *color = raws->descriptors.colors[creature->material[j]->state_color[GetState(creature->material[j])]];
// mat_def->mutable_state_color()->set_red(color->red * 255);
// mat_def->mutable_state_color()->set_green(color->green * 255);
// mat_def->mutable_state_color()->set_blue(color->blue * 255);
@ -948,7 +948,7 @@ static command_result GetMaterialList(color_ostream &stream, const EmptyMessage
mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(mat.getToken());
mat_def->set_name(mat.toString()); //find the name at cave temperature;
if (plant->material[j]->state_color[GetState(plant->material[j])] < raws->language.colors.size())
if (plant->material[j]->state_color[GetState(plant->material[j])] < raws->descriptors.colors.size())
{
ConvertDFColorDescriptor(plant->material[j]->state_color[GetState(plant->material[j])], mat_def->mutable_state_color());
}
@ -2753,13 +2753,13 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe
for (int l = 0; l < orig_mod->pattern_index.size(); l++)
{
auto orig_pattern = world->raws.language.patterns[orig_mod->pattern_index[l]];
auto orig_pattern = world->raws.descriptors.patterns[orig_mod->pattern_index[l]];
auto send_pattern = send_mod->add_patterns();
for (int m = 0; m < orig_pattern->colors.size(); m++)
{
auto send_color = send_pattern->add_colors();
auto orig_color = world->raws.language.colors[orig_pattern->colors[m]];
auto orig_color = world->raws.descriptors.colors[orig_pattern->colors[m]];
send_color->set_red(orig_color->red * 255.0);
send_color->set_green(orig_color->green * 255.0);
send_color->set_blue(orig_color->blue * 255.0);
@ -3050,9 +3050,9 @@ static command_result GetLanguage(color_ostream & stream, const EmptyMessage * i
if (!world)
return CR_FAILURE;
for (int i = 0; i < world->raws.language.shapes.size(); i++)
for (int i = 0; i < world->raws.descriptors.shapes.size(); i++)
{
auto shape = world->raws.language.shapes[i];
auto shape = world->raws.descriptors.shapes[i];
auto netShape = out->add_shapes();
netShape->set_id(shape->id);
netShape->set_tile(shape->tile);

@ -1 +1 @@
Subproject commit da3065a35362a8ae3190234792c8cd14fffac9dd
Subproject commit 4c3728880a1b8d94046283be28d2078aac9fbe05

@ -1 +1 @@
Subproject commit 9d8f2096fc4c247299cbc94c6a8d756f31690a4b
Subproject commit be21a2a52084e838e4b5eb1f296a03d5592389f8