Commit Graph
197 Commits
Author SHA1 Message Date
Le Philousophe 4da3b518b5 AGS: Avoid stack frame size warning in AGS3::unload_game
Instead of allocating the GameState and GameSetupStruct variables on
stack and erase the heap version, deallocate the old ones and reallocate
new ones.
2025-02-23 17:56:17 +02:00
Thierry Crozat 9a336aaa87 AGS: Clear all screen overlays in unload_game()
This is what upstream AGS does in the 3.6.1 and master branches,
while our code corresponded to the 3.6.0 branch.
This fixes an issue where deleting the screenoverlay vector later
on would try to access an already cleared SpriteCache.

This sould fix bugs #15488 and bug #15510.
2024-11-26 22:59:39 +00:00
D G Turner 298c54bcc1 AGS: Fix Various Signed vs. Unsigned Comparison GCC Compiler Warnings
These are emitted if -Wsign-compare is passed to GCC.
2024-11-05 22:54:04 +00:00
Walter Agazzi 1fad505ba5 AGS: Add old_keyhandle flag to ags_simulate_keypress
The flag is not really used, and scummvm has a different implementation.
From upstream babb4a9cce674bfa1338de1213956791af6181ca
2024-10-30 18:07:42 +02:00
Walter Agazzi 81757a1121 AGS: Engine: fixed text-based lipsync inconsistent frame delay
The problem was that the delay formula used integer division (twice), and precision loss
resulted in calculated value to "jump" up and down even from a slight change in input text length.
Fixed this by reimplementing calculation using a floating point division instead.
Used a different literal coefficient, found experimentally, to approximately match the result of the
old formula in certain key text lengths, for backwards compatibility.
From upstream d783f5678d974b8d4cfdde3c7011b0a56dc4c3ac
2024-10-30 18:07:42 +02:00
Walter Agazzi 4308801cae AGS: Engine: in GetDiskFreeSpaceMB() ensure we check the save dir's disk
Partially from upstream 220ada5413886e80f42c9f2950e20ea46c141283
2024-10-30 18:07:42 +02:00
Walter Agazzi 7f1ad613d5 AGS: Engine: added comments around remaining uses of STD_BUFFER_SIZE
From upstream 67a1cd06e115472d80e8ef546a7a134385571b8c
2024-10-30 18:07:42 +02:00
Walter Agazzi 6f20bee752 AGS: Engine: hotfix buffer size check in InputBox()
From upstream 2e282b99e92e60cd1eabe1777b053bdc593a69e9
2024-10-30 18:07:42 +02:00
Walter Agazzi 1025254465 AGS: Fix implicit warning 2024-10-30 18:07:42 +02:00
Walter Agazzi 7af9888de2 AGS: Engine: rewrote dynamic sprite change notification method
Previous existing method ran through virtually all the game objects that may reference a sprite, and
checked each one of them. Those who did reference the modified dynamic sprite were marked for
update and/or had their draw caches cleared.
Furthermore, for safety reasons, the Graphic properties of these objects were reset to 0.

This process was slow under two conditions:
- if there are alot of objects (especially overlays which may be created at runtime in large quantities);
- if there are alot of temporary dynamic sprites created and deleted per game frame (for example,
when drawing something complicated).

The new method:
1. We no longer reset object properties, this turned to be a bad design. There's another safety fix done
in the SpriteCache, which returns a placeholder sprite for any invalid sprite ID. This should make things
simpler and faster.
2. For the texture-based renderers, it turned out that updating the shared texture entries was enough
to make objects using them redraw. So for these renderers we don't need to reset any more caches.
3. For software renderer, introduced a GameState::spritemodified vector of bools. Whenever a sprite is
modified or deleted, engine sets a corresponding flag in this vector, and that triggers an update at the
next draw pass for all the objects that still reference that sprite.

