Added custom theater palette support in Rules.ini. Fixed a crash bug in TS/RA2 SHP were referenced frames can exceed total SHP frames.

This commit is contained in:
Justin Marshall
2020-08-01 10:27:11 -07:00
parent 93a0819fe9
commit 8e4a9a019c
10 changed files with 44 additions and 5 deletions
BIN
View File
Binary file not shown.
+14 -1
View File
@@ -661,7 +661,7 @@ static BuildingTypeClass const ClassFlameTurret(
static BuildingTypeClass const ClassConst(
STRUCT_CONST,
TXT_CONST_YARD, // NAME: Short name of the structure.
"FACT", // NAME: Short name of the structure.
"EGCNST", // NAME: Short name of the structure.
FACING_NONE, // Foundation direction from center of building.
XYP_COORD(0,0), // Exit point for produced units.
REMAP_ALTERNATE, // Sidebar remap logic.
@@ -2945,6 +2945,8 @@ BuildingTypeClass::BuildingTypeClass(
BuildupData(0)
{
memset(CustomTheatrePalette, 0, sizeof(CustomTheatrePalette));
Anims[BSTATE_CONSTRUCTION].Start = 0;
Anims[BSTATE_CONSTRUCTION].Count = 1;
Anims[BSTATE_CONSTRUCTION].Rate = 0;
@@ -4010,6 +4012,17 @@ bool BuildingTypeClass::Read_INI(CCINIClass & ini)
IsUnsellable = ini.Get_Bool(Name(), "Unsellable", IsUnsellable);
IsBase = ini.Get_Bool(Name(), "BaseNormal", IsBase);
Power = ini.Get_Int(Name(), "Power", (Power > 0) ? Power : -Drain);
char customPalName[512];
if(ini.Get_String(Name(), "Snow", "", &customPalName[0], sizeof(customPalName)) > 0) {
CustomTheatrePalette[THEATER_SNOW] = MFCD::Retrieve(customPalName);
}
if (ini.Get_String(Name(), "Temperate", "", &customPalName[0], sizeof(customPalName)) > 0) {
CustomTheatrePalette[THEATER_TEMPERATE] = MFCD::Retrieve(customPalName);
}
if (Power < 0) {
Drain = -Power;
Power = 0;
+8 -1
View File
@@ -468,13 +468,20 @@ void BuildingClass::Draw_It(int x, int y, WindowNumberType window) const
** Actually draw the building shape.
*/
IsTheaterShape = Class->IsTheater; //Let Build_Frame know if this is a theater specific shape
// jmarshall - added HD support
// jmarshall - added HD support & custom palette support.
PaletteClass globalPal = CCPalette;
if(Class->CustomTheatrePalette[LastTheater] != NULL) {
CCGlobalOveridePalette = (void *)Class->CustomTheatrePalette[LastTheater];
}
if (hdimage != NULL) {
Techno_Draw_Object_HD(hdimage, Shape_Number(), x, y, window);
}
else {
Techno_Draw_Object(shapefile, Shape_Number(), x, y, window);
}
CCGlobalOveridePalette = NULL;
// jmarshall end
IsTheaterShape = false;
+1
View File
@@ -321,6 +321,7 @@ extern bool SpecialFlag;
extern int ScenarioInit;
extern HouseClass * PlayerPtr;
extern PaletteClass CCPalette;
extern void* CCGlobalOveridePalette;
extern PaletteClass BlackPalette;
extern PaletteClass WhitePalette;
extern PaletteClass GamePalette;
+1
View File
@@ -550,6 +550,7 @@ HouseClass * PlayerPtr;
** black.
*/
PaletteClass CCPalette;
void* CCGlobalOveridePalette = NULL;
PaletteClass GamePalette;
//PaletteClass InGamePalette;
PaletteClass BlackPalette(RGBClass(0, 0, 0));
+4
View File
@@ -216,6 +216,10 @@ int TiberianSunSHPDecode(const byte* s, byte* d, int cx, int cy)
INT_PTR Build_Frame(void const* dataptr, unsigned short framenumber, void* buffptr) {
// Check to see if we need to render a Tiberian Sun SHP file.
if(Get_Build_TS_Shape(dataptr)) {
if(framenumber >= Get_Build_Frame_Count(dataptr)) {
framenumber = 0;
}
byte* frame_offset = (byte *)Get_Build_TS_FrameOffset(dataptr, framenumber);
int frameX = Get_Build_Frame_Width(dataptr, framenumber);
int frameY = Get_Build_Frame_Height(dataptr, framenumber);
+4
View File
@@ -4419,6 +4419,10 @@ void TechnoClass::Techno_Draw_Object(void const * shapefile, int shapenum, int x
void const * remap = Remap_Table();
void const * shadow = Map.UnitShadow;
if (shapenum >= Get_Build_Frame_Count(shapefile)) {
shapenum = 0;
}
#ifdef PARTIAL
/*
** Create a minimum shape rectangle if one hasn't already been
+1
View File
@@ -818,6 +818,7 @@ class BuildingTypeClass : public TechnoTypeClass {
static void const * WarFactoryOverlay;
static Image_t* WarFactoryHDOverlay;
const void* CustomTheatrePalette[3];
private:
/*
+8 -2
View File
@@ -489,8 +489,14 @@ Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsi
}
}
if (ccpalete == NULL)
ccpalete = (unsigned char*)CCPalette.Get_Data();
if (ccpalete == NULL) {
if (CCGlobalOveridePalette) {
ccpalete = (unsigned char *)CCGlobalOveridePalette;
}
else {
ccpalete = (unsigned char*)CCPalette.Get_Data();
}
}
Image_t* image = new Image_t();
+3 -1
View File
@@ -1406,7 +1406,7 @@ Explodes=no
Crewed=yes
; construction yard
[FACT]
[EGCNST]
Strength=1000
Armor=heavy
TechLevel=-1
@@ -1418,6 +1418,8 @@ Power=0
Bib=yes
Capturable=true
Crewed=yes
Snow=eapal1sno.pal
Temperate=eapal1tem.pal
; refinery
[PROC]