From ff982dcf738ba766270663d8fc751c55c1fe8699 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 7 Nov 2012 13:31:36 +0400 Subject: [PATCH] Fix representation and parsing of built-in materials. The trick is to support both FOO and FOO:NONE for all of them, including INORGANIC[:NONE]. Otherwise the workflow gui scripts have problems. --- NEWS | 2 ++ dfhack.init-example | 2 +- library/modules/Materials.cpp | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index d5080b05a..f2237cab9 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ DFHack future - fastdwarf: new mode using debug flags, and some internal consistency fixes. - added a small stand-alone utility for applying and removing binary patches. - removebadthoughts: add --dry-run option + New scripts: + - region-pops: displays animal populations of the region and allows tweaking them. New GUI scripts: - gui/guide-path: displays the cached path for minecart Guide orders. - gui/workshop-job: displays inputs of a workshop job and allows tweaking them. diff --git a/dfhack.init-example b/dfhack.init-example index d7f3f5399..20048e39e 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -18,7 +18,7 @@ keybinding add Ctrl-Alt-S@dwarfmode/Default quicksave # gui/rename script keybinding add Ctrl-Shift-N gui/rename -keybinding add Alt-Shift-P "gui/rename unit-profession" +keybinding add Ctrl-Shift-T "gui/rename unit-profession" ############################## # Generic adv mode bindings # diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 454fdf66d..7c06aeb4c 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -190,6 +190,8 @@ bool MaterialInfo::find(const std::vector &items) } else if (items.size() == 2) { + if (items[1] == "NONE" && findBuiltin(items[0])) + return true; if (findPlant(items[0], items[1])) return true; if (findCreature(items[0], items[1])) @@ -210,7 +212,7 @@ bool MaterialInfo::findBuiltin(const std::string &token) } df::world_raws &raws = world->raws; - for (int i = 1; i < NUM_BUILTIN; i++) + for (int i = 0; i < NUM_BUILTIN; i++) { auto obj = raws.mat_table.builtin[i]; if (obj && obj->id == token) @@ -312,7 +314,7 @@ std::string MaterialInfo::getToken() else if (index == 1) return "COAL:CHARCOAL"; } - return material->id + ":NONE"; + return material->id; case Inorganic: return "INORGANIC:" + inorganic->id; case Creature: