Commit graph

1627 commits

Author SHA1 Message Date
mausimus
8211a5fc25 AGS: fix DynamicSprite.Flip() to use CreateTransparentBitmap 2025-03-09 14:12:20 +02:00
Filippos Karapetis
7d9f2a175d AGS: Fix a warning in the script creation code
CreateImpl() is called with either the text or the length parameter,
thus there is no reason to set the length parameter, which is unsigned,
to -1. Therefore, using 0 for the length when a text buffer is used
yields the same result
2025-03-01 22:12:37 +02:00
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
Przemysław Romaniak
94614d19e9 AGS: Implement SoundClipWaveBase::set_speed
Calculate new sample rate based on new_speed and apply to channel
2025-01-23 21:39:53 +02:00
Hubert Maier
76210767fa
JANITORIAL: AGS: Fix typos 2024-12-25 17:08:44 +02:00
Walter Agazzi
162802ba0c AGS: Fix game.top_inv_item script variable not working (again)
This completes commit f1ce81461e
that was only partially working after the update to AGS 3.6.1
Fix #15545
2024-12-04 23:11:28 +01:00
Thierry Crozat
83eefd4214 AGS: Engine: create ccInstances wrapped in std::unique_ptr
This also fixed a potential memory leak in ccInstance::CreateEx().

From upstream 30167df0690e0a771a8eb4f14a4d6a72da526b49

Also remove unreachable code (same condition checked twice in a
function) as that caused a compilation error with the changes above
otherwise. This change is part of upstream commit
881d31966cf7600c9b5628fff4c194d628196f4a
2024-11-27 21:23:33 +00:00
Walter Agazzi
aa1d21fd5d AGS: Engine: fix Character.Animate in case called during idling
This fixes a regression after db71d92
in case Character.Animate() called during idling, and Loop number assertion is done
prior to view changing back to normal view, could cause game to error.

Pick out "stop_character_idling" function that checks idle state and releases the locked idle view.
From upstream 946fa71c9332cae98f31d8b7672a1fe7b76d46c5

Fix #15523
2024-11-27 16:45:50 +01:00
Walter Agazzi
69ba09c5fd AGS: Add two methods for handling multiscreen
For completeness, this adds functions sys_window_fit_in_display
and sys_get_window_display_index.
Practically it has no effect as in ScummVM we don't support
multiscreen and the resolution is hardcoded.

Partially from upstream 1afc61df54681ffe2fddc0d30bb2221c38a0fa79 and
b17f58d90061c3b12c9e4c04183dc59b094d66cb
2024-11-27 16:45:50 +01:00
Walter Agazzi
8d96ff3966 AGS: Engine: perform SetTextOverlay through new Overlay_SetText algorithm
The implementation of Overlay_SetText() was rewritten in aaf6144 , with a purpose of replacing
only the internal image of overlay, but not going all the way of removing/creating a new overlay
into the same slot.

In addition to the initial reasons, it became even more essential after the overlay storage
optimization (see merge commit 77b8264), as overlay system now records free ids on overlay
removal. As recreating overlay with exact same id would now require extra hacks into overlay
logic.

Unfortunately, an old SetTextOverlay() function was forgotten about, and it still doing this
remove/create way of resetting a text. This results in engine wrongly considering certain ids to
be free, while they are already taken.

This commit fixes this by making SetTextOverlay delegate to the new Overlay_SetText()
algorithm instead.
From upstream 4caf0765ef36b4ebc2fb609f99a36a56d0736255
2024-11-27 16:45:50 +01:00
Walter Agazzi
f1dcf66ad3 AGS: Engine: added AudioChannel's playback state to saves
AudioChannel.Pause and Resume commands were added back in 3.6.0,
but I forgot to write the paused state to save format...
From upstream e18091c2f32a057d4c6538b9b26e4f31ef9b6296
2024-11-27 16:45:50 +01:00
Walter Agazzi
b0cbe21288 AGS: Engine: fixed Wait function's negative time case for pre-3.6.0 API
Prior to 3.6.0 script API Wait function was treating negative values as "no time",
but since 3.6.0 it treats it as "infinite time".
Also, old engines let overflow happen when assigning > INT16_MAX values to the wait counter
(which is int16).
In the old engine this resulted in immediate timer stop, by pure accident.
From upstream 6777dad163b3f8c2678e5fc001feb15b78c36849
2024-11-27 16:45:50 +01:00
Walter Agazzi
bd66bd7e7f AGS: Add MatchesFormat method
Probably just for hardware renders, but added for completeness
Partially from upstream dcf3c2cc304f67a5f7f46259bb3dd53b4b369e5b
2024-11-27 16:45:49 +01:00
Walter Agazzi
49b7374dfe AGS: Engine: fixed FadeIn/Out() not marking screen faded if fast-forwarding
This results in post-cutscene state being different if it's skipped compared to
a normal run if a pairing FadeOut or FadeIn was not inside StartCutscene/EndCutscene too.
From upstream 14bc225fb64bef8aae56c2f791194d515d7a664b
2024-11-27 16:45:49 +01:00
Walter Agazzi
0c90054ead AGS: Engine: fixed playing transition-out effect while skipping cutscene
This is a regression since 3.6.0.
From upstream a18d94a61d698aeb4fba39330d4194ca5410d696
2024-11-27 16:45:49 +01:00
Walter Agazzi
6ec09a5e56 AGS: Engine: fixed default InvWindow not redrawn when player char changes
This is a regression since around 3.6.0, but apparently Inventory Window had always some problem
updating after SetAsPlayer is called.
In much older versions of AGS, even prior to GUI optimizations, it also did not update until player
moved mouse cursor around some interactive elements. Which probably made an impression
that it's not working without explicitly assigning InvWindow.CharacterToUse.
From upstream 0b758225a7801700a03e48fa72b733fd122ca1c9
2024-11-27 16:45:49 +01:00
Walter Agazzi
6a0da1f9c6 AGS: Engine: fix SetCharacterViewEx alignment value
From upstream e9c1c7e0477c8fe156d7e3b86e70b925535c9e2b
2024-11-27 16:45:49 +01:00
Walter Agazzi
1244fe78e9 AGS: Engine: also move frame fixup to FixupCurrentLoop()
From upstream ecf6fe02d73686651f4123fb59f8a0c1b821bea8
2024-11-27 16:45:49 +01:00
Walter Agazzi
2e2cf19168 AGS: Engine: do character loop fixup after move update
Loop fixup was introduced earlier to avoid crashes in certain old games,
and also in case users forgot to unlock a custom animation View.
But apparently I missed a case when a loop may be adjusted later on during walking update.
From upstream f04c4d7d9adff5134e48c1062b0214251797efdc
2024-11-27 16:45:49 +01: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
Le Philousophe
7cc927d73e AGS: Make NumberPtr a class instead of a union
It's illegal to reference an inactive member of a union and the types
are not layout compatible (and even not of the same size).
Instead, store every value in a integer of pointer size and cast
pointers to and from it.
This should really fix bug #13557.
2024-11-16 22:42:53 +01:00
Le Philousophe
c5bc568d41 AGS: Fix call_function signature
call_function returns from PluginMethod::operator() which returns a
NumberPtr.
Its two calls also expect a NumberPtr but the function returned an int.
This should fix bug #13557.
2024-11-15 22:39:15 +01:00
Walter Agazzi
8cbd20943e AGS: Engine: fix ypermove comparison
From upstream 9cf99a3583fcb05dd983d9ce06a513851e47dd57
2024-11-07 00:05:37 +01: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
D G Turner
b78318dbf1 AGS: Fix Usage Of Undefined Preprocessor Define GCC Compiler Warning
This is emitted if -Wundef is passed to GCC.
2024-11-03 17:28:44 +00:00
Le Philousophe
55fe1525ac AGS: Fix int vs int32 discrepancies 2024-10-31 08:53:43 +01:00
Walter Agazzi
37f8378cd6 AGS: Avoid unserializing plugins with zero datasize
This is to avoid a crash when using plugins with a stubbed unserialize method
(e.g. Controller plugin)
2024-10-30 18:07:42 +02:00
Walter Agazzi
543dff99a6 AGS: Expand info in cc_instance error logging macros 2024-10-30 18:07:42 +02:00
Walter Agazzi
dcf9cfd880 AGS: Move drawstate to globals 2024-10-30 18:07:42 +02:00
Walter Agazzi
281d798b84 AGS: Move globalDynamicStruct to globals 2024-10-30 18:07:42 +02:00
Walter Agazzi
5275aaaeec AGS: Move room_statuses to globals 2024-10-30 18:07:42 +02:00
Walter Agazzi
8d90ee9c2c AGS: Move valid_handles to globals 2024-10-30 18:07:42 +02:00
Walter Agazzi
cf3fcb8073 AGS: Move DrawFPS to globals 2024-10-30 18:07:42 +02:00
Walter Agazzi
a19929bd30 AGS: Fix operand typo 2024-10-30 18:07:42 +02:00
Walter Agazzi
6ee1a4978f AGS: Engine: expanded error messages for character being in wrong room
From upstream f1cdee7b689e6b12c14c593d1c540e2c13808554
2024-10-30 18:07:42 +02:00
Walter Agazzi
8e915febde AGS: Engine: fixed callstack not reported in case of script api errors
This was broken by 9e76800
From upstream 716a36aa0252a7481d299d4e409eed2d56239bb3
2024-10-30 18:07:42 +02: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
3e57cad5de AGS: Engine: fixed CopyScreenIntoBitmap not applying filter when resizing
From upstream f1bca5eaa7ba2f2eb1363e7198a6f9fcf3518d8d
2024-10-30 18:07:42 +02:00
Walter Agazzi
74b261a1c7 AGS: Engine: fixed walkbehind sprites not recreated after walkbehinds change
From upstream 821ee3a13a52dc6df41942f62d3f86d38f90c96d
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
99a6c04112 AGS: Engine: fixed DrawSpriteWithTransparency to keep mask pixels on conv
From upstream d6df7f5cd7f01d9852a1842babb6af5332887cef
2024-10-30 18:07:42 +02:00
Walter Agazzi
c5b8f70d65 AGS: Engine: clamp return value of get_walkable_area_at_location()
From upstream b6c425e1384665a514286b16cd14e8c9e71165bf
2024-10-30 18:07:42 +02:00
Walter Agazzi
a7a995571b AGS: Engine: reorganized code in DrawingSurface_DrawImageImpl() a little
From upstream a5f327901d5235ca2dd6a674cd47109a110bc9fd
2024-10-30 18:07:42 +02:00
Walter Agazzi
6f25625b91 AGS: Engine: simplify DrawSpriteWithTransparency()
From upstream ade4f4d066b683c39b5f771f552ae0dc1dc3a378
2024-10-30 18:07:42 +02:00
Walter Agazzi
fdab95b34b AGS: Engine: gui mouse handles accept mouse pos as arguments
* This also fixes GUI.ProcessClick, apparently it always had an issue of using mouse
coordinates instead of provided ones.
From upstream ab3561359eb23fe17ba0758741f139165eb1f13c
2024-10-30 18:07:42 +02:00
Walter Agazzi
d05eeb5dc2 AGS: Engine: get rid of the room object sorting hack, use same rules for all
The sorting of the room objects + walkbehinds used some old hack, which behavior
dependent on a "walkbehind method" setting. But this setting is now deprecated
(and software renderer does not make walk-behinds a separate object).

