From 11c93c3b3b0e59163cefe5a716c64086faa44ffe Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Wed, 6 Nov 2024 18:47:54 -0500 Subject: [PATCH] fixed teamtype copy missing script/waypoint/taskforce parameters . (#111) --- MissionEditor/TeamTypes.cpp | 48 +++++++++++++++++++++---------------- MissionEditor/TeamTypes.h | 2 +- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/MissionEditor/TeamTypes.cpp b/MissionEditor/TeamTypes.cpp index f9c186c..92f7349 100644 --- a/MissionEditor/TeamTypes.cpp +++ b/MissionEditor/TeamTypes.cpp @@ -358,14 +358,14 @@ int GetWaypoint(const char* c) return res; } +// Serialize waypoint, will be renamed later CString GetWaypoint(int n) { if (n == -1) { - return (CString)(""); + return ""; } - int i, e; - for (i = -1; i < 26; i++) { - for (e = 0; e < 26; e++) { + for (int i = -1; i < 26; i++) { + for (int e = 0; e < 26; e++) { char c[50]; CString p; if (i == -1) { @@ -385,7 +385,7 @@ CString GetWaypoint(int n) } } - return (CString)(""); + return ""; } @@ -1258,7 +1258,7 @@ void CTeamTypes::addTeamtype(const TeamTypeParams& params) s.SetInteger("Max", params.Max); s.SetInteger("TechLevel", params.TechLevel); s.SetInteger("Group", params.Group); - s.SetInteger("Waypoint", params.Waypoint); + s.SetString("Waypoint", params.Waypoint); s.SetInteger("TransportWaypoint", params.TransportWaypoint); s.SetBool("OnTransOnly", params.OnTransOnly); s.SetBool("AvoidThreats", params.AvoidThreats); @@ -1268,17 +1268,22 @@ void CTeamTypes::addTeamtype(const TeamTypeParams& params) s.SetBool("IsBaseDefense", params.IsBaseDefense); s.SetBool("OnlyTargetHouseEnemy", params.OnlyTargetHouseEnemy); + bool anythingCopied = false; if (!params.House.IsEmpty()) { s.SetString("House", params.House); + anythingCopied = true; } if (!params.TaskForce.IsEmpty()) { s.SetString("TaskForce", params.TaskForce); + anythingCopied = true; } if (!params.Script.IsEmpty()) { s.SetString("Script", params.Script); + anythingCopied = true; } if (!params.Tag.IsEmpty()) { s.SetString("Tag", params.Tag); + anythingCopied = true; } #ifdef RA2_MODE @@ -1302,19 +1307,22 @@ void CTeamTypes::addTeamtype(const TeamTypeParams& params) } } - CComboBox& houses = *(CComboBox*)GetDlgItem(IDC_HOUSE); - houses.SetCurSel(0); - OnEditchangeHouse(); - CComboBox& waypoints = *(CComboBox*)GetDlgItem(IDC_WAYPOINT); - waypoints.SetCurSel(0); - CComboBox& script = *(CComboBox*)GetDlgItem(IDC_SCRIPT); - script.SetCurSel(0); - CComboBox& taskforce = *(CComboBox*)GetDlgItem(IDC_TASKFORCE); - taskforce.SetCurSel(0); - OnKillfocusHouse(); - OnKillfocusWaypoint(); - OnKillfocusScript(); - OnKillfocusTaskforce(); + if (!anythingCopied) { + CComboBox& houses = *(CComboBox*)GetDlgItem(IDC_HOUSE); + houses.SetCurSel(0); + OnEditchangeHouse(); + CComboBox& waypoints = *(CComboBox*)GetDlgItem(IDC_WAYPOINT); + waypoints.SetCurSel(0); + CComboBox& script = *(CComboBox*)GetDlgItem(IDC_SCRIPT); + script.SetCurSel(0); + CComboBox& taskforce = *(CComboBox*)GetDlgItem(IDC_TASKFORCE); + taskforce.SetCurSel(0); + + OnKillfocusHouse(); + OnKillfocusWaypoint(); + OnKillfocusScript(); + OnKillfocusTaskforce(); + } } void CTeamTypes::OnNewteamtype() @@ -1349,7 +1357,7 @@ void CTeamTypes::OnBnClickedTeamtypeCopy() .Priority = sec.GetInteger("Priority"), .TechLevel = sec.GetInteger("TechLevel"), .Max = sec.GetInteger("Max"), - .Waypoint = sec.GetInteger("Waypoint"), + .Waypoint = sec.GetString("Waypoint"), .TransportWaypoint = sec.GetInteger("TransportWaypoint"), #ifdef RA2_MODE .MindControlDecision = sec.GetInteger("MindControlDecision"), diff --git a/MissionEditor/TeamTypes.h b/MissionEditor/TeamTypes.h index de88ec9..eaafe3a 100644 --- a/MissionEditor/TeamTypes.h +++ b/MissionEditor/TeamTypes.h @@ -45,7 +45,7 @@ struct TeamTypeParams int Priority{ 5 }; int TechLevel{}; int Max{ 1 }; - int Waypoint{}; + CString Waypoint{}; int TransportWaypoint{}; #ifdef RA2_MODE int MindControlDecision{};