mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-12 08:00:55 +02:00
Fixed a bug were cache was generating bad file names(increased to v4), some building animations now work.
This commit is contained in:
+27
-2
@@ -3144,7 +3144,19 @@ void BuildingTypeClass::One_Time(void)
|
||||
const char* imageFileName = Buildings_FindHDTexture(fullname, 0, 0);
|
||||
|
||||
if (imageFileName) {
|
||||
((void const*&)building.HDImageData) = Image_LoadImage(imageFileName, true, true);
|
||||
Image_t *image = Image_LoadImage(imageFileName, true, true);
|
||||
int numBuildingAnims = Buildings_GetNumFramesForTile(fullname, 0);
|
||||
if (numBuildingAnims > 0)
|
||||
{
|
||||
for (int i = 1; i < numBuildingAnims; i++) {
|
||||
imageFileName = Buildings_FindHDTexture(fullname, 0, i);
|
||||
for (int d = 0; d < MAX_MPLAYER_COLORS; d++) {
|
||||
Image_Add32BitImage(imageFileName, image, d, 0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
image->numFrames = numBuildingAnims;
|
||||
((void const*&)building.HDImageData) = image;
|
||||
}
|
||||
|
||||
if (building.ImageData != NULL && building.HDImageData != NULL) {
|
||||
@@ -3393,8 +3405,21 @@ void BuildingTypeClass::Init(TheaterType theater)
|
||||
const char* imageFileName = Buildings_FindHDTexture(fullname, 0, 0);
|
||||
|
||||
// Try load the theatre specific asset first
|
||||
if (imageFileName) {
|
||||
if (imageFileName) {
|
||||
((BuildingTypeClass*)classptr)->HDImageData = Image_LoadImage(imageFileName, true, true);
|
||||
|
||||
int numBuildingAnims = Buildings_GetNumFramesForTile(fullname, 0);
|
||||
if (numBuildingAnims > 0)
|
||||
{
|
||||
for (int i = 1; i < numBuildingAnims; i++) {
|
||||
imageFileName = Buildings_FindHDTexture(fullname, 0, i);
|
||||
for (int d = 0; d < MAX_MPLAYER_COLORS; d++) {
|
||||
Image_Add32BitImage(imageFileName, ((BuildingTypeClass*)classptr)->HDImageData, d, 0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
((BuildingTypeClass*)classptr)->HDImageData->numFrames = numBuildingAnims;
|
||||
}
|
||||
|
||||
if (classptr->ImageData != NULL && classptr->HDImageData != NULL) {
|
||||
|
||||
@@ -38,7 +38,10 @@ const char* Buildings_FindHDTexture(const char* shapeFileName, int shapeNum, int
|
||||
}
|
||||
|
||||
int Buildings_GetNumFramesForTile(const char* shapeFileName, int shapeNum) {
|
||||
int64_t hash = generateHashValue(shapeFileName, strlen(shapeFileName));
|
||||
char tmpFileName[2048];
|
||||
strcpy(tmpFileName, shapeFileName);
|
||||
COM_SetExtension(tmpFileName, strlen(tmpFileName), "");
|
||||
int64_t hash = generateHashValue(tmpFileName, strlen(tmpFileName));
|
||||
for (int i = 0; i < buildingsXmlRules.tiles.size(); i++) {
|
||||
if (buildingsXmlRules.tiles[i].hash == hash && buildingsXmlRules.tiles[i].shape == shapeNum) {
|
||||
return buildingsXmlRules.tiles[i].frames.size();
|
||||
|
||||
@@ -158,9 +158,9 @@ void Image_WriteTGA(const char* filename, const byte* data, int width, int heigh
|
||||
}
|
||||
|
||||
|
||||
static char* Image_GetGeneratedName(Image_t* image, const char* name, int houseid, int animid, int64_t hash) {
|
||||
static char* Image_GetGeneratedName(Image_t* image, const char* name, int houseid, int animid, int frameId, int64_t hash) {
|
||||
static char generatedFileName[1024];
|
||||
sprintf(generatedFileName, "cache/v2.%d.%d.%d.tga", hash, houseid, animid);
|
||||
sprintf(generatedFileName, "cache/v4.%d.%d.%d.%d.tga", frameId, houseid, animid, hash);
|
||||
return &generatedFileName[0];
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int
|
||||
// Check to see if we can load a generated image first.
|
||||
// We only generate images that need a houseid
|
||||
if (!writeGenerated && houseid >= 0) {
|
||||
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, hash);
|
||||
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, frameId, hash);
|
||||
if (Image_loadHDImage(image, generatedImageName, houseid, animid, frameId, hash, true)) {
|
||||
return true;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int
|
||||
//memcpy(image->buffer[houseid][animid], Data, Width * Height * Bpp);
|
||||
|
||||
if (!writeGenerated && Bpp == 4 && houseid >= 0) {
|
||||
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, hash);
|
||||
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, frameId, hash);
|
||||
Image_WriteTGA(generatedImageName, Data, Width, Height, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user