mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
AGS: Engine: hardcode alignment padding in remaining legacy save parts
From upstream b3951c9d8c8cfdd75c4a1f412735de76e1476ceb
This commit is contained in:
1 parent
498a3cb270
commit
8b4e30fa35
8 files changed
+25
-32
No files matched your search
@@ -48,7 +48,7 @@ void MoveList::SetPixelUnitFraction(float frac) {
|
||||
onpart = permove_dist > 0.f ? (1.f / permove_dist) * frac : 0.f;
|
||||
}
|
||||
|
||||
void MoveList::ReadFromFile_Legacy(Stream *in) {
|
||||
void MoveList::ReadFromSavegame_Legacy(Stream *in) {
|
||||
*this = MoveList(); // reset struct
|
||||
for (int i = 0; i < MAXNEEDSTAGES_LEGACY; ++i) {
|
||||
// X & Y was packed as high/low shorts, and hence reversed in lo-end
|
||||
@@ -66,11 +66,12 @@ void MoveList::ReadFromFile_Legacy(Stream *in) {
|
||||
in->ReadInt32(); // UNUSED
|
||||
doneflag = in->ReadInt8();
|
||||
direct = in->ReadInt8();
|
||||
in->ReadInt16(); // alignment padding to int32 (finalize struct)
|
||||
}
|
||||
|
||||
HSaveError MoveList::ReadFromFile(Stream *in, int32_t cmp_ver) {
|
||||
HSaveError MoveList::ReadFromSavegame(Stream *in, int32_t cmp_ver) {
|
||||
if (cmp_ver < kMoveSvgVersion_350) {
|
||||
ReadFromFile_Legacy(in);
|
||||
ReadFromSavegame_Legacy(in); // FIXME: pass an arg to not use padding; OR remove support of kMoveSvgVersion_Initial?
|
||||
return HSaveError::None();
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ HSaveError MoveList::ReadFromFile(Stream *in, int32_t cmp_ver) {
|
||||
return HSaveError::None();
|
||||
}
|
||||
|
||||
void MoveList::WriteToFile(Stream *out) const {
|
||||
void MoveList::WriteToSavegame(Stream *out) const {
|
||||
out->WriteInt32(numstage);
|
||||
if (numstage == 0)
|
||||
return;
|
||||
|
||||
@@ -83,9 +83,9 @@ struct MoveList {
|
||||
// Sets a step progress to this fraction of a coordinate unit
|
||||
void SetPixelUnitFraction(float frac);
|
||||
|
||||
void ReadFromFile_Legacy(Shared::Stream *in);
|
||||
AGS::Engine::HSaveError ReadFromFile(Shared::Stream *in, int32_t cmp_ver);
|
||||
void WriteToFile(Shared::Stream *out) const;
|
||||
void ReadFromSavegame_Legacy(Shared::Stream *in);
|
||||
AGS::Engine::HSaveError ReadFromSavegame(Shared::Stream *in, int32_t cmp_ver);
|
||||
void WriteToSavegame(Shared::Stream *out) const;
|
||||
};
|
||||
|
||||
} // namespace AGS3
|
||||
|
||||
@@ -65,7 +65,7 @@ void ScreenOverlay::SetSpriteNum(int sprnum, int offx, int offy) {
|
||||
MarkChanged();
|
||||
}
|
||||
|
||||
void ScreenOverlay::ReadFromFile(Stream *in, bool &has_bitmap, int32_t cmp_ver) {
|
||||
void ScreenOverlay::ReadFromSavegame(Stream *in, bool &has_bitmap, int32_t cmp_ver) {
|
||||
_pic.reset();
|
||||
ddb = nullptr;
|
||||
in->ReadInt32(); // ddb 32-bit pointer value (nasty legacy format)
|
||||
@@ -85,6 +85,9 @@ void ScreenOverlay::ReadFromFile(Stream *in, bool &has_bitmap, int32_t cmp_ver)
|
||||
_flags |= kOver_PositionAtRoomXY;
|
||||
}
|
||||
|
||||
if (cmp_ver < 0) {
|
||||
in->ReadInt16(); // alignment padding to int32 (finalize struct)
|
||||
}
|
||||
if (cmp_ver >= kOverSvgVersion_35028) {
|
||||
offsetX = in->ReadInt32();
|
||||
offsetY = in->ReadInt32();
|
||||
@@ -107,7 +110,7 @@ void ScreenOverlay::ReadFromFile(Stream *in, bool &has_bitmap, int32_t cmp_ver)
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenOverlay::WriteToFile(Stream *out) const {
|
||||
void ScreenOverlay::WriteToSavegame(Stream *out) const {
|
||||
out->WriteInt32(0); // ddb 32-bit pointer value (nasty legacy format)
|
||||
if (_flags & kOver_SpriteReference)
|
||||
out->WriteInt32(_sprnum); // sprite reference
|
||||
|
||||
@@ -122,8 +122,8 @@ struct ScreenOverlay {
|
||||
_hasChanged = false;
|
||||
}
|
||||
|
||||
void ReadFromFile(Shared::Stream *in, bool &has_bitmap, int32_t cmp_ver);
|
||||
void WriteToFile(Shared::Stream *out) const;
|
||||
void ReadFromSavegame(Shared::Stream *in, bool &has_bitmap, int32_t cmp_ver);
|
||||
void WriteToSavegame(Shared::Stream *out) const;
|
||||
|
||||
private:
|
||||
int _flags = 0; // OverlayFlags
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
#include "ags/plugins/plugin_engine.h"
|
||||
#include "ags/engine/script/script.h"
|
||||
#include "ags/shared/script/cc_common.h"
|
||||
#include "ags/shared/util/aligned_stream.h"
|
||||
#include "ags/shared/util/file.h"
|
||||
#include "ags/shared/util/stream.h"
|
||||
#include "ags/shared/util/string_utils.h"
|
||||
|
||||
@@ -509,7 +509,7 @@ HSaveError ReadCharacters(Stream *in, int32_t cmp_ver, const PreservedParams & /
|
||||
ReadTimesRun272(*_GP(game).intrChar[i], in);
|
||||
// character movement path (for old saves)
|
||||
if (cmp_ver < kCharSvgVersion_36109) {
|
||||
err = _GP(mls)[CHMLSOFFS + i].ReadFromFile(in, mls_cmp_ver);
|
||||
err = _GP(mls)[CHMLSOFFS + i].ReadFromSavegame(in, mls_cmp_ver);
|
||||
if (!err)
|
||||
return err;
|
||||
}
|
||||
@@ -773,7 +773,7 @@ HSaveError WriteOverlays(Stream *out) {
|
||||
if (over.type < 0)
|
||||
continue;
|
||||
valid_count++;
|
||||
over.WriteToFile(out);
|
||||
over.WriteToSavegame(out);
|
||||
if (!over.IsSpriteReference())
|
||||
serialize_bitmap(over.GetImage(), out);
|
||||
}
|
||||
@@ -792,7 +792,7 @@ HSaveError ReadOverlays(Stream *in, int32_t cmp_ver, const PreservedParams & /*p
|
||||
for (size_t i = 0; i < over_count; ++i) {
|
||||
ScreenOverlay over;
|
||||
bool has_bitmap;
|
||||
over.ReadFromFile(in, has_bitmap, cmp_ver);
|
||||
over.ReadFromSavegame(in, has_bitmap, cmp_ver);
|
||||
if (over.type < 0)
|
||||
continue; // safety abort
|
||||
if (has_bitmap)
|
||||
@@ -989,7 +989,7 @@ HSaveError ReadThisRoom(Stream *in, int32_t cmp_ver, const PreservedParams & /*p
|
||||
return err;
|
||||
const int mls_cmp_ver = cmp_ver > kRoomStatSvgVersion_Initial ? kMoveSvgVersion_350 : kMoveSvgVersion_Initial;
|
||||
for (int i = 0; i < objmls_count; ++i) {
|
||||
err = _GP(mls)[i].ReadFromFile(in, mls_cmp_ver);
|
||||
err = _GP(mls)[i].ReadFromSavegame(in, mls_cmp_ver);
|
||||
if (!err)
|
||||
return err;
|
||||
}
|
||||
@@ -1008,7 +1008,7 @@ HSaveError ReadThisRoom(Stream *in, int32_t cmp_ver, const PreservedParams & /*p
|
||||
HSaveError WriteMoveLists(Stream *out) {
|
||||
out->WriteInt32(static_cast<int32_t>(_GP(mls).size()));
|
||||
for (const auto &movelist : _GP(mls)) {
|
||||
movelist.WriteToFile(out);
|
||||
movelist.WriteToSavegame(out);
|
||||
}
|
||||
return HSaveError::None();
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ HSaveError ReadMoveLists(Stream *in, int32_t cmp_ver, const PreservedParams & /*
|
||||
if (!AssertGameContent(err, movelist_count, _GP(mls).size(), "Move Lists"))
|
||||
return err;
|
||||
for (size_t i = 0; i < movelist_count; ++i) {
|
||||
err = _GP(mls)[i].ReadFromFile(in, cmp_ver);
|
||||
err = _GP(mls)[i].ReadFromSavegame(in, cmp_ver);
|
||||
if (!err)
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
#include "ags/plugins/plugin_engine.h"
|
||||
#include "ags/engine/script/script.h"
|
||||
#include "ags/shared/script/cc_common.h"
|
||||
#include "ags/shared/util/aligned_stream.h"
|
||||
#include "ags/shared/util/string_utils.h"
|
||||
|
||||
namespace AGS3 {
|
||||
@@ -197,10 +196,8 @@ static void restore_game_play(Stream *in, GameDataVersion data_ver, RestoredData
|
||||
}
|
||||
|
||||
static void ReadMoveList_Aligned(Stream *in) {
|
||||
AlignedStream align_s(in, Shared::kAligned_Read);
|
||||
for (int i = 0; i < _GP(game).numcharacters + MAX_ROOM_OBJECTS_v300 + 1; ++i) {
|
||||
_GP(mls)[i].ReadFromFile_Legacy(&align_s);
|
||||
align_s.Reset();
|
||||
_GP(mls)[i].ReadFromSavegame_Legacy(in);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,10 +206,8 @@ static void ReadGameSetupStructBase_Aligned(Stream *in, GameDataVersion data_ver
|
||||
}
|
||||
|
||||
static void ReadCharacterExtras_Aligned(Stream *in) {
|
||||
AlignedStream align_s(in, Shared::kAligned_Read);
|
||||
for (int i = 0; i < _GP(game).numcharacters; ++i) {
|
||||
_GP(charextra)[i].ReadFromSavegame(&align_s, 0);
|
||||
align_s.Reset();
|
||||
_GP(charextra)[i].ReadFromSavegame(in, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,12 +229,10 @@ static void restore_game_more_dynamic_values(Stream *in) {
|
||||
}
|
||||
|
||||
void ReadAnimatedButtons_Aligned(Stream *in, int num_abuts) {
|
||||
AlignedStream align_s(in, Shared::kAligned_Read);
|
||||
for (int i = 0; i < num_abuts; ++i) {
|
||||
AnimatingGUIButton abtn;
|
||||
abtn.ReadFromSavegame(&align_s, 0);
|
||||
abtn.ReadFromSavegame(in, 0);
|
||||
AddButtonAnimation(abtn);
|
||||
align_s.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,15 +307,13 @@ static void restore_game_ambientsounds(Stream *in, RestoredData &r_data) {
|
||||
}
|
||||
|
||||
static void ReadOverlays_Aligned(Stream *in, std::vector<bool> &has_bitmap, size_t num_overs) {
|
||||
AlignedStream align_s(in, Shared::kAligned_Read);
|
||||
has_bitmap.resize(num_overs);
|
||||
// Remember that overlay indexes may be non-sequential
|
||||
auto &overs = get_overlays();
|
||||
for (size_t i = 0; i < num_overs; ++i) {
|
||||
bool has_bm;
|
||||
ScreenOverlay over;
|
||||
over.ReadFromFile(&align_s, has_bm, 0);
|
||||
align_s.Reset();
|
||||
over.ReadFromSavegame(in, has_bm, -1);
|
||||
if (over.type < 0)
|
||||
continue; // safety abort
|
||||
if (overs.size() <= static_cast<uint32_t>(over.type)) {
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "ags/engine/platform/base/ags_platform_driver.h"
|
||||
#include "ags/shared/script/cc_common.h"
|
||||
#include "ags/engine/script/script.h"
|
||||
#include "ags/shared/util/aligned_stream.h"
|
||||
#include "ags/shared/util/stream.h"
|
||||
#include "ags/shared/util/text_stream_reader.h"
|
||||
#include "ags/globals.h"
|
||||
|
||||
Reference in new issue
Block a user