Instead use a custom "sprite entry id" tag to help with sorting objects with equal zorder
(baseline). This lets to use same sorting algorithm for everything.
Walk-behinds should always be sorted back in case of equal zorder, so they receive
id = INT32_MIN.
From upstream 3b195eba0aaba9765e4dbfe427a0ba980fc3a1f6
2024-10-30 18:07:42 +02:00
Walter Agazzi
f314926323 AGS: Engine: fixed GetRegionAtScreen to return region[0] for off coordinates
This is for consistency with other masks (Hotspots etc), and backwards
 compatibility.
From upstream d318f83acc6cf02c92fb4bdad9318e66fa537c19
2024-10-30 18:07:42 +02:00
Walter Agazzi
6a2d740403 AGS: Engine: fix setting Viewport and Camera sizes in game_start
1. Fixed primary viewport and camera created with zero sizes, because they are initialized before the game resolution.
2. Fixed camera's size set in "game_start" function is clamped against a room placeholder size of 320x200.
From upstream ff615af2f5c8d0ee21e6ad633930352c2621883f
2024-10-30 18:07:42 +02:00
Walter Agazzi
0c4d929d6d AGS: Engine: hotfix certain platforms to not save "warnings.log" in cwd
ScummVM restricts file operations to the savedir, so this is added for the sake of completeness.
Partially from upstream 965d4ecd11b64b7bedb5f4cfc570cc7211be5332
2024-10-30 18:07:42 +02:00
Walter Agazzi
6814c8dbe2 AGS: Engine: support loading 3.5.0 saves with mismatching "Room States" ver
From upstream 02281846f8d25041b6179617eba4bd65ffef0cc2
2024-10-30 18:07:42 +02:00