[Scummvm-git-logs] scummvm master -> 990ab7fe2dfdba871951ae5c69309b009bebce6d
criezy
criezy at scummvm.org
Fri Apr 16 00:15:07 UTC 2021
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
44c0f0d115 AGS: Improve print of arguments when dumping script instruction
c0d10b9609 AGS: Handle the SAVE_FOLDER_PREFIX in stdio_compat
bef8781be5 AGS: Handle game datadir and savegame dir prefixes in File
5fde2a493c AGS: Fix deleting files
bb85f7aad9 AGS: Do not attempt to rename savegames after deleting one
990ab7fe2d AGS: Do not allow to load and save in non-blocking events
Commit: 44c0f0d1156923592242019fbb1a058588f8276f
https://github.com/scummvm/scummvm/commit/44c0f0d1156923592242019fbb1a058588f8276f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-16T01:14:45+01:00
Commit Message:
AGS: Improve print of arguments when dumping script instruction
Changed paths:
engines/ags/engine/script/cc_instance.cpp
engines/ags/engine/script/systemimports.cpp
engines/ags/engine/script/systemimports.h
diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index 62be478e6a..78ba82f0f9 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -1288,11 +1288,50 @@ void ccInstance::DumpInstruction(const ScriptOperation &op) {
if (i > 0) {
msg += ',';
}
+ RuntimeScriptValue arg = op.Args[i];
if (cmd_info.ArgIsReg[i]) {
- msg += Common::String::format(" %s", regnames[op.Args[i].IValue]);
+ msg += Common::String::format(" %s", regnames[arg.IValue]);
} else {
- // FIXME: check type and write appropriate values
- msg += Common::String::format(" %lld", (long long)op.Args[i].GetPtrWithOffset());
+ if (arg.Type == kScValStackPtr || arg.Type == kScValGlobalVar)
+ arg = *arg.RValue;
+ switch(arg.Type) {
+ case kScValInteger:
+ case kScValPluginArg:
+ msg += Common::String::format(" %d", arg.IValue);
+ break;
+ case kScValFloat:
+ msg += Common::String::format(" %f", arg.FValue);
+ break;
+ case kScValStringLiteral:
+ msg += Common::String::format(" \"%s\"", arg.Ptr);
+ break;
+ case kScValStackPtr:
+ case kScValGlobalVar:
+ msg += Common::String::format(" %p", (void*)arg.RValue);
+ break;
+ case kScValData:
+ case kScValCodePtr:
+ msg += Common::String::format(" %p", (void*)arg.GetPtrWithOffset());
+ break;
+ case kScValStaticArray:
+ case kScValStaticObject:
+ case kScValDynamicObject:
+ case kScValStaticFunction:
+ case kScValObjectFunction:
+ case kScValPluginFunction:
+ case kScValPluginObject:
+ {
+ String name = _GP(simp).findName(arg);
+ if (!name.IsEmpty())
+ msg += Common::String::format(" &%s", name.GetCStr());
+ else
+ msg += Common::String::format(" %p", (void*)arg.GetPtrWithOffset());
+ }
+ break;
+ case kScValUndefined:
+ msg += " undefined";
+ break;
+ }
}
}
msg += '\n';
diff --git a/engines/ags/engine/script/systemimports.cpp b/engines/ags/engine/script/systemimports.cpp
index 165d138114..b76e72067c 100644
--- a/engines/ags/engine/script/systemimports.cpp
+++ b/engines/ags/engine/script/systemimports.cpp
@@ -103,6 +103,14 @@ int SystemImports::get_index_of(const String &name) {
return -1;
}
+String SystemImports::findName(const RuntimeScriptValue &value) {
+ for (size_t i = 0; i < imports.size(); ++i) {
+ if (imports[i].Value == value)
+ return imports[i].Name;
+ }
+ return String();
+}
+
void SystemImports::RemoveScriptExports(ccInstance *inst) {
if (!inst) {
return;
diff --git a/engines/ags/engine/script/systemimports.h b/engines/ags/engine/script/systemimports.h
index f79fd65bff..5472b69366 100644
--- a/engines/ags/engine/script/systemimports.h
+++ b/engines/ags/engine/script/systemimports.h
@@ -59,6 +59,7 @@ public:
const ScriptImport *getByName(const String &name);
int get_index_of(const String &name);
const ScriptImport *getByIndex(int index);
+ String findName(const RuntimeScriptValue &value);
void RemoveScriptExports(ccInstance *inst);
void clear();
};
Commit: c0d10b9609bfd256c3b3cd8caf12ac2f95577dd6
https://github.com/scummvm/scummvm/commit/c0d10b9609bfd256c3b3cd8caf12ac2f95577dd6
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-16T01:14:46+01:00
Commit Message:
AGS: Handle the SAVE_FOLDER_PREFIX in stdio_compat
Changed paths:
engines/ags/shared/util/stdio_compat.cpp
diff --git a/engines/ags/shared/util/stdio_compat.cpp b/engines/ags/shared/util/stdio_compat.cpp
index f6b75a497a..5c918203bc 100644
--- a/engines/ags/shared/util/stdio_compat.cpp
+++ b/engines/ags/shared/util/stdio_compat.cpp
@@ -22,9 +22,12 @@
#include "ags/shared/util/stdio_compat.h"
#include "ags/shared/core/platform.h"
+#include "ags/shared/util/directory.h"
#include "common/config-manager.h"
+#include "common/system.h"
#include "common/file.h"
#include "common/fs.h"
+#include "common/savefile.h"
#include "common/textconsole.h"
namespace AGS3 {
@@ -49,19 +52,22 @@ file_off_t ags_ftell(Common::Stream *stream) {
}
Common::FSNode getFSNode(const char *path) {
- Common::FSNode node(path);
- if (node.isReadable())
- return node;
-
- node = Common::FSNode(ConfMan.get("path"));
+ Common::FSNode node;
Common::String filePath(path);
-
- // If it's the root game folder, return the node for it
if (filePath.empty() || filePath == "." || filePath == "./")
- return node;
-
- if (filePath.hasPrefix("./"))
- filePath = Common::String(filePath.c_str() + 2);
+ return Common::FSNode(ConfMan.get("path"));
+ else if (filePath.hasPrefix("./")) {
+ filePath = filePath.substr(2);
+ node = Common::FSNode(ConfMan.get("path"));
+ } else if (filePath.hasPrefixIgnoreCase(AGS::Shared::SAVE_FOLDER_PREFIX)) {
+ filePath = filePath.substr(strlen(AGS::Shared::SAVE_FOLDER_PREFIX));
+ node = Common::FSNode(ConfMan.get("savepath"));
+ } else {
+ node = Common::FSNode(filePath);
+ if (node.isReadable())
+ return node;
+ node = Common::FSNode(ConfMan.get("path"));
+ }
// Use FSDirectory for case-insensitive search
Common::SharedPtr<Common::FSDirectory> dir(new Common::FSDirectory(node));
Commit: bef8781be5c5e9d90a2bd78fcd93f0303a3cc1aa
https://github.com/scummvm/scummvm/commit/bef8781be5c5e9d90a2bd78fcd93f0303a3cc1aa
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-16T01:14:46+01:00
Commit Message:
AGS: Handle game datadir and savegame dir prefixes in File
This fixes in particular the File_Exists check for savegames.
It was always returning false, which resulted in savegames
being overwritten in Quest for Glory II (bug #12390).
Changed paths:
engines/ags/shared/util/file.cpp
diff --git a/engines/ags/shared/util/file.cpp b/engines/ags/shared/util/file.cpp
index 8324e363de..319f192899 100644
--- a/engines/ags/shared/util/file.cpp
+++ b/engines/ags/shared/util/file.cpp
@@ -25,6 +25,7 @@
#include "ags/shared/util/filestream.h"
#include "ags/shared/util/bufferedstream.h"
#include "ags/shared/util/file.h"
+#include "ags/shared/util/directory.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -34,28 +35,40 @@ namespace AGS {
namespace Shared {
soff_t File::GetFileSize(const String &filename) {
+ if (filename.IsEmpty())
+ return 0;
return ags_file_size(filename.GetCStr());
}
bool File::TestReadFile(const String &filename) {
- return Common::File::exists(filename.GetNullableCStr());
+ if (filename.IsEmpty())
+ return false;
+ return ags_file_exists(filename.GetNullableCStr());
}
bool File::TestWriteFile(const String &filename) {
+ if (filename.IsEmpty())
+ return false;
return TestCreateFile(filename);
}
bool File::TestCreateFile(const String &filename) {
+ if (filename.IsEmpty())
+ return false;
Common::DumpFile df;
-
- bool result = df.open(filename.GetNullableCStr());
+ bool result = df.open(getFSNode(filename.GetNullableCStr()));
df.close();
-
return result;
}
bool File::DeleteFile(const String &filename) {
- return g_system->getSavefileManager()->removeSavefile(filename.GetNullableCStr());
+ // Only allow deleting files in the savegame folder
+ if (filename.CompareLeftNoCase(SAVE_FOLDER_PREFIX) != 0) {
+ warning("Cannot delete file %s. Only files in the savegame directory can be deleted", filename.GetCStr());
+ return false;
+ }
+ Common::String file(filename.GetCStr() + strlen(SAVE_FOLDER_PREFIX));
+ return g_system->getSavefileManager()->removeSavefile(file);
}
bool File::GetFileModesFromCMode(const String &cmode, FileOpenMode &open_mode, FileWorkMode &work_mode) {
Commit: 5fde2a493c9584aeb1d91821a8c9bace5a4cd773
https://github.com/scummvm/scummvm/commit/5fde2a493c9584aeb1d91821a8c9bace5a4cd773
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-16T01:14:46+01:00
Commit Message:
AGS: Fix deleting files
The code was using ::remove() to remove files, and this does
not handle the "/saves/" prefix. Now it uses File::DeleteFile,
whose implementation was already fixed in the previous commit.
Also it only allows removing files from the savegame directory.
Since this is also the only directory where we allow creating
files, this is consistent and safer.
Changed paths:
engines/ags/engine/ac/file.cpp
engines/ags/engine/ac/global_game.cpp
diff --git a/engines/ags/engine/ac/file.cpp b/engines/ags/engine/ac/file.cpp
index 4ec91d5efe..a0abcf15a7 100644
--- a/engines/ags/engine/ac/file.cpp
+++ b/engines/ags/engine/ac/file.cpp
@@ -75,10 +75,10 @@ int File_Delete(const char *fnmm) {
if (!ResolveScriptPath(fnmm, false, rp))
return 0;
- if (::remove(rp.FullPath) == 0)
+ if (File::DeleteFile(rp.FullPath))
return 1;
if (_G(errnum) == AL_ENOENT && !rp.AltPath.IsEmpty() && rp.AltPath.Compare(rp.FullPath) != 0)
- return ::remove(rp.AltPath) == 0 ? 1 : 0;
+ return File::DeleteFile(rp.AltPath) ? 1 : 0;
return 0;
}
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index 4fbe0374d8..769653a5ce 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -109,7 +109,7 @@ void RestoreGameSlot(int slnum) {
void DeleteSaveSlot(int slnum) {
String nametouse;
nametouse = get_save_game_path(slnum);
- ::remove(nametouse);
+ Shared::File::DeleteFile(nametouse);
if ((slnum >= 1) && (slnum <= MAXSAVEGAMES)) {
String thisname;
for (int i = MAXSAVEGAMES; i > slnum; i--) {
Commit: bb85f7aad966d620787856e66e09858ce0597b8a
https://github.com/scummvm/scummvm/commit/bb85f7aad966d620787856e66e09858ce0597b8a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-16T01:14:46+01:00
Commit Message:
AGS: Do not attempt to rename savegames after deleting one
The original AGS engine, after removing a savegames, renames
the savegames with the highest slot to fill the gap. The code
does not work in ScummVM however, and furthermore it might
not be a good idea to do it. So in ScummVM we no longer try
to do it. A comment has been added to indicate why it doesn't
work and how it can be fixed, as well as to explain why it
might not be a good idea to do it in ScummVM.
Changed paths:
engines/ags/engine/ac/global_game.cpp
diff --git a/engines/ags/engine/ac/global_game.cpp b/engines/ags/engine/ac/global_game.cpp
index 769653a5ce..44c22dba85 100644
--- a/engines/ags/engine/ac/global_game.cpp
+++ b/engines/ags/engine/ac/global_game.cpp
@@ -110,6 +110,18 @@ void DeleteSaveSlot(int slnum) {
String nametouse;
nametouse = get_save_game_path(slnum);
Shared::File::DeleteFile(nametouse);
+ // The code below renames the highest save game to fill in the gap
+ // This does not work (because the system rename() function does not
+ // handle our "/saves/" prefix). We could remove it here and use
+ // g_system->getSavefileManager()->renameSavefile. But it might
+ // actually be better to not fill the gap. The original AGS engine
+ // sorts savegame by date, but as we don't have access to the date,
+ // we save them by slot. So moving the highest slot to the gap may
+ // not be a good idea. An alternative would be to shift by one all
+ // the savegames after the removed one.
+ // One aspect to keep in mind is that MAXSAVEGAMES is 50, but we
+ // allow slot up to 099. So we have some margin.
+#ifndef AGS_PLATFORM_SCUMMVM
if ((slnum >= 1) && (slnum <= MAXSAVEGAMES)) {
String thisname;
for (int i = MAXSAVEGAMES; i > slnum; i--) {
@@ -122,6 +134,7 @@ void DeleteSaveSlot(int slnum) {
}
}
+#endif
}
void PauseGame() {
Commit: 990ab7fe2dfdba871951ae5c69309b009bebce6d
https://github.com/scummvm/scummvm/commit/990ab7fe2dfdba871951ae5c69309b009bebce6d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-16T01:14:46+01:00
Commit Message:
AGS: Do not allow to load and save in non-blocking events
The AGS engine does not supports this and has a check when
saving that errors out when trying to save during a non-blocking
event (see can_run_delayed_command() call at the start of
save_game()). There is no such check when loading, but it
causes a crash. This can easily be reproduced in QfGII.
Changed paths:
engines/ags/ags.cpp
diff --git a/engines/ags/ags.cpp b/engines/ags/ags.cpp
index 6d4fc1a63b..a9c887b132 100644
--- a/engines/ags/ags.cpp
+++ b/engines/ags/ags.cpp
@@ -214,12 +214,12 @@ void AGSEngine::setGraphicsMode(size_t w, size_t h) {
bool AGSEngine::canLoadGameStateCurrently() {
return !_GP(thisroom).Options.SaveLoadDisabled &&
- !_G(inside_script) && !_GP(play).fast_forward;
+ !_G(inside_script) && !_GP(play).fast_forward && !_G(no_blocking_functions);
}
bool AGSEngine::canSaveGameStateCurrently() {
return !_GP(thisroom).Options.SaveLoadDisabled &&
- !_G(inside_script) && !_GP(play).fast_forward;
+ !_G(inside_script) && !_GP(play).fast_forward && !_G(no_blocking_functions);
}
Common::Error AGSEngine::loadGameState(int slot) {
More information about the Scummvm-git-logs
mailing list