[Scummvm-git-logs] scummvm master -> 5104b23bad0b27aadeb54ceb66b38dee4e8a8c1b
criezy
criezy at scummvm.org
Wed Apr 14 22:55:10 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:
02c7775465 AGS: More cleaning to ListBox_FillSaveGameList
31871e4730 AGS: Minor cleaning to match upstream code
4dfc191981 AGS: Fix assert when trying to save screenshots
b1683699bd AGS: Fix script dump
ba15b9c84b AGS: Add debug flag to enable script dump
5104b23bad AGS: Add debug console command to enable or disable script dump
Commit: 02c7775465a52b6b41fcba573db29a77ab4d861d
https://github.com/scummvm/scummvm/commit/02c7775465a52b6b41fcba573db29a77ab4d861d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-14T23:54:48+01:00
Commit Message:
AGS: More cleaning to ListBox_FillSaveGameList
The code is now closer to the code in the original. Also there
is no need to try to sort the list twice.
Changed paths:
engines/ags/engine/ac/listbox.cpp
diff --git a/engines/ags/engine/ac/listbox.cpp b/engines/ags/engine/ac/listbox.cpp
index e83b6f18e2..81e7774a2e 100644
--- a/engines/ags/engine/ac/listbox.cpp
+++ b/engines/ags/engine/ac/listbox.cpp
@@ -125,11 +125,6 @@ int ListBox_GetSaveGameSlots(GUIListBox *listbox, int index) {
}
int ListBox_FillSaveGameList(GUIListBox *listbox) {
- listbox->Clear();
-
- int numsaves = 0;
- long filedates[MAXSAVEGAMES];
-
SaveStateList saveList = ::AGS::g_vm->listSaves();
// The original AGS sorts the list from most recent to oldest.
@@ -139,6 +134,9 @@ int ListBox_FillSaveGameList(GUIListBox *listbox) {
Common::sort(saveList.begin(), saveList.end(),
[](const SaveStateDescriptor &x, const SaveStateDescriptor &y) {return x.getSaveSlot() > y.getSaveSlot(); });
+ listbox->Clear();
+
+ int numsaves = 0;
for (uint idx = 0; idx < saveList.size(); ++idx) {
if (numsaves >= MAXSAVEGAMES)
break;
@@ -148,30 +146,11 @@ int ListBox_FillSaveGameList(GUIListBox *listbox) {
listbox->AddItem(desc);
listbox->SavedGameIndex[numsaves] = saveGameSlot;
- filedates[numsaves] = 0;
numsaves++;
}
- int nn;
- for (nn = 0; nn < numsaves - 1; nn++) {
- for (int kk = 0; kk < numsaves - 1; kk++) { // Date order the games
-
- if (filedates[kk] < filedates[kk + 1]) { // swap them round
- String tempptr = listbox->Items[kk];
- listbox->Items[kk] = listbox->Items[kk + 1];
- listbox->Items[kk + 1] = tempptr;
- int numtem = listbox->SavedGameIndex[kk];
- listbox->SavedGameIndex[kk] = listbox->SavedGameIndex[kk + 1];
- listbox->SavedGameIndex[kk + 1] = numtem;
- long numted = filedates[kk];
- filedates[kk] = filedates[kk + 1];
- filedates[kk + 1] = numted;
- }
- }
- }
-
// update the global savegameindex[] array for backward compatibilty
- for (nn = 0; nn < numsaves; nn++) {
+ for (int nn = 0; nn < numsaves; nn++) {
_GP(play).filenumbers[nn] = listbox->SavedGameIndex[nn];
}
Commit: 31871e47306e2ce62310cea8dcdc1a2032a40b9e
https://github.com/scummvm/scummvm/commit/31871e47306e2ce62310cea8dcdc1a2032a40b9e
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-14T23:54:48+01:00
Commit Message:
AGS: Minor cleaning to match upstream code
Changed paths:
engines/ags/engine/ac/dialog.cpp
diff --git a/engines/ags/engine/ac/dialog.cpp b/engines/ags/engine/ac/dialog.cpp
index 6ad613395e..7dc2367c1e 100644
--- a/engines/ags/engine/ac/dialog.cpp
+++ b/engines/ags/engine/ac/dialog.cpp
@@ -562,16 +562,15 @@ void DialogOptions::Show() {
}
} else {
//dlgyp=(_GP(play).viewport.GetHeight()-numdisp*txthit)-1;
- const Rect &uiView = _GP(play).GetUIViewport();
- areawid = uiView.GetWidth() - 5;
+ areawid = ui_view.GetWidth() - 5;
padding = TEXTWINDOW_PADDING_DEFAULT;
GET_OPTIONS_HEIGHT
- dlgyp = uiView.GetHeight() - needheight;
+ dlgyp = ui_view.GetHeight() - needheight;
dirtyx = 0;
dirtyy = dlgyp - 1;
- dirtywidth = uiView.GetWidth();
- dirtyheight = uiView.GetHeight() - dirtyy;
+ dirtywidth = ui_view.GetWidth();
+ dirtyheight = ui_view.GetHeight() - dirtyy;
dialog_abs_x = 0;
}
if (!is_textwindow)
Commit: 4dfc191981fe439cdfd066597734ced6fb22b590
https://github.com/scummvm/scummvm/commit/4dfc191981fe439cdfd066597734ced6fb22b590
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-14T23:54:48+01:00
Commit Message:
AGS: Fix assert when trying to save screenshots
The SaveFileManager triggers an assert when passed a path and not
just a file name. And we were passing "/saves/scrshotname.bmp" to
it. Now the path is stripped and we also add the game target as
prefix to the filename.
Changed paths:
engines/ags/shared/gfx/allegrobitmap.cpp
diff --git a/engines/ags/shared/gfx/allegrobitmap.cpp b/engines/ags/shared/gfx/allegrobitmap.cpp
index 141c51e89b..fd62d90003 100644
--- a/engines/ags/shared/gfx/allegrobitmap.cpp
+++ b/engines/ags/shared/gfx/allegrobitmap.cpp
@@ -25,6 +25,7 @@
#include "ags/lib/aastr-0.1.1/aastr.h"
#include "common/savefile.h"
#include "common/system.h"
+#include "common/config-manager.h"
namespace AGS3 {
@@ -129,7 +130,14 @@ bool Bitmap::SaveToFile(Common::WriteStream &out, const void *palette) {
}
bool Bitmap::SaveToFile(const char *filename, const void *palette) {
- Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(filename, false);
+ // Only keeps the file name and add the game target as prefix.
+ Common::String name = filename;
+ size_t lastSlash = name.findLastOf('/');
+ if (lastSlash != Common::String::npos)
+ name = name.substr(lastSlash + 1);
+ name = ConfMan.getActiveDomainName() + "-" + name;
+
+ Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(name, false);
assert(out);
bool result = SaveToFile(*out, palette);
out->finalize();
Commit: b1683699bd213bb2ce1ce7b240523091c4786712
https://github.com/scummvm/scummvm/commit/b1683699bd213bb2ce1ce7b240523091c4786712
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-14T23:54:48+01:00
Commit Message:
AGS: Fix script dump
The code for dumping script was not working. One issue is that it
was opening and closing the file for each line, which was very
slow. Another issue is that we do not support opening in rw mode,
so it was open in write mode only and only the last line was
available in the file. The code switches to writing the file using
Common::DumpFile and keeps the file open until we close the engine.
Changed paths:
engines/ags/engine/script/cc_instance.cpp
engines/ags/globals.cpp
engines/ags/globals.h
diff --git a/engines/ags/engine/script/cc_instance.cpp b/engines/ags/engine/script/cc_instance.cpp
index eb0a3b8d30..776525cb92 100644
--- a/engines/ags/engine/script/cc_instance.cpp
+++ b/engines/ags/engine/script/cc_instance.cpp
@@ -1270,27 +1270,34 @@ void ccInstance::DumpInstruction(const ScriptOperation &op) {
return;
}
- Stream *data_s = ci_fopen("script.log", kFile_Create, kFile_Write);
- TextStreamWriter writer(data_s);
- writer.WriteFormat("Line %3d, IP:%8d (SP:%p) ", line_num, pc, registers[SREG_SP].RValue);
+ // The original opens and close the script.log file for each call, which
+ // is very slow, and also doesn't work in ScummVM (as the file is open
+ // in write only mode, which overwrites the previous content, so we only
+ // get the last line). So we use a Common::DumpFile that we keep open
+ // instead.
+ if (_G(scriptDumpFile) == nullptr) {
+ _G(scriptDumpFile) = new Common::DumpFile();
+ _G(scriptDumpFile)->open("script.log");
+ }
+ Common::String msg = Common::String::format("Line %3d, IP:%8d (SP:%p) ", line_num, pc, (void*)registers[SREG_SP].RValue);
const ScriptCommandInfo &cmd_info = sccmd_info[op.Instruction.Code];
- writer.WriteString(cmd_info.CmdName);
+ msg += cmd_info.CmdName;
for (int i = 0; i < cmd_info.ArgCount; ++i) {
if (i > 0) {
- writer.WriteChar(',');
+ msg += ',';
}
if (cmd_info.ArgIsReg[i]) {
- writer.WriteFormat(" %s", regnames[op.Args[i].IValue]);
+ msg += Common::String::format(" %s", regnames[op.Args[i].IValue]);
} else {
// MACPORT FIX 9/6/5: changed %d to %ld
// FIXME: check type and write appropriate values
- writer.WriteFormat(" %ld", op.Args[i].GetPtrWithOffset());
+ msg += Common::String::format(" %ld", (long)op.Args[i].GetPtrWithOffset());
}
}
- writer.WriteLineBreak();
- // the writer will delete data stream internally
+ msg += '\n';
+ _G(scriptDumpFile)->writeString(msg);
}
bool ccInstance::IsBeingRun() const {
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index 554d66aa2d..2757fdf5e2 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -92,6 +92,7 @@
#include "ags/engine/script/systemimports.h"
#include "ags/lib/std/limits.h"
#include "ags/plugins/pluginobjectreader.h"
+#include "common/file.h"
namespace AGS3 {
@@ -351,6 +352,7 @@ Globals::~Globals() {
// cc_instance.cpp globals
delete _GlobalReturnValue;
+ delete _scriptDumpFile;
// cc_serializer.cpp globals
delete _ccUnserializer;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 926d29288b..4aa7a7c631 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -42,6 +42,10 @@
#include "ags/lib/allegro/aintern.h"
#include "common/events.h"
+namespace Common {
+class DumpFile;
+}
+
namespace AGS3 {
#define MAXCURSORS 20
@@ -321,6 +325,7 @@ public:
// exported functions return value as a RuntimeScriptValue object;
// Of 2012-12-20: now used only for plugin exports
RuntimeScriptValue *_GlobalReturnValue;
+ Common::DumpFile *_scriptDumpFile = nullptr;
/**@}*/
Commit: ba15b9c84bc7c8068959c0a79bbbcb7ab6c53c1d
https://github.com/scummvm/scummvm/commit/ba15b9c84bc7c8068959c0a79bbbcb7ab6c53c1d
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-14T23:54:48+01:00
Commit Message:
AGS: Add debug flag to enable script dump
Changed paths:
engines/ags/ags.cpp
engines/ags/ags.h
diff --git a/engines/ags/ags.cpp b/engines/ags/ags.cpp
index 2ffc42109b..6d4fc1a63b 100644
--- a/engines/ags/ags.cpp
+++ b/engines/ags/ags.cpp
@@ -59,6 +59,7 @@
#include "ags/engine/ac/route_finder.h"
#include "ags/shared/core/assetmanager.h"
#include "ags/shared/util/directory.h"
+#include "ags/shared/script/cc_options.h"
#ifdef ENABLE_AGS_TESTS
#include "ags/tests/test_all.h"
@@ -77,6 +78,7 @@ AGSEngine::AGSEngine(OSystem *syst, const AGSGameDescription *gameDesc) : Engine
DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
DebugMan.addDebugChannel(kDebugFilePath, "FilePath", "File path debug level");
DebugMan.addDebugChannel(kDebugScan, "Scan", "Scan for unrecognised games");
+ DebugMan.addDebugChannel(kDebugScript, "Script", "Enable debug script dump");
_events = new EventsManager();
_music = new Music();
@@ -123,6 +125,9 @@ Common::Error AGSEngine::run() {
return Common::kNoError;
}
+ if (debugChannelSet(-1, kDebugScript))
+ AGS3::ccSetOption(SCOPT_DEBUGRUN, 1);
+
#ifdef ENABLE_AGS_TESTS
AGS3::Test_DoAllTests();
return Common::kNoError;
diff --git a/engines/ags/ags.h b/engines/ags/ags.h
index 8ddf4931e5..9dc8ea3a78 100644
--- a/engines/ags/ags.h
+++ b/engines/ags/ags.h
@@ -50,7 +50,8 @@ enum AGSDebugChannels {
kDebugGraphics = 1 << 0,
kDebugPath = 1 << 1,
kDebugScan = 1 << 2,
- kDebugFilePath = 1 << 3
+ kDebugFilePath = 1 << 3,
+ kDebugScript = 1 << 4
};
struct AGSGameDescription;
Commit: 5104b23bad0b27aadeb54ceb66b38dee4e8a8c1b
https://github.com/scummvm/scummvm/commit/5104b23bad0b27aadeb54ceb66b38dee4e8a8c1b
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-04-14T23:54:48+01:00
Commit Message:
AGS: Add debug console command to enable or disable script dump
This allows to only dump script for a targetted portion of
gameplay rather than dump for the whole time the engine is
running (script dump can be very verbose ;-) ).
Changed paths:
engines/ags/console.cpp
engines/ags/console.h
diff --git a/engines/ags/console.cpp b/engines/ags/console.cpp
index 56991edfc5..b81991a05a 100644
--- a/engines/ags/console.cpp
+++ b/engines/ags/console.cpp
@@ -25,6 +25,7 @@
#include "ags/globals.h"
#include "ags/shared/ac/spritecache.h"
#include "ags/shared/gfx/allegrobitmap.h"
+#include "ags/shared/script/cc_options.h"
#include "image/png.h"
namespace AGS {
@@ -32,6 +33,7 @@ namespace AGS {
AGSConsole::AGSConsole(AGSEngine *vm) : GUI::Debugger(), _vm(vm), _logOutputTarget(nullptr), _agsDebuggerOutput(nullptr) {
registerCmd("ags_debug_groups_list", WRAP_METHOD(AGSConsole, Cmd_listDebugGroups));
registerCmd("ags_debug_groups_set", WRAP_METHOD(AGSConsole, Cmd_setDebugGroupLevel));
+ registerCmd("ags_set_script_dump", WRAP_METHOD(AGSConsole, Cmd_SetScriptDump));
registerCmd("ags_sprite_info", WRAP_METHOD(AGSConsole, Cmd_getSpriteInfo));
registerCmd("ags_sprite_dump", WRAP_METHOD(AGSConsole, Cmd_dumpSprite));
@@ -170,6 +172,19 @@ void AGSConsole::printLevelList() {
debugPrintf(", %s", levelNames[i].name);
}
+bool AGSConsole::Cmd_SetScriptDump(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Usage: %s [on|off]\n", argv[0]);
+ return true;
+ }
+
+ if (strcmp(argv[1], "on") == 0 || strcmp(argv[1], "true") == 0)
+ AGS3::ccSetOption(SCOPT_DEBUGRUN, 1);
+ else
+ AGS3::ccSetOption(SCOPT_DEBUGRUN, 0);
+ return true;
+}
+
bool AGSConsole::Cmd_getSpriteInfo(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Usage: %s SpriteNumber\n", argv[0]);
diff --git a/engines/ags/console.h b/engines/ags/console.h
index b6ca224b31..45af92fb39 100644
--- a/engines/ags/console.h
+++ b/engines/ags/console.h
@@ -47,6 +47,8 @@ private:
bool Cmd_listDebugGroups(int argc, const char **argv);
bool Cmd_setDebugGroupLevel(int argc, const char **argv);
+ bool Cmd_SetScriptDump(int argc, const char **argv);
+
bool Cmd_getSpriteInfo(int argc, const char **argv);
bool Cmd_dumpSprite(int argc, const char **argv);
More information about the Scummvm-git-logs
mailing list