[Scummvm-git-logs] scummvm master -> d6d464f898b6b3da0f6e8df583efb7e88cadf005
criezy
noreply at scummvm.org
Thu Jun 16 22:16:30 UTC 2022
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:
5d8c66c511 AGS: Implemented debug keys for saving/restoring a game
9789a32bac AGS: In BufferedStream skip buffering if reading large chunk at once
5f29c6b523 AGS: Fixed frame delay was skipped each time the game speed changes
6690bfa5c7 AGS: Remove unused mutex variables in AGSEngine
3b2f9fed4e AGS: Removed unused thread and mutex utils
d6d464f898 AGS: Fixed sprite cache limit was reset on sprite file open
Commit: 5d8c66c51166caaa9f4dcf3a52c720d5baee8313
https://github.com/scummvm/scummvm/commit/5d8c66c51166caaa9f4dcf3a52c720d5baee8313
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-16T23:16:20+01:00
Commit Message:
AGS: Implemented debug keys for saving/restoring a game
This may be useful in case the game does not provide any save system, or one is broken.
>From upstream 86130ec92f6966cfa2d5565c749ba839acad8136
Changed paths:
engines/ags/engine/ac/game.cpp
engines/ags/engine/ac/game.h
engines/ags/engine/ac/game_setup.h
engines/ags/engine/main/config.cpp
engines/ags/engine/main/game_run.cpp
diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp
index 1c6ecbdfef6..dbe8c1ceab6 100644
--- a/engines/ags/engine/ac/game.cpp
+++ b/engines/ags/engine/ac/game.cpp
@@ -325,12 +325,16 @@ void restore_game_dialog() {
_G(curscript)->queue_action(ePSARestoreGameDialog, 0, "RestoreGameDialog");
return;
}
+ do_restore_game_dialog();
+}
+
+bool do_restore_game_dialog() {
setup_for_dialog();
int toload = loadgamedialog();
restore_after_dialog();
- if (toload >= 0) {
+ if (toload >= 0)
try_restore_save(toload);
- }
+ return toload >= 0;
}
void save_game_dialog() {
@@ -342,11 +346,16 @@ void save_game_dialog() {
_G(curscript)->queue_action(ePSASaveGameDialog, 0, "SaveGameDialog");
return;
}
+ do_save_game_dialog();
+}
+
+bool do_save_game_dialog() {
setup_for_dialog();
int toload = savegamedialog();
restore_after_dialog();
if (toload >= 0)
save_game(toload, get_gui_dialog_buffer());
+ return toload >= 0;
}
void free_do_once_tokens() {
diff --git a/engines/ags/engine/ac/game.h b/engines/ags/engine/ac/game.h
index 215a851701c..5240b5ac8a7 100644
--- a/engines/ags/engine/ac/game.h
+++ b/engines/ags/engine/ac/game.h
@@ -151,8 +151,16 @@ Shared::String get_save_game_suffix();
void set_save_game_suffix(const Shared::String &suffix);
// Returns full path to the save for the given slot number
Shared::String get_save_game_path(int slotNum);
+// Try calling built-in restore game dialog;
+// NOTE: this is a script command; may be aborted according to the game & room settings
void restore_game_dialog();
+// Unconditionally display a built-in restore game dialog
+bool do_restore_game_dialog();
+// Try calling built-in save game dialog;
+// NOTE: this is a script command; may be aborted according to the game & room settings
void save_game_dialog();
+// Unconditionally display a built-in save game dialog
+bool do_save_game_dialog();
void free_do_once_tokens();
// Free all the memory associated with the game
void unload_game_file();
diff --git a/engines/ags/engine/ac/game_setup.h b/engines/ags/engine/ac/game_setup.h
index d1d703656e7..1c0744ab94c 100644
--- a/engines/ags/engine/ac/game_setup.h
+++ b/engines/ags/engine/ac/game_setup.h
@@ -100,6 +100,12 @@ struct GameSetup {
DisplayModeSetup Screen;
String software_render_driver;
+ // Optional keys for calling built-in save/restore dialogs;
+ // primarily meant for the test runs of the games where save functionality
+ // is not implemented (or does not work correctly).
+ int key_save_game = 0;
+ int key_restore_game = 0;
+
GameSetup();
};
diff --git a/engines/ags/engine/main/config.cpp b/engines/ags/engine/main/config.cpp
index 709ff95c9cb..566815620fe 100644
--- a/engines/ags/engine/main/config.cpp
+++ b/engines/ags/engine/main/config.cpp
@@ -364,6 +364,8 @@ void apply_config(const ConfigTree &cfg) {
_GP(usetup).override_script_os = eOS_Mac;
}
_GP(usetup).override_upscale = CfgReadBoolInt(cfg, "override", "upscale", _GP(usetup).override_upscale);
+ _GP(usetup).key_save_game = CfgReadInt(cfg, "override", "save_game_key", 0);
+ _GP(usetup).key_restore_game = CfgReadInt(cfg, "override", "restore_game_key", 0);
}
// Apply logging configuration
diff --git a/engines/ags/engine/main/game_run.cpp b/engines/ags/engine/main/game_run.cpp
index 5e826bb30d4..9efef9c60c8 100644
--- a/engines/ags/engine/main/game_run.cpp
+++ b/engines/ags/engine/main/game_run.cpp
@@ -504,6 +504,15 @@ static void check_keyboard_controls() {
}
}
+ // Built-in key-presses
+ if (kgn == _GP(usetup).key_save_game) {
+ do_save_game_dialog();
+ return;
+ } else if (kgn == _GP(usetup).key_restore_game) {
+ do_restore_game_dialog();
+ return;
+ }
+
if (!keywasprocessed) {
int sckey = AGSKeyToScriptKey(kgn);
int sckeymod = ki.Mod;
Commit: 9789a32bacb06ffa5017379d01673ba276d0fa66
https://github.com/scummvm/scummvm/commit/9789a32bacb06ffa5017379d01673ba276d0fa66
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-16T23:16:20+01:00
Commit Message:
AGS: In BufferedStream skip buffering if reading large chunk at once
>From upstream 8137918c209a479edf5127bb7c21d29470b8c40e
Changed paths:
engines/ags/shared/util/buffered_stream.cpp
diff --git a/engines/ags/shared/util/buffered_stream.cpp b/engines/ags/shared/util/buffered_stream.cpp
index 95c8cb8a29b..e73c40aa2e1 100644
--- a/engines/ags/shared/util/buffered_stream.cpp
+++ b/engines/ags/shared/util/buffered_stream.cpp
@@ -97,7 +97,16 @@ bool BufferedStream::Flush() {
}
size_t BufferedStream::Read(void *buffer, size_t size) {
- auto to = static_cast<uint8_t*>(buffer);
+ // If the read size is larger than the internal buffer size,
+ // then read directly into the user buffer and bail out.
+ if (size >= BufferSize) {
+ FileStream::Seek(_position, kSeekBegin);
+ size_t sz = FileStream::Read(buffer, size);
+ _position += sz;
+ return sz;
+ }
+
+ auto *to = static_cast<uint8_t*>(buffer);
while(size > 0) {
if (_position < _bufferPosition || _position >= _bufferPosition + _buffer.size()) {
@@ -117,7 +126,6 @@ size_t BufferedStream::Read(void *buffer, size_t size) {
_position += chunkSize;
size -= chunkSize;
}
-
return to - static_cast<uint8_t*>(buffer);
}
Commit: 5f29c6b52339579975e40d4285dae6d95635bf22
https://github.com/scummvm/scummvm/commit/5f29c6b52339579975e40d4285dae6d95635bf22
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-16T23:16:20+01:00
Commit Message:
AGS: Fixed frame delay was skipped each time the game speed changes
This was not correct, and could cause endless frame skipping if
SetGameSpeed() is called repeatedly in game script.
>From upstream 690f08b8468dd61ae570c7480098708ba6dc669f
Changed paths:
engines/ags/engine/ac/timer.cpp
diff --git a/engines/ags/engine/ac/timer.cpp b/engines/ags/engine/ac/timer.cpp
index 834a0596dfa..f814eb6a20f 100644
--- a/engines/ags/engine/ac/timer.cpp
+++ b/engines/ags/engine/ac/timer.cpp
@@ -30,7 +30,7 @@
namespace AGS3 {
namespace {
-const auto MAXIMUM_FALL_BEHIND = 3;
+const auto MAXIMUM_FALL_BEHIND = 3; // number of full frames
}
std::chrono::microseconds GetFrameDuration() {
@@ -46,8 +46,8 @@ int setTimerFps(int new_fps) {
_G(framerate) = new_fps;
_G(framerate_maxed) = new_fps >= 1000;
- _G(last_tick_time) = AGS_Clock::now();
- _G(next_frame_timestamp) = AGS_Clock::now();
+ // Update next frame time
+ _G(next_frame_timestamp) = _G(last_tick_time) + _G(tick_duration);
return old_fps;
}
@@ -56,11 +56,12 @@ bool isTimerFpsMaxed() {
}
void WaitForNextFrame() {
- auto now = AGS_Clock::now();
- auto frameDuration = GetFrameDuration();
+ const auto now = AGS_Clock::now();
+ const auto frameDuration = GetFrameDuration();
// early exit if we're trying to maximise framerate
if (frameDuration <= std::chrono::milliseconds::zero()) {
+ _G(last_tick_time) = _G(next_frame_timestamp);
_G(next_frame_timestamp) = now;
// suspend while the game is being switched out
while (_G(game_update_suspend) && !_G(want_exit) && !_G(abort_engine)) {
@@ -80,6 +81,7 @@ void WaitForNextFrame() {
std::this_thread::sleep_for(frame_time_remaining);
}
+ _G(last_tick_time) = _G(next_frame_timestamp);
_G(next_frame_timestamp) += frameDuration;
// suspend while the game is being switched out
Commit: 6690bfa5c72bbb2de0dd8f531c4d0adb67882530
https://github.com/scummvm/scummvm/commit/6690bfa5c72bbb2de0dd8f531c4d0adb67882530
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-16T23:16:20+01:00
Commit Message:
AGS: Remove unused mutex variables in AGSEngine
The last use for those mutexes were removed respectively in:
a4569cb180d11edead179605148dc87e6f9d0198 - AGS: Properly remove sound caching
ce606cd25c73d63242ac663b05dfde0a4f958cd6 - AGS: Remove deprecated audio classes
c25b08448d6f0b3103b8cf3a0a619bdd42919f11 - AGS: Removed AudioChannelsLock as it's no longer needed
Changed paths:
engines/ags/ags.h
engines/ags/engine/media/audio/audio.h
engines/ags/engine/media/audio/sound_clip.h
diff --git a/engines/ags/ags.h b/engines/ags/ags.h
index 075fec226d2..bd786b958a7 100644
--- a/engines/ags/ags.h
+++ b/engines/ags/ags.h
@@ -36,7 +36,6 @@
#include "ags/detection.h"
#include "ags/shared/gfx/bitmap.h"
#include "ags/lib/allegro/system.h"
-#include "ags/engine/util/mutex_std.h"
namespace AGS3 {
class Globals;
@@ -68,9 +67,6 @@ public:
EventsManager *_events;
Music *_music;
::AGS3::GFX_DRIVER *_gfxDriver;
- ::AGS3::AGS::Engine::Mutex _sMutex;
- ::AGS3::AGS::Engine::Mutex _soundCacheMutex;
- ::AGS3::AGS::Engine::Mutex _mp3Mutex;
::AGS3::Globals *_globals;
bool _forceTextAA;
protected:
diff --git a/engines/ags/engine/media/audio/audio.h b/engines/ags/engine/media/audio/audio.h
index 2dda2bde08b..28659305a7f 100644
--- a/engines/ags/engine/media/audio/audio.h
+++ b/engines/ags/engine/media/audio/audio.h
@@ -27,8 +27,6 @@
#include "ags/shared/ac/dynobj/script_audio_clip.h"
#include "ags/engine/ac/dynobj/script_audio_channel.h"
#include "ags/engine/media/audio/ambient_sound.h"
-#include "ags/engine/util/mutex.h"
-#include "ags/engine/util/mutex_lock.h"
#include "ags/engine/ac/timer.h"
namespace AGS3 {
diff --git a/engines/ags/engine/media/audio/sound_clip.h b/engines/ags/engine/media/audio/sound_clip.h
index 24b169f7235..e02dbb4567f 100644
--- a/engines/ags/engine/media/audio/sound_clip.h
+++ b/engines/ags/engine/media/audio/sound_clip.h
@@ -28,7 +28,6 @@
#ifndef AGS_ENGINE_MEDIA_AUDIO_SOUNDCLIP_H
#define AGS_ENGINE_MEDIA_AUDIO_SOUNDCLIP_H
-#include "ags/engine/util/mutex.h"
#include "audio/mixer.h"
#include "audio/audiostream.h"
#include "common/stream.h"
Commit: 3b2f9fed4e007c627ad9538664edb7cc17c0de96
https://github.com/scummvm/scummvm/commit/3b2f9fed4e007c627ad9538664edb7cc17c0de96
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-16T23:16:20+01:00
Commit Message:
AGS: Removed unused thread and mutex utils
>From upstream 9173a2d8ea90b019c27d49a2d48018fab5a4c2b6
Changed paths:
R engines/ags/engine/util/mutex.h
R engines/ags/engine/util/mutex_base.h
R engines/ags/engine/util/mutex_lock.h
R engines/ags/engine/util/mutex_pthread.h
R engines/ags/engine/util/mutex_std.h
R engines/ags/engine/util/mutex_windows.h
R engines/ags/engine/util/thread_pthread.h
R engines/ags/engine/util/thread_std.h
R engines/ags/engine/util/thread_windows.h
diff --git a/engines/ags/engine/util/mutex.h b/engines/ags/engine/util/mutex.h
deleted file mode 100644
index 29b96ac0b70..00000000000
--- a/engines/ags/engine/util/mutex.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_UTIL_MUTEX_H
-#define AGS_ENGINE_UTIL_MUTEX_H
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-class BaseMutex {
-public:
- BaseMutex() {}
-
- virtual ~BaseMutex() {}
-
- BaseMutex &operator=(const BaseMutex &) = delete;
- BaseMutex(const BaseMutex &) = delete;
-
- virtual void Lock() = 0;
-
- virtual void Unlock() = 0;
-};
-
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/mutex_base.h b/engines/ags/engine/util/mutex_base.h
deleted file mode 100644
index 8031e2d948d..00000000000
--- a/engines/ags/engine/util/mutex_base.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_PLATFORM_MUTEX_BASE_H
-#define AGS_ENGINE_PLATFORM_MUTEX_BASE_H
-
-namespace AGS3 {
-namespace AGS {
-namespace Shared {
-
-
-class BaseMutex {
-public:
- BaseMutex() = 0;
- virtual ~BaseMutex() = 0;
- virtual void Lock() = 0;
- virtual void Unlock() = 0;
-};
-
-} // namespace Shared
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/mutex_lock.h b/engines/ags/engine/util/mutex_lock.h
deleted file mode 100644
index 1bc427937b1..00000000000
--- a/engines/ags/engine/util/mutex_lock.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_UTIL_MUTEX_LOCK_H
-#define AGS_ENGINE_UTIL_MUTEX_LOCK_H
-
-#include "ags/engine/util/mutex.h"
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-
-class MutexLock {
-private:
- BaseMutex *_m;
- MutexLock(MutexLock const &); // non-copyable
- MutexLock &operator=(MutexLock const &); // not copy-assignable
-
-public:
- void Release() {
- if (_m != nullptr) _m->Unlock();
- _m = nullptr;
- }
-
- void Acquire(BaseMutex &mutex) {
- Release();
- _m = &mutex;
- _m->Lock();
- }
-
- MutexLock() : _m(nullptr) {
- }
-
- explicit MutexLock(BaseMutex &mutex) : _m(nullptr) {
- Acquire(mutex);
- }
-
- ~MutexLock() {
- Release();
- }
-}; // class MutexLock
-
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/mutex_pthread.h b/engines/ags/engine/util/mutex_pthread.h
deleted file mode 100644
index 57ca1944cbb..00000000000
--- a/engines/ags/engine/util/mutex_pthread.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_UTIL_MUTEX_PTHREAD_H
-#define AGS_ENGINE_UTIL_MUTEX_PTHREAD_H
-
-//include <pthread.h>
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-
-class PThreadMutex : public BaseMutex {
-public:
- inline PThreadMutex() {
- pthread_mutex_init(&_mutex, NULL);
- }
-
- inline ~PThreadMutex() {
- pthread_mutex_destroy(&_mutex);
- }
-
- inline void Lock() {
- pthread_mutex_lock(&_mutex);
- }
-
- inline void Unlock() {
- pthread_mutex_unlock(&_mutex);
- }
-
-private:
- pthread_mutex_t _mutex;
-};
-
-typedef PThreadMutex Mutex;
-
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/mutex_std.h b/engines/ags/engine/util/mutex_std.h
deleted file mode 100644
index 87c2b8f013e..00000000000
--- a/engines/ags/engine/util/mutex_std.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_UTIL_MUTEX_STD_H
-#define AGS_ENGINE_UTIL_MUTEX_STD_H
-
-#include "ags/lib/std/mutex.h"
-#include "ags/engine/util/mutex.h"
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-class StdMutex : public BaseMutex {
-public:
- inline StdMutex() : mutex_() {
- }
- inline ~StdMutex() override {}
-
- StdMutex &operator=(const StdMutex &) = delete;
- StdMutex(const StdMutex &) = delete;
-
- inline void Lock() override {
- mutex_.lock();
- }
- inline void Unlock() override {
- mutex_.unlock();
- }
-
-private:
- std::recursive_mutex mutex_;
-};
-
-typedef StdMutex Mutex;
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/mutex_windows.h b/engines/ags/engine/util/mutex_windows.h
deleted file mode 100644
index 307cb910d13..00000000000
--- a/engines/ags/engine/util/mutex_windows.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_UTIL_WINDOWS_MUTEX_H
-#define AGS_ENGINE_UTIL_WINDOWS_MUTEX_H
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-
-class WindowsMutex : public BaseMutex {
-public:
- WindowsMutex() {
- _mutex = CreateMutex(NULL, FALSE, NULL);
-
- _ASSERT(_mutex != NULL);
- }
-
- ~WindowsMutex() {
- _ASSERT(_mutex != NULL);
-
- CloseHandle(_mutex);
- }
-
- inline void Lock() {
- _ASSERT(_mutex != NULL);
-
- WaitForSingleObject(_mutex, INFINITE);
- }
-
- inline void Unlock() {
- _ASSERT(_mutex != NULL);
-
- ReleaseMutex(_mutex);
- }
-
-private:
- HANDLE _mutex;
-};
-
-
-typedef WindowsMutex Mutex;
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/thread_pthread.h b/engines/ags/engine/util/thread_pthread.h
deleted file mode 100644
index 128ee8fff3d..00000000000
--- a/engines/ags/engine/util/thread_pthread.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_PLATFORM_THREAD_PTHREAD_H
-#define AGS_ENGINE_PLATFORM_THREAD_PTHREAD_H
-
-//include <pthread.h>
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-
-class PThreadThread : public BaseThread {
-public:
- PThreadThread() {
- _thread = 0;
- _entry = NULL;
- _running = false;
- _looping = false;
- }
-
- ~PThreadThread() {
- Stop();
- }
-
- inline bool Create(AGSThreadEntry entryPoint, bool looping) {
- _looping = looping;
- _entry = entryPoint;
-
- // Thread creation is delayed till the thread is started
- return true;
- }
-
- inline bool Start() {
- if (!_running) {
- _running = (pthread_create(&_thread, NULL, _thread_start, this) == 0);
-
- return _running;
- } else {
- return false;
- }
- }
-
- bool Stop() {
- if (_running) {
- if (_looping) {
- _looping = false;
- }
-
- pthread_join(_thread, NULL);
-
- _running = false;
- return true;
- } else {
- return false;
- }
- }
-
-private:
- pthread_t _thread;
- bool _running;
- bool _looping;
-
- AGSThreadEntry _entry;
-
- static void *_thread_start(void *arg) {
- AGSThreadEntry entry = ((PThreadThread *)arg)->_entry;
- bool *looping = &((PThreadThread *)arg)->_looping;
-
- do {
- entry();
- } while (*looping);
-
- return NULL;
- }
-};
-
-
-typedef PThreadThread Thread;
-
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/thread_std.h b/engines/ags/engine/util/thread_std.h
deleted file mode 100644
index 06f00577dcb..00000000000
--- a/engines/ags/engine/util/thread_std.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_PLATFORM_THREAD_STD_H
-#define AGS_ENGINE_PLATFORM_THREAD_STD_H
-
-//include <system_error>
-//include <thread>
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-class StdThread : public BaseThread {
-public:
- StdThread() : thread_(), entry_(nullptr), looping_(false) {
- }
-
- ~StdThread() override {
- Stop();
- }
-
- StdThread &operator=(const StdThread &) = delete;
- StdThread(const StdThread &) = delete;
-
- bool Create(AGSThreadEntry entryPoint, bool looping) override {
- if (!entryPoint) {
- return false;
- }
-
- entry_ = entryPoint;
- looping_ = looping;
- return true;
- }
-
- bool Start() override {
- if (thread_.joinable()) {
- return true;
- }
- if (!entry_) {
- return false;
- }
-
- //try {
- thread_ = std::thread(thread_start_, this);
- /*} catch (std::system_error) {
- return false;
- }*/
- return thread_.joinable();
- }
-
- bool Stop() override {
- if (!thread_.joinable()) {
- return true;
- }
-
- looping_ = false; // signal thread to stop
- thread_.join();
- return true;
- }
-
-private:
- std::thread thread_;
- AGSThreadEntry entry_;
- bool looping_;
-
- static void thread_start_(StdThread *self) {
- auto entry = self->entry_;
- for (;;) {
- entry();
- if (!self->looping_) {
- break;
- }
- std::this_thread::yield();
- }
- }
-};
-
-typedef StdThread Thread;
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
diff --git a/engines/ags/engine/util/thread_windows.h b/engines/ags/engine/util/thread_windows.h
deleted file mode 100644
index f88740b29d7..00000000000
--- a/engines/ags/engine/util/thread_windows.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AGS_ENGINE_UTIL_THREAD_WINDOWS_H
-#define AGS_ENGINE_UTIL_THREAD_WINDOWS_H
-
-namespace AGS3 {
-namespace AGS {
-namespace Engine {
-
-
-class WindowsThread : public BaseThread {
-public:
- WindowsThread() {
- _thread = NULL;
- _entry = NULL;
- _running = false;
- _looping = false;
- }
-
- ~WindowsThread() {
- Stop();
- }
-
- inline bool Create(AGSThreadEntry entryPoint, bool looping) {
- _looping = looping;
- _entry = entryPoint;
- _thread = CreateThread(NULL, 0, _thread_start, this, CREATE_SUSPENDED, NULL);
-
- return (_thread != NULL);
- }
-
- inline bool Start() {
- if ((_thread != NULL) && (!_running)) {
- DWORD result = ResumeThread(_thread);
-
- _running = (result != (DWORD) - 1);
- return _running;
- } else {
- return false;
- }
- }
-
- bool Stop() {
- if ((_thread != NULL) && (_running)) {
- if (_looping) {
- _looping = false;
- WaitForSingleObject(_thread, INFINITE);
- }
-
- CloseHandle(_thread);
-
- _running = false;
- _thread = NULL;
- return true;
- } else {
- return false;
- }
- }
-
-private:
- HANDLE _thread;
- bool _running;
- bool _looping;
-
- AGSThreadEntry _entry;
-
- static DWORD __stdcall _thread_start(LPVOID lpParam) {
- AGSThreadEntry entry = ((WindowsThread *)lpParam)->_entry;
- bool *looping = &((WindowsThread *)lpParam)->_looping;
-
- do {
- entry();
- } while (*looping);
-
- return 0;
- }
-};
-
-
-typedef WindowsThread Thread;
-
-
-} // namespace Engine
-} // namespace AGS
-} // namespace AGS3
-
-#endif
Commit: d6d464f898b6b3da0f6e8df583efb7e88cadf005
https://github.com/scummvm/scummvm/commit/d6d464f898b6b3da0f6e8df583efb7e88cadf005
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-06-16T23:16:20+01:00
Commit Message:
AGS: Fixed sprite cache limit was reset on sprite file open
>From upstream 4f57730e2b3d41af4fd0300e8b092d31d448f544
Changed paths:
engines/ags/engine/ac/game_setup.h
engines/ags/engine/ac/global_debug.cpp
engines/ags/engine/main/config.cpp
engines/ags/engine/main/engine.cpp
engines/ags/shared/ac/sprite_cache.cpp
engines/ags/shared/ac/sprite_cache.h
diff --git a/engines/ags/engine/ac/game_setup.h b/engines/ags/engine/ac/game_setup.h
index 1c0744ab94c..4eefbf3bef9 100644
--- a/engines/ags/engine/ac/game_setup.h
+++ b/engines/ags/engine/ac/game_setup.h
@@ -92,6 +92,7 @@ struct GameSetup {
MouseSpeedDef mouse_speed_def;
bool RenderAtScreenRes; // render sprites at screen resolution, as opposed to native one
int Supersampling;
+ size_t SpriteCacheSize = 0u;
bool clear_cache_on_room_change; // for low-end devices: clear resource caches on room change
bool load_latest_save; // load latest saved game on launch
ScreenRotation rotation;
diff --git a/engines/ags/engine/ac/global_debug.cpp b/engines/ags/engine/ac/global_debug.cpp
index 7874a530fb6..a0df887f507 100644
--- a/engines/ags/engine/ac/global_debug.cpp
+++ b/engines/ags/engine/ac/global_debug.cpp
@@ -59,7 +59,7 @@ String GetRuntimeInfo() {
"Adventure Game Studio run-time engine[ACI version %s"
"[Game resolution %d x %d (%d-bit)"
"[Running %d x %d at %d-bit%s[GFX: %s; %s[Draw frame %d x %d["
- "Sprite cache size: %d KB (limit %d KB; %d locked)",
+ "Sprite cache size: %d KB (limit %d KB; %d KB locked)",
_G(EngineVersion).LongString.GetCStr(), _GP(game).GetGameRes().Width, _GP(game).GetGameRes().Height, _GP(game).GetColorDepth(),
mode.Width, mode.Height, mode.ColorDepth,
mode.IsWindowed() ? " W" : "",
diff --git a/engines/ags/engine/main/config.cpp b/engines/ags/engine/main/config.cpp
index 566815620fe..e087eceabaa 100644
--- a/engines/ags/engine/main/config.cpp
+++ b/engines/ags/engine/main/config.cpp
@@ -326,7 +326,7 @@ void apply_config(const ConfigTree &cfg) {
int cache_size_kb = CfgReadInt(cfg, "misc", "cachemax", DEFAULTCACHESIZE_KB);
if (cache_size_kb > 0)
- _GP(spriteset).SetMaxCacheSize((size_t)cache_size_kb * 1024);
+ _GP(usetup).SpriteCacheSize = cache_size_kb * 1024;
_GP(usetup).mouse_auto_lock = CfgReadBoolInt(cfg, "mouse", "auto_lock");
diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index c7aeee52c71..73ebbd5f8c8 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -509,7 +509,6 @@ void show_preload() {
int engine_init_sprites() {
Debug::Printf(kDbgMsg_Info, "Initialize sprites");
-
HError err = _GP(spriteset).InitFile(SpriteFile::DefaultSpriteFileName, SpriteFile::DefaultSpriteIndexName);
if (!err) {
sys_main_shutdown();
@@ -521,6 +520,8 @@ int engine_init_sprites() {
return EXIT_ERROR;
}
+ if (_GP(usetup).SpriteCacheSize > 0)
+ _GP(spriteset).SetMaxCacheSize(_GP(usetup).SpriteCacheSize);
return 0;
}
diff --git a/engines/ags/shared/ac/sprite_cache.cpp b/engines/ags/shared/ac/sprite_cache.cpp
index 2940e93d8a8..ff375e35731 100644
--- a/engines/ags/shared/ac/sprite_cache.cpp
+++ b/engines/ags/shared/ac/sprite_cache.cpp
@@ -68,8 +68,8 @@ SpriteCache::SpriteData::~SpriteData() {
}
SpriteCache::SpriteCache(std::vector<SpriteInfo> &sprInfos)
- : _sprInfos(sprInfos) {
- Init();
+ : _sprInfos(sprInfos), _maxCacheSize(DEFAULTCACHESIZE_KB * 1024u),
+ _cacheSize(0u), _lockedSize(0u), _liststart(-1), _listend(-1) {
}
SpriteCache::~SpriteCache() {
@@ -96,14 +96,6 @@ void SpriteCache::SetMaxCacheSize(size_t size) {
_maxCacheSize = size;
}
-void SpriteCache::Init() {
- _cacheSize = 0;
- _lockedSize = 0;
- _maxCacheSize = (size_t)DEFAULTCACHESIZE_KB * 1024;
- _liststart = -1;
- _listend = -1;
-}
-
void SpriteCache::Reset() {
_file.Close();
// TODO: find out if it's safe to simply always delete _spriteData.Image with array element
@@ -115,10 +107,13 @@ void SpriteCache::Reset() {
}
_spriteData.clear();
+ _cacheSize = 0;
+ _lockedSize = 0;
_mrulist.clear();
_mrubacklink.clear();
- Init();
+ _liststart = -1;
+ _listend = -1;
}
void SpriteCache::SetSprite(sprkey_t index, Bitmap *sprite) {
diff --git a/engines/ags/shared/ac/sprite_cache.h b/engines/ags/shared/ac/sprite_cache.h
index 93b63d83773..d2a1b5b2412 100644
--- a/engines/ags/shared/ac/sprite_cache.h
+++ b/engines/ags/shared/ac/sprite_cache.h
@@ -146,7 +146,6 @@ public:
Shared::Bitmap *operator[](sprkey_t index);
private:
- void Init();
// Load sprite from game resource
size_t LoadSprite(sprkey_t index);
// Gets the index of a sprite which data is used for the given slot;
More information about the Scummvm-git-logs
mailing list