From 9d4d0b195a3fbf3c1e672deb0be87c81b9d0cd66 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 22 Jan 2020 17:33:39 +0100 Subject: [PATCH 01/75] Added switches for farm seeds and plant counts --- docs/changelog.txt | 5 ++ plugins/getplants.cpp | 198 +++++++++++++++++++++++++++++++++++------- 2 files changed, 172 insertions(+), 31 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 5c1b37561..41b371a8e 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -35,6 +35,11 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ======== IMPORTANT: rename this, and add a new "future" section, BEFORE ======== ======== making a new DFHack release! ======== ================================================================================ +# Future + +## Misc Improvements +- `getplants`: added switches for designations for farming seeds and for max number designated per plant + # 0.44.12-r3 ## New Plugins diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index ebd64d8d1..11717b36b 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -38,16 +38,53 @@ enum class selectability { Unselected }; -//selectability selectablePlant(color_ostream &out, const df::plant_raw *plant) -selectability selectablePlant(const df::plant_raw *plant) +// Determination of whether seeds can be collected is somewhat messy: +// - Growths of type SEEDS are collected only if they are edible either raw or cooked. +// - Growths of type PLANT_GROWTH are collected provided the STOCKPILE_PLANT_GROWTH +// flag is set. +// The two points above were determined through examination of the DF code, while the ones +// below were determined through examination of the behavior of bugged, working, and +// RAW manipulated shrubs on embarks. +// - If seeds are defined as explicit growths, they are the source of seeds, overriding +// the default STRUCTURAL part as the source. +// - If a growth has the reaction that extracts seeds as a side effect of other +// processing (brewing, eating raw, etc.), this overrides the STRUCTURAL part as the +// source of seeds. However, for some reason it does not produce seeds from eating +// raw growths unless the structural part is collected (at least for shrubs: other +// processing was not examined). +// - If a growth has a (non vanilla) reaction that produces seeds, seeds are produced, +// provided there is something (such as a workshop order) that triggers it. +// The code below is satisfied with detection of a seed producing reaction, and does not +// detect the bugged case where a seed extraction process is defined but doesn't get +// triggered. Such a process can be triggered either as a side effect of other +// processing, or as a workshop reaction, and it would be overkill for this code to +// try to determine if a workshop reaction exists and has been permitted for the played +// race. +// There are two bugged cases of this in the current vanilla RAWs: +// Both Red Spinach and Elephant-Head Amaranth have the seed extraction reaction +// explicitly specified for the structural part, but no other use for it. This causes +// these parts to be collected (a valid reaction is defined), but remain unusable. This +// is one ofthe issues in bug 9640 on the bug tracker (the others cases are detected and +// result in the plants not being usable for farming or even collectable at all). + +//selectability selectablePlant(color_ostream &out, const df::plant_raw *plant, bool farming) +selectability selectablePlant(const df::plant_raw *plant, bool farming) { const DFHack::MaterialInfo basic_mat = DFHack::MaterialInfo(plant->material_defs.type_basic_mat, plant->material_defs.idx_basic_mat); bool outOfSeason = false; + selectability result = selectability::Nonselectable; if (plant->flags.is_set(plant_raw_flags::TREE)) { // out.print("%s is a selectable tree\n", plant->id.c_str()); - return selectability::Selectable; + if (farming) + { + return selectability::Nonselectable; + } + else + { + return selectability::Selectable; + } } else if (plant->flags.is_set(plant_raw_flags::GRASS)) { @@ -55,11 +92,26 @@ selectability selectablePlant(const df::plant_raw *plant) return selectability::Grass; } + if (farming && plant->material_defs.type_seed == -1) + { + return selectability::Nonselectable; + } + if (basic_mat.material->flags.is_set(material_flags::EDIBLE_RAW) || basic_mat.material->flags.is_set(material_flags::EDIBLE_COOKED)) { // out.print("%s is edible\n", plant->id.c_str()); - return selectability::Selectable; + if (farming) + { + if (basic_mat.material->flags.is_set(material_flags::EDIBLE_RAW)) + { + result = selectability::Selectable; + } + } + else + { + return selectability::Selectable; + } } if (plant->flags.is_set(plant_raw_flags::THREAD) || @@ -69,14 +121,28 @@ selectability selectablePlant(const df::plant_raw *plant) plant->flags.is_set(plant_raw_flags::EXTRACT_STILL_VIAL)) { // out.print("%s is thread/mill/extract\n", plant->id.c_str()); - return selectability::Selectable; + if (farming) + { + result = selectability::Selectable; + } + else + { + return selectability::Selectable; + } } if (basic_mat.material->reaction_product.id.size() > 0 || basic_mat.material->reaction_class.size() > 0) { // out.print("%s has a reaction\n", plant->id.c_str()); - return selectability::Selectable; + if (farming) + { + result = selectability::Selectable; + } + else + { + return selectability::Selectable; + } } for (size_t i = 0; i < plant->growths.size(); i++) @@ -91,16 +157,37 @@ selectability selectablePlant(const df::plant_raw *plant) (plant->growths[i]->item_type == df::item_type::PLANT_GROWTH && growth_mat.material->flags.is_set(material_flags::LEAF_MAT))) // Will change name to STOCKPILE_PLANT_GROWTH any day now... { + bool seedSource = plant->growths[i]->item_type == df::item_type::SEEDS; + + if (plant->growths[i]->item_type == df::item_type::PLANT_GROWTH) + { + for (size_t k = 0; growth_mat.material->reaction_product.material.mat_type.size(); k++) + { + if (growth_mat.material->reaction_product.material.mat_type[k] == plant->material_defs.type_seed && + growth_mat.material->reaction_product.material.mat_index[k] == plant->material_defs.idx_seed) + { + seedSource = true; + break; + } + } + } + if (*cur_year_tick >= plant->growths[i]->timing_1 && (plant->growths[i]->timing_2 == -1 || *cur_year_tick <= plant->growths[i]->timing_2)) { // out.print("%s has an edible seed or a stockpile growth\n", plant->id.c_str()); - return selectability::Selectable; + if (!farming || seedSource) + { + return selectability::Selectable; + } } else { - outOfSeason = true; + if (!farming || seedSource) + { + outOfSeason = true; + } } } } @@ -133,7 +220,7 @@ selectability selectablePlant(const df::plant_raw *plant) else { // out.printerr("%s cannot be gathered\n", plant->id.c_str()); - return selectability::Nonselectable; + return result; } } @@ -143,8 +230,8 @@ command_result df_getplants (color_ostream &out, vector & parameters) std::vector plantSelections; std::vector collectionCount; set plantNames; - bool deselect = false, exclude = false, treesonly = false, shrubsonly = false, all = false, verbose = false; - + bool deselect = false, exclude = false, treesonly = false, shrubsonly = false, all = false, verbose = false, farming = false; + size_t maxCount = 999999; int count = 0; plantSelections.resize(world->raws.plants.all.size()); @@ -160,20 +247,43 @@ command_result df_getplants (color_ostream &out, vector & parameters) for (size_t i = 0; i < parameters.size(); i++) { - if(parameters[i] == "help" || parameters[i] == "?") + if (parameters[i] == "help" || parameters[i] == "?") return CR_WRONG_USAGE; - else if(parameters[i] == "-t") + else if (parameters[i] == "-t") treesonly = true; - else if(parameters[i] == "-s") + else if (parameters[i] == "-s") shrubsonly = true; - else if(parameters[i] == "-c") + else if (parameters[i] == "-c") deselect = true; - else if(parameters[i] == "-x") + else if (parameters[i] == "-x") exclude = true; - else if(parameters[i] == "-a") + else if (parameters[i] == "-a") all = true; - else if(parameters[i] == "-v") + else if (parameters[i] == "-v") verbose = true; + else if (parameters[i] == "-f") + farming = true; + else if (parameters[i] == "-n") + { + if (parameters.size() > i + 1) + { + maxCount = atoi(parameters[i + 1].c_str()); + if (maxCount >= 1) + { + i++; // We've consumed the next parameter, so we need to progress the iterator. + } + else + { + out.printerr("-n requires a positive integer parameter!\n"); + return CR_WRONG_USAGE; + } + } + else + { + out.printerr("-n requires a positive integer parameter!\n"); + return CR_WRONG_USAGE; + } + } else plantNames.insert(parameters[i]); } @@ -182,6 +292,11 @@ command_result df_getplants (color_ostream &out, vector & parameters) out.printerr("Cannot specify both -t and -s at the same time!\n"); return CR_WRONG_USAGE; } + if (treesonly && farming) + { + out.printerr("Cannot specify both -t and -f at the same time!\n"); + return CR_WRONG_USAGE; + } if (all && exclude) { out.printerr("Cannot specify both -a and -x at the same time!\n"); @@ -200,14 +315,14 @@ command_result df_getplants (color_ostream &out, vector & parameters) df::plant_raw *plant = world->raws.plants.all[i]; if (all) { -// plantSelections[i] = selectablePlant(out, plant); - plantSelections[i] = selectablePlant(plant); +// plantSelections[i] = selectablePlant(out, plant, farming); + plantSelections[i] = selectablePlant(plant, farming); } else if (plantNames.find(plant->id) != plantNames.end()) { plantNames.erase(plant->id); -// plantSelections[i] = selectablePlant(out, plant); - plantSelections[i] = selectablePlant(plant); +// plantSelections[i] = selectablePlant(out, plant, farming); + plantSelections[i] = selectablePlant(plant, farming); switch (plantSelections[i]) { case selectability::Grass: @@ -215,7 +330,14 @@ command_result df_getplants (color_ostream &out, vector & parameters) break; case selectability::Nonselectable: - out.printerr("%s does not have any parts that can be gathered\n", plant->id.c_str()); + if (farming) + { + out.printerr("%s does not have any parts that can be gathered for seeds for farming\n", plant->id.c_str()); + } + else + { + out.printerr("%s does not have any parts that can be gathered\n", plant->id.c_str()); + } break; case selectability::OutOfSeason: @@ -255,8 +377,8 @@ command_result df_getplants (color_ostream &out, vector & parameters) for (size_t i = 0; i < world->raws.plants.all.size(); i++) { df::plant_raw *plant = world->raws.plants.all[i]; -// switch (selectablePlant(out, plant)) - switch (selectablePlant(plant)) +// switch (selectablePlant(out, plant, farming)) + switch (selectablePlant(plant, farming)) { case selectability::Grass: case selectability::Nonselectable: @@ -264,13 +386,21 @@ command_result df_getplants (color_ostream &out, vector & parameters) case selectability::OutOfSeason: { - out.print("* (shrub) %s - %s is out of season\n", plant->id.c_str(), plant->name.c_str()); + if (!treesonly) + { + out.print("* (shrub) %s - %s is out of season\n", plant->id.c_str(), plant->name.c_str()); + } break; } case selectability::Selectable: { - out.print("* (%s) %s - %s\n", plant->flags.is_set(plant_raw_flags::TREE) ? "tree" : "shrub", plant->id.c_str(), plant->name.c_str()); + if ((treesonly && plant->flags.is_set(plant_raw_flags::TREE)) || + (shrubsonly && !plant->flags.is_set(plant_raw_flags::TREE)) || + (!treesonly && !shrubsonly)) // 'farming' weeds out trees when determining selectability, so no need to test that explicitly + { + out.print("* (%s) %s - %s\n", plant->flags.is_set(plant_raw_flags::TREE) ? "tree" : "shrub", plant->id.c_str(), plant->name.c_str()); + } break; } @@ -311,6 +441,8 @@ command_result df_getplants (color_ostream &out, vector & parameters) continue; if (cur->designation[x][y].bits.hidden) continue; + if (collectionCount[plant->material] >= maxCount) + continue; if (deselect && Designations::unmarkPlant(plant)) { collectionCount[plant->material]++; @@ -350,12 +482,16 @@ DFhackCExport command_result plugin_init ( color_ostream &out, vector Date: Wed, 22 Jan 2020 19:41:06 +0100 Subject: [PATCH 02/75] Updated getplants documentation --- docs/Plugins.rst | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/Plugins.rst b/docs/Plugins.rst index ac1f7dae8..d8d8bb85e 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -2298,16 +2298,19 @@ by spaces. Options: -:``-t``: Select trees only (exclude shrubs) -:``-s``: Select shrubs only (exclude trees) -:``-c``: Clear designations instead of setting them -:``-x``: Apply selected action to all plants except those specified (invert +:``-t``: Tree: Select trees only (exclude shrubs) +:``-s``: Shrub: Select shrubs only (exclude trees) +:``-f``: Farming: Designate only shrubs that yield seeds for farming. Implies -s +:``-c``: Clear: Clear designations instead of setting them +:``-x``: eXcept: Apply selected action to all plants except those specified (invert selection) -:``-a``: Select every type of plant (obeys ``-t``/``-s``) -:``-v``: Lists the number of (un)designations per plant +:``-a``: All: Select every type of plant (obeys ``-t``/``-s``/``-f``) +:``-v``: Verbose: Lists the number of (un)designations per plant +:``-n *``: Number: Designate up to * (an integer number) plants of each species -Specifying both ``-t`` and ``-s`` will have no effect. If no plant IDs are specified, -all valid plant IDs will be listed. +Specifying both ``-t`` and ``-s`` or ``-f`` will have no effect. If no plant IDs are +specified, all valid plant IDs will be listed, with ``-t``, ``-s``, and ``-f`` +restricting the list to trees, shrubs, and farmable shrubs, respectively. .. note:: @@ -2317,7 +2320,13 @@ all valid plant IDs will be listed. This leads to some shrubs being designated when they shouldn't be, causing a plant gatherer to walk there and do nothing (except clearing the designation). See :issue:`1479` for details. - + + The implementation another known deficiency: it's incapable of detecting that + RAW definitions that specify a seed extraction reaction for the structural part + but has no other use for it cannot actually yield any seeds, as the part is + never used (parts of bug tracker report 6940, e.g. Red Spinach), even though DF + collects it, unless there's a workshop reaction to do it (which there isn't + in vanilla). .. _infiniteSky: From c6bbf39c6c906a1600b9597f96da2760d6be7dd4 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 25 Jan 2020 12:43:02 +0100 Subject: [PATCH 03/75] Issue #1262. Added Items::getTitle and used in stocks --- docs/changelog.txt | 8 ++++ library/include/modules/Items.h | 5 ++ library/modules/Items.cpp | 81 +++++++++++++++++++++++++++++++++ plugins/stocks.cpp | 14 ++++-- 4 files changed, 105 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 5c1b37561..9e4bef7a0 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -35,6 +35,14 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ======== IMPORTANT: rename this, and add a new "future" section, BEFORE ======== ======== making a new DFHack release! ======== ================================================================================ +# Future + +## Fixes +- `stocks`: fixed display of titles by using the new ``Items::`getTitle`` operation before the original one, issue 1262 + +## API +- Added ``Items::`getTitle`` to get titles of "books". Catches titles buried in improvements, unlike getDescription. + # 0.44.12-r3 ## New Plugins diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index 776e935eb..e232bc953 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -159,6 +159,11 @@ DFHACK_EXPORT df::unit *getHolderUnit(df::item *item); /// Returns the true position of the item. DFHACK_EXPORT df::coord getPosition(df::item *item); +/// Returns the title of a codex or "tool", either as the codex title or as the title of the +/// first page or writing it has that has a non blank title. An empty string is returned if +/// no title is found (which is the casee for everything that isn't a "book"). +DFHACK_EXPORT std::string getTitle(df::item *item); + /// Returns the description string of the item. DFHACK_EXPORT std::string getDescription(df::item *item, int type = 0, bool decorate = false); diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index a1b4ace4d..f102bcc78 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -59,6 +59,8 @@ using namespace std; #include "df/general_ref_unit_holderst.h" #include "df/historical_entity.h" #include "df/item.h" +#include "df/item_bookst.h" +#include "df/item_toolst.h" #include "df/item_type.h" #include "df/itemdef_ammost.h" #include "df/itemdef_armorst.h" @@ -74,6 +76,9 @@ using namespace std; #include "df/itemdef_toyst.h" #include "df/itemdef_trapcompst.h" #include "df/itemdef_weaponst.h" +#include "df/itemimprovement.h" +#include "df/itemimprovement_pagesst.h" +#include "df/itemimprovement_writingst.h" #include "df/job_item.h" #include "df/mandate.h" #include "df/map_block.h" @@ -90,6 +95,7 @@ using namespace std; #include "df/viewscreen_itemst.h" #include "df/world.h" #include "df/world_site.h" +#include "df/written_content.h" using namespace DFHack; using namespace df::enums; @@ -681,6 +687,81 @@ static void addQuality(std::string &tmp, int quality) } } +// It's not impossible the functionality of this operation is provided by one of the unmapped item functions. +std::string Items::getTitle(df::item *item) +{ + CHECK_NULL_POINTER(item); + + std::string tmp; + + if (item->getType() == df::item_type::BOOK) + { + if (virtual_cast(item)->title != "") + { + return virtual_cast(item)->title; + } + else + { + for (size_t i = 0; i < virtual_cast(item)->improvements.size(); i++) + { + if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::PAGES) + { + for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + { + df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; + if (contents->title != "") + { + return contents->title; + } + } + } + else if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::WRITING) + { + for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + { + df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; + if (contents->title != "") + { + return contents->title; + } + } + } + } + } + } + else if (item->getType() == df::item_type::TOOL && + virtual_cast(item)->hasToolUse(df::tool_uses::CONTAIN_WRITING)) + { + for (size_t i = 0; i < virtual_cast(item)->improvements.size(); i++) + { + if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::PAGES) + { + for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + { + df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; + if (contents->title != "") + { + return contents->title; + } + } + } + else if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::WRITING) + { + for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + { + df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; + if (contents->title != "") + { + return contents->title; + } + } + } + } + } + + return ""; +} + std::string Items::getDescription(df::item *item, int type, bool decorate) { CHECK_NULL_POINTER(item); diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index b5831d159..e44cbb431 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -30,7 +30,7 @@ #include "df/ui_advmode.h" DFHACK_PLUGIN("stocks"); -#define PLUGIN_VERSION 0.12 +#define PLUGIN_VERSION 0.13 REQUIRE_GLOBAL(world); @@ -248,7 +248,11 @@ static string get_keywords(df::item *item) static string get_item_label(df::item *item, bool trim = false) { - auto label = Items::getDescription(item, 0, false); + auto label = Items::getTitle(item); + if (label == "") + { + label = Items::getDescription(item, 0, false); + } if (trim && item->getType() == item_type::BIN) { auto pos = label.find("<#"); @@ -562,7 +566,11 @@ class StockListColumn : public ListColumn if (!ListColumn::showEntry(entry, search_tokens)) return false; - string item_name = toLower(Items::getDescription(entry->elem->entries[0], 0, false)); + string item_name = toLower(Items::getTitle(entry->elem->entries[0])); + if (item_name == "") + { + item_name = toLower(Items::getDescription(entry->elem->entries[0], 0, false)); + } if ((match_start || match_end) && raw_search.size() > item_name.size()) return false; From 876ac6c056a0a9f0ce91ea2a06fe46efa8f01953 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 25 Jan 2020 21:46:10 +0100 Subject: [PATCH 04/75] Renamed to getBookTitle, cut down on virtual_cast --- library/include/modules/Items.h | 2 +- library/modules/Items.cpp | 56 ++++++++++++++++++--------------- plugins/stocks.cpp | 4 +-- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index e232bc953..838104bfe 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -162,7 +162,7 @@ DFHACK_EXPORT df::coord getPosition(df::item *item); /// Returns the title of a codex or "tool", either as the codex title or as the title of the /// first page or writing it has that has a non blank title. An empty string is returned if /// no title is found (which is the casee for everything that isn't a "book"). -DFHACK_EXPORT std::string getTitle(df::item *item); +DFHACK_EXPORT std::string getBookTitle(df::item *item); /// Returns the description string of the item. DFHACK_EXPORT std::string getDescription(df::item *item, int type = 0, bool decorate = false); diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index f102bcc78..14700f9e7 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -688,7 +688,7 @@ static void addQuality(std::string &tmp, int quality) } // It's not impossible the functionality of this operation is provided by one of the unmapped item functions. -std::string Items::getTitle(df::item *item) +std::string Items::getBookTitle(df::item *item) { CHECK_NULL_POINTER(item); @@ -696,30 +696,32 @@ std::string Items::getTitle(df::item *item) if (item->getType() == df::item_type::BOOK) { - if (virtual_cast(item)->title != "") + auto book = virtual_cast(item); + + if (book->title != "") { - return virtual_cast(item)->title; + return book->title; } else { - for (size_t i = 0; i < virtual_cast(item)->improvements.size(); i++) + for (size_t i = 0; i < book->improvements.size(); i++) { - if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::PAGES) + if (auto page = virtual_cast(book->improvements[i])) { - for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + for (size_t k = 0; k < page->contents.size(); k++) { - df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; + df::written_content *contents = world->written_contents.all[page->contents[k]]; if (contents->title != "") { return contents->title; } } } - else if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::WRITING) + else if (auto writing = virtual_cast(book->improvements[i])) { - for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + for (size_t k = 0; k < writing->contents.size(); k++) { - df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; + df::written_content *contents = world->written_contents.all[writing->contents[k]]; if (contents->title != "") { return contents->title; @@ -729,30 +731,34 @@ std::string Items::getTitle(df::item *item) } } } - else if (item->getType() == df::item_type::TOOL && - virtual_cast(item)->hasToolUse(df::tool_uses::CONTAIN_WRITING)) + else if (item->getType() == df::item_type::TOOL) { - for (size_t i = 0; i < virtual_cast(item)->improvements.size(); i++) + auto book = virtual_cast(item); + + if (book->hasToolUse(df::tool_uses::CONTAIN_WRITING)) { - if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::PAGES) + for (size_t i = 0; i < book->improvements.size(); i++) { - for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + if (auto page = virtual_cast(book->improvements[i])) { - df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; - if (contents->title != "") + for (size_t k = 0; k < page->contents.size(); k++) { - return contents->title; + df::written_content *contents = world->written_contents.all[page->contents[k]]; + if (contents->title != "") + { + return contents->title; + } } } - } - else if (virtual_cast(item)->improvements[i]->getType() == df::improvement_type::WRITING) - { - for (size_t k = 0; k < virtual_cast(virtual_cast(item)->improvements[i])->contents.size(); k++) + else if (auto writing = virtual_cast(book->improvements[i])) { - df::written_content *contents = world->written_contents.all[virtual_cast(virtual_cast(item)->improvements[i])->contents[k]]; - if (contents->title != "") + for (size_t k = 0; k < writing->contents.size(); k++) { - return contents->title; + df::written_content *contents = world->written_contents.all[writing->contents[k]]; + if (contents->title != "") + { + return contents->title; + } } } } diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index e44cbb431..4439d820a 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -248,7 +248,7 @@ static string get_keywords(df::item *item) static string get_item_label(df::item *item, bool trim = false) { - auto label = Items::getTitle(item); + auto label = Items::getBookTitle(item); if (label == "") { label = Items::getDescription(item, 0, false); @@ -566,7 +566,7 @@ class StockListColumn : public ListColumn if (!ListColumn::showEntry(entry, search_tokens)) return false; - string item_name = toLower(Items::getTitle(entry->elem->entries[0])); + string item_name = toLower(Items::getBookTitle(entry->elem->entries[0])); if (item_name == "") { item_name = toLower(Items::getDescription(entry->elem->entries[0], 0, false)); From 121497a466df789cac5a6d9ecf206538c01d0cb7 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sun, 26 Jan 2020 11:47:47 +0100 Subject: [PATCH 05/75] Propagated getBookTitle to Lua --- docs/Lua API.rst | 6 ++++++ docs/changelog.txt | 4 ++-- library/LuaApi.cpp | 1 + library/include/modules/Items.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/Lua API.rst b/docs/Lua API.rst index a4130096b..d7e94b92a 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -1292,6 +1292,12 @@ Items module Returns true *x,y,z* of the item, or *nil* if invalid; may be not equal to item.pos if in inventory. +* ``dfhack.items.getBookTitle(item)`` + + Returns the title of the "book" item, or an empty string if the item isn't a "book" or it doesn't + have a title. A "book" is a codex or a tool item that has page or writings improvements, such as + scrolls and quires. + * ``dfhack.items.getDescription(item, type[, decorate])`` Returns the string description of the item, as produced by the ``getItemDescription`` diff --git a/docs/changelog.txt b/docs/changelog.txt index 9e4bef7a0..36ac237be 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,10 +38,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## Fixes -- `stocks`: fixed display of titles by using the new ``Items::`getTitle`` operation before the original one, issue 1262 +- `stocks`: fixed display of titles by using the new ``Items::getBookTitle`` operation before the original one ## API -- Added ``Items::`getTitle`` to get titles of "books". Catches titles buried in improvements, unlike getDescription. +- Added ``Items::getBookTitle`` to get titles of "books". Catches titles buried in improvements, unlike getDescription. # 0.44.12-r3 diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 7c3ef965d..1d127930e 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1766,6 +1766,7 @@ static const LuaWrapper::FunctionReg dfhack_items_module[] = { WRAPM(Items, getContainer), WRAPM(Items, getHolderBuilding), WRAPM(Items, getHolderUnit), + WRAPM(Items, getBookTitle), WRAPM(Items, getDescription), WRAPM(Items, isCasteMaterial), WRAPM(Items, getSubtypeCount), diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index 838104bfe..33feea222 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -161,7 +161,7 @@ DFHACK_EXPORT df::coord getPosition(df::item *item); /// Returns the title of a codex or "tool", either as the codex title or as the title of the /// first page or writing it has that has a non blank title. An empty string is returned if -/// no title is found (which is the casee for everything that isn't a "book"). +/// no title is found (which is the case for everything that isn't a "book"). DFHACK_EXPORT std::string getBookTitle(df::item *item); /// Returns the description string of the item. From 63a26b987de676d2cdf81974ac9a393abcfbcf8e Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 1 Apr 2020 11:16:24 +0200 Subject: [PATCH 06/75] Fix issue #1528 --- library/modules/Translation.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/library/modules/Translation.cpp b/library/modules/Translation.cpp index d836e6122..e05154b44 100644 --- a/library/modules/Translation.cpp +++ b/library/modules/Translation.cpp @@ -180,14 +180,11 @@ string Translation::TranslateName(const df::language_name * name, bool inEnglish word.append(*world->raws.language.translations[name->language]->words[name->words[1]]); addNameWord(out, word); } - if (name->words[5] >= 0) - { - word.clear(); - for (int i = 2; i <= 5; i++) - if (name->words[i] >= 0) - word.append(*world->raws.language.translations[name->language]->words[name->words[i]]); - addNameWord(out, word); - } + word.clear(); + for (int i = 2; i <= 5; i++) + if (name->words[i] >= 0) + word.append(*world->raws.language.translations[name->language]->words[name->words[i]]); + addNameWord(out, word); if (name->words[6] >= 0) { word.clear(); @@ -206,18 +203,17 @@ string Translation::TranslateName(const df::language_name * name, bool inEnglish word.append(world->raws.language.words[name->words[1]]->forms[name->parts_of_speech[1]]); addNameWord(out, word); } - if (name->words[5] >= 0) + if (name->words[2] >= 0 || name->words[3] >= 0 || name->words[4] >= 0 || name->words[5] >= 0) { if (out.length() > 0) out.append(" the"); else out.append("The"); - - for (int i = 2; i <= 5; i++) - { - if (name->words[i] >= 0) - addNameWord(out, world->raws.language.words[name->words[i]]->forms[name->parts_of_speech[i]]); - } + } + for (int i = 2; i <= 5; i++) + { + if (name->words[i] >= 0) + addNameWord(out, world->raws.language.words[name->words[i]]->forms[name->parts_of_speech[i]]); } if (name->words[6] >= 0) { From 897e78b174d62d5782317b1a6ebc0e1c0fab4749 Mon Sep 17 00:00:00 2001 From: ymber Date: Wed, 1 Apr 2020 15:09:51 +0100 Subject: [PATCH 07/75] Activate autodump in default config --- dfhack.init-example | 1 + 1 file changed, 1 insertion(+) diff --git a/dfhack.init-example b/dfhack.init-example index d8cf832c7..0fd445fff 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -245,6 +245,7 @@ enable \ dwarfmonitor \ mousequery \ autogems \ + autodump \ automelt \ autotrade \ buildingplan \ From a0e2abe20a1906f5449be6d931e7b53f1b4f7e21 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 4 Apr 2020 14:00:26 +0200 Subject: [PATCH 08/75] Units update need coordination with structure identity --- library/modules/Units.cpp | 32 ++++++++++++------- .../remotefortressreader.cpp | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 3ac235203..07c3a7acf 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -58,6 +58,7 @@ using namespace std; #include "df/entity_position_assignment.h" #include "df/entity_raw.h" #include "df/entity_raw_flags.h" +#include "df/identity_type.h" #include "df/game_mode.h" #include "df/histfig_entity_link_positionst.h" #include "df/historical_entity.h" @@ -200,13 +201,23 @@ void Units::setNickname(df::unit *unit, std::string nick) if (auto identity = getFigureIdentity(figure)) { - auto id_hfig = df::historical_figure::find(identity->histfig_id); + df::historical_figure *id_hfig = NULL; + + switch (identity->type) { + case df::identity_type::Hiding_Curse: + case df::identity_type::Identity: + case df::identity_type::False_Identity: + break; // We want the nickname to end up in the identity + + case df::identity_type::Unk_1: // Guess, but that's how it worked in the past + case df::identity_type::Demon_Alias: + case df::identity_type::Unk_4: // Pure guess, as this is a new case, still unseen + id_hfig = df::historical_figure::find(identity->histfig_nemesis_id); + break; + } if (id_hfig) { - // Even DF doesn't do this bit, because it's apparently - // only used for demons masquerading as gods, so you - // can't ever change their nickname in-game. Translation::setNickname(&id_hfig->name, nick); } else @@ -247,7 +258,7 @@ bool Units::isHidingCurse(df::unit *unit) if (!unit->job.hunt_target) { auto identity = Units::getIdentity(unit); - if (identity && identity->unk_4c == 0) + if (identity && identity->type == df::identity_type::Hiding_Curse) return true; } @@ -722,12 +733,11 @@ double Units::getAge(df::unit *unit, bool true_age) double birth_time = unit->birth_year + unit->birth_time/year_ticks; double cur_time = *cur_year + *cur_year_tick / year_ticks; - if (!true_age && unit->curse_year >= 0) - { - if (auto identity = getIdentity(unit)) - { - if (identity->histfig_id < 0) - birth_time = identity->birth_year + identity->birth_second/year_ticks; + if (!true_age) { + if (auto identity = getIdentity(unit)) { + if (identity->birth_year != -1) { + birth_time = identity->birth_year + identity->birth_second / year_ticks; + } } } diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index f63ae5b2c..6ab401027 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1701,7 +1701,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques { if (auto identity = Units::getIdentity(unit)) { - if (identity->histfig_id < 0) + if (identity->histfig_nemesis_id < 0) birth_time = identity->birth_year * year_ticks + identity->birth_second; } } From c4853bd6e121ac4d0fab9b63991a3513a1de96e6 Mon Sep 17 00:00:00 2001 From: Nilsolm Date: Mon, 6 Apr 2020 19:13:18 +0200 Subject: [PATCH 09/75] Add search to justice screen --- plugins/search.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/plugins/search.cpp b/plugins/search.cpp index 43e14996a..7e72c2c1c 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -25,6 +25,7 @@ #include "df/viewscreen_buildinglistst.h" #include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_joblistst.h" +#include "df/viewscreen_justicest.h" #include "df/viewscreen_kitchenprefst.h" #include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_noblelistst.h" @@ -2327,6 +2328,85 @@ IMPLEMENT_HOOKS(df::viewscreen_layer_stone_restrictionst, stone_search); // END: Stone status screen search // +// +// START: Justice screen conviction search +// + +typedef search_generic justice_conviction_search_base; +class justice_conviction_search : public justice_conviction_search_base +{ +public: + bool can_init (df::viewscreen_justicest *screen) + { + return screen->cur_column == df::viewscreen_justicest::ConvictChoices; + } + + string get_element_description (df::unit *unit) const + { + return get_unit_description(unit); + } + + void render() const + { + print_search_option(37); + } + + vector *get_primary_list() + { + return &viewscreen->convict_choices; + } + + virtual int32_t *get_viewscreen_cursor() + { + return &viewscreen->cursor_right; + } +}; + +IMPLEMENT_HOOKS(df::viewscreen_justicest, justice_conviction_search); + +// +// END: Justice screen conviction search +// + +// +// START: Justice screen interrogation search +// + +typedef search_generic justice_interrogation_search_base; +class justice_interrogation_search : public justice_interrogation_search_base +{ +public: + bool can_init (df::viewscreen_justicest *screen) + { + return screen->cur_column == df::viewscreen_justicest::InterrogateChoices; + } + + string get_element_description (df::unit *unit) const + { + return get_unit_description(unit); + } + + void render() const + { + print_search_option(37); + } + + vector *get_primary_list() + { + return &viewscreen->interrogate_choices; + } + + virtual int32_t *get_viewscreen_cursor() + { + return &viewscreen->cursor_right; + } +}; + +IMPLEMENT_HOOKS(df::viewscreen_justicest, justice_interrogation_search); + +// +// END: Justice screen conviction search +// #define SEARCH_HOOKS \ HOOK_ACTION(unitlist_search_hook) \ @@ -2350,6 +2430,8 @@ IMPLEMENT_HOOKS(df::viewscreen_layer_stone_restrictionst, stone_search); HOOK_ACTION(location_assign_occupation_search_hook) \ HOOK_ACTION(kitchen_pref_search_hook) \ HOOK_ACTION(stone_search_hook) \ + HOOK_ACTION(justice_conviction_search_hook) \ + HOOK_ACTION(justice_interrogation_search_hook) \ DFhackCExport command_result plugin_enable ( color_ostream &out, bool enable) From f4dc5e827782f9e20ca62aacc472d706d656de18 Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 6 Apr 2020 19:57:20 -0400 Subject: [PATCH 10/75] Add an initial build workflow --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..1b8a6f715 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: Build and test + +on: [push, pull_request] + +jobs: + setup: + runs-on: ubuntu-18.04 + steps: + - name: Install dependencies + run: | + sudo apt install \ + libsdl-image1.2-dev \ + libsdl-ttf2.0-dev \ + libsdl1.2-dev \ + libxml-libxml-perl \ + libxml-libxslt-perl \ + lua5.3 \ + ninja-build \ + zlib1g-dev + sudo pip3 install --system sphinx + - name: Clone DFHack + uses: actions/checkout@v1 + - name: Set up environment + run: | + export DF_VERSION=$(sh travis/get-df-version.sh) + export DF_FOLDER="$HOME/DF/$DF_VERSION/df_linux" + - name: Download DF + run: | + sh travis/download-df.sh + - name: Git information + run: | + sh travis/git-info.sh + docs: + needs: [setup] + runs-on: ubuntu-18.04 + steps: + - name: Build docs + run: | + sphinx-build -qW -j3 . docs/html + - uses: actions/upload-artifact@master + with: + name: docs + path: docs/html From 6c9e3909fd62484d1dd75c834f49faa4baa777fd Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 6 Apr 2020 20:00:10 -0400 Subject: [PATCH 11/75] Run apt-get update first --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b8a6f715..1f3a66451 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,8 @@ jobs: steps: - name: Install dependencies run: | - sudo apt install \ + sudo apt-get update + sudo apt-get install \ libsdl-image1.2-dev \ libsdl-ttf2.0-dev \ libsdl1.2-dev \ From c8e63cf7a6fadd3216a3df3d43d602dc2bdc7d2f Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 7 Apr 2020 10:17:01 -0500 Subject: [PATCH 12/75] update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index 596e30324..a0c75e22c 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 596e3032417fb3d8dbe7d62a544ddd415ae2d89f +Subproject commit a0c75e22cdc918240e71ea738c8277499315f88d From 6b810b97a02a0e2b9fb91b7d0468e1163c9ae3c4 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 7 Apr 2020 13:46:44 -0500 Subject: [PATCH 13/75] DataDefs.h can have little a documentation --- library/include/DataDefs.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/include/DataDefs.h b/library/include/DataDefs.h index a6639f7b1..fd70b7ba8 100644 --- a/library/include/DataDefs.h +++ b/library/include/DataDefs.h @@ -68,6 +68,8 @@ namespace DFHack IDTYPE_UNION }; + // pointer flags (bitfield), stored in the count field of struct_field_info + // if mode is POINTER. enum pointer_identity_flags { PTRFLAG_IS_ARRAY = 1, PTRFLAG_HAS_BAD_POINTERS = 2, @@ -164,7 +166,12 @@ namespace DFHack // Bitfields struct bitfield_item_info { + // the name of the field, or null if the field is unnamed const char *name; + // size is positive for defined fields, zero for bits past the end + // of the field, and negative for padding on multi-bit fields + // + // ex. if bits[2].size is -2, then bits[0].size is at least 3 int size; }; From 509755d7269c0b8ce0c22afe0ca4fdceb38c0e5e Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 7 Apr 2020 16:08:19 -0500 Subject: [PATCH 14/75] update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index a0c75e22c..b585e182c 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit a0c75e22cdc918240e71ea738c8277499315f88d +Subproject commit b585e182c404a14130d42bf87a60f94aebbfd1fd From 55988e3fc4042af34408f362772c09d9a88b21f9 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 8 Apr 2020 08:45:40 +0200 Subject: [PATCH 15/75] adapted to updated structures, remote Using units for age --- library/modules/Units.cpp | 2 +- .../remotefortressreader/remotefortressreader.cpp | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 07c3a7acf..fa7007574 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -210,7 +210,7 @@ void Units::setNickname(df::unit *unit, std::string nick) break; // We want the nickname to end up in the identity case df::identity_type::Unk_1: // Guess, but that's how it worked in the past - case df::identity_type::Demon_Alias: + case df::identity_type::True_Name: case df::identity_type::Unk_4: // Pure guess, as this is a new case, still unseen id_hfig = df::historical_figure::find(identity->histfig_nemesis_id); break; diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 6ab401027..686c32211 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1693,20 +1693,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques using df::global::cur_year; using df::global::cur_year_tick; - int year_ticks = 403200; - int birth_time = unit->birth_year * year_ticks + unit->birth_time; - int cur_time = *cur_year * year_ticks + *cur_year_tick; - - if (unit->curse_year >= 0) - { - if (auto identity = Units::getIdentity(unit)) - { - if (identity->histfig_nemesis_id < 0) - birth_time = identity->birth_year * year_ticks + identity->birth_second; - } - } - - send_unit->set_age(cur_time - birth_time); + send_unit->set_age(Units::getAge(unit, false)); ConvertDfColor(Units::getProfessionColor(unit), send_unit->mutable_profession_color()); send_unit->set_flags1(unit->flags1.whole); From 9a2549bad6092bac2c2ee90a60c5f3d2d455196a Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 9 Apr 2020 23:56:01 -0400 Subject: [PATCH 16/75] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index b585e182c..e4522edf1 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit b585e182c404a14130d42bf87a60f94aebbfd1fd +Subproject commit e4522edf112824fb0edac874cec0d0f7f9c33c5f From 0b926e2d150a208b8989204f0424e0cb2e2ac2bc Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:29:00 -0400 Subject: [PATCH 17/75] Update changelog, authors --- docs/Authors.rst | 1 + docs/changelog.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/Authors.rst b/docs/Authors.rst index 1bfcf051b..72d61de06 100644 --- a/docs/Authors.rst +++ b/docs/Authors.rst @@ -34,6 +34,7 @@ Clayton Hughes Clément Vuchener cvuchener Dan Amlund danamlund Daniel Brooks db48x +David Nilsolm David Corbett dscorbett David Seguin dseguin David Timm dtimm diff --git a/docs/changelog.txt b/docs/changelog.txt index 34f5c3660..3ca170566 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -42,6 +42,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - `tweak` embark-profile-name: fixed handling of the native shift+space key +## Misc Improvements +- `search`: added support for the fortress mode justice screen + ## Lua - ``pairs()`` now returns available class methods for DF types From d72c3956608aa00afcc1a3115df3b6f664333545 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:33:06 -0400 Subject: [PATCH 18/75] Merge into one job --- .github/workflows/build.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f3a66451..96a623457 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build and test on: [push, pull_request] jobs: - setup: + main: runs-on: ubuntu-18.04 steps: - name: Install dependencies @@ -31,10 +31,6 @@ jobs: - name: Git information run: | sh travis/git-info.sh - docs: - needs: [setup] - runs-on: ubuntu-18.04 - steps: - name: Build docs run: | sphinx-build -qW -j3 . docs/html From 385aa0877d2e1c72319e93160739877b09213c0e Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:38:32 -0400 Subject: [PATCH 19/75] Checkout submodules too --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96a623457..10a653932 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,8 @@ jobs: sudo pip3 install --system sphinx - name: Clone DFHack uses: actions/checkout@v1 + with: + submodules: true - name: Set up environment run: | export DF_VERSION=$(sh travis/get-df-version.sh) From daad14ee66dd46f19e81d860992fd56c14f4c09b Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:46:19 -0400 Subject: [PATCH 20/75] Implement linting checks --- .github/workflows/build.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10a653932..4db414bd1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build and test on: [push, pull_request] jobs: - main: + build: runs-on: ubuntu-18.04 steps: - name: Install dependencies @@ -36,7 +36,32 @@ jobs: - name: Build docs run: | sphinx-build -qW -j3 . docs/html - - uses: actions/upload-artifact@master + - name: Upload docs + uses: actions/upload-artifact@master with: name: docs path: docs/html + lint: + runs-on: ubuntu-18.04 + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install \ + lua5.3 \ + ruby + - name: Check whitespace + run: | + python travis/lint.py + - name: Check Authors.rst + run: | + python travis/authors-rst.py + - name: Check for missing documentation + run: | + python travis/script-docs.py + - name: Check Lua syntax + run: | + python travis/script-syntax.py --ext=lua --cmd="luac5.3 -p" + - name: Check Ruby syntax + run: | + python travis/script-syntax.py --ext=rb --cmd="ruby -c" From 9a7c07b42bc32827d21cbc1ed2080eb0d56a4811 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:47:47 -0400 Subject: [PATCH 21/75] Clone the repo --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4db414bd1..dad202209 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,10 @@ jobs: sudo apt-get install \ lua5.3 \ ruby + - name: Clone DFHack + uses: actions/checkout@v1 + with: + submodules: true - name: Check whitespace run: | python travis/lint.py From 1ebad37c2cb33bf97c6f9ec7c8fec08a64333f48 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:53:12 -0400 Subject: [PATCH 22/75] Attempt to fix DF installation --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dad202209..6594dcb85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,10 +25,11 @@ jobs: submodules: true - name: Set up environment run: | - export DF_VERSION=$(sh travis/get-df-version.sh) - export DF_FOLDER="$HOME/DF/$DF_VERSION/df_linux" + echo 'export DF_VERSION=$(sh travis/get-df-version.sh)' >> "$HOME/.dfhackrc" + echo 'export DF_FOLDER="$HOME/DF/$DF_VERSION/df_linux"' >> "$HOME/.dfhackrc" - name: Download DF run: | + source "$HOME/.dfhackrc" sh travis/download-df.sh - name: Git information run: | From 0d4572e40a41f3ca152473762c1653c1a93a57e1 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 10 Apr 2020 23:56:28 -0400 Subject: [PATCH 23/75] Build DFHack --- .github/workflows/build.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6594dcb85..5b28ab101 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,18 @@ jobs: with: name: docs path: docs/html + - name: Build DFHack + run: | + source "$HOME/.dfhackrc" + mkdir build-ci + cd build-ci + cmake .. \ + -G Ninja \ + -DDFHACK_BUILD_ARCH=64 \ + -DBUILD_DOCS:BOOL=ON \ + -DBUILD_TESTS:BOOL=ON \ + -DCMAKE_INSTALL_PREFIX="$DF_FOLDER" + ninja install lint: runs-on: ubuntu-18.04 steps: From d2ba91e2cd3caf61d95896d835a101e0b3d05c99 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 00:10:28 -0400 Subject: [PATCH 24/75] Run tests --- .github/workflows/build.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b28ab101..aa179eb91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,7 +38,7 @@ jobs: run: | sphinx-build -qW -j3 . docs/html - name: Upload docs - uses: actions/upload-artifact@master + uses: actions/upload-artifact@v1 with: name: docs path: docs/html @@ -54,6 +54,20 @@ jobs: -DBUILD_TESTS:BOOL=ON \ -DCMAKE_INSTALL_PREFIX="$DF_FOLDER" ninja install + - name: Run tests + run: | + cd .. + mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init + python travis/run-tests.py --headless --keep-status "$DF_FOLDER" + python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" + mkdir -p artifacts + cp "$DF_FOLDER/test_status.json" "$DF_FOLDER"/*.log artifacts + - name: Upload test artifacts + uses: actions/upload-artifact@v1 + if: success() || failure() + with: + name: test-artifacts + path: artifacts lint: runs-on: ubuntu-18.04 steps: From 19f84603cd56dce355020944e49f92e8c737f015 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 00:18:01 -0400 Subject: [PATCH 25/75] Fix test environment --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa179eb91..b5283258f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,6 +56,7 @@ jobs: ninja install - name: Run tests run: | + source "$HOME/.dfhackrc" cd .. mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init python travis/run-tests.py --headless --keep-status "$DF_FOLDER" From 35dbf6cf5f46216e87ef902f9dfeb30c9ecd751c Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 00:31:15 -0400 Subject: [PATCH 26/75] Avoid changing working directory --- .github/workflows/build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5283258f..1b4ac36b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,19 +45,18 @@ jobs: - name: Build DFHack run: | source "$HOME/.dfhackrc" - mkdir build-ci - cd build-ci - cmake .. \ + cmake \ + -S . \ + -B build-ci \ -G Ninja \ -DDFHACK_BUILD_ARCH=64 \ -DBUILD_DOCS:BOOL=ON \ -DBUILD_TESTS:BOOL=ON \ -DCMAKE_INSTALL_PREFIX="$DF_FOLDER" - ninja install + ninja -C build-ci install - name: Run tests run: | source "$HOME/.dfhackrc" - cd .. mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init python travis/run-tests.py --headless --keep-status "$DF_FOLDER" python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" From ab81b1f06d9ac86adbccd6c957d439b67f52dee0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 00:40:25 -0400 Subject: [PATCH 27/75] Avoid running travis commands when starting DF --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b4ac36b7..afa907958 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,11 +25,11 @@ jobs: submodules: true - name: Set up environment run: | - echo 'export DF_VERSION=$(sh travis/get-df-version.sh)' >> "$HOME/.dfhackrc" - echo 'export DF_FOLDER="$HOME/DF/$DF_VERSION/df_linux"' >> "$HOME/.dfhackrc" + echo export DF_VERSION="$(sh travis/get-df-version.sh)" >> "$HOME/.df-env" + echo export DF_FOLDER="$HOME/DF/$DF_VERSION/df_linux" >> "$HOME/.df-env" - name: Download DF run: | - source "$HOME/.dfhackrc" + source "$HOME/.df-env" sh travis/download-df.sh - name: Git information run: | @@ -44,7 +44,7 @@ jobs: path: docs/html - name: Build DFHack run: | - source "$HOME/.dfhackrc" + source "$HOME/.df-env" cmake \ -S . \ -B build-ci \ @@ -56,7 +56,7 @@ jobs: ninja -C build-ci install - name: Run tests run: | - source "$HOME/.dfhackrc" + source "$HOME/.df-env" mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init python travis/run-tests.py --headless --keep-status "$DF_FOLDER" python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" From 023575071a165d7541d2956287421bafbbd1c351 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 00:49:16 -0400 Subject: [PATCH 28/75] Run tests with TERM=dumb --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afa907958..2d158dc7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,7 @@ jobs: - name: Run tests run: | source "$HOME/.df-env" + export TERM=dumb mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init python travis/run-tests.py --headless --keep-status "$DF_FOLDER" python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" From 8b7989e93f69021f7d4b37aefb6b6c907e87995b Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 01:17:43 -0400 Subject: [PATCH 29/75] Try with TERM=xterm to get test output logged to console It's currently going to stderr.log only --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d158dc7c..0c5c857f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: - name: Run tests run: | source "$HOME/.df-env" - export TERM=dumb + export TERM=xterm mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init python travis/run-tests.py --headless --keep-status "$DF_FOLDER" python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" From 9e9e71cad7f43a224c069adf2cd327e48fa3f175 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 01:31:41 -0400 Subject: [PATCH 30/75] Fix spacing in error message --- conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.py b/conf.py index bfd69d828..2f47d5644 100644 --- a/conf.py +++ b/conf.py @@ -174,7 +174,7 @@ def all_keybinds_documented(): plugin_binds = set(re.findall(':dfhack-keybind:`(.*?)`', f.read())) undocumented_binds = configured_binds - script_commands - plugin_binds if undocumented_binds: - raise ValueError('The following DFHack commands have undocumented' + raise ValueError('The following DFHack commands have undocumented ' 'keybindings: {}'.format(sorted(undocumented_binds))) From 148b5495cc589d2a4ddd6c0be67ae7f3dea3ad92 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 01:32:05 -0400 Subject: [PATCH 31/75] Fall back to dfout_C if set before stderr.log --- library/Console-posix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/Console-posix.cpp b/library/Console-posix.cpp index 6fb1cbff3..76b5a8cb2 100644 --- a/library/Console-posix.cpp +++ b/library/Console-posix.cpp @@ -903,7 +903,10 @@ void Console::add_text(color_value color, const std::string &text) if (inited) d->print_text(color, text); else - fwrite(text.data(), 1, text.size(), stderr); + { + FILE *out = d->dfout_C ? d->dfout_C : stderr; + fwrite(text.data(), 1, text.size(), out); + } } int Console::get_columns(void) From 44be99388e487998661a851ffdd72cb7fd4bb3f0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 01:43:06 -0400 Subject: [PATCH 32/75] Revert "Fall back to dfout_C if set before stderr.log" Makes stuff go to stdout.log instead This reverts commit 148b5495cc589d2a4ddd6c0be67ae7f3dea3ad92. --- library/Console-posix.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/Console-posix.cpp b/library/Console-posix.cpp index 76b5a8cb2..6fb1cbff3 100644 --- a/library/Console-posix.cpp +++ b/library/Console-posix.cpp @@ -903,10 +903,7 @@ void Console::add_text(color_value color, const std::string &text) if (inited) d->print_text(color, text); else - { - FILE *out = d->dfout_C ? d->dfout_C : stderr; - fwrite(text.data(), 1, text.size(), out); - } + fwrite(text.data(), 1, text.size(), stderr); } int Console::get_columns(void) From cdc82bd7dbfb85f9294adcb62cb55da26b4bb29f Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 01:49:53 -0400 Subject: [PATCH 33/75] Run tests within `script` --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c5c857f5..bc8101b8f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,9 +57,8 @@ jobs: - name: Run tests run: | source "$HOME/.df-env" - export TERM=xterm mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init - python travis/run-tests.py --headless --keep-status "$DF_FOLDER" + script -qe -c "python travis/run-tests.py --headless --keep-status \"$DF_FOLDER\"" python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" mkdir -p artifacts cp "$DF_FOLDER/test_status.json" "$DF_FOLDER"/*.log artifacts From 6bbda95dd4fc3519fd65c773849d4bdada3352f3 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 01:58:06 -0400 Subject: [PATCH 34/75] Add TERM=dumb back --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc8101b8f..bb1791a67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,6 +57,7 @@ jobs: - name: Run tests run: | source "$HOME/.df-env" + export TERM=dumb mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init script -qe -c "python travis/run-tests.py --headless --keep-status \"$DF_FOLDER\"" python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" From b3db62742c0ca150aa442bda7e81b5a99db35fb0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 02:15:57 -0400 Subject: [PATCH 35/75] Rename workflow to match Travis, update badge --- .github/workflows/build.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bb1791a67..deab07958 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build and test +name: Build on: [push, pull_request] diff --git a/README.md b/README.md index fd95e1e5e..a0499a333 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DFHack Readme -[![Build Status](https://travis-ci.org/DFHack/dfhack.svg?branch=develop)](https://travis-ci.org/DFHack/dfhack) +[![Build Status](https://github.com/DFHack/dfhack/workflows/Build/badge.svg)](https://github.com/DFHack/dfhack/actions?query=workflow%3ABuild) [![Documentation Status](https://readthedocs.org/projects/dfhack/badge)](https://dfhack.readthedocs.org) [![License](https://img.shields.io/badge/license-ZLib-blue.svg)](https://en.wikipedia.org/wiki/Zlib_License) From dbdd98829f46f6e9e98196a94dbfed20844bded8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 02:22:12 -0400 Subject: [PATCH 36/75] Add check for PR base branch --- .github/workflows/build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index deab07958..a585b6e80 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,3 +97,13 @@ jobs: - name: Check Ruby syntax run: | python travis/script-syntax.py --ext=rb --cmd="ruby -c" + check-pr: + runs-on: ubuntu-latest + steps: + - name: Check that PR is based on develop branch + if: github.event_name == 'pull_request' + env: + BASE_BRANCH: ${{ github.base_ref }} + run: | + echo "PR base branch: $BASE_BRANCH" + test "$BASE_BRANCH" = develop From dc598d501a799e043b6d5c04ab8e075091d58542 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 02:24:40 -0400 Subject: [PATCH 37/75] Limit entire check-pr job to PRs only --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a585b6e80..f737a1539 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -99,9 +99,9 @@ jobs: python travis/script-syntax.py --ext=rb --cmd="ruby -c" check-pr: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' steps: - name: Check that PR is based on develop branch - if: github.event_name == 'pull_request' env: BASE_BRANCH: ${{ github.base_ref }} run: | From dbff3355ba92d2ba944b5093ec0e781cec9719c8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 02:32:07 -0400 Subject: [PATCH 38/75] Remove .travis.yml --- .travis.yml | 64 ----------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c096552bc..000000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -sudo: false -language: cpp -cache: - pip: true - directories: - - $HOME/DF-travis - - $HOME/lua53 -addons: - apt: - packages: &default_packages - - libsdl-image1.2-dev - - libsdl-ttf2.0-dev - - libsdl1.2-dev - - libxml-libxml-perl - - libxml-libxslt-perl - - ninja-build - - zlib1g-dev -matrix: - include: - - env: GCC_VERSION=4.8 - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - *default_packages - - gcc-4.8 - - g++-4.8 -before_install: -- export DF_VERSION=$(sh travis/get-df-version.sh) -- export DF_FOLDER="$HOME/DF-travis/$DF_VERSION/df_linux" -- pip install --user "sphinx==1.4" "requests[security]" -- sh travis/build-lua.sh -- sh travis/download-df.sh -script: -- export PATH="$PATH:$HOME/lua53/bin" -- git tag tmp-travis-build -- sh travis/git-info.sh -- sphinx-build -qW -j3 . docs/html -- python travis/pr-check-base.py -- python travis/lint.py -- python travis/authors-rst.py -- python travis/script-docs.py -- python travis/script-syntax.py --ext=lua --cmd="luac5.3 -p" -- python travis/script-syntax.py --ext=rb --cmd="ruby -c" -- mkdir build-travis -- cd build-travis -- cmake .. -G Ninja -DCMAKE_C_COMPILER=gcc-$GCC_VERSION -DCMAKE_CXX_COMPILER=g++-$GCC_VERSION -DDFHACK_BUILD_ARCH=64 -DBUILD_DOCS:BOOL=ON -DBUILD_TESTS:BOOL=ON -DCMAKE_INSTALL_PREFIX="$DF_FOLDER" -- ninja -j3 install -- mv "$DF_FOLDER"/dfhack.init-example "$DF_FOLDER"/dfhack.init -- cd .. -- python travis/run-tests.py --headless --keep-status "$DF_FOLDER" -- python travis/check-rpc.py "$DF_FOLDER/dfhack-rpc.txt" -- cat "$DF_FOLDER/test_status.json" -before_cache: -- cat "$DF_FOLDER/stderr.log" -- rm -rf "$DF_FOLDER" -notifications: - email: false - irc: - channels: - - "chat.freenode.net#dfhack" - on_success: change - on_failure: always From ba12e0c6d4446248683f0fa6ae3fc8709898e34d Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 11 Apr 2020 02:33:50 -0400 Subject: [PATCH 39/75] Remove obsolete travis scripts --- .github/workflows/build.yml | 3 --- travis/build-lua.sh | 54 ------------------------------------- travis/git-info.sh | 2 -- travis/pr-check-base.py | 18 ------------- 4 files changed, 77 deletions(-) delete mode 100644 travis/build-lua.sh delete mode 100644 travis/git-info.sh delete mode 100644 travis/pr-check-base.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f737a1539..17af62cb1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,9 +31,6 @@ jobs: run: | source "$HOME/.df-env" sh travis/download-df.sh - - name: Git information - run: | - sh travis/git-info.sh - name: Build docs run: | sphinx-build -qW -j3 . docs/html diff --git a/travis/build-lua.sh b/travis/build-lua.sh deleted file mode 100644 index e29d7ce87..000000000 --- a/travis/build-lua.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh - -set -e - -LUA_ROOT="$HOME/lua53" -LUA_URL="http://www.lua.org/ftp/lua-5.3.3.tar.gz" -LUA_TAR=$(basename "$LUA_URL") -LUA_DIR="$LUA_ROOT/${LUA_TAR%.tar.*}" -LUA_SHA1="a0341bc3d1415b814cc738b2ec01ae56045d64ef" - -echo LUA_ROOT $LUA_ROOT -echo LUA_TAR $LUA_TAR -echo LUA_DIR $LUA_DIR - -sha1() { - python -c 'import hashlib, sys; print(hashlib.sha1(open(sys.argv[1],"rb").read()).hexdigest())' "$1" -} - -download() { - echo "Downloading $LUA_URL" - wget -O "$LUA_ROOT/$LUA_TAR" "$LUA_URL" - tar xvf "$LUA_ROOT/$LUA_TAR" -} - -build() { - cd "$LUA_DIR/src" - make generic -} - -main() { - mkdir -p "$LUA_ROOT" - cd "$LUA_ROOT" - mkdir -p bin - - if [ "$(sha1 "$LUA_ROOT/$LUA_TAR" 2>/dev/null)" != "$LUA_SHA1" ]; then - download - build - else - echo "Already downloaded" - - if [ -x "$LUA_DIR/src/luac" ]; then - echo "Already built" - else - build - fi - fi - - echo "Linking" - ln -sf "$LUA_DIR/src/lua" "$LUA_ROOT/bin/lua5.3" - ln -sf "$LUA_DIR/src/luac" "$LUA_ROOT/bin/luac5.3" - echo "Done" -} - -main diff --git a/travis/git-info.sh b/travis/git-info.sh deleted file mode 100644 index 333d13bc1..000000000 --- a/travis/git-info.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -git log --pretty="commit %h (parents: %p): %s" -1 diff --git a/travis/pr-check-base.py b/travis/pr-check-base.py deleted file mode 100644 index 47605b051..000000000 --- a/travis/pr-check-base.py +++ /dev/null @@ -1,18 +0,0 @@ -import os, sys -repo = os.environ.get('TRAVIS_REPO_SLUG', 'dfhack/dfhack').lower() -branch = os.environ.get('TRAVIS_BRANCH', 'master') -try: - pr_id = int(os.environ.get('TRAVIS_PULL_REQUEST', 'false')) -except ValueError: - print('Not a pull request') - sys.exit(0) -print('Pull request %s#%i' % (repo, pr_id)) -if repo != 'dfhack/dfhack': - print('Not in dfhack/dfhack') - sys.exit(0) -if branch != 'develop': - print('Not based on develop branch') - sys.exit(1) -else: - print('Ok') - sys.exit(0) From 2b44e52cab541ec3b7a902cdb52277af6a750ccf Mon Sep 17 00:00:00 2001 From: Nilsolm Date: Sat, 11 Apr 2020 16:47:29 +0200 Subject: [PATCH 40/75] Add intrigue skill to manipulator --- plugins/manipulator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 33d5ff884..e9206dc0f 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -242,6 +242,7 @@ const SkillColumn columns[] = { {16, 3, profession::NONE, unit_labor::NONE, job_skill::FLATTERY, "Fl"}, {16, 3, profession::NONE, unit_labor::NONE, job_skill::CONSOLE, "Cs"}, {16, 3, profession::NONE, unit_labor::NONE, job_skill::PACIFY, "Pc"}, + {16, 3, profession::NONE, unit_labor::NONE, job_skill::INTRIGUE, "Sc"}, // Noble {17, 5, profession::TRADER, unit_labor::NONE, job_skill::APPRAISAL, "Ap"}, {17, 5, profession::ADMINISTRATOR, unit_labor::NONE, job_skill::ORGANIZATION, "Or"}, From d734c83a280400c0c9ca7c51edc21c7e6cc20826 Mon Sep 17 00:00:00 2001 From: Nilsolm Date: Sat, 11 Apr 2020 17:26:09 +0200 Subject: [PATCH 41/75] also update the changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 3ca170566..d2404c951 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -43,6 +43,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `tweak` embark-profile-name: fixed handling of the native shift+space key ## Misc Improvements +- `manipulator`: added intrigue to displayed skills - `search`: added support for the fortress mode justice screen ## Lua From 67c1321a0695b86b010c42ba10d650712228ceef Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sat, 11 Apr 2020 13:03:38 -0500 Subject: [PATCH 42/75] update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index e4522edf1..f185d0b22 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit e4522edf112824fb0edac874cec0d0f7f9c33c5f +Subproject commit f185d0b22acb1daf36b3a017f7a30b48994ee42c From 362e49c0bc9c0c5cde28e1e9ff3a0ae427e27dd8 Mon Sep 17 00:00:00 2001 From: Nilsolm Date: Sun, 12 Apr 2020 11:02:26 +0200 Subject: [PATCH 43/75] autogems: check bin content in linked stockpiles --- plugins/autogems.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/autogems.cpp b/plugins/autogems.cpp index 4121b562f..f22d20d30 100644 --- a/plugins/autogems.cpp +++ b/plugins/autogems.cpp @@ -167,6 +167,16 @@ void create_jobs() { stockpiled.insert(item->id); piled[item->getMaterialIndex()] += 1; } + else if (item->flags.bits.container) { + std::vector binneditems; + Items::getContainedItems(item, &binneditems); + for (df::item *it : binneditems) { + if (valid_gem(it)) { + stockpiled.insert(it->id); + piled[it->getMaterialIndex()] += 1; + } + } + } } // Decrement current jobs from all linked workshops, not just this one. From f7630a52707b9d8e5e4d0ae82ed98244c71a7b8b Mon Sep 17 00:00:00 2001 From: Nilsolm Date: Sun, 12 Apr 2020 11:03:28 +0200 Subject: [PATCH 44/75] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index d2404c951..ba75f09fb 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## Fixes +- `autogems`: fixed an issue with binned gems being ignored in linked stockpiles - `tweak` embark-profile-name: fixed handling of the native shift+space key ## Misc Improvements From c97adb91735becad845d8af630e62c19c8e94d03 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 15 Apr 2020 01:09:16 -0400 Subject: [PATCH 45/75] Update changelog (#1528, #1530) --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index ba75f09fb..11734d9f7 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -40,6 +40,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## Fixes +- Fixed translation of certain types of in-game names - `autogems`: fixed an issue with binned gems being ignored in linked stockpiles - `tweak` embark-profile-name: fixed handling of the native shift+space key From 79387647d39a326fa3c82e620e7c435b4f7c2002 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 15 Apr 2020 01:09:29 -0400 Subject: [PATCH 46/75] Update scripts --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index 8618cd0b0..b3ce8fa65 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 8618cd0b0a17935fe07f329b249726cda61f5bdf +Subproject commit b3ce8fa650f86c7a1dbd5329d72c3d73dd76d05d From 36df6eac8b649f7787c54d95c93b42280a7f6d81 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 15 Apr 2020 01:15:09 -0400 Subject: [PATCH 47/75] Restrict status badge to push events only --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a0499a333..e4bfefb38 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DFHack Readme -[![Build Status](https://github.com/DFHack/dfhack/workflows/Build/badge.svg)](https://github.com/DFHack/dfhack/actions?query=workflow%3ABuild) +[![Build Status](https://github.com/DFHack/dfhack/workflows/Build/badge.svg?event=push)](https://github.com/DFHack/dfhack/actions?query=workflow%3ABuild) [![Documentation Status](https://readthedocs.org/projects/dfhack/badge)](https://dfhack.readthedocs.org) [![License](https://img.shields.io/badge/license-ZLib-blue.svg)](https://en.wikipedia.org/wiki/Zlib_License) From f4f2aa0d5ef0814adce64af3f8339207e9c97aef Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 15 Apr 2020 10:18:37 +0200 Subject: [PATCH 48/75] removed underscores, adapted to structure (re)naming --- library/modules/Items.cpp | 2 +- library/modules/Job.cpp | 4 ++-- library/modules/Units.cpp | 8 ++++---- plugins/orders.cpp | 6 +++--- plugins/stocks.cpp | 10 +++++----- plugins/workflow.cpp | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 4939aa9dd..4b6010718 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -658,7 +658,7 @@ df::coord Items::getPosition(df::item *item) switch (ref->type) { case specific_ref_type::VERMIN_ESCAPED_PET: - return ref->data.VERMIN_ESCAPED_PET->pos; + return ref->data.vermin->pos; default: break; diff --git a/library/modules/Job.cpp b/library/modules/Job.cpp index d0487941f..0aa01af95 100644 --- a/library/modules/Job.cpp +++ b/library/modules/Job.cpp @@ -311,7 +311,7 @@ void DFHack::Job::disconnectJobItem(df::job *job, df::job_item_ref *ref) { auto ref = item->specific_refs[refIndex]; if (ref->type == df::specific_ref_type::JOB) { - if (ref->data.JOB == job) { + if (ref->data.job == job) { vector_erase_at(item->specific_refs, refIndex); delete ref; } else { @@ -579,7 +579,7 @@ bool DFHack::Job::attachJobItem(df::job *job, df::item *item, auto item_link = new df::specific_ref(); item_link->type = specific_ref_type::JOB; - item_link->data.JOB = job; + item_link->data.job = job; item->specific_refs.push_back(item_link); auto job_link = new df::job_item_ref(); diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index fa7007574..313d6ee9f 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -204,13 +204,13 @@ void Units::setNickname(df::unit *unit, std::string nick) df::historical_figure *id_hfig = NULL; switch (identity->type) { - case df::identity_type::Hiding_Curse: + case df::identity_type::HidingCurse: case df::identity_type::Identity: - case df::identity_type::False_Identity: + case df::identity_type::FalseIdentity: break; // We want the nickname to end up in the identity case df::identity_type::Unk_1: // Guess, but that's how it worked in the past - case df::identity_type::True_Name: + case df::identity_type::TrueName: case df::identity_type::Unk_4: // Pure guess, as this is a new case, still unseen id_hfig = df::historical_figure::find(identity->histfig_nemesis_id); break; @@ -258,7 +258,7 @@ bool Units::isHidingCurse(df::unit *unit) if (!unit->job.hunt_target) { auto identity = Units::getIdentity(unit); - if (identity && identity->type == df::identity_type::Hiding_Curse) + if (identity && identity->type == df::identity_type::HidingCurse) return true; } diff --git a/plugins/orders.cpp b/plugins/orders.cpp index f600b0cd0..045c07a1f 100644 --- a/plugins/orders.cpp +++ b/plugins/orders.cpp @@ -798,13 +798,13 @@ static command_result orders_clear_command(color_ostream & out) { delete condition; } - if (order->anon_1) + if (order->items) { - for (auto anon_1 : *order->anon_1) + for (auto anon_1 : *order->items) { delete anon_1; } - delete order->anon_1; + delete order->items; } delete order; diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index d9ec97c0d..af49dcb2a 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -179,8 +179,8 @@ static map items_in_cages; static df::job *get_item_job(df::item *item) { auto ref = Items::getSpecificRef(item, specific_ref_type::JOB); - if (ref && ref->data.JOB) - return ref->data.JOB; + if (ref && ref->data.job) + return ref->data.job; return nullptr; } @@ -1008,12 +1008,12 @@ private: if (item->flags.bits.in_job) { auto ref = Items::getSpecificRef(item, specific_ref_type::JOB); - if (ref && ref->data.JOB) + if (ref && ref->data.job) { - if (ref->data.JOB->job_type == job_type::Eat || ref->data.JOB->job_type == job_type::Drink) + if (ref->data.job->job_type == job_type::Eat || ref->data.job->job_type == job_type::Drink) return pos; - auto unit = Job::getWorker(ref->data.JOB); + auto unit = Job::getWorker(ref->data.job); if (unit) return unit->pos; } diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index 3e31d14ab..600a8bef1 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -1151,10 +1151,10 @@ static bool itemInRealJob(df::item *item) return false; auto ref = Items::getSpecificRef(item, specific_ref_type::JOB); - if (!ref || !ref->data.JOB) + if (!ref || !ref->data.job) return true; - return ENUM_ATTR(job_type, type, ref->data.JOB->job_type) + return ENUM_ATTR(job_type, type, ref->data.job->job_type) != job_type_class::Hauling; } From b5c6fd26e2632286a8d9dc8a4fb3cdea33f10be6 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 15 Apr 2020 17:33:58 -0400 Subject: [PATCH 49/75] Update changelog (#1531) --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 11734d9f7..47f891cb5 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -45,6 +45,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - `tweak` embark-profile-name: fixed handling of the native shift+space key ## Misc Improvements +- ``dfhack.init-example``: enabled `autodump` - `manipulator`: added intrigue to displayed skills - `search`: added support for the fortress mode justice screen From 253b15aeb98581b7cc61013be88db464f3c5a3d7 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Wed, 15 Apr 2020 19:03:40 -0500 Subject: [PATCH 50/75] update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index f185d0b22..96a8df43d 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit f185d0b22acb1daf36b3a017f7a30b48994ee42c +Subproject commit 96a8df43d1c4508800c209701ce39ca972579e3b From 8427f518c941f8e5734e98f2ff56648522f1281b Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Wed, 15 Apr 2020 20:05:15 -0500 Subject: [PATCH 51/75] match capitalization changes I made to df-structures in specific_ref --- library/modules/Items.cpp | 2 +- library/modules/Job.cpp | 4 ++-- plugins/orders.cpp | 8 ++++---- plugins/stocks.cpp | 10 +++++----- plugins/workflow.cpp | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 4939aa9dd..4b6010718 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -658,7 +658,7 @@ df::coord Items::getPosition(df::item *item) switch (ref->type) { case specific_ref_type::VERMIN_ESCAPED_PET: - return ref->data.VERMIN_ESCAPED_PET->pos; + return ref->data.vermin->pos; default: break; diff --git a/library/modules/Job.cpp b/library/modules/Job.cpp index d0487941f..0aa01af95 100644 --- a/library/modules/Job.cpp +++ b/library/modules/Job.cpp @@ -311,7 +311,7 @@ void DFHack::Job::disconnectJobItem(df::job *job, df::job_item_ref *ref) { auto ref = item->specific_refs[refIndex]; if (ref->type == df::specific_ref_type::JOB) { - if (ref->data.JOB == job) { + if (ref->data.job == job) { vector_erase_at(item->specific_refs, refIndex); delete ref; } else { @@ -579,7 +579,7 @@ bool DFHack::Job::attachJobItem(df::job *job, df::item *item, auto item_link = new df::specific_ref(); item_link->type = specific_ref_type::JOB; - item_link->data.JOB = job; + item_link->data.job = job; item->specific_refs.push_back(item_link); auto job_link = new df::job_item_ref(); diff --git a/plugins/orders.cpp b/plugins/orders.cpp index f600b0cd0..6c6888c0e 100644 --- a/plugins/orders.cpp +++ b/plugins/orders.cpp @@ -798,13 +798,13 @@ static command_result orders_clear_command(color_ostream & out) { delete condition; } - if (order->anon_1) + if (order->items) { - for (auto anon_1 : *order->anon_1) + for (auto item : *order->items) { - delete anon_1; + delete item; } - delete order->anon_1; + delete order->items; } delete order; diff --git a/plugins/stocks.cpp b/plugins/stocks.cpp index d9ec97c0d..af49dcb2a 100644 --- a/plugins/stocks.cpp +++ b/plugins/stocks.cpp @@ -179,8 +179,8 @@ static map items_in_cages; static df::job *get_item_job(df::item *item) { auto ref = Items::getSpecificRef(item, specific_ref_type::JOB); - if (ref && ref->data.JOB) - return ref->data.JOB; + if (ref && ref->data.job) + return ref->data.job; return nullptr; } @@ -1008,12 +1008,12 @@ private: if (item->flags.bits.in_job) { auto ref = Items::getSpecificRef(item, specific_ref_type::JOB); - if (ref && ref->data.JOB) + if (ref && ref->data.job) { - if (ref->data.JOB->job_type == job_type::Eat || ref->data.JOB->job_type == job_type::Drink) + if (ref->data.job->job_type == job_type::Eat || ref->data.job->job_type == job_type::Drink) return pos; - auto unit = Job::getWorker(ref->data.JOB); + auto unit = Job::getWorker(ref->data.job); if (unit) return unit->pos; } diff --git a/plugins/workflow.cpp b/plugins/workflow.cpp index 3e31d14ab..600a8bef1 100644 --- a/plugins/workflow.cpp +++ b/plugins/workflow.cpp @@ -1151,10 +1151,10 @@ static bool itemInRealJob(df::item *item) return false; auto ref = Items::getSpecificRef(item, specific_ref_type::JOB); - if (!ref || !ref->data.JOB) + if (!ref || !ref->data.job) return true; - return ENUM_ATTR(job_type, type, ref->data.JOB->job_type) + return ENUM_ATTR(job_type, type, ref->data.job->job_type) != job_type_class::Hauling; } From c8ff8d0d8efa7a7c69658a30d18255a73c2955c8 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Fri, 17 Apr 2020 11:52:16 -0500 Subject: [PATCH 52/75] update scripts and structures --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 96a8df43d..816497911 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 96a8df43d1c4508800c209701ce39ca972579e3b +Subproject commit 81649791116754a789aae85222797c4df3945b08 diff --git a/scripts b/scripts index b3ce8fa65..c6bb439ad 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit b3ce8fa650f86c7a1dbd5329d72c3d73dd76d05d +Subproject commit c6bb439ad18455fff85cdfab480689a1c94f56fe From 54d4b68f3cdef054b55849a248a8bcdaac8033df Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sat, 18 Apr 2020 20:39:57 -0500 Subject: [PATCH 53/75] don't crash if the path to an instance-vector contains a null pointer --- library/DataStatics.cpp | 5 +++-- library/xml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/library/DataStatics.cpp b/library/DataStatics.cpp index 61b7b6378..275cae584 100644 --- a/library/DataStatics.cpp +++ b/library/DataStatics.cpp @@ -12,10 +12,11 @@ namespace { template - inline T &_toref(T &r) { return r; } + inline T *_toptr(T &r) { return &r; } template - inline T &_toref(T *&p) { return *p; } + inline T *_toptr(T *&p) { return p; } } +#define _fieldptr(ptr, fn) (ptr) ? _toptr((ptr)->fn) : NULL #define INIT_GLOBAL_FUNCTION_PREFIX \ DFHack::VersionInfo *global_table_ = DFHack::Core::getInstance().vinfo.get(); \ diff --git a/library/xml b/library/xml index 816497911..d9a31fa45 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 81649791116754a789aae85222797c4df3945b08 +Subproject commit d9a31fa45228a7507b975dbbddbf00c7905644ea From d3a007489c5248b758627d019d1a6c4f4a53fd34 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sun, 19 Apr 2020 12:16:48 -0400 Subject: [PATCH 54/75] Fix ZLIB_ROOT in newer CMake versions --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e40c932a0..f8dd5dc86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,12 @@ if("${CMAKE_GENERATOR}" STREQUAL Ninja) endif() endif() +if(NOT("${CMAKE_VERSION}" VERSION_LESS 3.12)) + # make ZLIB_ROOT work in CMake >= 3.12 + # https://cmake.org/cmake/help/git-stage/policy/CMP0074.html + cmake_policy(SET CMP0074 NEW) +endif() + # Set up build types if(CMAKE_CONFIGURATION_TYPES) set(CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo" CACHE STRING "List of supported configuration types" FORCE) From 2f1e057bc7efc215702cf14d0448dfaeaf1574e0 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sun, 19 Apr 2020 22:03:03 -0500 Subject: [PATCH 55/75] check-structures-sanity: report known void* types with a better message --- plugins/devel/check-structures-sanity/dispatch.cpp | 5 +++++ plugins/devel/check-structures-sanity/types.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/devel/check-structures-sanity/dispatch.cpp b/plugins/devel/check-structures-sanity/dispatch.cpp index fcc6b0b8e..f6342d03c 100644 --- a/plugins/devel/check-structures-sanity/dispatch.cpp +++ b/plugins/devel/check-structures-sanity/dispatch.cpp @@ -67,6 +67,11 @@ bool Checker::queue_item(const QueueItem & item, CheckedStructure cs) auto offset = uintptr_t(item.ptr) - uintptr_t(prev->first); if (!prev->second.second.has_type_at_offset(cs, offset)) { + if (offset == 0 && cs.identity == df::identity_traits::get()) + { + FAIL("unknown pointer is " << prev->second.second.identity->getFullName() << ", previously seen at " << prev->second.first); + return false; + } // TODO FAIL("TODO: handle merging structures: " << item.path << " overlaps " << prev->second.first << " (backward)"); return false; diff --git a/plugins/devel/check-structures-sanity/types.cpp b/plugins/devel/check-structures-sanity/types.cpp index 9e565215a..86d691f1d 100644 --- a/plugins/devel/check-structures-sanity/types.cpp +++ b/plugins/devel/check-structures-sanity/types.cpp @@ -129,7 +129,6 @@ bool CheckedStructure::has_type_at_offset(const CheckedStructure & type, size_t auto st = dynamic_cast(identity); if (!st) { - UNEXPECTED; return false; } From 66314806b137a86a0ff7627b08251ab9ce4d0d6f Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sun, 19 Apr 2020 22:03:13 -0500 Subject: [PATCH 56/75] update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index d9a31fa45..ce91eb750 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit d9a31fa45228a7507b975dbbddbf00c7905644ea +Subproject commit ce91eb750026e97b0044e88043f36fe4ff5218c0 From 9a10ea9fe5cec8b84a68f0846012f4cf4fca470a Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 22 Apr 2020 02:13:24 -0400 Subject: [PATCH 57/75] Update submodules --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index ce91eb750..353caa341 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit ce91eb750026e97b0044e88043f36fe4ff5218c0 +Subproject commit 353caa3413f728938821c8aaccebb389a322bfef diff --git a/scripts b/scripts index c6bb439ad..1468a773e 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit c6bb439ad18455fff85cdfab480689a1c94f56fe +Subproject commit 1468a773e4b56716d94c28cc90a6988739d0c561 From f371ae6da86e3bf770b2a2412f10e12eccf99c63 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 22 Apr 2020 12:38:37 +0200 Subject: [PATCH 58/75] adapted to histfig_nemesis_id->union --- library/modules/Units.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 313d6ee9f..dc76c6802 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -212,7 +212,7 @@ void Units::setNickname(df::unit *unit, std::string nick) case df::identity_type::Unk_1: // Guess, but that's how it worked in the past case df::identity_type::TrueName: case df::identity_type::Unk_4: // Pure guess, as this is a new case, still unseen - id_hfig = df::historical_figure::find(identity->histfig_nemesis_id); + id_hfig = df::historical_figure::find(identity->figure.historical); break; } From 21be5cf061c65ef9d0ec7e9e8c1ab99adc97fa77 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 22 Apr 2020 15:32:49 +0200 Subject: [PATCH 59/75] adapted to structures --- library/modules/Units.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index dc76c6802..c4b9e60fa 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -212,7 +212,7 @@ void Units::setNickname(df::unit *unit, std::string nick) case df::identity_type::Unk_1: // Guess, but that's how it worked in the past case df::identity_type::TrueName: case df::identity_type::Unk_4: // Pure guess, as this is a new case, still unseen - id_hfig = df::historical_figure::find(identity->figure.historical); + id_hfig = df::historical_figure::find(identity->histfig_id); break; } From 75c8bf1a59e49f8f64371b11a528eb086edfd685 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 22 Apr 2020 22:05:48 -0400 Subject: [PATCH 60/75] Indent more --- plugins/remotefortressreader/remotefortressreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index 686c32211..e94c3f832 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1693,7 +1693,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques using df::global::cur_year; using df::global::cur_year_tick; - send_unit->set_age(Units::getAge(unit, false)); + send_unit->set_age(Units::getAge(unit, false)); ConvertDfColor(Units::getProfessionColor(unit), send_unit->mutable_profession_color()); send_unit->set_flags1(unit->flags1.whole); From 0272fd57f8cf662537f1896beca31e2c0041bba8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 22 Apr 2020 22:16:24 -0400 Subject: [PATCH 61/75] Update submodules --- library/xml | 2 +- scripts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 353caa341..eb99251b8 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 353caa3413f728938821c8aaccebb389a322bfef +Subproject commit eb99251b8f5e0a07788e1a3704bc9859323fdbc4 diff --git a/scripts b/scripts index 1468a773e..068ae1342 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 1468a773e4b56716d94c28cc90a6988739d0c561 +Subproject commit 068ae13427c7bad0c084c21a1ac83eec91395efa From c5513c3ca1fa194b459b103bae2bd4d103c31454 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 23 Apr 2020 01:11:29 -0400 Subject: [PATCH 62/75] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index eb99251b8..3e83ae5fc 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit eb99251b8f5e0a07788e1a3704bc9859323fdbc4 +Subproject commit 3e83ae5fc53ae6ff2e4e76ac0fa83af39cd6794d From 84f13b643b38c87f77b9c3c9ed0599e30c1b442a Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 23 Apr 2020 15:34:26 -0500 Subject: [PATCH 63/75] update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index 3e83ae5fc..275f5c519 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 3e83ae5fc53ae6ff2e4e76ac0fa83af39cd6794d +Subproject commit 275f5c5199cc4f6293dac1cfeb17ffdebee4312a From 27e42ed25dd426182237eaa242291d1d4df89368 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 23 Apr 2020 23:10:30 -0400 Subject: [PATCH 64/75] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index 275f5c519..a106b5e98 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 275f5c5199cc4f6293dac1cfeb17ffdebee4312a +Subproject commit a106b5e98381184004fa9dfff44072239755e554 From c6ed0a24584c2c279828e26cb89c7082b2483660 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 24 Apr 2020 21:15:04 -0400 Subject: [PATCH 65/75] Update xml, scripts, authors --- docs/Authors.rst | 1 + library/xml | 2 +- scripts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Authors.rst b/docs/Authors.rst index 72d61de06..6821a84b0 100644 --- a/docs/Authors.rst +++ b/docs/Authors.rst @@ -117,6 +117,7 @@ Priit Laes plaes Putnam Putnam3145 Quietust quietust _Q Raidau Raidau +Ralph Bisschops ralpha Ramblurr Ramblurr rampaging-poet Raoul van Putten diff --git a/library/xml b/library/xml index a106b5e98..3a1e2159a 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit a106b5e98381184004fa9dfff44072239755e554 +Subproject commit 3a1e2159a55ea46622b8bcfab35333b3674405fd diff --git a/scripts b/scripts index 068ae1342..73f89fe3d 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 068ae13427c7bad0c084c21a1ac83eec91395efa +Subproject commit 73f89fe3d48e52d9d860462df02d488b73de0953 From 7bdf958518d2892ee89a7173224a069c4a2190d8 Mon Sep 17 00:00:00 2001 From: Ben Rosser Date: Fri, 24 Apr 2020 21:18:46 -0400 Subject: [PATCH 66/75] Fix protobuf compilation with GCC 10 on Fedora Fixes #1506 --- depends/protobuf/google/protobuf/message.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/depends/protobuf/google/protobuf/message.cc b/depends/protobuf/google/protobuf/message.cc index 91e6878e8..37db6a485 100644 --- a/depends/protobuf/google/protobuf/message.cc +++ b/depends/protobuf/google/protobuf/message.cc @@ -32,6 +32,7 @@ // Based on original Protocol Buffers design by // Sanjay Ghemawat, Jeff Dean, and others. +#include #include #include From 55a82e43c6838849417723780be4f09f048d6b0b Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 24 Apr 2020 23:50:35 -0400 Subject: [PATCH 67/75] Update xml, fix stockpiles build --- library/xml | 2 +- plugins/stockpiles/StockpileSerializer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index 3a1e2159a..e42376086 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 3a1e2159a55ea46622b8bcfab35333b3674405fd +Subproject commit e42376086e04fe6db338eadefb00511dcccf1d7b diff --git a/plugins/stockpiles/StockpileSerializer.cpp b/plugins/stockpiles/StockpileSerializer.cpp index cdeced990..e5873988f 100644 --- a/plugins/stockpiles/StockpileSerializer.cpp +++ b/plugins/stockpiles/StockpileSerializer.cpp @@ -417,7 +417,7 @@ void StockpileSerializer::serialize_list_itemdef ( FuncWriteExport add_value, s { const df::itemdef *a = items.at ( i ); // skip procedurally generated items - if ( a->base_flags.is_set ( 0 ) ) continue; + if ( a->base_flags.is_set ( df::itemdef_flags::GENERATED ) ) continue; ItemTypeInfo ii; if ( !ii.decode ( type, i ) ) continue; add_value ( ii.getToken() ); From 405af5a20b131f8bc0a098c56b02fca6cd2811f1 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 02:01:21 -0400 Subject: [PATCH 68/75] Update structures --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index e42376086..a7dae6083 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit e42376086e04fe6db338eadefb00511dcccf1d7b +Subproject commit a7dae6083d295821afe2ba91073d9b7547395b45 From 1546d9ec1a3c5673dfa49795bb8a956bf17c3b2d Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 02:41:27 -0400 Subject: [PATCH 69/75] Tweak docs from #1484 --- docs/Plugins.rst | 4 ++-- plugins/getplants.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Plugins.rst b/docs/Plugins.rst index 9e8911db1..421e5e81b 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -2322,9 +2322,9 @@ restricting the list to trees, shrubs, and farmable shrubs, respectively. designation). See :issue:`1479` for details. The implementation another known deficiency: it's incapable of detecting that - RAW definitions that specify a seed extraction reaction for the structural part + raw definitions that specify a seed extraction reaction for the structural part but has no other use for it cannot actually yield any seeds, as the part is - never used (parts of bug tracker report 6940, e.g. Red Spinach), even though DF + never used (parts of :bug:`6940`, e.g. Red Spinach), even though DF collects it, unless there's a workshop reaction to do it (which there isn't in vanilla). diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index 11717b36b..d678a63b0 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -64,7 +64,7 @@ enum class selectability { // Both Red Spinach and Elephant-Head Amaranth have the seed extraction reaction // explicitly specified for the structural part, but no other use for it. This causes // these parts to be collected (a valid reaction is defined), but remain unusable. This -// is one ofthe issues in bug 9640 on the bug tracker (the others cases are detected and +// is one of the issues in bug 9640 on the bug tracker (the others cases are detected and // result in the plants not being usable for farming or even collectable at all). //selectability selectablePlant(color_ostream &out, const df::plant_raw *plant, bool farming) From f008da32f8ef555cb048e76a31434c7b5214c869 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 17:58:09 -0400 Subject: [PATCH 70/75] Update submodules --- library/xml | 2 +- plugins/getplants.cpp | 2 +- scripts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/xml b/library/xml index a7dae6083..08d81cea7 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit a7dae6083d295821afe2ba91073d9b7547395b45 +Subproject commit 08d81cea7c32fee3fd55deb434d9f43e3b228497 diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index d678a63b0..d1ee79a04 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -64,7 +64,7 @@ enum class selectability { // Both Red Spinach and Elephant-Head Amaranth have the seed extraction reaction // explicitly specified for the structural part, but no other use for it. This causes // these parts to be collected (a valid reaction is defined), but remain unusable. This -// is one of the issues in bug 9640 on the bug tracker (the others cases are detected and +// is one of the issues in bug 6940 on the bug tracker (the others cases are detected and // result in the plants not being usable for farming or even collectable at all). //selectability selectablePlant(color_ostream &out, const df::plant_raw *plant, bool farming) diff --git a/scripts b/scripts index 73f89fe3d..b5ea085b5 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 73f89fe3d48e52d9d860462df02d488b73de0953 +Subproject commit b5ea085b5cfc9411d7374257db245a0ebefed380 From 02c118335f3f399ea41f9c0129cd13e840abc7c7 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 17:59:50 -0400 Subject: [PATCH 71/75] Restore build-lua.sh for build-env --- travis/build-lua.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 travis/build-lua.sh diff --git a/travis/build-lua.sh b/travis/build-lua.sh new file mode 100644 index 000000000..e29d7ce87 --- /dev/null +++ b/travis/build-lua.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e + +LUA_ROOT="$HOME/lua53" +LUA_URL="http://www.lua.org/ftp/lua-5.3.3.tar.gz" +LUA_TAR=$(basename "$LUA_URL") +LUA_DIR="$LUA_ROOT/${LUA_TAR%.tar.*}" +LUA_SHA1="a0341bc3d1415b814cc738b2ec01ae56045d64ef" + +echo LUA_ROOT $LUA_ROOT +echo LUA_TAR $LUA_TAR +echo LUA_DIR $LUA_DIR + +sha1() { + python -c 'import hashlib, sys; print(hashlib.sha1(open(sys.argv[1],"rb").read()).hexdigest())' "$1" +} + +download() { + echo "Downloading $LUA_URL" + wget -O "$LUA_ROOT/$LUA_TAR" "$LUA_URL" + tar xvf "$LUA_ROOT/$LUA_TAR" +} + +build() { + cd "$LUA_DIR/src" + make generic +} + +main() { + mkdir -p "$LUA_ROOT" + cd "$LUA_ROOT" + mkdir -p bin + + if [ "$(sha1 "$LUA_ROOT/$LUA_TAR" 2>/dev/null)" != "$LUA_SHA1" ]; then + download + build + else + echo "Already downloaded" + + if [ -x "$LUA_DIR/src/luac" ]; then + echo "Already built" + else + build + fi + fi + + echo "Linking" + ln -sf "$LUA_DIR/src/lua" "$LUA_ROOT/bin/lua5.3" + ln -sf "$LUA_DIR/src/luac" "$LUA_ROOT/bin/luac5.3" + echo "Done" +} + +main From 3380f9ccf49e47e551168cfa48b947a4d00f9ded Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 21:03:32 -0400 Subject: [PATCH 72/75] Update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 6ce9f69fd..3a20e1766 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -41,6 +41,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - Fixed translation of certain types of in-game names +- Fixed a crash in ``find()`` for some types when no world is loaded - `autogems`: fixed an issue with binned gems being ignored in linked stockpiles - `tweak` embark-profile-name: fixed handling of the native shift+space key From 7a2ef4ff608df930c5cdf7d70e8367330a96997d Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 21:14:27 -0400 Subject: [PATCH 73/75] Update scripts --- scripts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts b/scripts index b5ea085b5..b3c2e1402 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit b5ea085b5cfc9411d7374257db245a0ebefed380 +Subproject commit b3c2e14029ebc544ea677738e3d155eaf732ef4c From f76b890cc8434f077285e83ca7ca147c245f0140 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 21:18:33 -0400 Subject: [PATCH 74/75] Ensure that dev changelogs are also sorted, since they are pulled in from multiple files now --- docs/gen_changelog.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/gen_changelog.py b/docs/gen_changelog.py index cd27d99d2..8b1a6771e 100644 --- a/docs/gen_changelog.py +++ b/docs/gen_changelog.py @@ -235,6 +235,7 @@ def generate_changelog(all=False): dev_entries[entry.dev_version][entry.section].append(entry) consolidate_changelog(stable_entries) + consolidate_changelog(dev_entries) print_changelog(versions, stable_entries, 'docs/_auto/news.rst') print_changelog(versions, dev_entries, 'docs/_auto/news-dev.rst') From 6bdbf5b0ddaa045a8fc6ff91e91dc30cb3d21e3f Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 25 Apr 2020 21:33:02 -0400 Subject: [PATCH 75/75] Update to 0.47.04-r1, update xml, scripts, changelog version --- CMakeLists.txt | 4 ++-- docs/changelog.txt | 2 ++ library/xml | 2 +- scripts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8dd5dc86..5a5e8312b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,8 +180,8 @@ endif() # set up versioning. set(DF_VERSION "0.47.04") -set(DFHACK_RELEASE "beta1") -set(DFHACK_PRERELEASE TRUE) +set(DFHACK_RELEASE "r1") +set(DFHACK_PRERELEASE FALSE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") diff --git a/docs/changelog.txt b/docs/changelog.txt index 16105efc2..d3ed3e51c 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -39,6 +39,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future +# 0.47.04-r1 + ## Fixes - Fixed translation of certain types of in-game names - Fixed a crash in ``find()`` for some types when no world is loaded diff --git a/library/xml b/library/xml index 08d81cea7..0792fc020 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 08d81cea7c32fee3fd55deb434d9f43e3b228497 +Subproject commit 0792fc0202fb6a04bfdaa262bc36a3b14c8581e5 diff --git a/scripts b/scripts index b3c2e1402..2079b9fb6 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit b3c2e14029ebc544ea677738e3d155eaf732ef4c +Subproject commit 2079b9fb69b8b4db48aa35ec54a96f5cca7cc8ef