From 47a770cdcbba12e79e6d4e59bbe3892d0d8e427d Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Sun, 24 Nov 2024 21:21:53 -0500 Subject: [PATCH] make codes more readable . --- MissionEditor/Loading.cpp | 24 +++++++++++++----- MissionEditor/MapData.cpp | 53 ++++++++++++++++++++++++++++----------- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/MissionEditor/Loading.cpp b/MissionEditor/Loading.cpp index a8537da..b86afaa 100644 --- a/MissionEditor/Loading.cpp +++ b/MissionEditor/Loading.cpp @@ -4085,12 +4085,24 @@ void CLoading::PrepareUnitGraphic(const CString& lpUnittype) auto const bPowerUp = !rules.GetString(lpUnittype, "PowersUpBuilding").IsEmpty(); HTSPALETTE hPalette; - if (theat == 'T') hPalette = m_palettes.m_hPalIsoTemp; - if (theat == 'A') hPalette = m_palettes.m_hPalIsoSnow; - if (theat == 'U') hPalette = m_palettes.m_hPalIsoUrb; - if (theat == 'L') hPalette = m_palettes.m_hPalIsoLun; - if (theat == 'D') hPalette = m_palettes.m_hPalIsoDes; - if (theat == 'N') hPalette = m_palettes.m_hPalIsoUbn; + if (theat == 'T') { + hPalette = m_palettes.m_hPalIsoTemp; + } + if (theat == 'A') { + hPalette = m_palettes.m_hPalIsoSnow; + } + if (theat == 'U') { + hPalette = m_palettes.m_hPalIsoUrb; + } + if (theat == 'L') { + hPalette = m_palettes.m_hPalIsoLun; + } + if (theat == 'D') { + hPalette = m_palettes.m_hPalIsoDes; + } + if (theat == 'N') { + hPalette = m_palettes.m_hPalIsoUbn; + } CIsoView& v = *((CFinalSunDlg*)theApp.m_pMainWnd)->m_view.m_isoview; diff --git a/MissionEditor/MapData.cpp b/MissionEditor/MapData.cpp index cedf670..409f873 100644 --- a/MissionEditor/MapData.cpp +++ b/MissionEditor/MapData.cpp @@ -428,7 +428,7 @@ CString CMapData::GetAITriggerTypeID(DWORD dwAITriggerType) CIniFile& CMapData::GetIniFile() { - UpdateIniFile(); + UpdateIniFile(MAPDATA_UPDATE_TO_INI); return m_mapfile; } @@ -450,8 +450,9 @@ in order to do this. void CMapData::UpdateIniFile(DWORD dwFlags) { BOOL bSave = TRUE; - if (dwFlags == MAPDATA_UPDATE_FROM_INI) + if (dwFlags == MAPDATA_UPDATE_FROM_INI) { bSave = FALSE; + } if (dwFlags == MAPDATA_UPDATE_FROM_INI) { CalcMapRect(); @@ -505,17 +506,31 @@ void CMapData::UpdateIniFile(DWORD dwFlags) return; } - if (!bSave) UpdateAircraft(bSave); + if (!bSave) { + UpdateAircraft(false); + } UpdateCelltags(bSave); - if (!bSave) UpdateInfantry(bSave); + if (!bSave) { + UpdateInfantry(false); + } UpdateNodes(bSave); - if (!bSave) UpdateOverlay(bSave); - if (!bSave) UpdateStructures(bSave); - if (!bSave) UpdateTerrain(bSave); + if (!bSave) { + UpdateOverlay(false); + } + if (!bSave) { + UpdateStructures(false); + } + if (!bSave) { + UpdateTerrain(false); + } #ifdef SMUDGE_SUPP - if (!bSave) UpdateSmudges(bSave); + if (!bSave) { + UpdateSmudges(false); + } #endif - if (!bSave) UpdateUnits(bSave); + if (!bSave) { + UpdateUnits(false); + } UpdateWaypoints(bSave); UpdateTubes(bSave); @@ -526,9 +541,11 @@ void CMapData::LoadMap(const std::string& file) errstream << "LoadMap() frees memory\n"; errstream.flush(); - if (fielddata != NULL) delete[] fielddata; - int i; - for (i = 0; i < dwSnapShotCount; i++) { + if (fielddata != NULL) { + delete[] fielddata; + } + + for (auto i = 0; i < dwSnapShotCount; i++) { delete[] m_snapshots[i].bHeight; delete[] m_snapshots[i].bMapData; delete[] m_snapshots[i].bSubTile; @@ -2413,10 +2430,16 @@ void CMapData::InitializeUnitTypes() INT CMapData::GetUnitTypeID(LPCTSTR lpType) { // we only support building types, terrain types and smudge types at the moment - if (buildingid.find(lpType) != buildingid.end()) return buildingid[lpType]; - if (terrainid.find(lpType) != terrainid.end()) return terrainid[lpType]; + if (buildingid.find(lpType) != buildingid.end()) { + return buildingid[lpType]; + } + if (terrainid.find(lpType) != terrainid.end()) { + return terrainid[lpType]; + } #ifdef SMUDGE_SUPP - if (smudgeid.find(lpType) != smudgeid.end()) return smudgeid[lpType]; + if (smudgeid.find(lpType) != smudgeid.end()) { + return smudgeid[lpType]; + } #endif return 0; }