GUI PROBLEM: because GUIs rendering is still different from other objects, even in texture render
mode, they are still marked for update the old way.
This should be addressed separately in the future.
From upstream 0b84a21cfb486e3a9fa03e6c2b354750742ed3fd
and 3f70782761a698a69d31af77833c05bf38eb7394
2024-10-30 18:07:42 +02:00
Walter Agazzi 8d7cca3acf AGS: Engine: fixed read_savedgame_screenshot() in case there's no screenshot
From upstream a1032d1018a86d611f8cfe1b82320d54d3553f11
2024-10-30 18:07:42 +02:00
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 5ce015027f AGS: Add const_casts, comment out unneeded bindings 2024-10-30 18:07:42 +02:00
Walter Agazzi 77c508662f AGS: Fixed "Engine: hotfix potential exception if cc_error is called during quit()"
From upstream a7416bfb473a68ad34958bcba028454565bb5756
2024-10-30 18:07:42 +02:00
Walter Agazzi 7a0876b6b0 AGS: Engine: in CopyScreenIntoBitmap support src rect for legacy letterbox
Partially From upstream 6c028465648be5afe20eef34f0e5d0955329d3dd
2024-10-30 18:07:42 +02:00
Walter Agazzi 822842d038 AGS: Engine, Common: refactor guard using set_our_eip
Remove naked our_eip usages
From upstream 9f4371ab8c2fbc9ccf41b49f7b975ebe8bc5d1b8
2024-10-30 18:07:42 +02:00
Walter Agazzi 9972dcee53 AGS: Removed unused variables in precache_view 2024-10-30 18:07:42 +02:00
Walter Agazzi bc3fb837c1 AGS: Engine: added diagnostic measurements to PrecacheSprite, PrecacheView
Partially from upstream 28d9badacd319e13684081e2752bbc5228752d31
2024-10-30 18:07:42 +02:00
Walter Agazzi d904cac0c5 AGS: Script API: implemented Game.PrecacheSprite() and PrecacheView()
Partially from upstream 76aee247b7f8ae9eff613393a18192ceab4aca9f
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 b498b14ecc AGS: Engine: save global draw method args in DrawState struct
Avoid query gfxDriver's properties all the time, instead save them once in init_draw_method() and use saved values.

From upstream db535512af65119d50ae3d6fb06c221d56f42d85
2024-10-30 18:07:42 +02:00
Walter Agazzi 1527b38a5c AGS: Engine: SpriteCache uses proper callbacks instead of hardcoded externs
From upstream 9354aaf7d105158418dfbc1ba67e75adcd9f89d4
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 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 60c4c2d484 AGS: Fix ResetDoOnceOnly registration 2024-10-30 18:07:42 +02:00
Walter Agazzi 16cb64b080 AGS: Engine: implemented proper manager for ScriptSystem script struct
From upstream 7d309dad0eaeddca1612fbaacb8cc466b672e141
2024-10-30 18:07:42 +02:00
Walter Agazzi dd43bf35d6 AGS: Engine: implemented proper manager for ScriptMouse script struct
From upstream 487acd23845fda7be5ad29b17631878b7e1a7433
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 795dacac07 AGS: Engine: inherit StaticObject managers from ICCDynamicObject
This removes an excessive separation between "static managers" and "dynamic managers",
and let use the single ICCDynamicObject interface when working with both kinds.
Simplifies RuntimeScriptValue and StaticArray classes.

Picked out most common implementation into CCBasicObject, which is inherited by
AGSCCDynamicObject and AGSCCStaticObject.

From upstream 781632881dd64af2b57b789617da15107bca9451
2024-10-30 18:07:42 +02:00
Walter Agazzi 20706c475f AGS: Engine: Complete move to new API registering
This complements the previous commits related to the upstream commit
9221ea54c1a81b9f37829d7fafc90ac2806d4eb1:
Engine: replaced script API registration with cleaner array tables
The benefits are:
1. Cleaner registration view, an array initializer instead of myriads of function calls.
2. Implicit distinction between static and object member functions based on prototype
detection, no need to explicitly pass a parameter or call respective registration function.
3. Enforced function registration for plugins, now combined with the regular registration
in one table entry, so more difficult to skip plugin variant
2024-10-30 18:07:42 +02:00
Walter Agazzi d03da04675 AGS: Common: hide GUIButton's image properties behind the get/set methods
from upstream 56659d75d0bbf31b4679be89e9b9a3bfbc259f97
2024-10-30 18:07:42 +02:00
Walter Agazzi 9c633e250e AGS: Engine: cut out DebugConsole implementation, as unusable
This "console" implementation has multiple issues, making it unusable in practice:
- saves and displays only few lines, cannot scroll back;
while multiple game messages may be printed per a single game frame;
- messages cannot be filtered at runtime;
- uses a game font of a fixed number, which in unreliable (as the font may not be suitable);

