From a9f219baf9dda6d8cc300251fc040420e84bbc49 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 29 Jun 2020 16:16:44 -0500 Subject: [PATCH 1/3] update for DFHack/df-structures#7dfea1f1d4e453b97d5529785701db46360596ce --- library/modules/Kitchen.cpp | 4 ++-- library/modules/MapCache.cpp | 8 ++++---- library/modules/Materials.cpp | 2 +- library/xml | 2 +- plugins/autochop.cpp | 2 +- plugins/getplants.cpp | 10 +++++----- plugins/stonesense | 2 +- scripts | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/modules/Kitchen.cpp b/library/modules/Kitchen.cpp index 63372d564..fa4d1dea7 100644 --- a/library/modules/Kitchen.cpp +++ b/library/modules/Kitchen.cpp @@ -95,7 +95,7 @@ void Kitchen::denyPlantSeedCookery(t_materialIndex materialIndex) { ui->kitchen.item_types.push_back(item_type::SEEDS); ui->kitchen.item_subtypes.push_back(organicSubtype); - ui->kitchen.mat_types.push_back(type->material_defs.type_seed); + ui->kitchen.mat_types.push_back(type->material_defs.type[plant_material_def::seed]); ui->kitchen.mat_indices.push_back(materialIndex); ui->kitchen.exc_types.push_back(df::kitchen_exc_type::Cook); } @@ -103,7 +103,7 @@ void Kitchen::denyPlantSeedCookery(t_materialIndex materialIndex) { ui->kitchen.item_types.push_back(item_type::PLANT); ui->kitchen.item_subtypes.push_back(organicSubtype); - ui->kitchen.mat_types.push_back(type->material_defs.type_basic_mat); + ui->kitchen.mat_types.push_back(type->material_defs.type[plant_material_def::basic_mat]); ui->kitchen.mat_indices.push_back(materialIndex); ui->kitchen.exc_types.push_back(df::kitchen_exc_type::Cook); } diff --git a/library/modules/MapCache.cpp b/library/modules/MapCache.cpp index b61ba375e..ce3039ecf 100644 --- a/library/modules/MapCache.cpp +++ b/library/modules/MapCache.cpp @@ -899,8 +899,8 @@ t_matpair MapExtras::BlockInfo::getBaseMaterial(df::tiletype tt, df::coord2d pos { if (auto raw = df::plant_raw::find(plant->material)) { - rv.mat_type = raw->material_defs.type_basic_mat; - rv.mat_index = raw->material_defs.idx_basic_mat; + rv.mat_type = raw->material_defs.type[plant_material_def::basic_mat]; + rv.mat_index = raw->material_defs.idx[plant_material_def::basic_mat]; } } break; @@ -912,8 +912,8 @@ t_matpair MapExtras::BlockInfo::getBaseMaterial(df::tiletype tt, df::coord2d pos rv.mat_type = MaterialInfo::PLANT_BASE; if (auto raw = df::plant_raw::find(grass[x][y])) { - rv.mat_type = raw->material_defs.type_basic_mat; - rv.mat_index = raw->material_defs.idx_basic_mat; + rv.mat_type = raw->material_defs.type[plant_material_def::basic_mat]; + rv.mat_index = raw->material_defs.idx[plant_material_def::basic_mat]; } break; diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 51d717d05..c341ea99e 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -261,7 +261,7 @@ bool MaterialInfo::findPlant(const std::string &token, const std::string &subtok // As a special exception, return the structural material with empty subtoken if (subtoken.empty()) - return decode(p->material_defs.type_basic_mat, p->material_defs.idx_basic_mat); + return decode(p->material_defs.type[plant_material_def::basic_mat], p->material_defs.idx[plant_material_def::basic_mat]); for (size_t j = 0; j < p->material.size(); j++) if (p->material[j]->id == subtoken) diff --git a/library/xml b/library/xml index 97084e556..7dfea1f1d 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 97084e556119ce4445c3745151180467338a746a +Subproject commit 7dfea1f1d4e453b97d5529785701db46360596ce diff --git a/plugins/autochop.cpp b/plugins/autochop.cpp index e7f3874d3..8f2225f72 100644 --- a/plugins/autochop.cpp +++ b/plugins/autochop.cpp @@ -258,7 +258,7 @@ static bool skip_plant(const df::plant * plant, bool *restricted) const df::plant_raw *plant_raw = df::plant_raw::find(plant->material); // Skip fruit trees if set. - if (skip.fruit_trees && plant_raw->material_defs.type_drink != -1) + if (skip.fruit_trees && plant_raw->material_defs.type[plant_material_def::drink] != -1) { if (restricted) *restricted = true; diff --git a/plugins/getplants.cpp b/plugins/getplants.cpp index d1ee79a04..b4b7a493b 100644 --- a/plugins/getplants.cpp +++ b/plugins/getplants.cpp @@ -70,7 +70,7 @@ enum class selectability { //selectability selectablePlant(color_ostream &out, const df::plant_raw *plant, bool farming) selectability selectablePlant(const df::plant_raw *plant, bool farming) { - const DFHack::MaterialInfo basic_mat = DFHack::MaterialInfo(plant->material_defs.type_basic_mat, plant->material_defs.idx_basic_mat); + const DFHack::MaterialInfo basic_mat = DFHack::MaterialInfo(plant->material_defs.type[plant_material_def::basic_mat], plant->material_defs.idx[plant_material_def::basic_mat]); bool outOfSeason = false; selectability result = selectability::Nonselectable; @@ -92,7 +92,7 @@ selectability selectablePlant(const df::plant_raw *plant, bool farming) return selectability::Grass; } - if (farming && plant->material_defs.type_seed == -1) + if (farming && plant->material_defs.type[plant_material_def::seed] == -1) { return selectability::Nonselectable; } @@ -163,8 +163,8 @@ selectability selectablePlant(const df::plant_raw *plant, bool farming) { for (size_t k = 0; growth_mat.material->reaction_product.material.mat_type.size(); k++) { - if (growth_mat.material->reaction_product.material.mat_type[k] == plant->material_defs.type_seed && - growth_mat.material->reaction_product.material.mat_index[k] == plant->material_defs.idx_seed) + if (growth_mat.material->reaction_product.material.mat_type[k] == plant->material_defs.type[plant_material_def::seed] && + growth_mat.material->reaction_product.material.mat_index[k] == plant->material_defs.idx[plant_material_def::seed]) { seedSource = true; break; @@ -193,7 +193,7 @@ selectability selectablePlant(const df::plant_raw *plant, bool farming) } /* else if (plant->growths[i]->behavior.bits.has_seed) // This code designates beans, etc. when DF doesn't, but plant gatherers still fail to collect anything, so it's useless: bug #0006940. { - const DFHack::MaterialInfo seed_mat = DFHack::MaterialInfo(plant->material_defs.type_seed, plant->material_defs.idx_seed); + const DFHack::MaterialInfo seed_mat = DFHack::MaterialInfo(plant->material_defs.type[plant_material_def::seed], plant->material_defs.idx[plant_material_def::seed]); if (seed_mat.material->flags.is_set(material_flags::EDIBLE_RAW) || seed_mat.material->flags.is_set(material_flags::EDIBLE_COOKED)) diff --git a/plugins/stonesense b/plugins/stonesense index 5b7e7743a..bdab71c99 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 5b7e7743a1372b929acb2ccb75080e139ac11691 +Subproject commit bdab71c99a0a7cc268ca517a0cd3f0a5fb41042a diff --git a/scripts b/scripts index 47d9b3c93..792ae44ab 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 47d9b3c9390d21ecc49ddaba477b16071884ee87 +Subproject commit 792ae44ab14afd3a2b3e850a6fcb463d714b0a44 From d13e5a3f3157b02fd552a90c2722046745626791 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 29 Jun 2020 20:20:37 -0500 Subject: [PATCH 2/3] update structures handle renaming of caste_raw::gender --- library/xml | 2 +- plugins/remotefortressreader/remotefortressreader.cpp | 2 +- plugins/tweak/tweaks/tradereq-pet-gender.h | 2 +- scripts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/xml b/library/xml index 7dfea1f1d..b11433eea 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 7dfea1f1d4e453b97d5529785701db46360596ce +Subproject commit b11433eea0a1117edc2a4a51f7a30b01594cb52b diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index e94c3f832..1a0d045dc 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -2685,7 +2685,7 @@ static command_result GetPartialCreatureRaws(color_ostream &stream, const ListRe send_caste->add_child_name(orig_caste->child_name[0]); send_caste->add_child_name(orig_caste->child_name[1]); - send_caste->set_gender(orig_caste->gender); + send_caste->set_gender(orig_caste->sex); for (size_t partIndex = 0; partIndex < orig_caste->body_info.body_parts.size(); partIndex++) { diff --git a/plugins/tweak/tweaks/tradereq-pet-gender.h b/plugins/tweak/tweaks/tradereq-pet-gender.h index ca786bef2..c62a56f67 100644 --- a/plugins/tweak/tweaks/tradereq-pet-gender.h +++ b/plugins/tweak/tweaks/tradereq-pet-gender.h @@ -20,7 +20,7 @@ struct pet_gender_hook : df::viewscreen_topicmeeting_takerequestsst { vector& castes = entity->resources.animals.pet_castes; for (int i = (good_idx / 17) * 17, y = 4; i < (good_idx / 17) * 17 + 17 && size_t(i) < races.size(); i++, y++) { int x = 30 + 1 + world->raws.creatures.all[races[i]]->caste[castes[i]]->caste_name[0].size(); - bool male = (bool)world->raws.creatures.all[races[i]]->caste[castes[i]]->gender; + bool male = world->raws.creatures.all[races[i]]->caste[castes[i]]->sex == pronoun_type::he; OutputString((i == good_idx) ? COLOR_WHITE : COLOR_GREY, x, y, male ? "\013" : "\014"); } diff --git a/scripts b/scripts index 792ae44ab..91060d6d2 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 792ae44ab14afd3a2b3e850a6fcb463d714b0a44 +Subproject commit 91060d6d2c79196f6b332b9b88492eb0e7ef32da From 9def098ef914a9c8e0f7121889b17cf550e879a8 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 29 Jun 2020 21:30:22 -0500 Subject: [PATCH 3/3] add enum-attrs to pronoun_type --- library/xml | 2 +- plugins/manipulator.cpp | 4 +++- scripts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/xml b/library/xml index b11433eea..b67b3fa4b 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit b11433eea0a1117edc2a4a51f7a30b01594cb52b +Subproject commit b67b3fa4b02f834dc76a2e1eae21136e0be089f7 diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index e9206dc0f..a013df335 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -2032,7 +2032,9 @@ void viewscreen_unitlaborsst::render() int x = 1, y = 3 + num_rows + 2; Screen::Pen white_pen(' ', 15, 0); - Screen::paintString(white_pen, x, y, (cur->unit && cur->unit->sex) ? "\x0b" : "\x0c"); + auto symbol = cur->unit ? ENUM_ATTR(pronoun_type, symbol, cur->unit->sex) : nullptr; + if (symbol) + Screen::paintString(white_pen, x, y, symbol); x += 2; Screen::paintString(white_pen, x, y, cur->transname); x += cur->transname.length(); diff --git a/scripts b/scripts index 91060d6d2..3987d0314 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 91060d6d2c79196f6b332b9b88492eb0e7ef32da +Subproject commit 3987d031469420d64aff23097d9548676f1ab752