From 5cb110d9e5f9eaed9136972c00f3ce1e8fcd00aa Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Thu, 6 Jun 2024 00:16:38 -0400 Subject: [PATCH] #33 fixed, taskforce delete should be normal now . --- MissionEditor/IniFile.h | 6 ++++++ MissionEditor/TaskForce.cpp | 34 +++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/MissionEditor/IniFile.h b/MissionEditor/IniFile.h index e00c108..d2ca281 100644 --- a/MissionEditor/IniFile.h +++ b/MissionEditor/IniFile.h @@ -324,6 +324,12 @@ public: this->SetString(section, key, INIHelper::ToString(value)); } + void RemoveValue(const CString& section, const CString& value) { + if (auto pSec = this->TryGetSection(section)) { + pSec->RemoveValue(value); + } + } + void RemoveValueByKey(const CString& section, const CString& key) { if (auto pSec = this->TryGetSection(section)) { pSec->RemoveByKey(key); diff --git a/MissionEditor/TaskForce.cpp b/MissionEditor/TaskForce.cpp index c487da2..37d33e1 100644 --- a/MissionEditor/TaskForce.cpp +++ b/MissionEditor/TaskForce.cpp @@ -181,22 +181,26 @@ void CTaskForce::OnSelchangeTaskforces() int i; while (m_Units.DeleteString(0) != LB_ERR); - for (i = 0; i < sec.Size() - 2; i++) { - char p[50]; - itoa(i, p, 10); - auto const& data = sec.GetString(p); - CString type = GetParam(data, 1); - CString s = GetParam(data, 0); - s += " "; - /*if(ini.sections.find((char*)(LPCTSTR)type)!=ini.sections.end() && ini.sections[(char*)(LPCTSTR)type].values.find("Name")!=ini.sections[(char*)(LPCTSTR)type].values.end()) - s+=ini.sections[(char*)(LPCTSTR)type].values["Name"]; - else - s+=rules.sections[(char*)(LPCTSTR)type].values["Name"];*/ - s += Map->GetUnitName(type); - //s+=")"; - m_Units.SetItemData(m_Units.AddString(s), i); + if (sec.Size()) { + for (i = 0; i < sec.Size() - 2; i++) { + char p[50]; + itoa(i, p, 10); + auto const& data = sec.GetString(p); + CString type = GetParam(data, 1); + CString s = GetParam(data, 0); + s += " "; + /*if(ini.sections.find((char*)(LPCTSTR)type)!=ini.sections.end() && ini.sections[(char*)(LPCTSTR)type].values.find("Name")!=ini.sections[(char*)(LPCTSTR)type].values.end()) + s+=ini.sections[(char*)(LPCTSTR)type].values["Name"]; + else + s+=rules.sections[(char*)(LPCTSTR)type].values["Name"];*/ + s += Map->GetUnitName(type); + //s+=")"; + + m_Units.SetItemData(m_Units.AddString(s), i); + } } + UpdateData(FALSE); if (m_Units.SetCurSel(0) != LB_ERR) { @@ -426,7 +430,7 @@ void CTaskForce::OnDeletetaskforce() return; } - ini.RemoveValueByKey("TaskForces", tf); + ini.RemoveValue("TaskForces", tf); ini.DeleteSection(tf); while (m_Units.DeleteString(0) != LB_ERR); //UpdateDialog();