There's not much value in its code; if a new console will be wanted in the future, then it
would be best to reimplement one from scratch, but with a good planning first.
From upstream c303590efca4632fef0fb2ab3143faba6e605ba8
2024-10-30 18:07:42 +02:00
Walter Agazzi 48f18177e7 AGS: Engine: picked out SetObjectFrameSimple that does not play frame sound
From upstream 98ea0fe0c0b0d82d5caf9d085c8b6c04cdb28c38
2024-10-30 18:07:42 +02:00
Walter Agazzi 34a00ea83b AGS: Fix typos: loose -> lose
From upstream 9a51653eff376c1663f70222884d6ee672e5e7c3
2024-10-30 18:07:42 +02:00
Walter Agazzi 92d702c4ab AGS: Engine: Fix DoOnceOnly not finding any tokens
Was broken in d65935c2761ddf89d9e4270a61100cf09bdf0633
2024-10-30 18:07:42 +02:00
Walter Agazzi 178826a9d8 AGS: Engine: init few more things along the GameState struct
This fixes more variables not initialized after 5596736 .
From upstream 99db1355bf9eb00f03ff2a10d01d9f1b80363945
2024-10-30 18:07:42 +02:00
Walter Agazzi d8d4a77724 AGS: Engine: hide "screenover" vector behind interface functions
From upstream 3b049092875293b0960013910586f3adb017c862
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 ac85f7fc52 AGS: Engine: unified API assertions for view, loop and frame
From upstream 1fe83591970e6a87d1f97c8f4e2d752a3a35b301
2024-10-30 18:07:42 +02:00
Walter Agazzi 90e338e875 AGS: Common: hide Dialog::optionscripts under OBSOLETE
They are not used anywhere in Editor nor Engine, looks like a pre-2.5 feature we have no knowledge about.
From upstream bf0cab71384c6eca996143ac12e56e1af2510004
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 072a9ee824 AGS: Engine: simplified GameSetupStruct and GameState reset in unload_game()
Partially from upstream 55967364f40b53d33ccb6760dfb94335816dba29
2024-10-30 18:07:42 +02:00
Walter Agazzi 572bdbfe74 AGS: Script API: implemented Game.ResetDoOnceOnly()
From upstream 614f1808c78d183d7957249dd19b24a48b3b7836
2024-10-30 18:07:42 +02:00
Walter Agazzi 2de9c546b5 AGS: Engine: store DoOnceOnly tokens in a unordered_set
From upstream c3927ec4b225778eba98d9ab0eb1f785eb3e6c03
2024-10-30 18:07:42 +02:00
Walter Agazzi 12be21d0c6 AGS: Engine: implement eEventGameSaved
From upstream adc8d3dd48bfeb444c179e2b416057e0fca1dc45
2024-10-30 18:07:42 +02:00
Walter Agazzi ad168dbee8 AGS: Engine: added explicit functions for Speech api and GetAudioClipCount()
from upstream 45dcb946a818a65768dfa7f08f27b27a2dccffc2
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 5acc31c4ed AGS: Engine: remake LipSync arrays into std::vectors
From upstream b4f937a5c9900c0b05ef6ae2bc6051e970c2889a
2024-10-30 18:07:42 +02:00
Walter Agazzi c0cc23c570 AGS: Engine: remake ScriptGUI and ScriptDialog arrays into std::vectors
From upstream bc44a84892128250ebb08576e4640d0a2858d436
2024-10-30 18:07:42 +02:00
Walter Agazzi 076e8ea4c2 AGS: Engine: in SetSaveGameDirectory use utility FileCopy() function
From upstream cf6754cca84f6c1870a6b7315052b876cd5c8392
2024-10-30 18:07:42 +02:00