From 53916dbe6b7418f4871f078bbc56d926b01bc85b Mon Sep 17 00:00:00 2001 From: lethosor Date: Tue, 17 Nov 2020 23:33:18 -0500 Subject: [PATCH] Use charToKey and clean up logic a bit Ref #1714 --- plugins/buildingplan.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/buildingplan.cpp b/plugins/buildingplan.cpp index 126624a93..8d17d5dbc 100644 --- a/plugins/buildingplan.cpp +++ b/plugins/buildingplan.cpp @@ -860,13 +860,13 @@ struct buildingplan_room_hook : public df::viewscreen_dwarfmodest return false; auto np = getNoblePositionOfSelectedBuildingOwner(); df::interface_key last_token = get_string_key(input); - if (last_token >= interface_key::STRING_A048 - && last_token <= interface_key::STRING_A058) + if (last_token >= Screen::charToKey('1') + && last_token <= Screen::charToKey('9')) { - size_t selection = last_token - interface_key::STRING_A048; - if (np.size() < selection || selection == 0) + size_t index = last_token - Screen::charToKey('1'); + if (index >= np.size()) return false; - roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(selection-1).position->code); + roomMonitor.toggleRoomForPosition(world->selected_building->id, np.at(index).position->code); return true; }