[Scummvm-git-logs] scummvm master -> cfa1ad6de2416693eca11382b4b7379e252dcb8a
sluicebox
noreply at scummvm.org
Wed Nov 8 08:28:29 UTC 2023
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:
cfa1ad6de2 SCI: Fix errorString version query
Commit: cfa1ad6de2416693eca11382b4b7379e252dcb8a
https://github.com/scummvm/scummvm/commit/cfa1ad6de2416693eca11382b4b7379e252dcb8a
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-11-08T01:09:59-07:00
Commit Message:
SCI: Fix errorString version query
Changed paths:
engines/sci/engine/savegame.cpp
engines/sci/engine/state.cpp
engines/sci/engine/state.h
engines/sci/sci.cpp
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 8dd3a859093..3070095fd34 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -1249,21 +1249,9 @@ bool gamestate_save(EngineState *s, Common::WriteStream *fh, const Common::Strin
// If the game version is empty, we are probably saving from the GMM, so read it
// from the version global and then the VERSION file
- if (ver == "") {
- // The version global was originally 28 but then became 27.
- // When it was 28, 27 was a volume level, so differentiate by type.
- reg_t versionRef = s->variables[VAR_GLOBAL][kGlobalVarVersionNew];
- if (versionRef.isNumber()) {
- versionRef = s->variables[VAR_GLOBAL][kGlobalVarVersionOld];
- }
-#ifdef ENABLE_SCI32
- // LSL7 and Phant2 store the version string as an object instead of a reference
- if (s->_segMan->isObject(versionRef)) {
- versionRef = readSelector(s->_segMan, versionRef, SELECTOR(data));
- }
-#endif
- ver = s->_segMan->getString(versionRef);
- if (ver == "") {
+ if (ver.empty()) {
+ ver = s->getGameVersionFromGlobal();
+ if (ver.empty()) {
Common::ScopedPtr<Common::SeekableReadStream> versionFile(SearchMan.createReadStreamForMember("VERSION"));
ver = versionFile ? versionFile->readLine() : "";
}
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index d4810ea2081..b0bd05a23d6 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -453,4 +453,23 @@ bool EngineState::callInStack(const reg_t object, const Selector selector) const
return false;
}
+Common::String EngineState::getGameVersionFromGlobal() const {
+ // The version global was originally 28 but then became 27.
+ // When it was 28, 27 was a volume level, so differentiate by type.
+ reg_t versionRef = variables[VAR_GLOBAL][kGlobalVarVersionNew];
+ if (versionRef.isNumber()) {
+ versionRef = variables[VAR_GLOBAL][kGlobalVarVersionOld];
+ }
+#ifdef ENABLE_SCI32
+ // LSL7 and Phant2 store the version string as an object instead of a reference
+ if (_segMan->isObject(versionRef)) {
+ versionRef = readSelector(_segMan, versionRef, SELECTOR(data));
+ }
+#endif
+ if (versionRef.isPointer()) {
+ return _segMan->getString(versionRef);
+ }
+ return Common::String();
+}
+
} // End of namespace Sci
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index fba3c2d857e..5233ea1a93a 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -98,13 +98,11 @@ struct SciCallOrigin {
};
struct EngineState : public Common::Serializable {
-public:
EngineState(SegManager *segMan);
~EngineState() override;
void saveLoadWithSerializer(Common::Serializer &ser) override;
-public:
SegManager *_segMan; /**< The segment manager */
/* Non-VM information */
@@ -144,7 +142,6 @@ public:
Common::Point _cursorWorkaroundPoint;
Common::Rect _cursorWorkaroundRect;
-public:
/* VM Information */
Common::List<ExecStack> _executionStack; /**< The execution stack */
@@ -216,6 +213,13 @@ public:
* Determines whether the given object method is in the current stack.
*/
bool callInStack(const reg_t object, const Selector selector) const;
+
+ /**
+ * Returns the game's version string from its global variable.
+ * Most games initialize this to a string embedded in a script resource,
+ * or the contents of the VERSION file in the game directory.
+ */
+ Common::String getGameVersionFromGlobal() const;
};
} // End of namespace Sci
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 118721d9d5d..c780813312b 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -737,8 +737,10 @@ void SciEngine::errorString(const char *buf_input, char *buf_output, int buf_out
const ExecStack *call = &(s->_executionStack.back());
// Note: if we are too early in the initialization process, this may not be populated yet.
- const reg_t regVersion = s->variables[VAR_GLOBAL][kGlobalVarVersionNew];
- const Common::String version = (regVersion.getOffset() > 0) ? ", Version: " + s->_segMan->getString(regVersion) : "";
+ Common::String version = s->getGameVersionFromGlobal();
+ if (!version.empty()) {
+ version.insertString("Version: ", 0);
+ }
const char *objname = s->_segMan->getObjectName(call->sendp);
Common::String callType;
More information about the Scummvm-git-logs
mailing list