mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 08:17:40 +00:00
SCI: Fix errorString version query
This commit is contained in:
parent
a083710834
commit
cfa1ad6de2
@ -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() : "";
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user