Commit Graph
80 Commits
Author SHA1 Message Date
Walter Agazzi 3078b207d3 AGS: Engine: refactor around add_dynamic_sprite()
* separate variant of add_dynamic_sprite() that searches for the free slot itself,
not requiring user to do this;
* the previously existing variant is used for: replacing modified dynamic sprite
and restoring sprites from save.
* add_dynamic_sprite() accepts unique_ptr<Bitmap>, explicitly saying that the
ownership will be taken by the spriteset.
* sprite info and SPF_* flags are set inside spriteset, instead of hacking them in
add_dynamic_sprite().
* simplified LoadSaveSlotScreenshot()

From upstream 0913f49e4212fea3a48539251ffc1ab92518a231
and aca47b9f466fe41d73d99a15b9f0ae41e65c6926
+ minor changes
2024-10-30 18:07:42 +02:00
Walter Agazzi 1bce308ff0 AGS: Add casts in ags_plugin 2024-10-30 18:07:42 +02:00
Walter Agazzi c3b5eac297 AGS: Engine: fixed IAGSEngine::SimulateMouseClick()
From upstream 2acb74a7d7769139efc678fd03e2ae631c6ce0de
2024-10-30 18:07:42 +02:00
Walter Agazzi 5b793dbd38 AGS: Engine: new plugins save format, stores name & data size per plugin
From upstream e84746a5049b2855cd0774ba0ff641753f640c27
2024-10-30 18:07:42 +02:00
Walter Agazzi 50e11cf086 AGS: Engine: basic stream range safeguard for plugin serialization
Reimplemented from 99ae439a1dbdca965c58f69894b623de536f5163
2024-10-30 18:07:42 +02:00
Walter Agazzi e158764267 AGS: Engine: unrestricted game name and save folder name
From upstream 3b06711da90621b2ee5ba33ff82da91f797cabbb
2024-10-30 18:07:42 +02:00
Walter Agazzi ee82074a47 AGS: Engine: further tidy up around agsplugin.h/cpp
* Moved plugin API event constants to a separate header agsplugin_evts.h.
Engine should not include whole plugin API, this is unnecessary, and may
 create naming conflicts.
* Moved SimulateMouseClick to mouse.cpp.
* Minor cleanup in agsplugin.cpp

From upstream 510293c1fd277d853544534423ceea27b8ae3e2d
2024-10-30 18:07:42 +02:00
Walter Agazzi 961b06447f AGS: Engine: use internal interface alias for plugin's object readers
The idea is to have similar interface internally in the engine, without having to refer to the
 plugin's API; at least to keep things consistent with the rest of interfaces for now.
 (The whole engine interface system may need to be reorganized.)

* Renamed existing ICCObjectReader to ICCObjectCollectionReader, an interface that supports
 multiple object types.
* ICCObjectReader is now an internal engine's alias for plugin's IAGSManagedObjectReader
(but it may be used for the internal purposes too if a need arises).
* Moved PluginObjectReader declaration, save 1 small h/cpp pair.
* Store pluginReaders in a std::vector, remove MAX_PLUGIN_OBJECT_READERS as redundant.

From upstream 49d037671e4daaa909a7a98e19456e0f29f8e3cb
2024-10-30 18:07:42 +02:00
Walter Agazzi 815041ec6a AGS: Engine: store game's ccInstances as unique_ptrs instead
The script handling part of the engine appeared to be too fragile and dependent on
 a precise timing of **deleting** a ccInstance.
For example, restoring a saved game may execute in the midst of the call to
RunScriptFunction(), at the "post script cleanup" stage, while there are still references
to ccInstance on the engine's call stack (and few other places). If anything prevents
 ccInstance's disposal at this moment, that would in turn lead to logical errors due to
  the game scripts "instances" counting. The most outstanding consequence is that the
   script exports are kept pointing into the deleted memory and not re-registered after the save is restored.

Overall, the script handling part of the engine would benefit from a major refactor,
 with a goal to make it safe and consistent, but this is not something I might do at the moment.

