diff --git a/MissionEditor/IsoView.cpp b/MissionEditor/IsoView.cpp index 665d868..fe24b82 100644 --- a/MissionEditor/IsoView.cpp +++ b/MissionEditor/IsoView.cpp @@ -2259,7 +2259,7 @@ void CIsoView::HandleProperties(int n, int type) Map->DeleteInfantry(n); - Map->AddInfantry(&data, nullptr, nullptr, 0, n); + Map->AddInfantry(&data, n); RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); break; @@ -3015,7 +3015,7 @@ void CIsoView::OnLButtonUp(UINT nFlags, CPoint point) Map->DeleteInfantry(m_id); } - Map->AddInfantry(&infantry, nullptr, nullptr, 0, m_id); + Map->AddInfantry(&infantry, m_id); break; } @@ -4866,7 +4866,7 @@ void CIsoView::PlaceCurrentObjectAt(int x, int y) return; } - Map->AddInfantry(NULL, AD.data_s, currentOwner, x + y * Map->GetIsoSize()); + Map->AddInfantry(NULL, -1, AD.data_s, currentOwner, x + y * Map->GetIsoSize()); //RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); } break; case MouseActionType::AddStructure: { @@ -4954,7 +4954,7 @@ void CIsoView::PlaceCurrentObjectAt(int x, int y) Map->GetInfantryData(t, &infantry); Map->DeleteInfantry(t); infantry.house = AD.data_s; - Map->AddInfantry(&infantry); + Map->AddInfantry(&infantry, t); bchanged = TRUE; } } diff --git a/MissionEditor/MapData.cpp b/MissionEditor/MapData.cpp index 5e38938..055b2a7 100644 --- a/MissionEditor/MapData.cpp +++ b/MissionEditor/MapData.cpp @@ -2180,7 +2180,7 @@ BOOL CMapData::AddNode(NODE* lpNode, WORD dwPos) return TRUE; } -BOOL CMapData::AddInfantry(INFANTRY* lpInfantry, LPCTSTR lpType, LPCTSTR lpHouse, DWORD dwPos, int suggestedIndex) +BOOL CMapData::AddInfantry(INFANTRY* lpInfantry, int suggestedIndex, LPCTSTR lpType, LPCTSTR lpHouse, DWORD dwPos) { INFANTRY infantry; @@ -2238,7 +2238,7 @@ BOOL CMapData::AddInfantry(INFANTRY* lpInfantry, LPCTSTR lpType, LPCTSTR lpHouse itoa(i, c, 10); inf.pos = c; DeleteInfantry(oldInf); - AddInfantry(&inf); + AddInfantry(&inf, oldInf); break; } @@ -6337,7 +6337,9 @@ void CMapData::ResizeMap(int iLeft, int iTop, DWORD dwNewWidth, DWORD dwNewHeigh int y = atoi(obj.y); - if (x < 0 || y < 0 || x >= m_IsoSize || y >= m_IsoSize) continue; + if (x < 0 || y < 0 || x >= m_IsoSize || y >= m_IsoSize) { + continue; + } AddInfantry(&obj); diff --git a/MissionEditor/MapData.h b/MissionEditor/MapData.h index df49702..b4c2675 100644 --- a/MissionEditor/MapData.h +++ b/MissionEditor/MapData.h @@ -258,7 +258,7 @@ public: INT GetUnitTypeID(LPCTSTR lpType); void InitializeUnitTypes(); BOOL AddStructure(STRUCTURE* lpStructure, LPCTSTR lpType = NULL, LPCTSTR lpHouse = NULL, DWORD dwPos = 0, CString suggestedID = ""); - BOOL AddInfantry(INFANTRY* lpInfantry, LPCTSTR lpType = NULL, LPCTSTR lpHouse = NULL, DWORD dwPos = 0, int suggestedIndex = -1); + BOOL AddInfantry(INFANTRY* lpInfantry, int suggestedIndex = -1, LPCTSTR lpType = NULL, LPCTSTR lpHouse = NULL, DWORD dwPos = 0); BOOL AddNode(NODE* lpNode, WORD dwPos); void GetStdStructureData(DWORD dwIndex, STDOBJECTDATA* lpStdStructure) const; CString GetStructureData(DWORD dwIndex, STRUCTURE* lpStructure) const; diff --git a/MissionEditor/UserScriptsDlg.cpp b/MissionEditor/UserScriptsDlg.cpp index 7b16a13..2472402 100644 --- a/MissionEditor/UserScriptsDlg.cpp +++ b/MissionEditor/UserScriptsDlg.cpp @@ -2350,7 +2350,7 @@ void CUserScriptsDlg::OnOK() id.flag4 = GetParam(data, 12); id.flag5 = GetParam(data, 13); - if (Map->AddInfantry(&id, NULL, NULL, NULL, lastInfantryDeleted) == FALSE) { + if (Map->AddInfantry(&id, lastInfantryDeleted, NULL, NULL, NULL) == FALSE) { report += "AddInfantry failed\r\n"; } else { report += "Infantry added\r\n";