AGS: Engine: fixed restoring a legacy savegame

From upstream 9776df3c8403f252e981f5518c48eace2e83d373
This commit is contained in:
Thierry Crozat 2022-12-15 16:29:43 +01:00
parent 39c98f652c
commit 7d88a52275
5 changed files with 10 additions and 9 deletions

View File

@ -82,12 +82,13 @@ void RoomStatus::ReadFromFile_v321(Stream *in) {
beenhere = in->ReadInt32();
numobj = in->ReadInt32();
obj.resize(numobj);
objProps.resize(numobj);
intrObject.resize(numobj);
obj.resize(MAX_ROOM_OBJECTS_v300);
objProps.resize(MAX_ROOM_OBJECTS_v300);
intrObject.resize(MAX_ROOM_OBJECTS_v300);
ReadRoomObjects_Aligned(in);
in->Seek(MAX_LEGACY_ROOM_FLAGS * sizeof(int16_t)); // flagstates (OBSOLETE)
int16_t dummy[MAX_LEGACY_ROOM_FLAGS]; // cannot seek with AlignedStream
in->ReadArrayOfInt16(dummy, MAX_LEGACY_ROOM_FLAGS); // flagstates (OBSOLETE)
tsdatasize = in->ReadInt32();
in->ReadInt32(); // tsdata
for (int i = 0; i < MAX_ROOM_HOTSPOTS; ++i) {

View File

@ -173,7 +173,7 @@ static void restore_game_play(Stream *in, RestoredData &r_data) {
static void ReadMoveList_Aligned(Stream *in) {
AlignedStream align_s(in, Shared::kAligned_Read);
for (int i = 0; i < _GP(game).numcharacters + MAX_ROOM_OBJECTS + 1; ++i) {
for (int i = 0; i < _GP(game).numcharacters + MAX_ROOM_OBJECTS_v300 + 1; ++i) {
_GP(mls)[i].ReadFromFile_Legacy(&align_s);
align_s.Reset();
}
@ -395,8 +395,6 @@ static HSaveError restore_game_audioclips_and_crossfade(Stream *in, RestoredData
}
HSaveError restore_save_data_v321(Stream *in, const PreservedParams &pp, RestoredData &r_data) {
int vv;
HSaveError err = restore_game_head_dynamic_values(in, r_data);
if (!err)
return err;
@ -418,7 +416,8 @@ HSaveError restore_save_data_v321(Stream *in, const PreservedParams &pp, Restore
WordsDictionary *olddict = _GP(game).dict;
char *mesbk[MAXGLOBALMES];
int numchwas = _GP(game).numcharacters;
for (vv = 0; vv < MAXGLOBALMES; vv++) mesbk[vv] = _GP(game).messages[vv];
for (size_t i = 0; i < MAXGLOBALMES; ++i)
mesbk[i] = _GP(game).messages[i];
int numdiwas = _GP(game).numdialog;
int numinvwas = _GP(game).numinvitems;
int numviewswas = _GP(game).numviews;

View File

@ -24,7 +24,6 @@
#include "ags/lib/std/vector.h"
#include "ags/shared/game/room_struct.h" // MAX_ROOM_OBJECTS
#include "ags/engine/script/cc_instance.h"
#include "ags/engine/script/executing_script.h"
#include "ags/engine/script/non_blocking_script_function.h"

View File

@ -102,6 +102,7 @@ enum RoomFlags {
#define MAX_ROOM_BGFRAMES 5 // max number of frames in animating bg scene
#define MAX_ROOM_HOTSPOTS 50 // v2.62: 20 -> 30; v2.8: -> 50
#define MAX_ROOM_OBJECTS_v300 40 // for some legacy logic support
#define MAX_ROOM_OBJECTS 256 // v3.6.0: 40 -> 256 (now limited by room format)
#define MAX_ROOM_REGIONS 16
// TODO: this is remains of the older code, MAX_WALK_AREAS = real number - 1, where

View File

@ -189,6 +189,7 @@ size_t AlignedStream::WriteArrayOfInt64(const int64_t *buffer, size_t count) {
bool AlignedStream::Seek(soff_t /*offset*/, StreamSeek /*origin*/) {
// TODO: split out Seekable Stream interface
warning("AlignedStream::Seek not supported");
return false;
}