From 56eadd70868696cbd0c665c14d9679a61a243637 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Sat, 1 Aug 2020 15:36:03 -0700 Subject: [PATCH] Added building faction colors. --- code/redalert/building.cpp | 11 +++++++++++ code/redalert/externs.h | 2 ++ code/redalert/globals.cpp | 12 ++++++++++++ code/redalert/winstub.cpp | 40 +++++++++++++++++++++++++++++++++----- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/code/redalert/building.cpp b/code/redalert/building.cpp index caf877c..26da5dd 100644 --- a/code/redalert/building.cpp +++ b/code/redalert/building.cpp @@ -472,6 +472,17 @@ void BuildingClass::Draw_It(int x, int y, WindowNumberType window) const PaletteClass globalPal = CCPalette; if(Class->CustomTheatrePalette[LastTheater] != NULL) { CCGlobalOveridePalette = (void *)Class->CustomTheatrePalette[LastTheater]; + HouseTypeClass* houseType = House->Class; + + if (houseType->House >= HOUSE_MULTI1) { + CCPaletteHouseColor = House->RemapColor; + } + else if (houseType->House <= HOUSE_TURKEY) { + CCPaletteHouseColor = houseType->House; + } + else { + CCPaletteHouseColor = 0; + } } { diff --git a/code/redalert/externs.h b/code/redalert/externs.h index 7d91cac..762635e 100644 --- a/code/redalert/externs.h +++ b/code/redalert/externs.h @@ -322,6 +322,8 @@ extern int ScenarioInit; extern HouseClass * PlayerPtr; extern PaletteClass CCPalette; extern void* CCGlobalOveridePalette; +extern int CCPaletteHouseColor; +extern float HouseRGBColors[8][3]; extern PaletteClass BlackPalette; extern PaletteClass WhitePalette; extern PaletteClass GamePalette; diff --git a/code/redalert/globals.cpp b/code/redalert/globals.cpp index 1258229..c2931f8 100644 --- a/code/redalert/globals.cpp +++ b/code/redalert/globals.cpp @@ -551,6 +551,7 @@ HouseClass * PlayerPtr; */ PaletteClass CCPalette; void* CCGlobalOveridePalette = NULL; +int CCPaletteHouseColor = 0; PaletteClass GamePalette; //PaletteClass InGamePalette; PaletteClass BlackPalette(RGBClass(0, 0, 0)); @@ -558,6 +559,17 @@ PaletteClass WhitePalette(RGBClass(RGBClass::MAX_VALUE, RGBClass::MAX_VALUE, RGB PaletteClass OriginalPalette; PaletteClass ScorePalette; +float HouseRGBColors[8][3] = { + { 255.0f, 223.0f, 94.0f }, + {160,164,200 }, // Allies Blue + {255.0f, 20.0f, 20.0f }, + {140, 244, 140 }, // Green + {255.0f, 155.0f, 0.0f}, + {92, 192, 164}, + {204, 184, 176}, + {170, 93, 71} +}; + /*************************************************************************** ** These are the event queues. One is for holding events until they are ready to be diff --git a/code/redalert/winstub.cpp b/code/redalert/winstub.cpp index 7685220..b608296 100644 --- a/code/redalert/winstub.cpp +++ b/code/redalert/winstub.cpp @@ -504,14 +504,44 @@ Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsi for (int i = 0; i < Width * Height; i++) { unsigned char c = data[i]; - if (remap) { + + unsigned char r = 0; + unsigned char g = 0; + unsigned char b = 0; + unsigned char a = 0; + + if (CCGlobalOveridePalette && remap) { + r = ccpalete[(c * 3) + 0] << 2; + g = ccpalete[(c * 3) + 1] << 2; + b = ccpalete[(c * 3) + 2] << 2; + a = 0; + + // Assume we are loading TS palettes. + if (c >= 0x10 && c <= 0x1f) { + float greyscale = r / 255.0f; + + r = HouseRGBColors[CCPaletteHouseColor][0] * greyscale; + g = HouseRGBColors[CCPaletteHouseColor][1] * greyscale; + b = HouseRGBColors[CCPaletteHouseColor][2] * greyscale; + a = 0; + } + } + else if (remap) { c = remap[c]; + r = ccpalete[(c * 3) + 0] << 2; + g = ccpalete[(c * 3) + 1] << 2; + b = ccpalete[(c * 3) + 2] << 2; + a = 0; + } + else + { + r = ccpalete[(c * 3) + 0] << 2; + g = ccpalete[(c * 3) + 1] << 2; + b = ccpalete[(c * 3) + 2] << 2; + a = 0; } - unsigned char r = ccpalete[(c * 3) + 0] << 2; - unsigned char g = ccpalete[(c * 3) + 1] << 2; - unsigned char b = ccpalete[(c * 3) + 2] << 2; - unsigned char a = 0; + if ((r == 84 && g == 252 && b == 84) || (r == 0 && g == 168 && b == 0)) { r = 0;