From 12914b8303206b083d9724c94d9158aa14588f93 Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Sat, 1 Jun 2024 22:21:07 -0400 Subject: [PATCH] fixed #22, corrected GetFreeID refactor logic issue . --- MissionEditor/functions.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/MissionEditor/functions.cpp b/MissionEditor/functions.cpp index 943a24a..25e6803 100644 --- a/MissionEditor/functions.cpp +++ b/MissionEditor/functions.cpp @@ -1268,24 +1268,40 @@ CString GetFreeID() int n = 1000000; auto isIDInUse = [&ini](const CString& input) { - static const CString typeListSections[] = { + // [TypeList] + // 0=TYPE1 + // 1=TYPE2 + static const CString typeLists[] = { "ScriptTypes", "TaskForces", "TeamTypes", }; - static const CString idListSections[] = { + // [ItemList] + // ID1=SOME_DEFINITION1 + // ID2=SOME_DEFINITION2 + static const CString itemLists[] = { "Triggers", "Events", "Tags", "Actions", "AITriggerTypes", }; - if (std::find(std::begin(typeListSections), std::end(typeListSections), input) != std::end(typeListSections)) { - return true; + + for (auto const& id : typeLists) { + for (auto const& [_, id] : ini[id]) { + if (id == input) { + return true; + } + } } - if (std::find(std::begin(idListSections), std::end(idListSections), input) != std::end(idListSections)) { - return true; + for (auto const& id : itemLists) { + for (auto const& [id, _] : ini[id]) { + if (id == input) { + return true; + } + } } + return false; };