From 018deec91250a17717e41af2d8dd9181c6c3826d Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 11 May 2018 22:18:26 -0400 Subject: [PATCH] Fix another occasional segfault in block-labors Fixes #1057 --- plugins/tweak/tweaks/block-labors.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/tweak/tweaks/block-labors.h b/plugins/tweak/tweaks/block-labors.h index 8243afbf6..bc407ed19 100644 --- a/plugins/tweak/tweaks/block-labors.h +++ b/plugins/tweak/tweaks/block-labors.h @@ -75,12 +75,12 @@ struct block_labors_hook : df::viewscreen_dwarfmodest { DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set *input)) { using namespace df::enums::interface_key; - if (valid_mode()) - { - df::unit *unit = Gui::getAnyUnit(this); - df::unit_labor labor = unit_labors_sidemenu[*ui_look_cursor]; - df::unit_labor_category cat = df::unit_labor_category(labor); + df::unit *unit = Gui::getAnyUnit(this); + df::unit_labor labor = vector_get(unit_labors_sidemenu, *ui_look_cursor, df::unit_labor::NONE); + df::unit_labor_category cat = df::unit_labor_category(labor); + if (valid_mode() && labor != df::unit_labor::NONE) + { if ((input->count(SELECT) || input->count(SELECT_ALL)) && forbidden_labor(unit, labor)) { unit->status.labors[labor] = false;