From 9319ebfba0f2890605f9ba3541b9a4955316bf18 Mon Sep 17 00:00:00 2001 From: AtomicChicken Date: Tue, 19 Apr 2016 15:47:05 +0200 Subject: [PATCH 01/51] Update item-trigger.lua Fixed an error caused by item-trigger attempting to handle item types which lack a subtype, whilst simultaneously adding support for such items. --- scripts/modtools/item-trigger.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/modtools/item-trigger.lua b/scripts/modtools/item-trigger.lua index 78c8a4332..cf00ed749 100644 --- a/scripts/modtools/item-trigger.lua +++ b/scripts/modtools/item-trigger.lua @@ -64,10 +64,18 @@ function processTrigger(command) dfhack.run_command(table.unpack(command2)) end +function getitemType(item) +if item:getSubtype() ~= -1 then +itemType = dfhack.items.getSubtypeDef(item:getType(),item:getSubtype()).id +else itemType = df.item_type[item:getType()] +end +return itemType +end + function handler(table) local itemMat = dfhack.matinfo.decode(table.item) local itemMatStr = itemMat:getToken() - local itemType = dfhack.items.getSubtypeDef(table.item:getType(),table.item:getSubtype()).id + local itemType = getitemType(table.item) table.itemMat = itemMat table.itemType = itemType @@ -177,6 +185,7 @@ arguments: trigger the command for items of this type examples: ITEM_WEAPON_PICK + RING -onStrike trigger the command when someone strikes someone with an appropriate weapon -onEquip @@ -243,6 +252,7 @@ if not args.command then end if args.itemType then + if dfhack.items.findType(args.itemType) == -1 then local temp for _,itemdef in ipairs(df.global.world.raws.itemdefs.all) do if itemdef.id == args.itemType then @@ -254,6 +264,7 @@ if args.itemType then error 'Could not find item type.' end args.itemType = temp + end end local numConditions = (args.material and 1 or 0) + (args.itemType and 1 or 0) + (args.contaminant and 1 or 0) From acac839371d1d15d20c0316575721e8e1e8fae1c Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Wed, 20 Apr 2016 11:08:02 +1000 Subject: [PATCH 02/51] Replace fixdiplomats, fixmerchants with scripts --- NEWS.rst | 2 + docs/Plugins.rst | 12 -- plugins/CMakeLists.txt | 1 - plugins/fixpositions.cpp | 244 -------------------------------------- scripts/fix/diplomats.lua | 100 ++++++++++++++++ scripts/fix/merchants.lua | 95 +++++++++++++++ 6 files changed, 197 insertions(+), 257 deletions(-) delete mode 100644 plugins/fixpositions.cpp create mode 100644 scripts/fix/diplomats.lua create mode 100644 scripts/fix/merchants.lua diff --git a/NEWS.rst b/NEWS.rst index 54954029b..751daceb3 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -112,6 +112,8 @@ Misc Improvements - `createitem`: Can now create items anywhere without specifying a unit, as long as a unit exists on the map - `devel/export-dt-ini`: Updated for 0.42.06 - `devel/find-offsets`: Automated several more scans +- `fix/diplomats`: replaces ``fixdiplomats`` +- `fix/merchants`: replaces ``fixmerchants`` - `gui/gm-editor`: Now supports finding some items with a numeric ID (with ``i``) - `lua`: Now supports some built-in variables like `gui/gm-editor`, e.g. ``unit``, ``screen`` - `remotefortressreader`: Can now trigger keyboard events diff --git a/docs/Plugins.rst b/docs/Plugins.rst index 4e1886e8d..0c4a3237b 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -180,18 +180,6 @@ Bugfixes .. contents:: :local: -fixdiplomats -============ -Adds a Diplomat position to all Elven civilizations, allowing them to negotiate -tree cutting quotas - and you to violate them and start wars. -This was vanilla behaviour until ``0.31.12``, in which the "bug" was "fixed". - -fixmerchants -============ -Adds the Guild Representative position to all Human civilizations, -allowing them to make trade agreements. This was the default behaviour in -``0.28.181.40d`` and earlier. - .. _fix-unit-occupancy: fix-unit-occupancy diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index dd1c6344f..cc0de019f 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -99,7 +99,6 @@ if (BUILD_SUPPORTED) DFHACK_PLUGIN(fastdwarf fastdwarf.cpp) DFHACK_PLUGIN(filltraffic filltraffic.cpp) DFHACK_PLUGIN(fix-armory fix-armory.cpp) - DFHACK_PLUGIN(fixpositions fixpositions.cpp) DFHACK_PLUGIN(fix-unit-occupancy fix-unit-occupancy.cpp) DFHACK_PLUGIN(fixveins fixveins.cpp) DFHACK_PLUGIN(flows flows.cpp) diff --git a/plugins/fixpositions.cpp b/plugins/fixpositions.cpp deleted file mode 100644 index e136ee0a9..000000000 --- a/plugins/fixpositions.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// Fix Entity Positions - make sure Elves have diplomats and Humans have guild representatives - -#include "Core.h" -#include -#include -#include - -#include -#include "df/world.h" -#include "df/historical_entity.h" -#include "df/entity_raw.h" -#include "df/entity_position.h" -#include "df/entity_position_responsibility.h" -#include "df/entity_position_assignment.h" - -using std::string; -using std::vector; -using namespace DFHack; -using namespace df::enums; - -DFHACK_PLUGIN("fixpositions"); -REQUIRE_GLOBAL(world); - -command_result df_fixdiplomats (color_ostream &out, vector ¶meters) -{ - if (!parameters.empty()) - return CR_WRONG_USAGE; - - CoreSuspender suspend; - - int checked = 0, fixed = 0; - for (int i = 0; i < world->entities.all.size(); i++) - { - df::historical_entity *ent = world->entities.all[i]; - // only work with civilizations - ignore groups and religions - if (ent->type != 0) - continue; - // only add diplomats for tree cap diplomacy - if (!ent->entity_raw->flags.is_set(entity_raw_flags::TREE_CAP_DIPLOMACY)) - continue; - checked++; - - bool update = true; - df::entity_position *pos = NULL; - // see if we need to add a new position or modify an existing one - for (int j = 0; j < ent->positions.own.size(); j++) - { - pos = ent->positions.own[j]; - if (pos->responsibilities[entity_position_responsibility::MAKE_INTRODUCTIONS] && - pos->responsibilities[entity_position_responsibility::MAKE_PEACE_AGREEMENTS] && - pos->responsibilities[entity_position_responsibility::MAKE_TOPIC_AGREEMENTS]) - { - // a diplomat position exists with the proper responsibilities - skip to the end - update = false; - break; - } - // Diplomat position already exists, but has the wrong options - modify it instead of creating a new one - if (pos->code == "DIPLOMAT") - break; - pos = NULL; - } - if (update) - { - // either there's no diplomat, or there is one and it's got the wrong responsibilities - if (!pos) - { - // there was no diplomat - create it - pos = new df::entity_position; - ent->positions.own.push_back(pos); - - pos->code = "DIPLOMAT"; - pos->id = ent->positions.next_position_id++; - pos->flags.set(entity_position_flags::DO_NOT_CULL); - pos->flags.set(entity_position_flags::MENIAL_WORK_EXEMPTION); - pos->flags.set(entity_position_flags::SLEEP_PRETENSION); - pos->flags.set(entity_position_flags::PUNISHMENT_EXEMPTION); - pos->flags.set(entity_position_flags::ACCOUNT_EXEMPT); - pos->flags.set(entity_position_flags::DUTY_BOUND); - pos->flags.set(entity_position_flags::COLOR); - pos->flags.set(entity_position_flags::HAS_RESPONSIBILITIES); - pos->flags.set(entity_position_flags::IS_DIPLOMAT); - pos->flags.set(entity_position_flags::IS_LEADER); - // not sure what these flags do, but the game sets them for a valid diplomat - pos->flags.set(entity_position_flags::unk_12); - pos->flags.set(entity_position_flags::unk_1a); - pos->flags.set(entity_position_flags::unk_1b); - pos->name[0] = "Diplomat"; - pos->name[1] = "Diplomats"; - pos->precedence = 70; - pos->color[0] = 7; - pos->color[1] = 0; - pos->color[2] = 1; - } - // assign responsibilities - pos->responsibilities[entity_position_responsibility::MAKE_INTRODUCTIONS] = true; - pos->responsibilities[entity_position_responsibility::MAKE_PEACE_AGREEMENTS] = true; - pos->responsibilities[entity_position_responsibility::MAKE_TOPIC_AGREEMENTS] = true; - } - - // make sure the diplomat position, whether we created it or not, is set up for proper assignment - bool assign = true; - for (int j = 0; j < ent->positions.assignments.size(); j++) - { - if (ent->positions.assignments[j]->position_id == pos->id) - { - // it is - nothing more to do here - assign = false; - break; - } - } - if (assign) - { - // it isn't - set it up - df::entity_position_assignment *asn = new df::entity_position_assignment; - ent->positions.assignments.push_back(asn); - - asn->id = ent->positions.next_assignment_id++; - asn->position_id = pos->id; - asn->flags.extend(0x1F); // make room for 32 flags - asn->flags.set(0); // and set the first one - } - if (update || assign) - fixed++; - } - out.print("Fixed %d of %d civilizations to enable tree cap diplomacy.\n", fixed, checked); - return CR_OK; -} - -command_result df_fixmerchants (color_ostream &out, vector ¶meters) -{ - if (!parameters.empty()) - return CR_WRONG_USAGE; - - CoreSuspender suspend; - - int checked = 0, fixed = 0; - for (int i = 0; i < world->entities.all.size(); i++) - { - df::historical_entity *ent = world->entities.all[i]; - // only work with civilizations - ignore groups and religions - if (ent->type != 0) - continue; - // only add guild reps for merchant nobility - if (!ent->entity_raw->flags.is_set(entity_raw_flags::MERCHANT_NOBILITY)) - continue; - checked++; - - bool update = true; - df::entity_position *pos = NULL; - // see if we need to add a new position or modify an existing one - for (int j = 0; j < ent->positions.own.size(); j++) - { - pos = ent->positions.own[j]; - if (pos->responsibilities[entity_position_responsibility::TRADE]) - { - // a guild rep exists with the proper responsibilities - skip to the end - update = false; - break; - } - // Guild Representative position already exists, but has the wrong options - modify it instead of creating a new one - if (pos->code == "GUILD_REPRESENTATIVE") - break; - pos = NULL; - } - if (update) - { - // either there's no guild rep, or there is one and it's got the wrong responsibilities - if (!pos) - { - // there was no guild rep - create it - pos = new df::entity_position; - ent->positions.own.push_back(pos); - - pos->code = "GUILD_REPRESENTATIVE"; - pos->id = ent->positions.next_position_id++; - pos->flags.set(entity_position_flags::DO_NOT_CULL); - pos->flags.set(entity_position_flags::MENIAL_WORK_EXEMPTION); - pos->flags.set(entity_position_flags::SLEEP_PRETENSION); - pos->flags.set(entity_position_flags::PUNISHMENT_EXEMPTION); - pos->flags.set(entity_position_flags::ACCOUNT_EXEMPT); - pos->flags.set(entity_position_flags::DUTY_BOUND); - pos->flags.set(entity_position_flags::COLOR); - pos->flags.set(entity_position_flags::HAS_RESPONSIBILITIES); - pos->flags.set(entity_position_flags::IS_DIPLOMAT); - pos->flags.set(entity_position_flags::IS_LEADER); - // not sure what these flags do, but the game sets them for a valid guild rep - pos->flags.set(entity_position_flags::unk_12); - pos->flags.set(entity_position_flags::unk_1a); - pos->flags.set(entity_position_flags::unk_1b); - pos->name[0] = "Guild Representative"; - pos->name[1] = "Guild Representatives"; - pos->precedence = 40; - pos->color[0] = 7; - pos->color[1] = 0; - pos->color[2] = 1; - } - // assign responsibilities - pos->responsibilities[entity_position_responsibility::TRADE] = true; - } - - // make sure the guild rep position, whether we created it or not, is set up for proper assignment - bool assign = true; - for (int j = 0; j < ent->positions.assignments.size(); j++) - { - if (ent->positions.assignments[j]->position_id == pos->id) - { - // it is - nothing more to do here - assign = false; - break; - } - } - if (assign) - { - // it isn't - set it up - df::entity_position_assignment *asn = new df::entity_position_assignment; - ent->positions.assignments.push_back(asn); - - asn->id = ent->positions.next_assignment_id++; - asn->position_id = pos->id; - asn->flags.extend(0x1F); // make room for 32 flags - asn->flags.set(0); // and set the first one - } - if (update || assign) - fixed++; - } - out.print("Fixed %d of %d civilizations to enable merchant nobility.\n", fixed, checked); - return CR_OK; -} - -DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) -{ - commands.push_back(PluginCommand( - "fixdiplomats", "Add Diplomat position to Elven civilizations for tree cap diplomacy.", - df_fixdiplomats, false)); - commands.push_back(PluginCommand( - "fixmerchants", "Add Guild Representative position to Human civilizations for merchant nobility.", - df_fixmerchants, false)); - return CR_OK; -} - -DFhackCExport command_result plugin_shutdown ( color_ostream &out ) -{ - return CR_OK; -} diff --git a/scripts/fix/diplomats.lua b/scripts/fix/diplomats.lua new file mode 100644 index 000000000..b1bcfe70b --- /dev/null +++ b/scripts/fix/diplomats.lua @@ -0,0 +1,100 @@ +-- Add Elven diplomats to negotiate tree caps +--[[=begin + +fix/diplomats +============= +Adds a Diplomat position to all Elven civilizations, allowing them to negotiate +tree cutting quotas - and you to violate them and start wars. +This was vanilla behaviour until ``0.31.12``, in which the "bug" was "fixed". + +=end]] + + +function update_pos(pos, ent) + pos = df.entity_position:new() + ent.positions.own:insert('#', pos) + + pos.code = "DIPLOMAT" + pos.id = ent.positions.next_position_id + 1 + pos.flags.DO_NOT_CULL = true + pos.flags.MENIAL_WORK_EXEMPTION = true + pos.flags.SLEEP_PRETENSION = true + pos.flags.PUNISHMENT_EXEMPTION = true + pos.flags.ACCOUNT_EXEMPT = true + pos.flags.DUTY_BOUND = true + pos.flags.COLOR = true + pos.flags.HAS_RESPONSIBILITIES = true + pos.flags.IS_DIPLOMAT = true + pos.flags.IS_LEADER = true + -- not sure what these flags do, but the game sets them for a valid diplomat + pos.flags.unk_12 = true + pos.flags.unk_1a = true + pos.flags.unk_1b = true + pos.name[0] = "Diplomat" + pos.name[1] = "Diplomats" + pos.precedence = 70 + pos.color[0] = 7 + pos.color[1] = 0 + pos.color[2] = 1 + + return pos +end + + + +checked = 0 +fixed = 0 + +for _,ent in pairs(df.global.world.entities.all) do + if ent.type == 0 and ent.entity_raw.flags.TREE_CAP_DIPLOMACY then + checked = checked + 1 + + update = true + -- see if we need to add a new position or modify an existing one + for _,pos in pairs(ent.positions.own) do + if pos.responsibilities.MAKE_INTRODUCTIONS and + pos.responsibilities.MAKE_PEACE_AGREEMENTS and + pos.responsibilities.MAKE_TOPIC_AGREEMENTS then + -- a diplomat position exists with the proper responsibilities - skip to the end + update = false + break + end + -- Diplomat position already exists, but has the wrong options - modify it instead of creating a new one + if pos.code == "DIPLOMAT" then break end + pos = nil + end + if update then + -- either there's no diplomat, or there is one and it's got the wrong responsibilities + if not pos then + pos = add_guild_rep(pos, ent) + end + -- assign responsibilities + pos.responsibilities.MAKE_INTRODUCTIONS = true + pos.responsibilities.MAKE_PEACE_AGREEMENTS = true + pos.responsibilities.MAKE_TOPIC_AGREEMENTS = true + end + -- make sure the diplomat position, whether we created it or not, is set up for proper assignment + assign = true + for _,p in pairs(ent.positions.assignments) do + if p.position_id == pos.id then -- it is - nothing more to do here + assign = false + break + end + end + if assign then -- it isn't - set it up + asn = df.entity_position_assignment:new() + ent.positions.assignments:insert('#', asn); + + asn.id = ent.positions.next_assignment_id + ent.positions.next_assignment_id = asn.id + 1 + asn.position_id = pos.id + asn.flags:resize(math.max(32, #asn.flags)) -- make room for 32 flags + asn.flags[0] = true -- and set the first one + end + if update or assign then + fixed = fixed + 1 + end + end +end + +print("Enabled tree cap diplomacy for "..fixed.." of "..checked.." civilizations.") diff --git a/scripts/fix/merchants.lua b/scripts/fix/merchants.lua new file mode 100644 index 000000000..ae25ec9b2 --- /dev/null +++ b/scripts/fix/merchants.lua @@ -0,0 +1,95 @@ +-- Allow humans to make trade agreements +--[[=begin + +fix/merchants +============= +Adds the Guild Representative position to all Human civilizations, +allowing them to make trade agreements. This was the default behaviour in +``0.28.181.40d`` and earlier. + +=end]] +checked = 0 +fixed = 0 + +function add_guild_rep(pos, ent) + -- there was no guild rep - create it + pos = df.entity_position:new() + ent.positions.own:insert('#', pos) + + pos.code = "GUILD_REPRESENTATIVE" + pos.id = ent.positions.next_position_id + 1 + pos.flags.DO_NOT_CULL = true + pos.flags.MENIAL_WORK_EXEMPTION = true + pos.flags.SLEEP_PRETENSION = true + pos.flags.PUNISHMENT_EXEMPTION = true + pos.flags.ACCOUNT_EXEMPT = true + pos.flags.DUTY_BOUND = true + pos.flags.COLOR = true + pos.flags.HAS_RESPONSIBILITIES = true + pos.flags.IS_DIPLOMAT = true + pos.flags.IS_LEADER = true + -- not sure what these flags do, but the game sets them for a valid guild rep + pos.flags.unk_12 = true + pos.flags.unk_1a = true + pos.flags.unk_1b = true + pos.name[0] = "Guild Representative" + pos.name[1] = "Guild Representatives" + pos.precedence = 40 + pos.color[0] = 7 + pos.color[1] = 0 + pos.color[2] = 1 + return pos +end + + +for _,ent in pairs(df.global.world.entities.all) do + if ent.type == 0 and ent.entity_raw.flags.MERCHANT_NOBILITY then + checked = checked + 1 + + update = true + -- see if we need to add a new position or modify an existing one + for _,pos in pairs(ent.positions.own) do + if pos.responsibilities.TRADE then + -- a guild rep exists with the proper responsibilities - skip to the end + update = false + break + end + -- Guild Representative position already exists, but has the wrong options - modify it instead of creating a new one + if pos.code == "GUILD_REPRESENTATIVE" then break end + pos = nil + end + if update then + -- either there's no guild rep, or there is one and it's got the wrong responsibilities + if not pos then + pos = add_guild_rep(pos, ent) + end + -- assign responsibilities + pos.responsibilities.ESTABLISH_COLONY_TRADE_AGREEMENTS = true + end + + -- make sure the guild rep position, whether we created it or not, is set up for proper assignment + assign = true + for _,p in pairs(ent.positions.assignments) do + if p.position_id == pos.id then -- it is - nothing more to do here + assign = false + break + end + end + if assign then + -- it isn't - set it up + asn = df.entity_position_assignment:new() + ent.positions.assignments:insert('#', asn) + + asn.id = ent.positions.next_assignment_id + ent.positions.next_assignment_id = asn.id + 1 + asn.position_id = pos.id + asn.flags:resize(math.max(32, #asn.flags)) -- make room for 32 flags + asn.flags[0] = true -- and set the first one + end + if update or assign then + fixed = fixed + 1 + end + end +end + +print("Added merchant nobility for "..fixed.." of "..checked.." civilizations.") From 0d8a80c2ecf1c7af2962aa69d1da31afe8274e4d Mon Sep 17 00:00:00 2001 From: AtomicChicken Date: Wed, 20 Apr 2016 11:08:49 +0200 Subject: [PATCH 03/51] Update item-trigger.lua added proper indentation --- scripts/modtools/item-trigger.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/modtools/item-trigger.lua b/scripts/modtools/item-trigger.lua index cf00ed749..1e973d6aa 100644 --- a/scripts/modtools/item-trigger.lua +++ b/scripts/modtools/item-trigger.lua @@ -65,11 +65,12 @@ function processTrigger(command) end function getitemType(item) -if item:getSubtype() ~= -1 then -itemType = dfhack.items.getSubtypeDef(item:getType(),item:getSubtype()).id -else itemType = df.item_type[item:getType()] -end -return itemType + if item:getSubtype() ~= -1 then + itemType = dfhack.items.getSubtypeDef(item:getType(),item:getSubtype()).id + else + itemType = df.item_type[item:getType()] + end + return itemType end function handler(table) From 68267d2ab3cac1b70550f364d9a11a6abf8fa3f9 Mon Sep 17 00:00:00 2001 From: AtomicChicken Date: Wed, 20 Apr 2016 12:05:48 +0200 Subject: [PATCH 04/51] Update item-trigger.lua whitespace removed --- scripts/modtools/item-trigger.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/modtools/item-trigger.lua b/scripts/modtools/item-trigger.lua index 1e973d6aa..378937961 100644 --- a/scripts/modtools/item-trigger.lua +++ b/scripts/modtools/item-trigger.lua @@ -65,10 +65,10 @@ function processTrigger(command) end function getitemType(item) - if item:getSubtype() ~= -1 then + if item:getSubtype() ~= -1 then itemType = dfhack.items.getSubtypeDef(item:getType(),item:getSubtype()).id - else - itemType = df.item_type[item:getType()] + else + itemType = df.item_type[item:getType()] end return itemType end From 3ee829f05b8876362baa446233c6340bc2df405f Mon Sep 17 00:00:00 2001 From: Warmist Date: Sat, 30 Apr 2016 22:10:01 +0300 Subject: [PATCH 05/51] Allow to insert ints and other simple types. Also allow inserting of same base type as the container. Also simplify it a bit. --- scripts/gui/gm-editor.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/gui/gm-editor.lua b/scripts/gui/gm-editor.lua index 9012cbd55..c8cdf5d3d 100644 --- a/scripts/gui/gm-editor.lua +++ b/scripts/gui/gm-editor.lua @@ -211,22 +211,26 @@ function GmEditorUi:find_id() end function GmEditorUi:insertNew(typename) local tp=typename - if typename== nil then - dialog.showInputPrompt("Class type","Input class type:",COLOR_WHITE,"",self:callback("insertNew")) - return - end - local ntype=df[tp] - if ntype== nil then - dialog.showMessage("Error!","Type '"..tp.." not found",COLOR_LIGHTRED) + if typename == nil then + dialog.showInputPrompt("Class type","Input class type or leave empty for auto and '*' for new ptr type auto:",COLOR_WHITE,"",self:callback("insertNew")) return end local trg=self:currentTarget() if trg.target and trg.target._kind and trg.target._kind=="container" then - local thing=ntype:new() - dfhack.call_with_finalizer(1,false,df.delete,thing,function (tscreen,target,to_insert) - target:insert("#",to_insert); tscreen:updateTarget(true,true);end,self,trg.target,thing) - + if tp == "" then + trg.target:resize(#trg.target+1) + elseif tp== "*" then + trg.target:insert("#",{new=true}) + else + local ntype=df[tp] + if ntype== nil then + dialog.showMessage("Error!","Type '"..tp.." not found",COLOR_RED) + return + end + trg.target:insert("#",{new=ntype}) + end + self:updateTarget(true,true) end end function GmEditorUi:deleteSelected(key) From 523638a89912f493f2740133b028d78b718c9284 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sat, 30 Apr 2016 22:13:38 +0300 Subject: [PATCH 06/51] Add news entry --- NEWS.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 3bf4c4276..ddefbf985 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -33,6 +33,10 @@ Changelog DFHack future ============= +Lua +--- +- `gui/gm-editor` it's now possible to insert default types to containers. For primitive types leave the type entry empty, for references use ``*``. + DFHack 0.42.06-r1 ================= From a5a61ce6b0ef2b97eb04c338888e60f774eb5d86 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sat, 30 Apr 2016 23:01:48 +0300 Subject: [PATCH 07/51] I think i got the perfect message now. --- scripts/gui/gm-editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gui/gm-editor.lua b/scripts/gui/gm-editor.lua index c8cdf5d3d..9b03ba279 100644 --- a/scripts/gui/gm-editor.lua +++ b/scripts/gui/gm-editor.lua @@ -212,7 +212,7 @@ end function GmEditorUi:insertNew(typename) local tp=typename if typename == nil then - dialog.showInputPrompt("Class type","Input class type or leave empty for auto and '*' for new ptr type auto:",COLOR_WHITE,"",self:callback("insertNew")) + dialog.showInputPrompt("Class type","You can:\n * Enter type name (without 'df.')\n * Leave empty for default type and 'nil' value\n * Enter '*' for default type and 'new' constructed pointer value",COLOR_WHITE,"",self:callback("insertNew")) return end From ce3c9d06a00e3b6102f0b022173b37553fdd9b44 Mon Sep 17 00:00:00 2001 From: Matsor Browncoat Date: Sun, 1 May 2016 19:50:03 +0200 Subject: [PATCH 08/51] Fixed quality in gui/create-item with -multi. When -multi option is selected, gui/create-item doesn't set quality neither on stackable nor unstackable items. Fixed this quirk. No refactoring or optimizations. Just moved a variable and added code inside the createItem function. --- scripts/gui/create-item.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/gui/create-item.lua b/scripts/gui/create-item.lua index d22f68904..a2c38247a 100644 --- a/scripts/gui/create-item.lua +++ b/scripts/gui/create-item.lua @@ -117,7 +117,7 @@ local function getMatFilter(itemtype) return itemTypes[df.item_type[itemtype]] or getRestrictiveMatFilter(itemtype) end -local function createItem(mat,itemType,quality,creator,description) +local function createItem(mat,itemType,quality,creator,description,amount) local item=df.item.find(dfhack.items.createItem(itemType[1], itemType[2], mat[1], mat[2], creator)) assert(item, 'failed to create item') quality = math.max(0, math.min(5, quality - 1)) @@ -125,6 +125,9 @@ local function createItem(mat,itemType,quality,creator,description) if df.item_type[itemType[1]]=='SLAB' then item.description=description end + if tonumber(amount) > 1 then + item:setStackSize(amount) + end end local function qualityTable() @@ -207,11 +210,10 @@ function hackWish(unit) if not amountok then return end if mattype and itemtype then if df.item_type.attrs[itemtype].is_stackable then - local proper_item=df.item.find(dfhack.items.createItem(itemtype, itemsubtype, mattype, matindex, unit)) - proper_item:setStackSize(amount) + createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,amount) else for i=1,amount do - dfhack.items.createItem(itemtype, itemsubtype, mattype, matindex, unit) + createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,1) end end return true @@ -219,7 +221,7 @@ function hackWish(unit) return false else if mattype and itemtype then - createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description) + createItem({mattype,matindex},{itemtype,itemsubtype},quality,unit,description,1) return true end return false From 88d1a79c0ce1e76cadea69d3e7e9a69f8bb01ad8 Mon Sep 17 00:00:00 2001 From: Warmist Date: Thu, 5 May 2016 13:47:29 +0300 Subject: [PATCH 09/51] Fix gui/mod-manager it fails if mods folder does not exist --- scripts/gui/mod-manager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gui/mod-manager.lua b/scripts/gui/mod-manager.lua index 692deeb62..5c3b39375 100644 --- a/scripts/gui/mod-manager.lua +++ b/scripts/gui/mod-manager.lua @@ -159,7 +159,7 @@ function manager:init(args) local mods=self.mods local mlist=dfhack.internal.getDir(mod_dir) - if #mlist==0 then + if mlist==nil or #mlist==0 then qerror("Mod directory not found! Are you sure it is in:"..mod_dir) end for k,v in ipairs(mlist) do From dde7d151b73144d812f28894442b2e73552256dc Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 8 May 2016 09:39:28 +0300 Subject: [PATCH 10/51] Fix few bugs with fix/diplomats.lua and fix/merchants.lua --- scripts/fix/diplomats.lua | 38 ++++++++++++++++++++++---------------- scripts/fix/merchants.lua | 39 ++++++++++++++++++++++++--------------- 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/scripts/fix/diplomats.lua b/scripts/fix/diplomats.lua index b1bcfe70b..5c2138f65 100644 --- a/scripts/fix/diplomats.lua +++ b/scripts/fix/diplomats.lua @@ -10,12 +10,14 @@ This was vanilla behaviour until ``0.31.12``, in which the "bug" was "fixed". =end]] -function update_pos(pos, ent) - pos = df.entity_position:new() +function update_pos(ent) + local pos = df.entity_position:new() ent.positions.own:insert('#', pos) pos.code = "DIPLOMAT" pos.id = ent.positions.next_position_id + 1 + ent.positions.next_position_id = ent.positions.next_position_id + 1 + pos.flags.DO_NOT_CULL = true pos.flags.MENIAL_WORK_EXEMPTION = true pos.flags.SLEEP_PRETENSION = true @@ -42,14 +44,15 @@ end -checked = 0 -fixed = 0 +local checked = 0 +local fixed = 0 for _,ent in pairs(df.global.world.entities.all) do - if ent.type == 0 and ent.entity_raw.flags.TREE_CAP_DIPLOMACY then + if ent.type == df.historical_entity_type.Civilization and ent.entity_raw.flags.TREE_CAP_DIPLOMACY then checked = checked + 1 update = true + local found_position -- see if we need to add a new position or modify an existing one for _,pos in pairs(ent.positions.own) do if pos.responsibilities.MAKE_INTRODUCTIONS and @@ -57,37 +60,40 @@ for _,ent in pairs(df.global.world.entities.all) do pos.responsibilities.MAKE_TOPIC_AGREEMENTS then -- a diplomat position exists with the proper responsibilities - skip to the end update = false + found_position=pos break end -- Diplomat position already exists, but has the wrong options - modify it instead of creating a new one - if pos.code == "DIPLOMAT" then break end - pos = nil + if pos.code == "DIPLOMAT" then + found_position=pos + break + end end if update then -- either there's no diplomat, or there is one and it's got the wrong responsibilities - if not pos then - pos = add_guild_rep(pos, ent) + if not found_position then + found_position = add_guild_rep( ent ) end -- assign responsibilities - pos.responsibilities.MAKE_INTRODUCTIONS = true - pos.responsibilities.MAKE_PEACE_AGREEMENTS = true - pos.responsibilities.MAKE_TOPIC_AGREEMENTS = true + found_position.responsibilities.MAKE_INTRODUCTIONS = true + found_position.responsibilities.MAKE_PEACE_AGREEMENTS = true + found_position.responsibilities.MAKE_TOPIC_AGREEMENTS = true end -- make sure the diplomat position, whether we created it or not, is set up for proper assignment - assign = true + local assign = true for _,p in pairs(ent.positions.assignments) do - if p.position_id == pos.id then -- it is - nothing more to do here + if p.position_id == found_position.id then -- it is - nothing more to do here assign = false break end end if assign then -- it isn't - set it up - asn = df.entity_position_assignment:new() + local asn = df.entity_position_assignment:new() ent.positions.assignments:insert('#', asn); asn.id = ent.positions.next_assignment_id ent.positions.next_assignment_id = asn.id + 1 - asn.position_id = pos.id + asn.position_id = found_position.id asn.flags:resize(math.max(32, #asn.flags)) -- make room for 32 flags asn.flags[0] = true -- and set the first one end diff --git a/scripts/fix/merchants.lua b/scripts/fix/merchants.lua index ae25ec9b2..09a158f48 100644 --- a/scripts/fix/merchants.lua +++ b/scripts/fix/merchants.lua @@ -8,16 +8,17 @@ allowing them to make trade agreements. This was the default behaviour in ``0.28.181.40d`` and earlier. =end]] -checked = 0 -fixed = 0 -function add_guild_rep(pos, ent) + +function add_guild_rep(ent) -- there was no guild rep - create it - pos = df.entity_position:new() + local pos = df.entity_position:new() ent.positions.own:insert('#', pos) pos.code = "GUILD_REPRESENTATIVE" pos.id = ent.positions.next_position_id + 1 + ent.positions.next_position_id = ent.positions.next_position_id + 1 + pos.flags.DO_NOT_CULL = true pos.flags.MENIAL_WORK_EXEMPTION = true pos.flags.SLEEP_PRETENSION = true @@ -38,51 +39,59 @@ function add_guild_rep(pos, ent) pos.color[0] = 7 pos.color[1] = 0 pos.color[2] = 1 + return pos end +local checked = 0 +local fixed = 0 for _,ent in pairs(df.global.world.entities.all) do - if ent.type == 0 and ent.entity_raw.flags.MERCHANT_NOBILITY then + if ent.type == df.historical_entity_type.Civilization and ent.entity_raw.flags.MERCHANT_NOBILITY then checked = checked + 1 update = true -- see if we need to add a new position or modify an existing one + local found_position for _,pos in pairs(ent.positions.own) do - if pos.responsibilities.TRADE then + if pos.responsibilities.TRADE and pos.responsibilities.ESTABLISH_COLONY_TRADE_AGREEMENTS then -- a guild rep exists with the proper responsibilities - skip to the end update = false + found_position=pos break end -- Guild Representative position already exists, but has the wrong options - modify it instead of creating a new one - if pos.code == "GUILD_REPRESENTATIVE" then break end - pos = nil + if pos.code == "GUILD_REPRESENTATIVE" then + found_position=pos + break + end end if update then -- either there's no guild rep, or there is one and it's got the wrong responsibilities - if not pos then - pos = add_guild_rep(pos, ent) + if not found_position then + found_position = add_guild_rep(ent) end -- assign responsibilities - pos.responsibilities.ESTABLISH_COLONY_TRADE_AGREEMENTS = true + found_position.responsibilities.ESTABLISH_COLONY_TRADE_AGREEMENTS = true + found_position.responsibilities.TRADE=true end -- make sure the guild rep position, whether we created it or not, is set up for proper assignment - assign = true + local assign = true for _,p in pairs(ent.positions.assignments) do - if p.position_id == pos.id then -- it is - nothing more to do here + if p.position_id == found_position.id then -- it is - nothing more to do here assign = false break end end if assign then -- it isn't - set it up - asn = df.entity_position_assignment:new() + local asn = df.entity_position_assignment:new() ent.positions.assignments:insert('#', asn) asn.id = ent.positions.next_assignment_id ent.positions.next_assignment_id = asn.id + 1 - asn.position_id = pos.id + asn.position_id = found_position.id asn.flags:resize(math.max(32, #asn.flags)) -- make room for 32 flags asn.flags[0] = true -- and set the first one end From c283e85fd559794d5f13bd28035c948a7029761e Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 8 May 2016 12:10:36 +0300 Subject: [PATCH 11/51] Fix whitespace --- scripts/fix/diplomats.lua | 4 ++-- scripts/fix/merchants.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/fix/diplomats.lua b/scripts/fix/diplomats.lua index 5c2138f65..4e8c6daf7 100644 --- a/scripts/fix/diplomats.lua +++ b/scripts/fix/diplomats.lua @@ -64,9 +64,9 @@ for _,ent in pairs(df.global.world.entities.all) do break end -- Diplomat position already exists, but has the wrong options - modify it instead of creating a new one - if pos.code == "DIPLOMAT" then + if pos.code == "DIPLOMAT" then found_position=pos - break + break end end if update then diff --git a/scripts/fix/merchants.lua b/scripts/fix/merchants.lua index 09a158f48..ae3ef4233 100644 --- a/scripts/fix/merchants.lua +++ b/scripts/fix/merchants.lua @@ -61,9 +61,9 @@ for _,ent in pairs(df.global.world.entities.all) do break end -- Guild Representative position already exists, but has the wrong options - modify it instead of creating a new one - if pos.code == "GUILD_REPRESENTATIVE" then + if pos.code == "GUILD_REPRESENTATIVE" then found_position=pos - break + break end end if update then From 8b8b58faefa711c61303731e56cae8a7a147e868 Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 9 May 2016 21:03:12 -0400 Subject: [PATCH 12/51] Update NEWS.rst and Authors.rst --- NEWS.rst | 20 +++++++++++++------- docs/Authors.rst | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 7ea93c13a..f5bbeae5d 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -33,16 +33,24 @@ Changelog DFHack future ============= -Lua ---- +New Features +------------ - `gui/gm-editor` it's now possible to insert default types to containers. For primitive types leave the type entry empty, for references use ``*``. -DFHack 0.42.06-r1 -================= - Fixes ----- - `exportlegends`: Improved handling of unknown enum items (fixes many errors) +- `gui/create-item`: Fixed quality when creating multiple items +- `gui/mod-manager`: Fixed error when mods folder doesn't exist +- `modtools/item-trigger`: Fixed handling of items with subtypes + +Misc Improvements +----------------- +- `fix/diplomats`: replaces ``fixdiplomats`` +- `fix/merchants`: replaces ``fixmerchants`` + +DFHack 0.42.06-r1 +================= Internals --------- @@ -127,8 +135,6 @@ Misc Improvements - `createitem`: Can now create items anywhere without specifying a unit, as long as a unit exists on the map - `devel/export-dt-ini`: Updated for 0.42.06 - `devel/find-offsets`: Automated several more scans -- `fix/diplomats`: replaces ``fixdiplomats`` -- `fix/merchants`: replaces ``fixmerchants`` - `gui/gm-editor`: Now supports finding some items with a numeric ID (with ``i``) - `lua`: Now supports some built-in variables like `gui/gm-editor`, e.g. ``unit``, ``screen`` - `remotefortressreader`: Can now trigger keyboard events diff --git a/docs/Authors.rst b/docs/Authors.rst index cff3ab352..29521320f 100644 --- a/docs/Authors.rst +++ b/docs/Authors.rst @@ -16,6 +16,7 @@ AndreasPK AndreasPK Angus Mezick amezick Antalia tamarakorr Anuradha Dissanayake falconne +AtomicChicken AtomicChicken belal jimhester Ben Lubar BenLubar Caldfir caldfir @@ -83,6 +84,7 @@ root Roses Pheosics Ross M RossM rout +rubybrowncoat rubybrowncoat Rumrusher rumrusher RusAnon RusAnon sami From c1e44c178f437beb4489bc66fad20a02d6340514 Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 9 May 2016 21:29:04 -0400 Subject: [PATCH 13/51] Add on_click/on_rclick handlers to widgets.Label Closes #919 --- NEWS.rst | 4 ++++ docs/Lua API.rst | 15 +++++++++------ library/lua/gui/widgets.lua | 20 ++++++++++++++++++-- scripts/gui/gm-editor.lua | 3 ++- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index f5bbeae5d..240e0ffc4 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -33,6 +33,10 @@ Changelog DFHack future ============= +Lua +--- +- Label widgets can now easily register handlers for mouse clicks + New Features ------------ - `gui/gm-editor` it's now possible to insert default types to containers. For primitive types leave the type entry empty, for references use ``*``. diff --git a/docs/Lua API.rst b/docs/Lua API.rst index 000884b19..2db98abad 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -44,7 +44,7 @@ also broadly maps to the ``df`` namespace in the headers generated for C++. The wrapper provides almost raw access to the memory of the game, so mistakes in manipulating objects are as likely to crash the game as equivalent plain C++ code would be. - + eg. NULL pointer access is safely detected, but dangling pointers aren't. Objects managed by the wrapper can be broadly classified into the following groups: @@ -180,7 +180,7 @@ They implement the following features: In case of inheritance, *superclass* fields have precedence over the subclass, but fields shadowed in this way can still be accessed as ``ref['subclasstype.field']``. - + This shadowing order is necessary because vtable-based classes are automatically exposed in their exact type, and the reverse rule would make access to superclass fields unreliable. @@ -3051,10 +3051,13 @@ It has the following attributes: :text_pen: Specifies the pen for active text. :text_dpen: Specifies the pen for disabled text. +:text_hpen: Specifies the pen for text hovered over by the mouse, if a click handler is registered. :disabled: Boolean or a callback; if true, the label is disabled. :enabled: Boolean or a callback; if false, the label is disabled. :auto_height: Sets self.frame.h from the text height. :auto_width: Sets self.frame.w from the text width. +:on_click: A callback called when the label is clicked (optional) +:on_rclick: A callback called when the label is right-clicked (optional) The text itself is represented as a complex structure, and passed to the object via the ``text`` argument of the constructor, or via @@ -3499,7 +3502,7 @@ Functions :name: custom workshop id e.g. ``SOAPMAKER`` - + .. note:: this is the only mandatory field. :fix_impassible: @@ -3678,15 +3681,15 @@ Note that this function lets errors propagate to the caller. Run an Lua script and return its environment. This command allows you to use scripts like modules for increased portability. It is highly recommended that if you are a modder you put your custom modules in ``raw/scripts`` and use ``script_environment`` instead of ``require`` so that saves with your mod installed will be self-contained and can be transferred to people who do have DFHack but do not have your mod installed. - + You can say ``dfhack.script_environment('add-thought').addEmotionToUnit([arguments go here])`` and it will have the desired effect. It will call the script in question with the global ``moduleMode`` set to ``true`` so that the script can return early. This is useful because if the script is called from the console it should deal with its console arguments and if it is called by ``script_environment`` it should only create its global functions and return. You can also access global variables with, for example ``print(dfhack.script_environment('add-thought').validArgs)`` - + The function ``script_environment`` is fast enough that it is recommended that you not store its result in a nonlocal variable, because your script might need to load a different version of that script if the save is unloaded and a save with a different mod that overrides the same script with a slightly different functionality is loaded. This will not be an issue in most cases. - + This function also permits circular dependencies of scripts. * ``dfhack.reqscript(name)`` or ``reqscript(name)`` diff --git a/library/lua/gui/widgets.lua b/library/lua/gui/widgets.lua index 6e789d35d..4bc48c1b5 100644 --- a/library/lua/gui/widgets.lua +++ b/library/lua/gui/widgets.lua @@ -330,15 +330,21 @@ Label = defclass(Label, Widget) Label.ATTRS{ text_pen = COLOR_WHITE, - text_dpen = COLOR_DARKGREY, + text_dpen = COLOR_DARKGREY, -- disabled + text_hpen = DEFAULT_NIL, -- highlight - default is text_pen with reversed brightness disabled = DEFAULT_NIL, enabled = DEFAULT_NIL, auto_height = true, auto_width = false, + on_click = DEFAULT_NIL, + on_rclick = DEFAULT_NIL, } function Label:init(args) self:setText(args.text) + if not self.text_hpen then + self.text_hpen = ((tonumber(self.text_pen) or tonumber(self.text_pen.fg) or 0) + 8) % 16 + end end function Label:setText(text) @@ -374,11 +380,21 @@ function Label:getTextWidth() end function Label:onRenderBody(dc) - render_text(self,dc,0,0,self.text_pen,self.text_dpen,is_disabled(self)) + local text_pen = self.text_pen + if self:getMousePos() and (self.on_click or self.on_rclick) then + text_pen = self.text_hpen + end + render_text(self,dc,0,0,text_pen,self.text_dpen,is_disabled(self)) end function Label:onInput(keys) if not is_disabled(self) then + if keys._MOUSE_L_DOWN and self:getMousePos() and self.on_click then + self:on_click() + end + if keys._MOUSE_R_DOWN and self:getMousePos() and self.on_rclick then + self:on_rclick() + end return check_text_keys(self, keys) end end diff --git a/scripts/gui/gm-editor.lua b/scripts/gui/gm-editor.lua index 9b03ba279..576649013 100644 --- a/scripts/gui/gm-editor.lua +++ b/scripts/gui/gm-editor.lua @@ -136,7 +136,8 @@ function GmEditorUi:init(args) subviews={ mainList, widgets.Label{text={{text="",id="name"},{gap=1,text="Help",key=keybindings.help.key,key_sep = '()'}}, view_id = 'lbl_current_item',frame = {l=1,t=1,yalign=0}}, - widgets.Label{text={{text="Search",key=keybindings.start_filter.key,key_sep = '()'},{text=": "}},frame={l=1,t=2}}, + widgets.Label{text={{text="Search",key=keybindings.start_filter.key,key_sep = '()'},{text=": "}},frame={l=1,t=2}, + on_click=function() self:enable_input(true) end}, widgets.EditField{frame={l=12,t=2},active=false,on_change=self:callback('text_input'),on_submit=self:callback("enable_input",false),view_id="filter_input"}, --widgets.Label{text="BLAH2"} } From c7bdd600eab62607ac26e53cfabcd3785db9c29e Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Tue, 10 May 2016 22:43:42 +1000 Subject: [PATCH 14/51] Add new item descriptions for DF 43.01 --- scripts/item-descriptions.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/item-descriptions.lua b/scripts/item-descriptions.lua index fe7e7ac00..b2c57d2e4 100644 --- a/scripts/item-descriptions.lua +++ b/scripts/item-descriptions.lua @@ -360,8 +360,12 @@ descriptions = { ITEM_TOOL_FORK_CARVING = { "A carving fork typically has only two prongs and is exceptionally long.", "It is used to hold down a piece of cooked meat while using a knife."}, + ITEM_TOOL_HELVE = { + "A helve is the handle of a tool such as an axe.", + "It is not useful in this state - but adding a rock makes a stone axe,", + "which can be used for woodcutting in Adventure mode."}, ITEM_TOOL_HIVE = { - " Hives are structures that house colonies of honey bees. To be", + "Hives are structures that house colonies of honey bees. To be", "productive, they need to be constructed on an above-ground tile with", "an accessible honey bee colony somewhere on the map. Some time after", "bees are 'installed' by a beekeeper, the hive will be ready to harvest", @@ -417,6 +421,9 @@ descriptions = { ITEM_TOOL_STEPLADDER = { "A small stepladder. If you have one of these, you can use zones to", "assign your dwarves to pick fruit from certain trees."}, + ITEM_TOOL_STONE_AXE = { + "This tool can be made in Adventure mode, and is used to cut", + "trees for building or carpentry."}, ITEM_TOOL_WHEELBARROW = { "A small hand-cart with long handles and a single wheel, this", "wheelbarrow makes heavy hauling jobs much more manageable."}, From b53f829737c8f90b0884baa5f6db2d8055820f78 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 10 May 2016 17:48:50 -0400 Subject: [PATCH 15/51] Update to 0.43.01-alpha0 and update xml --- CMakeLists.txt | 4 ++-- library/xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46fd565b0..427e71730 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,8 +105,8 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac endif() # set up versioning. -set(DF_VERSION "0.42.06") -SET(DFHACK_RELEASE "r1") +set(DF_VERSION "0.43.01") +SET(DFHACK_RELEASE "alpha0") SET(DFHACK_PRERELEASE FALSE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") diff --git a/library/xml b/library/xml index 98cc1e018..fc53068ec 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 98cc1e01886aaea161d651cf97229ad08e9782b0 +Subproject commit fc53068ec4dc7b9d5544a50176f7755c48333c2d From 52f99f4285d6543ac0c4f51f111fd9b2c0165cda Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 10 May 2016 17:49:12 -0400 Subject: [PATCH 16/51] Fix cursor position directions for process_dig/jobs scan --- scripts/devel/find-offsets.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/devel/find-offsets.lua b/scripts/devel/find-offsets.lua index eb34dadab..9cfacece0 100644 --- a/scripts/devel/find-offsets.lua +++ b/scripts/devel/find-offsets.lua @@ -1604,7 +1604,7 @@ local function find_process_jobs() if dwarfmode_to_top() and dfhack.internal.getAddress('cursor') then local cursor = df.global.T_cursor:new() addr = zone:find_interactive([[ -Searching for process_jobs. Please position the cursor to the right +Searching for process_jobs. Please position the cursor to the left of at least 10 vacant natural floor tiles.]], 'int8_t', function(idx) @@ -1660,7 +1660,7 @@ local function find_process_dig() if dwarfmode_to_top() and dfhack.internal.getAddress('cursor') then local cursor = df.global.T_cursor:new() addr = zone:find_interactive([[ -Searching for process_dig. Please position the cursor to the right +Searching for process_dig. Please position the cursor to the left of at least 10 unmined, unrevealed tiles.]], 'int8_t', function(idx) From e0a0a26739c53c4de9cfc835498ee6488320be5b Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 10 May 2016 17:57:15 -0400 Subject: [PATCH 17/51] ANY_GENERIC35 -> 36 --- plugins/strangemood.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/strangemood.cpp b/plugins/strangemood.cpp index 04c42f3bc..783f73d1f 100644 --- a/plugins/strangemood.cpp +++ b/plugins/strangemood.cpp @@ -885,10 +885,10 @@ command_result df_strangemood (color_ostream &out, vector & parameters) case job_skill::WEAVING: case job_skill::CLOTHESMAKING: filter = NULL; - // TODO: do proper search through world->items.other[items_other_id::ANY_GENERIC35] for item_type CLOTH, mat_type 0, flags2.deep_material, and min_dimension 10000 - for (size_t i = 0; i < world->items.other[items_other_id::ANY_GENERIC35].size(); i++) + // TODO: do proper search through world->items.other[items_other_id::ANY_GENERIC36] for item_type CLOTH, mat_type 0, flags2.deep_material, and min_dimension 10000 + for (size_t i = 0; i < world->items.other[items_other_id::ANY_GENERIC36].size(); i++) { - filter = world->items.other[items_other_id::ANY_GENERIC35][i]; + filter = world->items.other[items_other_id::ANY_GENERIC36][i]; if (filter->getType() != item_type::CLOTH) { filter = NULL; @@ -973,10 +973,10 @@ command_result df_strangemood (color_ostream &out, vector & parameters) case job_skill::FORGE_FURNITURE: case job_skill::METALCRAFT: filter = NULL; - // TODO: do proper search through world->items.other[items_other_id::ANY_GENERIC35] for item_type BAR, mat_type 0, and flags2.deep_material - for (size_t i = 0; i < world->items.other[items_other_id::ANY_GENERIC35].size(); i++) + // TODO: do proper search through world->items.other[items_other_id::ANY_GENERIC36] for item_type BAR, mat_type 0, and flags2.deep_material + for (size_t i = 0; i < world->items.other[items_other_id::ANY_GENERIC36].size(); i++) { - filter = world->items.other[items_other_id::ANY_GENERIC35][i]; + filter = world->items.other[items_other_id::ANY_GENERIC36][i]; if (filter->getType() != item_type::BAR) { filter = NULL; From 38051a5a4848b85db4d505d096b9a5afe1d2b06e Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 11 May 2016 17:51:57 -0400 Subject: [PATCH 18/51] remove tweak manager-quantity --- NEWS.rst | 4 ++ docs/Plugins.rst | 1 - library/xml | 2 +- plugins/tweak/tweak.cpp | 5 --- plugins/tweak/tweaks/manager-quantity.h | 53 ------------------------- 5 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 plugins/tweak/tweaks/manager-quantity.h diff --git a/NEWS.rst b/NEWS.rst index 240e0ffc4..49b71e477 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -53,6 +53,10 @@ Misc Improvements - `fix/diplomats`: replaces ``fixdiplomats`` - `fix/merchants`: replaces ``fixmerchants`` +Removed +------- +- `tweak` manager-quantity: no longer needed + DFHack 0.42.06-r1 ================= diff --git a/docs/Plugins.rst b/docs/Plugins.rst index 0c4a3237b..75d2d988d 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -290,7 +290,6 @@ Subcommands that persist until disabled or DF quits: :kitchen-keys: Fixes DF kitchen meal keybindings (:bug:`614`) :kitchen-prefs-color: Changes color of enabled items to green in kitchen preferences :kitchen-prefs-empty: Fixes a layout issue with empty kitchen tabs (:bug:`9000`) -:manager-quantity: Removes the limit of 30 jobs per manager order :max-wheelbarrow: Allows assigning more than 3 wheelbarrows to a stockpile :military-color-assigned: Color squad candidates already assigned to other squads in yellow/green diff --git a/library/xml b/library/xml index fc53068ec..fbf9e118d 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit fc53068ec4dc7b9d5544a50176f7755c48333c2d +Subproject commit fbf9e118d53e357a7225fa0d83faa7b49149335f diff --git a/plugins/tweak/tweak.cpp b/plugins/tweak/tweak.cpp index 3b17d9fa0..88c57fb62 100644 --- a/plugins/tweak/tweak.cpp +++ b/plugins/tweak/tweak.cpp @@ -93,7 +93,6 @@ #include "tweaks/kitchen-keys.h" #include "tweaks/kitchen-prefs-color.h" #include "tweaks/kitchen-prefs-empty.h" -#include "tweaks/manager-quantity.h" #include "tweaks/max-wheelbarrow.h" #include "tweaks/military-assign.h" #include "tweaks/nestbox-color.h" @@ -212,8 +211,6 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector - -#include "df/viewscreen_createquotast.h" -#include "df/manager_order.h" - -using df::global::world; - -struct manager_quantity_hook : df::viewscreen_createquotast { - typedef df::viewscreen_createquotast interpose_base; - DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set* input)) - { - bool cancel = false; - bool wanted_quantity = want_quantity; - if (want_quantity) - { - for (auto it = input->begin(); it != input->end(); ++it) - { - char c = DFHack::Screen::keyToChar(*it); - if (c >= '0' && c <= '9') - { - cancel = true; - size_t len = strlen(str_filter); - if (len < 5) - { - str_filter[len] = c; - str_filter[len + 1] = '\0'; - } - } - } - } - if (cancel) - return; - // Native feed() adds manager order, updates want_quantity, and removes SELECT from input - int select = input->count(df::interface_key::SELECT); - INTERPOSE_NEXT(feed)(input); - if (wanted_quantity && select && strlen(str_filter) > 0) - { - df::manager_order* order = world->manager_orders[world->manager_orders.size() - 1]; - int16_t count = 1; - try - { - count = std::stoi(str_filter); - } - catch (...) { } - if (count < 1) - count = 1; - order->amount_total = count; - order->amount_left = count; - } - } -}; - -IMPLEMENT_VMETHOD_INTERPOSE(manager_quantity_hook, feed); From ed81be16b3fa9c274dfcd3d53177fce81597b0e8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 11 May 2016 17:52:10 -0400 Subject: [PATCH 19/51] Improve logging of vtable interpose errors --- library/VTableInterpose.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/VTableInterpose.cpp b/library/VTableInterpose.cpp index 1184865ac..eb8dec861 100644 --- a/library/VTableInterpose.cpp +++ b/library/VTableInterpose.cpp @@ -24,6 +24,7 @@ distribution. #include "Internal.h" +#include #include #include #include @@ -414,7 +415,11 @@ bool VMethodInterposeLinkBase::apply(bool enable) if (is_applied()) return true; if (!host->vtable_ptr) + { + std::cerr << "VMethodInterposeLinkBase::apply(" << enable << "): " << name() + << ": no vtable pointer: " << host->getName() << endl; return false; + } // Retrieve the current vtable entry VMethodInterposeLinkBase *old_link = host->interpose_list[vmethod_idx]; @@ -440,6 +445,7 @@ bool VMethodInterposeLinkBase::apply(bool enable) } else if (!host->set_vmethod_ptr(patcher, vmethod_idx, interpose_method)) { + std::cerr << "VMethodInterposeLinkBase::apply(" << enable << "): " << name() << ": set_vmethod_ptr failed" << endl; set_chain(NULL); return false; } From fee6e57b40bd149e09213804507c594c32eeed29 Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 11 May 2016 17:52:56 -0400 Subject: [PATCH 20/51] Disable viewscreen_layer_workshop_profilest focus handler for now --- library/modules/Gui.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index ae7c97236..df89b1932 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -56,7 +56,6 @@ using namespace DFHack; #include "df/viewscreen_buildinglistst.h" #include "df/viewscreen_itemst.h" #include "df/viewscreen_layer.h" -#include "df/viewscreen_layer_workshop_profilest.h" #include "df/viewscreen_layer_noblelistst.h" #include "df/viewscreen_layer_overall_healthst.h" #include "df/viewscreen_layer_assigntradest.h" @@ -66,6 +65,7 @@ using namespace DFHack; #include "df/viewscreen_petst.h" #include "df/viewscreen_tradegoodsst.h" #include "df/viewscreen_storesst.h" +#include "df/viewscreen_workshop_profilest.h" #include "df/ui_unit_view_mode.h" #include "df/ui_sidebar_menus.h" #include "df/ui_look_list.h" @@ -429,16 +429,16 @@ DEFINE_GET_FOCUS_STRING_HANDLER(layer_military) } } -DEFINE_GET_FOCUS_STRING_HANDLER(layer_workshop_profile) -{ - auto list1 = getLayerList(screen, 0); - if (!list1) return; +// DEFINE_GET_FOCUS_STRING_HANDLER(layer_workshop_profile) +// { +// auto list1 = getLayerList(screen, 0); +// if (!list1) return; - if (vector_get(screen->workers, list1->cursor)) - focus += "/Unit"; - else - focus += "/None"; -} +// if (vector_get(screen->workers, list1->cursor)) +// focus += "/Unit"; +// else +// focus += "/None"; +// } DEFINE_GET_FOCUS_STRING_HANDLER(layer_noblelist) { @@ -810,12 +810,12 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top) return ref ? ref->getUnit() : NULL; } - if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_workshop_profilest, top)) - { - if (auto list1 = getLayerList(screen, 0)) - return vector_get(screen->workers, list1->cursor); - return NULL; - } + // if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_workshop_profilest, top)) + // { + // if (auto list1 = getLayerList(screen, 0)) + // return vector_get(screen->workers, list1->cursor); + // return NULL; + // } if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_noblelistst, top)) { From 74898a54247bed03dd4f5592a7da2cedbf8dd62a Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 11 May 2016 17:54:37 -0400 Subject: [PATCH 21/51] createitem: move all created items to cursor if applicable --- NEWS.rst | 1 + plugins/createitem.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.rst b/NEWS.rst index 49b71e477..7571ec45a 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -43,6 +43,7 @@ New Features Fixes ----- +- `createitem`: Now moves multiple created items to cursor correctly - `exportlegends`: Improved handling of unknown enum items (fixes many errors) - `gui/create-item`: Fixed quality when creating multiple items - `gui/mod-manager`: Fixed error when mods folder doesn't exist diff --git a/plugins/createitem.cpp b/plugins/createitem.cpp index 8f7b47107..156176bbe 100644 --- a/plugins/createitem.cpp +++ b/plugins/createitem.cpp @@ -128,7 +128,7 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it } } if ((is_gloves || is_shoes) && !second_item) - return makeItem(prod, unit, true); + return makeItem(prod, unit, true, move_to_cursor); return true; } From 97f7cd6081c9fa68102665fa6cec7f34b3a5810b Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 12 May 2016 16:03:33 -0400 Subject: [PATCH 22/51] Bump version and update xml --- CMakeLists.txt | 2 +- library/xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 427e71730..c3f6f06a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac endif() # set up versioning. -set(DF_VERSION "0.43.01") +set(DF_VERSION "0.43.02") SET(DFHACK_RELEASE "alpha0") SET(DFHACK_PRERELEASE FALSE) diff --git a/library/xml b/library/xml index fbf9e118d..83aa92b37 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit fbf9e118d53e357a7225fa0d83faa7b49149335f +Subproject commit 83aa92b3717e876afbd26d300175c17a075c0678 From 35de4e34b088af8ebbe20797cf210ec73e859db2 Mon Sep 17 00:00:00 2001 From: lethosor Date: Thu, 12 May 2016 16:03:52 -0400 Subject: [PATCH 23/51] devel/save-version: add 0.43.01/02 --- scripts/devel/save-version.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/devel/save-version.lua b/scripts/devel/save-version.lua index 12761a14f..450aa04cf 100644 --- a/scripts/devel/save-version.lua +++ b/scripts/devel/save-version.lua @@ -47,6 +47,7 @@ versions = { [1360] = "0.31.23", [1361] = "0.31.24", [1362] = "0.31.25", + [1372] = "0.34.01", [1374] = "0.34.02", [1376] = "0.34.03", @@ -58,6 +59,7 @@ versions = { [1402] = "0.34.09", [1403] = "0.34.10", [1404] = "0.34.11", + [1441] = "0.40.01", [1442] = "0.40.02", [1443] = "0.40.03", @@ -82,12 +84,16 @@ versions = { [1479] = "0.40.22", [1480] = "0.40.23", [1481] = "0.40.24", + [1531] = "0.42.01", [1532] = "0.42.02", [1533] = "0.42.03", [1534] = "0.42.04", [1537] = "0.42.05", [1542] = "0.42.06", + + [1551] = "0.43.01", + [1552] = "0.43.02", } min_version = math.huge From 55e58e5f06dd5cec0a83aa2f8dc02411fb918f98 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 11:43:37 -0400 Subject: [PATCH 24/51] Update handling of viewscreen_workshop_profilest in Gui module, search/sort plugins --- library/modules/Gui.cpp | 38 ++++++++++++++++++++++---------------- library/xml | 2 +- plugins/search.cpp | 16 +++++++++++++--- plugins/sort.cpp | 34 ++++++++++++++++------------------ 4 files changed, 52 insertions(+), 38 deletions(-) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index df89b1932..3fc353abf 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -429,16 +429,22 @@ DEFINE_GET_FOCUS_STRING_HANDLER(layer_military) } } -// DEFINE_GET_FOCUS_STRING_HANDLER(layer_workshop_profile) -// { -// auto list1 = getLayerList(screen, 0); -// if (!list1) return; - -// if (vector_get(screen->workers, list1->cursor)) -// focus += "/Unit"; -// else -// focus += "/None"; -// } +DEFINE_GET_FOCUS_STRING_HANDLER(workshop_profile) +{ + typedef df::viewscreen_workshop_profilest::T_tab T_tab; + switch(screen->tab) + { + case T_tab::Workers: + focus += "/Unit"; + break; + case T_tab::Orders: + focus += "/Orders"; + break; + case T_tab::Restrictions: + focus += "/Restrictions"; + break; + } +} DEFINE_GET_FOCUS_STRING_HANDLER(layer_noblelist) { @@ -810,12 +816,12 @@ df::unit *Gui::getAnyUnit(df::viewscreen *top) return ref ? ref->getUnit() : NULL; } - // if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_workshop_profilest, top)) - // { - // if (auto list1 = getLayerList(screen, 0)) - // return vector_get(screen->workers, list1->cursor); - // return NULL; - // } + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_workshop_profilest, top)) + { + if (screen->tab == df::viewscreen_workshop_profilest::Workers) + return vector_get(screen->workers, screen->worker_idx); + return NULL; + } if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_noblelistst, top)) { diff --git a/library/xml b/library/xml index 83aa92b37..eae49d13a 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 83aa92b3717e876afbd26d300175c17a075c0678 +Subproject commit eae49d13af541710f6f6f5a42368e915f74bd749 diff --git a/plugins/search.cpp b/plugins/search.cpp index 83d498367..0b7556552 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -15,7 +15,7 @@ #include "df/viewscreen_layer_stockpilest.h" #include "df/viewscreen_layer_militaryst.h" #include "df/viewscreen_layer_noblelistst.h" -#include "df/viewscreen_layer_workshop_profilest.h" +#include "df/viewscreen_workshop_profilest.h" #include "df/viewscreen_topicmeeting_fill_land_holder_positionsst.h" #include "df/viewscreen_tradegoodsst.h" #include "df/viewscreen_unitlistst.h" @@ -1654,11 +1654,16 @@ IMPLEMENT_HOOKS(df::viewscreen_layer_noblelistst, nobles_search); // // START: Workshop profiles search list // -typedef layered_search profiles_search_base; +typedef search_generic profiles_search_base; class profiles_search : public profiles_search_base { public: + bool can_init (df::viewscreen_workshop_profilest *screen) + { + return screen->tab == df::viewscreen_workshop_profilest::T_tab::Workers; + } + string get_element_description(df::unit *element) const { return get_unit_description(element); @@ -1673,9 +1678,14 @@ public: { return &viewscreen->workers; } + + int32_t *get_viewscreen_cursor() + { + return &viewscreen->worker_idx; + } }; -IMPLEMENT_HOOKS(df::viewscreen_layer_workshop_profilest, profiles_search); +IMPLEMENT_HOOKS(df::viewscreen_workshop_profilest, profiles_search); // // END: Workshop profiles search list diff --git a/plugins/sort.cpp b/plugins/sort.cpp index 7d80b4aa1..264da21db 100644 --- a/plugins/sort.cpp +++ b/plugins/sort.cpp @@ -16,7 +16,6 @@ #include "df/viewscreen_joblistst.h" #include "df/viewscreen_unitlistst.h" #include "df/viewscreen_layer_militaryst.h" -#include "df/viewscreen_layer_workshop_profilest.h" #include "df/viewscreen_layer_noblelistst.h" #include "df/viewscreen_layer_overall_healthst.h" #include "df/viewscreen_layer_assigntradest.h" @@ -24,6 +23,7 @@ #include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_petst.h" #include "df/viewscreen_storesst.h" +#include "df/viewscreen_workshop_profilest.h" #include "df/layer_object_listst.h" #include "df/assign_trade_status.h" @@ -310,23 +310,6 @@ DEFINE_SORT_HANDLER(unit_sorters, layer_military, "/Positions/Candidates", milit } -/* - * Sort units in the workshop 'q'uery 'P'rofile modification screen. - */ - -DEFINE_SORT_HANDLER(unit_sorters, layer_workshop_profile, "/Unit", profile) -{ - auto list1 = getLayerList(profile, 0); - - PARSE_SPEC("units", parameters); - - if (compute_order(*pout, L, top, &order, profile->workers)) - { - reorder_cursor(&list1->cursor, order); - reorder_vector(&profile->workers, order); - } -} - DEFINE_SORT_HANDLER(unit_sorters, layer_noblelist, "/Appoint", nobles) { auto list2 = getLayerList(nobles, 1); @@ -443,6 +426,21 @@ DEFINE_SORT_HANDLER(unit_sorters, dwarfmode, "/QueryBuilding/Some/Assign", scree } } +/* + * Sort units in the workshop 'q'uery 'P'rofile modification screen. + */ + +DEFINE_SORT_HANDLER(unit_sorters, workshop_profile, "/Unit", profile) +{ + PARSE_SPEC("units", parameters); + + if (compute_order(*pout, L, top, &order, profile->workers)) + { + reorder_cursor(&profile->worker_idx, order); + reorder_vector(&profile->workers, order); + } +} + /* * Sort pen assignment candidate units in 'z'->'N'. */ From 118d88e44ffa302a5bea7d2ce74671b3b34841bb Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 16:07:10 -0400 Subject: [PATCH 25/51] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index eae49d13a..c2b1a540b 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit eae49d13af541710f6f6f5a42368e915f74bd749 +Subproject commit c2b1a540b026555944f3ab60cef37dd6a4b2fe5c From a89251cdf87bbe1fd885edb5e48842a641180952 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 16:07:27 -0400 Subject: [PATCH 26/51] Find job in job screen --- library/modules/Gui.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 3fc353abf..2cc955d63 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -51,6 +51,7 @@ using namespace DFHack; #include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_dungeonmodest.h" #include "df/viewscreen_dungeon_monsterstatusst.h" +#include "df/viewscreen_jobst.h" #include "df/viewscreen_joblistst.h" #include "df/viewscreen_unitlistst.h" #include "df/viewscreen_buildinglistst.h" @@ -761,6 +762,10 @@ df::job *Gui::getSelectedJob(color_ostream &out, bool quiet) { df::viewscreen *top = Core::getTopViewscreen(); + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_jobst, top)) + { + return screen->job; + } if (VIRTUAL_CAST_VAR(joblist, df::viewscreen_joblistst, top)) { df::job *job = vector_get(joblist->jobs, joblist->cursor_pos); @@ -1057,9 +1062,12 @@ df::building *Gui::getAnyBuilding(df::viewscreen *top) using df::global::world; using df::global::ui_sidebar_menus; - if (auto screen = strict_virtual_cast(top)) + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_buildinglistst, top)) return vector_get(screen->buildings, screen->cursor); + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_workshop_profilest, top)) + return df::building::find(screen->building_id); + if (auto dfscreen = dfhack_viewscreen::try_cast(top)) return dfscreen->getSelectedBuilding(); From 8fd25f7320bba99faf1f2fd558b622954724405a Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 16:07:35 -0400 Subject: [PATCH 27/51] Set prerelease flag again --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3f6f06a4..c34e0fedc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,7 @@ endif() # set up versioning. set(DF_VERSION "0.43.02") SET(DFHACK_RELEASE "alpha0") -SET(DFHACK_PRERELEASE FALSE) +SET(DFHACK_PRERELEASE TRUE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") From a6c10307b0debc1e3efd9a389b17504805027de6 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 19:39:10 -0400 Subject: [PATCH 28/51] Reset terminal color on exit --- package/darwin/dfhack | 1 + package/linux/dfhack | 1 + 2 files changed, 2 insertions(+) diff --git a/package/darwin/dfhack b/package/darwin/dfhack index 5a04bd591..66b574cf8 100755 --- a/package/darwin/dfhack +++ b/package/darwin/dfhack @@ -14,4 +14,5 @@ fi old_tty_settings=$(stty -g) DYLD_INSERT_LIBRARIES=./hack/libdfhack.dylib ./dwarfort.exe "$@" stty "$old_tty_settings" +tput sgr0 echo "" diff --git a/package/linux/dfhack b/package/linux/dfhack index 2b2d04465..b7ce1d812 100755 --- a/package/linux/dfhack +++ b/package/linux/dfhack @@ -95,6 +95,7 @@ esac # Restore previous terminal settings stty "$old_tty_settings" +tput sgr0 echo if [ -n "$DF_POST_CMD" ]; then From 1832e563b746632dfcb1a8c5a7f8058003ba902b Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 19:41:41 -0400 Subject: [PATCH 29/51] Update xml --- docs/Authors.rst | 1 + library/xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/Authors.rst b/docs/Authors.rst index 29521320f..c4462a987 100644 --- a/docs/Authors.rst +++ b/docs/Authors.rst @@ -33,6 +33,7 @@ Erik Youngren Artanis Espen Wiborg expwnent expwnent Feng +gchristopher gchristopher Harlan Playford playfordh IndigoFenix James Logsdon jlogsdon diff --git a/library/xml b/library/xml index c2b1a540b..ab8d62fb7 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit c2b1a540b026555944f3ab60cef37dd6a4b2fe5c +Subproject commit ab8d62fb7fc89f5c100439475f7101b010b0bd95 From 3af24507a32e18d875a430807897e1675080438e Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sat, 14 May 2016 20:15:49 -0500 Subject: [PATCH 30/51] adjust autogems to work with the workshop profile changes --- plugins/autogems.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/autogems.cpp b/plugins/autogems.cpp index 9bdfcb02c..013038834 100644 --- a/plugins/autogems.cpp +++ b/plugins/autogems.cpp @@ -134,7 +134,7 @@ void create_jobs() { for (auto w = workshops->begin(); w != workshops->end(); ++w) { auto workshop = virtual_cast(*w); - auto links = workshop->links.take_from_pile; + auto links = workshop->profile.links.take_from_pile; if (workshop->construction_stage < 3) { // Construction in progress. From b7aa8aca260253854d986338c5b4de9ed5e8c313 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 14 May 2016 22:27:21 -0400 Subject: [PATCH 31/51] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index ab8d62fb7..82e00df85 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit ab8d62fb7fc89f5c100439475f7101b010b0bd95 +Subproject commit 82e00df85ec147a4a6263f93b03421d76eb24fe0 From 02e0b9e72197ffdf5949c594f24f31b05893db8a Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 14 May 2016 22:42:49 -0600 Subject: [PATCH 32/51] Manager interface now uses the full height. Its navigation behavior has also changed, and it now has key hints for navigation. --- plugins/lua/stockflow.lua | 89 +++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 14 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 7b038d34c..9bf254c67 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -24,9 +24,9 @@ entry_ints = { trigger_number = 3, } -PageSize = 16 -FirstRow = 4 +FirstRow = 3 CenterCol = 38 +ExtraLines = 9 -- Populate the reaction and stockpile order lists. -- To be called whenever a world is loaded. @@ -797,10 +797,26 @@ screen = gui.FramedScreen { function screen:onRenderBody(dc) -- Emulates the built-in manager screen. + + -- Top instruction line. dc:seek(1, 1):string("Type in parts of the name to narrow your search. ", COLOR_WHITE) dc:string(gui.getKeyDisplay("LEAVESCREEN"), COLOR_LIGHTGREEN) dc:string(" to abort.", COLOR_WHITE) - dc:seek(1, PageSize + 5):string(self.search_string, COLOR_LIGHTCYAN) + + -- Search term, if any. + dc:seek(1, FirstRow + self.page_size + 1):string(self.search_string, COLOR_LIGHTCYAN) + + -- Bottom instruction line. + dc:seek(1, FirstRow + self.page_size + 2) + dc:string(gui.getKeyDisplay("STANDARDSCROLL_UP"), COLOR_LIGHTGREEN) + dc:string(gui.getKeyDisplay("STANDARDSCROLL_DOWN"), COLOR_LIGHTGREEN) + dc:string(gui.getKeyDisplay("STANDARDSCROLL_PAGEUP"), COLOR_LIGHTGREEN) + dc:string(gui.getKeyDisplay("STANDARDSCROLL_PAGEDOWN"), COLOR_LIGHTGREEN) + dc:string(gui.getKeyDisplay("STANDARDSCROLL_LEFT"), COLOR_LIGHTGREEN) + dc:string(gui.getKeyDisplay("STANDARDSCROLL_RIGHT"), COLOR_LIGHTGREEN) + dc:string(": Select", COLOR_WHITE) + + -- Reaction lines. for _, item in ipairs(self.displayed) do dc:seek(item.x, item.y):string(item.name, item.color) end @@ -820,23 +836,61 @@ function screen:onInput(keys) elseif keys.STANDARDSCROLL_DOWN then self.position = self.position + 1 elseif keys.STANDARDSCROLL_LEFT then - self.position = self.position - PageSize + if self.position == 1 then + -- Move from the very first item to the very last item. + self.position = #self.reactions + elseif self.position < self.page_size then + -- On the first column, move to the very first item. + self.position = 1 + else + -- Move to the same position on the previous column. + self.position = self.position - self.page_size + end elseif keys.STANDARDSCROLL_RIGHT then - self.position = self.position + PageSize + if self.position == #self.reactions then + -- Move from the very last item to the very first item. + self.position = 1 + else + -- Move to the same position on the next column. + self.position = self.position + self.page_size + if self.position > #self.reactions then + -- If that's past the end, move to the very last item. + self.position = #self.reactions + end + end elseif keys.STANDARDSCROLL_PAGEUP then - -- Moves to the first item displayed on the new page, for some reason. - self.position = self.position - PageSize*2 - ((self.position-1) % (PageSize*2)) + if self.position == 1 then + -- Move from the very first item to the very last item. + self.position = #self.reactions + elseif self.position < self.page_size*2 then + -- On the first page, move to the very first item. + self.position = 1 + else + -- Move to the same position on the previous page. + self.position = self.position - self.page_size*2 + end elseif keys.STANDARDSCROLL_PAGEDOWN then - -- Moves to the first item displayed on the new page, for some reason. - self.position = self.position + PageSize*2 - ((self.position-1) % (PageSize*2)) + if self.position == #self.reactions then + -- Move from the very last item to the very first item. + self.position = 1 + else + -- Move to the same position on the next page. + self.position = self.position + self.page_size*2 + if self.position > #self.reactions then + -- If that's past the end, move to the very last item. + self.position = #self.reactions + end + end elseif keys.STRING_A000 then -- This seems like an odd way to check for Backspace. self.search_string = string.sub(self.search_string, 1, -2) + self.position = 1 elseif keys._STRING and keys._STRING >= 32 then -- This interface only accepts letters and spaces. local char = string.char(keys._STRING) if char == " " or string.find(char, "^%a") then self.search_string = self.search_string .. string.upper(char) + self.position = 1 end end @@ -886,6 +940,13 @@ function splitstring(full, pattern) end function screen:refilter() + -- Determine which rows to show, and in which colors. + -- Todo: The official one now has three categories of search results: + -- * Cyan: Contains at least one exact word from the search terms + -- * Yellow: At least one word starts with at least one search term + -- * Grey: Each search term is found in the middle of a word + self.page_size = self.frame_rect.height - ExtraLines + local filtered = {} local needles = splitstring(self.search_string, " ") for key, value in ipairs(reaction_list) do @@ -904,12 +965,12 @@ function screen:refilter() end local start = 1 - while self.position >= start + PageSize*2 do - start = start + PageSize*2 + while self.position >= start + self.page_size*2 do + start = start + self.page_size*2 end local displayed = {} - for n = 0, PageSize*2 - 1 do + for n = 0, self.page_size*2 - 1 do local item = filtered[start + n] if not item then break @@ -918,9 +979,9 @@ function screen:refilter() local x = 1 local y = FirstRow + n - if n >= PageSize then + if n >= self.page_size then x = CenterCol - y = y - PageSize + y = y - self.page_size name = " "..name end From 8c7d5366c95edc398ef597a080843e1536f7a11c Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 14 May 2016 23:33:38 -0600 Subject: [PATCH 33/51] Switching to the new manager order flags --- plugins/lua/stockflow.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 9bf254c67..3422425ad 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1087,7 +1087,8 @@ function create_orders(order, amount) new_order.amount_left = amount new_order.amount_total = amount -- Todo: Create in a validated state if the fortress is small enough? - new_order.is_validated = 0 + new_order.status.validated = false + new_order.status.active = true df.global.world.manager_orders:insert('#', new_order) end From 3e8d4f925753e35465bb6b3076ddd03ff3ca8d67 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 14 May 2016 23:35:07 -0600 Subject: [PATCH 34/51] New command for clearing the stockpile order. Shift-Space by default, using the SETUPGAME_SAVE_PROFILE_ABORT key. --- plugins/lua/stockflow.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 3422425ad..1590bf4c4 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -816,6 +816,10 @@ function screen:onRenderBody(dc) dc:string(gui.getKeyDisplay("STANDARDSCROLL_RIGHT"), COLOR_LIGHTGREEN) dc:string(": Select", COLOR_WHITE) + dc:seek(CenterCol, FirstRow + self.page_size + 2) + dc:string(gui.getKeyDisplay("SETUPGAME_SAVE_PROFILE_ABORT"), COLOR_LIGHTGREEN) + dc:string(": No order", COLOR_WHITE) + -- Reaction lines. for _, item in ipairs(self.displayed) do dc:seek(item.x, item.y):string(item.name, item.color) @@ -831,6 +835,9 @@ function screen:onInput(keys) if selected then store_order(self.stockpile, selected.index) end + elseif keys.SETUPGAME_SAVE_PROFILE_ABORT then + self:dismiss() + clear_order(self.stockpile) elseif keys.STANDARDSCROLL_UP then self.position = self.position - 1 elseif keys.STANDARDSCROLL_DOWN then @@ -1002,6 +1009,14 @@ function screen:refilter() self.displayed = displayed end +function clear_order(stockpile) + local saved = saved_orders[stockpile.id] + if saved then + saved.entry:delete() + saved_orders[stockpile.id] = nil + end +end + function store_order(stockpile, order_number) local name = reaction_list[order_number].name -- print("Setting stockpile #"..stockpile.stockpile_number.." to "..name.." (#"..order_number..")") From 6575f5f4126a71552875a8b5725c6bcbc6949400 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 14 May 2016 23:40:01 -0600 Subject: [PATCH 35/51] Removing the quantity limit on stockflow orders. --- plugins/lua/stockflow.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 1590bf4c4..394d3f1b5 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1087,12 +1087,6 @@ function order_quantity(order, quantity) end end - if amount > 30 then - -- Respect the quantity limit. - -- With this many in the queue, we can wait for the next cycle. - return 30 - end - return amount end From b68cff0384faa936984206c34563be9a9daeb0f7 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sat, 14 May 2016 23:44:25 -0600 Subject: [PATCH 36/51] Removing stockflow and workflow from the example dfhack.init They're no longer necessary, now that the default manager interface has been improved. --- dfhack.init-example | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dfhack.init-example b/dfhack.init-example index a367d3441..4d2a1b2f3 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -128,10 +128,6 @@ keybinding add Alt-P@dwarfmode/Hauling/DefineStop/Cond/Guide gui/guide-path # workshop job details keybinding add Alt-A@dwarfmode/QueryBuilding/Some/Workshop/Job gui/workshop-job -# workflow front-end -keybinding add Alt-W@dwarfmode/QueryBuilding/Some/Workshop/Job gui/workflow -keybinding add Alt-W@overallstatus "gui/workflow status" - # autobutcher front-end keybinding add Shift-B@pet/List/Unit "gui/autobutcher" @@ -220,7 +216,6 @@ enable \ zone \ stocks \ autochop \ - stockflow \ stockpiles #end a line with a backslash to make it continue to the next line. The \ is deleted for the final command. # Multiline commands are ONLY supported for scripts like dfhack.init. You cannot do multiline command manually on the DFHack console. From 6add87b3582bd80ef9d935ff3e0b62b1e22288b1 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sun, 15 May 2016 08:58:45 -0600 Subject: [PATCH 37/51] Simplifying key strings --- plugins/lua/stockflow.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 394d3f1b5..0728b8db8 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -800,25 +800,20 @@ function screen:onRenderBody(dc) -- Top instruction line. dc:seek(1, 1):string("Type in parts of the name to narrow your search. ", COLOR_WHITE) - dc:string(gui.getKeyDisplay("LEAVESCREEN"), COLOR_LIGHTGREEN) - dc:string(" to abort.", COLOR_WHITE) + dc:key("LEAVESCREEN"):string(" to abort.", COLOR_WHITE) -- Search term, if any. dc:seek(1, FirstRow + self.page_size + 1):string(self.search_string, COLOR_LIGHTCYAN) -- Bottom instruction line. dc:seek(1, FirstRow + self.page_size + 2) - dc:string(gui.getKeyDisplay("STANDARDSCROLL_UP"), COLOR_LIGHTGREEN) - dc:string(gui.getKeyDisplay("STANDARDSCROLL_DOWN"), COLOR_LIGHTGREEN) - dc:string(gui.getKeyDisplay("STANDARDSCROLL_PAGEUP"), COLOR_LIGHTGREEN) - dc:string(gui.getKeyDisplay("STANDARDSCROLL_PAGEDOWN"), COLOR_LIGHTGREEN) - dc:string(gui.getKeyDisplay("STANDARDSCROLL_LEFT"), COLOR_LIGHTGREEN) - dc:string(gui.getKeyDisplay("STANDARDSCROLL_RIGHT"), COLOR_LIGHTGREEN) + dc:key("STANDARDSCROLL_UP"):key("STANDARDSCROLL_DOWN") + dc:key("STANDARDSCROLL_PAGEUP"):key("STANDARDSCROLL_PAGEDOWN") + dc:key("STANDARDSCROLL_LEFT"):key("STANDARDSCROLL_RIGHT") dc:string(": Select", COLOR_WHITE) dc:seek(CenterCol, FirstRow + self.page_size + 2) - dc:string(gui.getKeyDisplay("SETUPGAME_SAVE_PROFILE_ABORT"), COLOR_LIGHTGREEN) - dc:string(": No order", COLOR_WHITE) + dc:key("SETUPGAME_SAVE_PROFILE_ABORT"):string(": No order", COLOR_WHITE) -- Reaction lines. for _, item in ipairs(self.displayed) do From 0b1004f2b8910589000af52663e2bb805cd1d28d Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sun, 15 May 2016 09:14:30 -0600 Subject: [PATCH 38/51] Notice resizing immediately, instead of on next key press --- plugins/lua/stockflow.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 0728b8db8..b5fd186cc 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -798,6 +798,11 @@ screen = gui.FramedScreen { function screen:onRenderBody(dc) -- Emulates the built-in manager screen. + if not (self.page_size == self.frame_rect.height - ExtraLines) then + -- The screen size has changed. + self:refilter() + end + -- Top instruction line. dc:seek(1, 1):string("Type in parts of the name to narrow your search. ", COLOR_WHITE) dc:key("LEAVESCREEN"):string(" to abort.", COLOR_WHITE) From 2df41e6bade1ce956bc7310b9c438a3e4e13945b Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sun, 15 May 2016 22:03:36 -0600 Subject: [PATCH 39/51] Clearing the active flag for new stockflow orders. It's not entirely clear what this flag does when there aren't any conditions on the order, but new manual orders start as Ready instead of Active. --- plugins/lua/stockflow.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index b5fd186cc..9a5a4f080 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1097,7 +1097,7 @@ function create_orders(order, amount) new_order.amount_total = amount -- Todo: Create in a validated state if the fortress is small enough? new_order.status.validated = false - new_order.status.active = true + new_order.status.active = false df.global.world.manager_orders:insert('#', new_order) end From 11a0bea00279b56add1a1a3b8bac351cff5cc083 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sun, 15 May 2016 22:49:35 -0600 Subject: [PATCH 40/51] Moving a search option to the bottom of the screen. The list of workers in the workshop profile page can take nearly the full height of the screen. --- plugins/search.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/search.cpp b/plugins/search.cpp index 0b7556552..a177665ad 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -1671,7 +1671,7 @@ public: void render() const { - print_search_option(2, 23); + print_search_option(2, gps->dimy - 5); } vector *get_primary_list() From 3f0857bff3eea450adce702973e850fc97e7c848 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Sun, 15 May 2016 22:47:43 -0600 Subject: [PATCH 41/51] Incrementing the manager order id properly. There's a chance that not doing so could lead to a crash, somehow. --- library/xml | 2 +- plugins/lua/stockflow.lua | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/library/xml b/library/xml index 82e00df85..23edfbdfa 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 82e00df85ec147a4a6263f93b03421d76eb24fe0 +Subproject commit 23edfbdfadd5f5599c0ce4a5e06ee68e9472d30b diff --git a/plugins/lua/stockflow.lua b/plugins/lua/stockflow.lua index 9a5a4f080..4d7889843 100644 --- a/plugins/lua/stockflow.lua +++ b/plugins/lua/stockflow.lua @@ -1098,6 +1098,8 @@ function create_orders(order, amount) -- Todo: Create in a validated state if the fortress is small enough? new_order.status.validated = false new_order.status.active = false + new_order.id = df.global.world.manager_order_next_id + df.global.world.manager_order_next_id = df.global.world.manager_order_next_id + 1 df.global.world.manager_orders:insert('#', new_order) end From d198bf547a2f29fbee54bb4fd18fa030c973a0cc Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 17 May 2016 23:23:54 -0400 Subject: [PATCH 42/51] Unit list search: reset cursor position to 0 before switching pages On empty lists, pressing "up" sets the cursor position to -1. This results in a crash if the list is populated, which the search plugin does before switching pages. Fixes #928 --- plugins/search.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/search.cpp b/plugins/search.cpp index a177665ad..80dcc0f61 100644 --- a/plugins/search.cpp +++ b/plugins/search.cpp @@ -1160,6 +1160,9 @@ private: if (!in_entry_mode()) { // Changing screens, reset search + int32_t *cursor_pos = get_viewscreen_cursor(); + if (cursor_pos && *cursor_pos < 0) + *cursor_pos = 0; clear_search(); reset_all(); } From d93cf2cd2e2933852be3121df13a1a1a08192493 Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 17 May 2016 23:26:21 -0400 Subject: [PATCH 43/51] Update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index 82e00df85..af8548bb1 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 82e00df85ec147a4a6263f93b03421d76eb24fe0 +Subproject commit af8548bb118851f3da2618ab6055066774614cb2 From 9be928541cc27ae5e46c76bdcc072fef6a6ed49d Mon Sep 17 00:00:00 2001 From: carbohydratesn Date: Sun, 22 May 2016 14:03:53 -0600 Subject: [PATCH 44/51] Include math.h 3dveins.cpp won't build for me without math.h as a dependency - errors about 'fabsf' and other math functions arch linux, gcc-multilib 6.1.1-1 --- plugins/3dveins.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/3dveins.cpp b/plugins/3dveins.cpp index 3e51e6582..0bd2cd6c1 100644 --- a/plugins/3dveins.cpp +++ b/plugins/3dveins.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "Core.h" #include "Console.h" From fc311a83450f4230413885328726d1c0e371509e Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 24 May 2016 13:26:16 -0500 Subject: [PATCH 45/51] convert the key to a string so gm-editor doesn't error on vector elements --- scripts/gui/gm-editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gui/gm-editor.lua b/scripts/gui/gm-editor.lua index 576649013..38394ec36 100644 --- a/scripts/gui/gm-editor.lua +++ b/scripts/gui/gm-editor.lua @@ -188,7 +188,7 @@ function GmEditorUi:find(test) end end function GmEditorUi:find_id() - local key = self:getSelectedKey() + local key = tostring(self:getSelectedKey()) local id = tonumber(self:getSelectedValue()) if not id then return end local opts = {} From 61bff2f668c80944983fe3023044fc553d03ae7b Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 25 May 2016 16:12:02 -0400 Subject: [PATCH 46/51] Update 3rdparty/lethosor --- scripts/3rdparty/lethosor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/3rdparty/lethosor b/scripts/3rdparty/lethosor index 26c600132..704aed444 160000 --- a/scripts/3rdparty/lethosor +++ b/scripts/3rdparty/lethosor @@ -1 +1 @@ -Subproject commit 26c60013223e02b5558e31bed8e0625495430995 +Subproject commit 704aed4447f27ae802dae6994479ebc9c46568cc From e76258b040eec1d56a662af949cdc8a384150ee1 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 26 May 2016 15:15:42 -0500 Subject: [PATCH 47/51] knowledge category flag --- .../knowledge_scholar_category_flag.methods.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 library/include/df/custom/knowledge_scholar_category_flag.methods.inc diff --git a/library/include/df/custom/knowledge_scholar_category_flag.methods.inc b/library/include/df/custom/knowledge_scholar_category_flag.methods.inc new file mode 100644 index 000000000..f5c4e9a76 --- /dev/null +++ b/library/include/df/custom/knowledge_scholar_category_flag.methods.inc @@ -0,0 +1,13 @@ +df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() const +{ + int32_t value = category * 32; + for (int32_t i = 0; i < 32; i++) + { + if (flags & (1 << i)) + { + value += i; + break; + } + } + return df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag(value); +} From c1ba4350582db5221cca0f7153a0dfbadc8186e8 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 27 May 2016 17:41:23 -0400 Subject: [PATCH 48/51] Update version and xml --- CMakeLists.txt | 2 +- library/xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c34e0fedc..aedb6037a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac endif() # set up versioning. -set(DF_VERSION "0.43.02") +set(DF_VERSION "0.43.03") SET(DFHACK_RELEASE "alpha0") SET(DFHACK_PRERELEASE TRUE) diff --git a/library/xml b/library/xml index af8548bb1..f36723039 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit af8548bb118851f3da2618ab6055066774614cb2 +Subproject commit f36723039bc5b5475c0edd2960c72cccc201e83d From 4d3df60470b200b84057530dcaae6042235781d4 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 27 May 2016 17:51:01 -0400 Subject: [PATCH 49/51] Update xml (offsets) --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index f36723039..c259ac961 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit f36723039bc5b5475c0edd2960c72cccc201e83d +Subproject commit c259ac961bb881233f715e34bfa9ca3af555d7e2 From ae3052f79a39ef84e138add084e9787c5a06546b Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 28 May 2016 10:28:22 -0400 Subject: [PATCH 50/51] Make knowledge_scholar_category_flag::value() non-const const methods can't be wrapped at the moment, at least without changing things in DataFuncs.h --- .../df/custom/knowledge_scholar_category_flag.methods.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/include/df/custom/knowledge_scholar_category_flag.methods.inc b/library/include/df/custom/knowledge_scholar_category_flag.methods.inc index f5c4e9a76..6fe896804 100644 --- a/library/include/df/custom/knowledge_scholar_category_flag.methods.inc +++ b/library/include/df/custom/knowledge_scholar_category_flag.methods.inc @@ -1,4 +1,4 @@ -df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() const +df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() { int32_t value = category * 32; for (int32_t i = 0; i < 32; i++) From 113325f8852f7522781a732fe91a8ba7b5002d86 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 28 May 2016 10:29:53 -0400 Subject: [PATCH 51/51] update xml --- library/xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/xml b/library/xml index c259ac961..d48de9e90 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit c259ac961bb881233f715e34bfa9ca3af555d7e2 +Subproject commit d48de9e904150c4cd0e8502b6edf246737849607