diff --git a/MissionEditor/IsoView.cpp b/MissionEditor/IsoView.cpp index 365e154..376578f 100644 --- a/MissionEditor/IsoView.cpp +++ b/MissionEditor/IsoView.cpp @@ -635,7 +635,7 @@ __forceinline void BlitPic(void* dst, int x, int y, int dleft, int dtop, int dpi if (dest >= dst) { int c; - if (!color || newPal != iPalUnit || val < houseColorMin || val > houseColorMax) { + if (!color || !pd.bHouseColor || val < houseColorMin || val > houseColorMax) { c = newPal[val]; } else { // Replace the original palette color with the house color diff --git a/MissionEditor/Loading.cpp b/MissionEditor/Loading.cpp index 4e69841..6945e59 100644 --- a/MissionEditor/Loading.cpp +++ b/MissionEditor/Loading.cpp @@ -1959,14 +1959,19 @@ void CLoading::LoadVehicleOrAircraft(const CString& ID) } -void CLoading::SetImageData(unsigned char* pBuffer, const CString& NameInDict, int FullWidth, int FullHeight, Palette* pPal) +void CLoading::SetImageData(unsigned char* pBuffer, const CString& NameInDict, int FullWidth, int FullHeight, Palette* pPal, bool forceNoRemap) { ASSERT(!NameInDict.IsEmpty()); auto& data = pics[NameInDict]; - SetImageData(pBuffer, data, FullWidth, FullHeight, pPal); + + if (NameInDict.Find("CNST") >= 0) { + printf(""); + } + + SetImageData(pBuffer, data, FullWidth, FullHeight, pPal, forceNoRemap); } -void CLoading::SetImageData(unsigned char* pBuffer, PICDATA& pData, const int FullWidth, const int FullHeight, Palette* pPal) +void CLoading::SetImageData(unsigned char* pBuffer, PICDATA& pData, const int FullWidth, const int FullHeight, Palette* pPal, bool forceNoRemap) { if (pData.pic) { delete[](pData.pic); @@ -2019,7 +2024,13 @@ void CLoading::SetImageData(unsigned char* pBuffer, PICDATA& pData, const int Fu //auto limited_to_theater = artSection.GetBool("TerrainPalette") ? shp->mixfile_theater : TheaterChar::None; auto limited_to_theater = TheaterChar::None; pData.bTerrain = limited_to_theater; - pData.pal = pPal ? reinterpret_cast(pPal->GetData()) : iPalUnit; + if (pPal) { + pData.pal = reinterpret_cast(pPal->GetData()); + pData.bHouseColor = pPal->IsRemappable() && !forceNoRemap; + return; + } + pData.pal = iPalUnit; + pData.bHouseColor = true; } void CLoading::LoadBuildingSubGraphic(const CString& subkey, const CIniFileSection& artSection, BOOL bAlwaysSetChar, char theat, HMIXFILE hShpMix, SHPHEADER& shp_h, BYTE*& shp) @@ -3461,7 +3472,7 @@ void CLoading::LoadOverlayGraphic(const CString& lpOvrlName_, int iOvrlNum) char ic[50]; itoa(i, ic, 10); - pics[(CString)"OVRL" + OvrlID + "_" + ic].bTried = TRUE; + pics[(CString)"OVRL" + OvrlID + "_" + ic].bTried = true; } diff --git a/MissionEditor/Loading.h b/MissionEditor/Loading.h index 084c572..e5318ac 100644 --- a/MissionEditor/Loading.h +++ b/MissionEditor/Loading.h @@ -115,8 +115,8 @@ public: void LoadTerrainOrSmudge(const CString& ID); void LoadVehicleOrAircraft(const CString& ID); - void SetImageData(unsigned char* pBuffer, const CString& NameInDict, int FullWidth, int FullHeight, Palette* pPal); - void SetImageData(unsigned char* pBuffer, PICDATA& pData, const int FullWidth, const int FullHeight, Palette* pPal); + void SetImageData(unsigned char* pBuffer, const CString& NameInDict, int FullWidth, int FullHeight, Palette* pPal, bool forceNoRemap = false); + void SetImageData(unsigned char* pBuffer, PICDATA& pData, const int FullWidth, const int FullHeight, Palette* pPal, bool forceNoRemap); void UnionSHP_Add(unsigned char* pBuffer, int Width, int Height, int DeltaX = 0, int DeltaY = 0, bool UseTemp = false); void UnionSHP_GetAndClear(unsigned char*& pOutBuffer, int* OutWidth, int* OutHeight, bool clearBuffer = true, bool UseTemp = false); void VXL_Add(const unsigned char* pCache, int X, int Y, int Width, int Height); diff --git a/MissionEditor/Palettes.cpp b/MissionEditor/Palettes.cpp index fbe1be6..4584ea7 100644 --- a/MissionEditor/Palettes.cpp +++ b/MissionEditor/Palettes.cpp @@ -113,12 +113,12 @@ void Palettes::Init() LoadedPalettes["isolun.pal"] = new Palette(m_hPalIsoLun); LoadedPalettes["isodes.pal"] = new Palette(m_hPalIsoDes); - LoadedPalettes["unittem.pal"] = new Palette(m_hPalUnitTemp); - LoadedPalettes["unitsno.pal"] = new Palette(m_hPalUnitSnow); - LoadedPalettes["uniturb.pal"] = new Palette(m_hPalUnitUrb); - LoadedPalettes["unitubn.pal"] = new Palette(m_hPalUnitUbn); - LoadedPalettes["unitlun.pal"] = new Palette(m_hPalUnitLun); - LoadedPalettes["unitdes.pal"] = new Palette(m_hPalUnitDes); + LoadedPalettes["unittem.pal"] = new Palette(m_hPalUnitTemp, true); + LoadedPalettes["unitsno.pal"] = new Palette(m_hPalUnitSnow, true); + LoadedPalettes["uniturb.pal"] = new Palette(m_hPalUnitUrb, true); + LoadedPalettes["unitubn.pal"] = new Palette(m_hPalUnitUbn, true); + LoadedPalettes["unitlun.pal"] = new Palette(m_hPalUnitLun, true); + LoadedPalettes["unitdes.pal"] = new Palette(m_hPalUnitDes, true); LoadedPalettes["temperat.pal"] = new Palette(m_hPalTemp); LoadedPalettes["snow.pal"] = new Palette(m_hPalSnow); @@ -327,7 +327,8 @@ void Palettes::Clear() Init(); } -Palette::Palette(const BytePalette& bytes) +Palette::Palette(const BytePalette& bytes, bool remappable) : + Remappable(remappable) { for (auto idx = 0; idx < 256; idx++) { Data[idx].R = bytes.Data[idx].red; @@ -337,7 +338,8 @@ Palette::Palette(const BytePalette& bytes) } } -Palette::Palette(HTSPALETTE indexer) +Palette::Palette(HTSPALETTE indexer, bool remappable) : + Remappable(remappable) { for (auto idx = 0; idx < 256; idx++) { RGBTRIPLE ret; diff --git a/MissionEditor/Palettes.h b/MissionEditor/Palettes.h index ac44dec..0d929fc 100644 --- a/MissionEditor/Palettes.h +++ b/MissionEditor/Palettes.h @@ -29,8 +29,8 @@ public: class Palette { public: - Palette(const BytePalette& bytes); - Palette(HTSPALETTE raw); + Palette(const BytePalette& bytes, bool remappable = false); + Palette(HTSPALETTE raw, bool remappable = false); BGRStruct& operator[](int index) { return Data[index]; } ColorStruct GetByteColor(int index) { @@ -42,9 +42,11 @@ public: return ret; } const BGRStruct* GetData() const { return Data; } + bool IsRemappable() const { return Remappable; } private: - BGRStruct Data[256]; + BGRStruct Data[256]{}; + bool Remappable{}; }; class Palettes diff --git a/MissionEditor/Structs.h b/MissionEditor/Structs.h index bdf15c0..af4c963 100644 --- a/MissionEditor/Structs.h +++ b/MissionEditor/Structs.h @@ -133,7 +133,8 @@ struct PICDATA { WORD wMaxHeight = 0; // for SHPs (size of whole surface) BYTE bType = 0; // is loaded from voxel, shp, bmp, etc... (for drawing logic) TheaterChar bTerrain = TheaterChar::None; - BOOL bTried = 0; // already tried to load this? - superseded by global array missingimages + bool bTried = false; // already tried to load this? - superseded by global array missingimages + bool bHouseColor = false; inline ProjectedVec drawOffset() const {