[Scummvm-git-logs] scummvm master -> b36e2a8ba8b0502bcca38f3b91eb02314cfdb7be
aquadran
aquadran at gmail.com
Sat Mar 13 14:06:05 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b36e2a8ba8 ICB: Cleanup saving code a bit
Commit: b36e2a8ba8b0502bcca38f3b91eb02314cfdb7be
https://github.com/scummvm/scummvm/commit/b36e2a8ba8b0502bcca38f3b91eb02314cfdb7be
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2021-03-13T15:06:00+01:00
Commit Message:
ICB: Cleanup saving code a bit
Changed paths:
engines/icb/mission.cpp
engines/icb/remora.cpp
engines/icb/set_pc.cpp
diff --git a/engines/icb/mission.cpp b/engines/icb/mission.cpp
index 255edd2aaf..0fd75bf33f 100644
--- a/engines/icb/mission.cpp
+++ b/engines/icb/mission.cpp
@@ -384,10 +384,6 @@ uint32 _mission::Game_cycle() {
session->Process_conveyors(); // conveyor belts
-#if defined(DEBUG_AUTOSAVE)
- RAM_save_and_restore();
-#endif
-
// Update global timer by a tick
g_globalScriptVariables.SetVariable("missionelapsedtime", g_globalScriptVariables.GetVariable("missionelapsedtime") + 1);
@@ -615,35 +611,12 @@ void _mission::Save_game_position(const char *filename, const char *slot_label,
}
}
- error("TODO: Fix savegame-path");
- /*
- #ifdef _WIN32
- mkdir("saves");
- #else
- mkdir("saves", 0755);
- #endif
- */
-
// first save the index file which contains the session name and mission name that we're currently running - and hence want to
// restore to later
Common::WriteStream *stream = openDiskWriteStream(filename); // attempt to open the file for writing
-
-#if defined(DEBUG_AUTOSAVE)
-
- // NULL is only an error if the filename is something other than the name of
- // the debug autosave file.
- if (strcmp(filename, AUTOSAVE_FILENAME) != 0) {
- if (fh == NULL)
- Fatal_error("Save_game_position cannot *OPEN* [%s]", (const char *)filename);
- }
-
-#else
-
if (stream == NULL)
Fatal_error("Save_game_position cannot *OPEN* [%s]", (const char *)filename);
-#endif
-
// specific stuff for pc save game menu
stream->write(slot_label, MAX_LABEL_LENGTH);
stream->writeSint32LE(timeplayed);
@@ -653,11 +626,11 @@ void _mission::Save_game_position(const char *filename, const char *slot_label,
avalue = strlen(Fetch_tiny_mission_name()) + 1;
stream->writeSint32LE(avalue);
- stream->write((const char *)Fetch_tiny_mission_name(), strlen(Fetch_tiny_mission_name()) + 1); // TODO: Refactor to string
+ stream->write((const char *)Fetch_tiny_mission_name(), avalue);
avalue = strlen(Fetch_tiny_session_name()) + 1;
stream->writeSint32LE(avalue);
- stream->write((const char *)Fetch_tiny_session_name(), strlen(Fetch_tiny_session_name()) + 1); // TODO: Refactor to string
+ stream->write((const char *)Fetch_tiny_session_name(), avalue);
// now write the globals out
atinyvalue = (uint8)g_globalScriptVariables.GetNoItems();
@@ -680,7 +653,7 @@ void _mission::Save_game_position(const char *filename, const char *slot_label,
// write length of icon name then the string
avalue = strlen(iconnames[j]) + 1;
stream->writeSint32LE(avalue);
- stream->write((const void *)iconnames[j], avalue); // TODO: Refactor to string?
+ stream->write((const void *)iconnames[j], avalue);
// write the hash value
avalue = (uint32)iconHashes[j];
@@ -707,7 +680,7 @@ void _mission::Save_game_position(const char *filename, const char *slot_label,
avalue = strlen(micro_sessions[j].session__name) + 1;
stream->writeSint32LE(avalue);
Tdebug("save_restore.txt", " name len %d", avalue);
- stream->write((const void *)micro_sessions[j].session__name, strlen(micro_sessions[j].session__name) + 1); // TODO: Refactor to string?
+ stream->write((const void *)micro_sessions[j].session__name, avalue);
for (l = 0; l < MAX_fvars; l++) {
fval = micro_sessions[j].fvars[l];
@@ -815,7 +788,7 @@ void _mission::Save_game_position(const char *filename, const char *slot_label,
stream->writeByte(atinyvalue);
// save name
- stream->write(session->manual_camera_name, ENGINE_STRING_LEN); // TODO: Refactor to string?
+ stream->write(session->manual_camera_name, ENGINE_STRING_LEN);
// cam number
stream->writeUint32LE(session->cur_camera_number);
} else {
@@ -836,16 +809,6 @@ void _mission::Save_game_position(const char *filename, const char *slot_label,
// Save the Remora's locations-visited information.
g_oRemora->Save(stream);
- // Need to guard against NULL pointer in use by debug autosave.
-#if 0 // TODO: Do we actually need to do this? We don't have a max size...
- if (stream) {
- fseek(fh, 0, SEEK_END); //get size of file
- if (ftell(fh) > SAVE_GAME_MAX_SIZE)
- Message_box("Warning : save game is greater than %d bytes (is %d bytes)\nthis will not work on the PSX please tell Jake",
- SAVE_GAME_MAX_SIZE, ftell(fh));
- }
-#endif
-
// save gfx init info for initing a set...
MSS.SaveGFXInfo(stream);
SavePlatformSpecific(stream);
diff --git a/engines/icb/remora.cpp b/engines/icb/remora.cpp
index 0a8391c579..0048f80bae 100644
--- a/engines/icb/remora.cpp
+++ b/engines/icb/remora.cpp
@@ -661,7 +661,7 @@ void _remora::AddFloorRange(uint32 nLower, uint32 nUpper) {
void _remora::Save(Common::WriteStream *stream) const {
// Save any outstanding email. Just write the whole string since it is small and there's only one.
- stream->write(m_pcEmailID, sizeof(char) * (REMORA_MAXLEN_EMAIL_ID_STRING + 1)); // TODO: Refactor to string.
+ stream->write(m_pcEmailID, sizeof(char) * (REMORA_MAXLEN_EMAIL_ID_STRING + 1));
}
void _remora::Restore(Common::SeekableReadStream *stream) {
diff --git a/engines/icb/set_pc.cpp b/engines/icb/set_pc.cpp
index 6664ab7840..8ac3a9cbd2 100644
--- a/engines/icb/set_pc.cpp
+++ b/engines/icb/set_pc.cpp
@@ -1827,9 +1827,10 @@ void _set::HackMakeCamera() {
// read in init values for set from file
void _set::LoadGFXInfo(Common::SeekableReadStream *stream) {
- // TODO: Add a proper stream-read of the rects.
- stream->read(&surface_manager->BorderRect(), sizeof(LRECT)); // FIXME endian and alignment
- // FIXME: Plug a deserializer into surface-manager directly instead of exposing these.
+ surface_manager->BorderRect().left = stream->readSint32LE();
+ surface_manager->BorderRect().top = stream->readSint32LE();
+ surface_manager->BorderRect().right = stream->readSint32LE();
+ surface_manager->BorderRect().bottom = stream->readSint32LE();
surface_manager->BorderRed() = stream->readByte();
surface_manager->BorderGreen() = stream->readByte();
surface_manager->BorderBlue() = stream->readByte();
@@ -1847,9 +1848,10 @@ void _set::LoadGFXInfo(Common::SeekableReadStream *stream) {
// write out current init values1 to file
void _set::SaveGFXInfo(Common::WriteStream *stream) {
- // TODO: Refactor.
- // FIXME HACK TODO: Don't write rects this way:
- stream->write(&surface_manager->BorderRect(), sizeof(LRECT));
+ stream->writeSint32LE(surface_manager->BorderRect().left);
+ stream->writeSint32LE(surface_manager->BorderRect().top);
+ stream->writeSint32LE(surface_manager->BorderRect().right);
+ stream->writeSint32LE(surface_manager->BorderRect().bottom);
stream->writeByte(surface_manager->BorderRed());
stream->writeByte(surface_manager->BorderGreen());
stream->writeByte(surface_manager->BorderBlue());
More information about the Scummvm-git-logs
mailing list