From upstream 1f6abf4b678f77825c710d4ae18b57ff8f882c93
2024-10-30 18:07:42 +02:00
Walter Agazzi 09ffee9ed7 AGS: Engine: store ccInstances in shared_ptr, tidy freeing of instances (take two)
After the updates to cc_instance this should now work

From upstream b1e4f75141ce88b3146f55ecd9d7a95378428072
and 49e8aa0b566dea4ce025f9530a9f2392dbe67a33
2024-10-30 18:07:42 +02:00
Walter Agazzi f13f7cfac2 AGS: Engine: rem the distinction between static/dynamic objects in script VM
From upstream 04450b2a41f0e0f107a4ea85dab375f439b4ffae
2024-10-30 18:07:42 +02:00
Walter Agazzi ac0422354a AGS: Engine: renamed ICCDynamicObject to IScriptObject
because this interface is now used for both Dynamic and
Static object managers.
From upstream 1bb14f7a2bae43534edf950c040bcd4a1be5f7df
2024-10-30 18:07:42 +02:00
Walter Agazzi 54b8b1d873 AGS: Engine: changed script object data pointers from char* to void*
This seems to be far more appropriate.
From upstream a495538a5e0106a655e4e04cf547be8ec9284d7c
2024-10-30 18:07:42 +02:00
Walter Agazzi 22cb981566 AGS: Engine: rewrote MoveList to avoid packed shorts
From upstream d463adac63817fd08eb757038f90c730726124d3
and 09203df6efb19cf0f2eafd098c798733bd85cfe0
2024-10-30 18:07:42 +02:00
Walter Agazzi 455caa2f84 AGS: Engine: some simplification for IAGSEngine::PlaySoundChannel()
partially from upstream c34ec5a2d4ab77e9e1a1ca10bbce97c6528c9b70
2024-10-30 18:07:42 +02:00
Walter Agazzi 7e3aac02bf AGS: Plugin API: added ResolveFilePath()
From upstream 0f143a54e7eb6997ad86e5d2769af206543d5f2a
2024-10-30 18:07:42 +02:00
Walter Agazzi 0f5d6a1f5e AGS: Engine: store plugin infos in std::vector
Partially from upstream 32fb3fbe2d7186fafcf948dba92b5347b12cb7ee
2024-10-30 18:07:42 +02:00
Walter Agazzi 5bb1770019 AGS: Engine: fixed IAGSEngine::GetFontType() not using proper font test
From upstream fda06dba238c19f4ea226417933751b640afd39f
2024-10-30 18:07:42 +02:00
Walter Agazzi 8153a59121 Revert "AGS: Engine: store ccInstances in shared_ptr, tidy freeing of instances"
This reverts commit 016323f1f9797827a36a77ae3a5859b56d3b0998.
2024-10-30 18:07:42 +02:00
Walter Agazzi 253187f4e2 Revert "AGS: Engine: store game's ccInstances as unique_ptrs instead"
This reverts commit 547cd40186876f17914f6a96261aaf5c4dfc21b4.
2024-10-30 18:07:42 +02:00
Walter Agazzi b1e7617964 AGS: Engine: store game's ccInstances as unique_ptrs instead
From upstream 1f6abf4b678f77825c710d4ae18b57ff8f882c93
2024-10-30 18:07:42 +02:00
Walter Agazzi 4019f9305b AGS: Engine: store ccInstances in shared_ptr, tidy freeing of instances
From upstream b1e4f75141ce88b3146f55ecd9d7a95378428072
and 49e8aa0b566dea4ce025f9530a9f2392dbe67a33
2024-10-30 18:07:42 +02:00
Walter Agazzi 34e15c2e57 AGS: Engine: simplifications for ManagedPool
* Don't call CheckDispose() from SubRef, we may call Remove directly,
as we already know that reference count is zero.
* Don't pass a "plugin_object" flag to the object registration methods,
pass actual ScriptValueType instead. This also allows to have more subtypes if necessary.

