mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
Made loadResourcesFromSave internally use the loadResource-function.
Fixes Operation Stealth savegame loading! HURRAH! FINALLY! svn-id: r33530
This commit is contained in:
parent
6307c46604
commit
efd4a7a72f
@ -762,17 +762,9 @@ int loadResource(const char *resourceName, int16 idx) {
|
|||||||
* at a time.
|
* at a time.
|
||||||
*/
|
*/
|
||||||
void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) {
|
void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) {
|
||||||
int16 currentAnim, foundFileIdx;
|
int16 currentAnim, foundFileIdx, frame;
|
||||||
int8 isMask = 0, isSpl = 0;
|
char *animName, part[256], name[10];
|
||||||
byte *dataPtr, *ptr;
|
|
||||||
char *animName, part[256];
|
|
||||||
byte transparentColor = 0;
|
|
||||||
AnimHeaderStruct animHeader;
|
|
||||||
|
|
||||||
uint16 width, height, bpp, var1;
|
uint16 width, height, bpp, var1;
|
||||||
int16 frame;
|
|
||||||
char name[10];
|
|
||||||
int type;
|
|
||||||
|
|
||||||
strcpy(part, currentPartName);
|
strcpy(part, currentPartName);
|
||||||
|
|
||||||
@ -781,11 +773,8 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam
|
|||||||
|
|
||||||
const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30);
|
const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30);
|
||||||
const int fileStartPos = fHandle.pos();
|
const int fileStartPos = fHandle.pos();
|
||||||
for (currentAnim = 0; currentAnim < NUM_MAX_ANIMDATA; currentAnim += animHeader.numFrames) {
|
currentAnim = 0;
|
||||||
// Initialize the number of frames variable to a sane number.
|
while (currentAnim < NUM_MAX_ANIMDATA) {
|
||||||
// This is needed when using continue later in this function.
|
|
||||||
animHeader.numFrames = 1;
|
|
||||||
|
|
||||||
// Seek to the start of the current animation's entry
|
// Seek to the start of the current animation's entry
|
||||||
fHandle.seek(fileStartPos + currentAnim * entrySize);
|
fHandle.seek(fileStartPos + currentAnim * entrySize);
|
||||||
// Read in the current animation entry
|
// Read in the current animation entry
|
||||||
@ -812,6 +801,7 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam
|
|||||||
|
|
||||||
// Don't try to load invalid entries.
|
// Don't try to load invalid entries.
|
||||||
if (foundFileIdx < 0 || !validPtr) {
|
if (foundFileIdx < 0 || !validPtr) {
|
||||||
|
currentAnim++; // Jump over the invalid entry
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,52 +812,10 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam
|
|||||||
}
|
}
|
||||||
|
|
||||||
animName = partBuffer[foundFileIdx].partName;
|
animName = partBuffer[foundFileIdx].partName;
|
||||||
ptr = dataPtr = readBundleFile(foundFileIdx);
|
loadRelatedPalette(animName); // Is this for Future Wars only?
|
||||||
|
const int16 prevAnim = currentAnim;
|
||||||
// isSpl and isMask are mutually exclusive cases
|
currentAnim = loadResource(animName, currentAnim);
|
||||||
isSpl = (strstr(animName, ".SPL")) ? 1 : 0;
|
assert(currentAnim > prevAnim); // Make sure we advance forward
|
||||||
isMask = (strstr(animName, ".MSK")) ? 1 : 0;
|
|
||||||
|
|
||||||
if (isSpl) {
|
|
||||||
width = (uint16) partBuffer[foundFileIdx].unpackedSize;
|
|
||||||
height = 1;
|
|
||||||
animHeader.numFrames = 1;
|
|
||||||
type = ANIM_RAW;
|
|
||||||
} else {
|
|
||||||
Common::MemoryReadStream readS(ptr, 0x16);
|
|
||||||
loadAnimHeader(animHeader, readS);
|
|
||||||
ptr += 0x16;
|
|
||||||
|
|
||||||
width = animHeader.frameWidth;
|
|
||||||
height = animHeader.frameHeight;
|
|
||||||
|
|
||||||
if (isMask) {
|
|
||||||
type = ANIM_MASK;
|
|
||||||
} else {
|
|
||||||
type = ANIM_MASKSPRITE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadRelatedPalette(animName);
|
|
||||||
transparentColor = getAnimTransparentColor(animName);
|
|
||||||
// Make sure we load at least one frame and also that we
|
|
||||||
// don't overflow the animDataTable by writing beyond its end.
|
|
||||||
animHeader.numFrames = CLIP<uint16>(animHeader.numFrames, 1, NUM_MAX_ANIMDATA - currentAnim);
|
|
||||||
|
|
||||||
// Load the frames
|
|
||||||
for (frame = 0; frame < animHeader.numFrames; frame++) {
|
|
||||||
// special case transparency handling
|
|
||||||
if (!strcmp(animName, "L2202.ANI")) {
|
|
||||||
transparentColor = (frame < 2) ? 0 : 7;
|
|
||||||
} else if (!strcmp(animName, "L4601.ANI")) {
|
|
||||||
transparentColor = (frame < 1) ? 0xE : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load a single frame
|
|
||||||
animDataTable[currentAnim + frame].load(ptr + frame * width * height, type, width, height, foundFileIdx, frame, name, transparentColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(dataPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPart(part);
|
loadPart(part);
|
||||||
|
Loading…
Reference in New Issue
Block a user