from upstream 9b93f6f4340e8291d671245a082c1ad88a8da554
2024-10-30 18:07:42 +02:00
Walter Agazzi 3a5ccd4cba AGS: Engine: moved dynamic object management functions to a separate unit
From upstream 1a9df937e3ac9eba0c2f5b663507a52569d635e0
2024-10-30 18:07:42 +02:00
Walter Agazzi afa54e0526 AGS: Engine: simplify IAGSEngine::GetManagedObjectAddressByKey()
from upstream 9648cc3c733681da4b8793fb9d8d96c7b0f6b8c1
2024-10-30 18:07:42 +02:00
Hubert Maier 130b81208f JANITORIAL: Fix loosing typo in ags_plugin.cpp 2024-07-15 20:50:41 +03:00
Le Philousophe 49b4c1b3c4 AGS: Revert to use std namespace
This allows to minimize changes from upstream
2024-07-08 21:37:28 +02:00
Paul Gilbert c2a476411c AGS: Move std namespace into common/std/ 2024-07-07 15:28:31 -07:00
Walter Agazzi 30fc1a911d AGS: Engine: fixed System.ColorDepth to returning game's native depth
This logic got confused at some point in engine development. This property had a meaning back when display mode matched the game's native color depth.
Plugins also could rely on this, when drawing on a software renderer's virtual screen, which must match game's native depth and not the final display resolution.
From upstream 67c3bdc403d5178f1c5c390af820bc446f94f21b
2024-01-17 03:12:31 +01:00
Walter Agazzi 2b2fa06142 AGS: Inline some library functions + minor changes
This is the only relevant part of upstream commit
a46b97fc3bf7fdff82b84a863a3c0cacc37e7a2b
"Engine: explicitly search for plugins in a game's data dir too"

(ScummVM does not support external plugins)
2023-06-19 22:01:30 +03:00
Thierry Crozat 28a4c3d8da AGS: Remove mention of the DLL in plugin loading message
When starting a game that uses plugins, a message is printed
indicating 'Plugin X loaded from Y.dll, resolving imports...'.
However in ScummVM we do not use the DLLs, and provide replacements
for the plugins. So the message could be confusing for users.
2023-06-02 22:50:30 +01:00
Walter Agazzi 72888a7a8c AGS: Engine: move cursor and cursor-over-gui updates to the game update fn
This is necessary for the touch-to-mouse emulation to work
properly (and perhaps true touch controls in the future).
The order of updates is a bit wrong historically, where cursor
position and gui control focus is updated later than the
handling of button events. This means, for example, that if the
cursor was positioned over button in game frame 1, then the
mouse click will only trigger button press not later than the frame 2.

Changes:
* moved "cursor over gui" poll from draw_gui_and_overlays()
to update_cursor_over_gui(), call it in the main game update fn.
* moved update_mouse_cursor() call from
construct_game_screen_overlay() to the game update fn
(renamed to update_cursor_view().
* picked out "cursor over location" trigger out of the "render"
function into update_cursor_over_location(), call it explicitly in
the main game update fn.

Effect on user script callbacks:
* the cursor position (and gui focus) will now be updated prior
to `late_repeatedly_execute_always()` callback. Other callbacks
will not be affected, as their relative order won't change
compared with these updates.

From upstream 23493a681d4f66ae0b1088cddb82241b0bc80dbb
2023-04-29 13:11:41 +02:00
Walter Agazzi 07bbbcd233 AGS: Engine: replaced couple more shared_ptr<char> with vector<char>
From upstream 1cccdfea5c1009123de7ba25be72b2757f74d06f
2023-03-12 20:58:28 +00:00
Walter Agazzi 50d8eaddcf AGS: Engine: in IAGSEngine::SetVirtualScreen set Stage buffer, not whole VS
When plugin calls SetVirtualScreen (for software renderer), don't
replace whole virtual screen, instead replace only the current
render stage buffer.
This is complementary to the older changes in software renderer,
made during development of AGS 3.5.0, which featured advanced
room viewports and cameras. Since that change, separate render
stages could draw on sub-bitmaps of smaller size.

While IAGSEngine::GetVirtualScreen() was adjusted to follow that
change, and return not the whole virtual screen, but only a "stage
buffer" (which may be a VS sub-bitmap, or an intermediate bitmap
created specifically for this render stage), SetVirtualScreen() was
NOT adjusted accordingly and kept replacing whole VS. As a
result, this discrepancy could cause logical errors, as well as
crashes with plugins that use this API (e.g. original SnowRain
plugin).

The immediate reason of error is that plugin would remember a
pointer returned from GetVirtualScreen (which is a stage buffer),
and then try to set it back with SetVirtualScreen. As a result,
engine's own stage buffer is assigned as a full virtual screen.

From upstream 09143ea7fbf8474f78932116ae1c81ceff4de95a
2023-03-12 20:58:28 +00:00
Walter Agazzi c366ce5eef AGS: Removed update_polled_stuff_if_runtime() from data loading functions
Leave it with a new name as `update_polled_stuff()` only in functions
related to the game update.
From upstream 95dc139f51e704da19792e5480e69bbfe7ec27aa
2023-03-12 20:58:28 +00:00
Thierry Crozat aa6c07f03e AGS: Plugin API: few adjustments to recently added methods
From upstream ddf9aee9c360a60edcc2f3107fbac41f8efbe93c
2022-12-15 22:40:17 +01:00
Le Philousophe 7f90669bdd AGS: Don't use unsafe strcat and strcpy 2022-10-23 22:46:19 +02:00
Thierry Crozat 98f4b82f36 AGS: added IAGSFontRenderer2 and NotifyFontUpdated
From upstream e42b1371a8258ddd47c79af04a6f78fab2a136f4
2022-10-10 23:42:34 +01:00
Thierry Crozat 69eeb18d36 AGS: Added GetGameInfo to plugin interface
From upstream 97d02b47babb0cdd0e82e8815f3f5dbf8e7b2e1b
2022-10-10 23:42:34 +01:00
Thierry Crozat 5987bc5e6e AGS: rewrote eAGSMouseButton enum to sync with the script API
* Changed from -1 - based constants to 0 - based constants;
* These were purely internal values, therefore no API would be harmed;
* Removed necessity of converting from internal mouse button code to script and back all the time;
* On a side note, this fixes a bug where WaitMouse etc were returning incorrect values on mouse skip, because we forgot to convert from internal to script code.

From upstream 471098d239b076c494beb2d554572ccb69372667
2022-10-10 00:16:16 +01:00
Thierry Crozat 817ddb19c9 AGS: Tidied Library class
From upstream 58a6f421e3b97f6e2db49b88a6434686c62f5142
2022-06-25 23:33:30 +01:00
Thierry Crozat a336b97f4e AGS: Fixed few more warnings
From upstream 343dda7e508e5c3b6b50ad13756020e200d513ef
2022-06-21 23:28:01 +01:00
Thierry Crozat 2c7d51ce16 AGS: Replaced EnginePlugin's filename from char array to String
From upstream 252d9d198ac665546bd7ed3f3b8afa018bd62b9f
2022-06-19 20:50:24 +01:00
D G Turner f567b0f96a AGS: Fix GCC Compiler Warnings 2022-06-18 14:10:00 +01:00
Paul Gilbert 2e726fa214 AGS: Removed deprecated globals 2022-05-30 15:23:20 -07:00
Paul Gilbert 97c12e8435 AGS: Merged Character and ObjectCache structs, and hid in draw.cpp
From upstream 753d47d975b10666702c47a22cbc4e68847787f1
2022-05-05 22:41:09 -07:00
Paul Gilbert 6482e38803 AGS: CharacterExtras and MoveLists are stored in std::vector
From upstream 0c81cfefb788c0dcfdb2cad914f939f28110edca
2022-05-05 22:41:08 -07:00
Paul Gilbert 17bac5b1ef AGS: Removed redundant function domouse(int what)
From upstream 3dfda41382bdd10e3b2b78f797fade8b5dcc1efa
2022-04-23 18:15:02 -07:00
Paul Gilbert 62574f8eda AGS: Use outlined width/height when arranging text on GUI
From upstream 8fd4b1b55dc08949e70d295afb4be91d1a26da5c
2022-04-22 20:54:00 -07:00
Paul Gilbert 5060848b48 AGS: Support requesting particular audio driver
From upstream 076e675a3d031cd0a9d162f914e6d94c93a10d71
2022-04-21 21:20:58 -07:00