Because some things were previously updated during the
render, we also need to explicitly run these whenever we do
not update whole game, but need to keep cursor updated:
* Dialog options;
* blocking Display command
* built-in gui dialogs
From upstream e236f3ee05bb7e1e748fb050c99ba1afa564ec65
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
This is a slightly "hacky" way to fix the queued sounds
starting with a small gap after the previous sound ends.
Because of the new audio playback subsystem in AGS 3.6.0,
the clip start timing changed a little, and there appear to be
small gap, about 1-2 game frame long, between previous and
next sound in queue. The queue in AGS is not implemented
ideally, because it relies on being updated once per game
frame, rather than on an audio thread etc, but this is
something we cannot change easily right now (maybe will
reimplement whole thing later).
This commit does 2 things:
1. Sync logical channels with the audio subsystem also *prior*
to updating queue and other things (crossfade etc). This fixes
a 1 game frame queue delay.
2. Additionally, force queued clips to start 1 extra game
frame earlier, by testing current playback position of active clips.
From upstream e87e3a8d862d39cd6eaab7a6245373fba84c4f78
Apparently, this field was used to store light level of the
walkable area in pre-2.55 engines, prior to introduction of the
Regions.
In current engine, when loading games that old, this value is
copied into Regions for backwards compatibility.
While in newer games it actually stores "player character
view" override.
Renamed update_shadow_areas() into update_player_view(),
and tidied the code for clarity.
From upstream 71e7dc880b4496dd6937cec00a56f0de66137482
This fixes internal mod key counter not being reset, which
may break service key combos (alt+ctrl, and so forth).
From upstream 142e1aaa11e7de2995ddfd24c3f1df0ae6c1b072
The base class will now take care of not applying vsync when
not necessary, saving the new state, and anything else generic.
SetVsyncImpl() virtual method will be overridden by each
renderer to provide actual implementation. This also allows
setting vsync to be forced internally.
Partially from upstream 81aa25ab6af683f52ebf5a5054f59824fa8851fc
The graphic mode config has now separate options for
window size, game scaling and filter, but command line is
lagging behind, so all the scaling is still set in `--gfxfilter`.
This is a hotfix for the time being, we shall think this over in
the future, maybe introduce more args.
Partially from upstream a28160b24a2f27b59cbb12a1de358cc9ec9c19ef and
f19043d902ff9a7e7d6478f51093ef3c807dd258
Screen limits are hardcoded in ScummVM's implementation, so this function
does not really validate anything
Partially from upstream cbe729f93c9b204db41ddd1b28c455d4a98ff703
This is because of legacy AnimateObject behavior, which treated IDs >= 100
as a command to run AnimateCharacter(ID - 100) instead.
From upstream 8365802092cd3f704aecffe7d08b4d9f65f1f396
Also restored a check in System_SetVolume(), where it skipped updating a volume if the value
is the same (this was removed unexpectedly when introducing a SDL2-based audio system).
From upstream 8d1772b90105ca5b4b150bfb303781af2ceac1a0
This is a (ugly) backward compatible workaround in game_sprite_deleted().
Apparently there are few games that may rely (either with or without author's intent) on newly
created dynamic sprite being assigned same index as a recently deleted one, which results in
new sprite "secretly" taking place of an old one on the GUI, etc.
One known example is "Kathy Rain" game.
For old games we keep only partial index reset (full cleanup is 3.5.0+).
From upstream e8409920049b2a8859856d3525a8f112227df4df
Assume that SDL2 devices, custom devices, and event handling unit have prepared a correct absolute mouse coordinates, in correspondence to the mouse settings.
From upstream c63e5e93657f2e525df8f3f5390f74a31a21858d
Apparently, this is an ancient bug, but it became noticeable
now after some changes to the GUI update logic fixes and
optimizations.
From upstream e069c3f51c08c163df023157e99e14bbcefd317a
The original AGS uses a proportional stretch that preserves the
video aspect ratio, but we were doing a stretch to the full game
screen. As a result if the video and game do not have the same
aspect ratio we were losing the video aspect ratio. This could
for example be seen with the AGDI logo at the start of all the
AGDI games. The games re at 320x200, but the video are 320x160.
Before this commit the video was stretched incorrectly to
320x200.
From upstream b3f4909.
Fixes a regression from d2b0380 (86564e9 in upstream) where the extra
channel allowance was added excessively for all cases.
Fixes bug #14353 (crash in unavowed).
ags64 (and also ags32) are the name of the engine executable on Linux.
These names seems to be exclusivelly used for that OS.
Fix a bug in Zniw Adventure (GOG, Linux) due to translation path being
different between Linux and Windows.
NOTE: the code theoretically allows any object to be sorted this
way, but the problem is, the ID sequences are not shared, and
multiple object types may have same IDs.
This is something to consider in the future.
This allows to properly fixup (upgrade) RoomStatus structs
restored from a older format save in an upgraded game.
For example: game was upgraded from 3.4.0 to 3.6.0, but player
tries loading 3.4.0 save. In this situation the engine must know and
keep track of what version each RoomStatus was saved in.
This is necessary, because RoomStatus can only be updated upon
loading a corresponding room file (when entering a room). This
means that multiple RoomStatus objects will be staying in memory
not being upgraded yet, until player enters particular room.
From upstream 205232af5909e0a257494ff404f36003b004ebc4
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
In ALSoftwareGraphicsDriver:
* Save index of a currently rendered sprite batch (or none, if not inside
a render pass).
* In SetMemoryBackBuffer() don't reset virtual screen subbitmaps
unless we are outside render pass.
* In InitSpriteBatch() also test if batch's surface is subbitmap to the
current virtual screen (in case one was replaced, but batch's surface
stayed).
Partially from upstream 5dd078961020da6478347dac01dea729471333d1
This is primarily for backwards compatibility with the older plugins,
that relied only on software drawing.
Previously we added "stage screens" to the hardware-accelerated
graphic drivers (Direct3D/OpenGL), which provide a surface for
plugins to draw upon. If used, these surfaces would then be rendered
as plain sprites in 3D scene at certain place in the sprite sequence.
The remaining problem (left unnoticed) was that the surfaces which
correspond to the two room render callbacks (right after background,
and right after all objects) did not follow the room camera position and
scaling correctly (not all, tbh). This commit addresses these problems by
letting the engine to request certain size and optional position for these
"stage screens" for particular sprite batches.
Partially from upstream 2d43bffc2cb07935ae72d7c5677ad622c8b4d37e
This significantly reduces memory usage, as screens will be only
created for sprite batches, during which the plugin requested
memory backbuffer for drawing.
Partially from upstream 1b71780d6e94eca33ee3234fd138213874640ab1
This may be a temporary solution, but it's necessary, because otherwise
engine will fail later, with a seemingly unrelated error, which will
be harder to diagnose.
From upstream 902568c4eba9dba4eb762882890c6e8a308683aa
The example when this could happen:
Parser.Said("climb,get in bed");
where "climb", "get" and "bed" are dictionary words.
From upstream b633ca77076137e2402faa903f5b6fbcd3f4c3bc
I'm baffled how I did not notice this behavior earlier, but engine was
created at least 2 redundant intermediate bitmaps meant to cache
transformed sprites per each object and character on screen for
HW-accelerated renderers, - which they do not need, as they don't
use software transformations.
The resulting effect won't be too notable for low-res games with low
amount of simultaneous objects, but may be quite significant for the
high-res games with multiple large objects in the room.
From upstream cca997fe83ec5f7014677a69095a7c9ec1494cd9
Leave it with a new name as `update_polled_stuff()` only in functions
related to the game update.
From upstream 95dc139f51e704da19792e5480e69bbfe7ec27aa
Completes commit 8e77b04062d865e35bbadedce2fb7ba4971b837c.
We don't support subdirs in saves, the previous change causes some
games to be unable to save/restore
This was a silly thing to have, and actually it was not
implemented correctly, as a cam or viewport with 0th index is not
necessarily the "primary" one (set as Game.Camera and
Screen.Viewport). The logic was rather weak there anyway.
From upstream eb90cfa46251d595f8b8f8c5f29ea720d2833038
Previously Overlay.SetText was passing into CreateTextOverlay() -> Overlay_CreateTextCore() -> _display_main().
This effectively removed and recreated an overlay with different image but the same ID.
Also, previously, this method could have been only called for custom overlays in practice.
For these the script object was not touched, and kept the correct overlay reference.
The situation has changed when we let user script to access some of the internally created
overlays, such as Text and Portrait overlays created by a blocking Say command.
When these overlays are recreated, they also must be completely destroyed, invalidating any
existing script references. Hence calling _display_main() from Overlay.SetText() is no longer
acceptable, as it leads to a full overlay recreation, and possible duplication of a script
reference with two (or more) separate managed handles (this is almost like, two shared
pointers owning same object).
To fix this problem, here we replace a call to CreateTextOverlay() with manual recreation of a
textual image, and assigning a new image to the same overlay.
This does not change anything from the script's POV, as SetText method already suggests
that the overlay reference remains valid (previously only the internal object was secretly
replaced).
From upstream aaf6144e5123d36e4f04fcc6592b02ec18f869e0
This simply makes generation of the textual image a separate function that may be used elsewhere, besides creating a new message overlay.
From upstream a49550d32e9ea210e2d9b6711157251359d3c4c0
Before playing a sound clip, check that the sample rate is acceptable for the sound system.
This avoids a crash to debugger in "The Excavation of Hob's
Barrow" which contains a sound effect that gets detected
at an incorrectly high sample rate.
Was broken by dec92f05ea
(e38df03c5d1658a2c44a26ba4ee6f22663c1e701 in upstream).
Some games do not have function arg count appended to the function names in
the export table; in that case `export_args` remained uninitialized.
From upstream cdbb7a7367db57e14983015232ecc97f6a3dd212
From upstream 6a238e9cb4acda222898dd4b597cf20581b401f6
This replaces a slightly different fix we had in ScummVM. But this new
code works better and fixes bug #12949
This argument works similarily to Viewport.ScreenToRoomPoint():
if it's set to true then the function returns null if there's no
viewport under the cursor; if it's set to false it converts
coordinates through the primary viewport in such case.
From upstream 5014c502aa487d3cbdf01e99d57306f2131d4c54
Some custom engines supported Label.TextAlignment before 3.5.0 got this
added officially, except they used old alignment constants.
From upstream 46fc9bac4fa6082561a1937861b3e567ccea2cd4
The code is present but not used in ScummVM. Keeping it synchronized
with upstream might help in the future.
From upstream fcf4b76914a25daaf5a7b711b7ed287e5eaae9f6
This is mostly a cosmetic fix, as graphic mode was created successfully anyway.
But the engine was incorrectly reporting no suitable modes available.
From upstream 4399d6448c579c648fe7e0c157a6d5f1adc74a6c
This render stage overlays the room with objects and characters, but
stays within room transform, therefore will work with non-standard
viewport positions and multiple cameras.
The next closest stage is AGSE_PREGUIDRAW, which is rendered outside
room viewport. The new one fills the missing stage, lacking after the
viewport/camera update in 3.5.0.
From upstream 4ff7e14400ab81693fb64195d9ada70e979647ac
This may result in object texture not updating if the old sprite was deleted but a new dynamic sprite was created right after having same ID.
Was broken by upstream 9dffb04 in 3.5.1, and also some later changes in 3.6.0.
From upstream 7ed51861898d864902b0f61b0cb7d0acadef1fe3
This allows to fully pack InputType, KeyMod and KeyCode/MouseButton/etc in a int32:
- 8 bits (0xFF) - input type
- 8 bits (0xFF) - key mod flags
- 4 bits (0xF) - reserved (potentially for expanding mod flags, if that will be necessary)
- 12 bits (0xFFF) - KeyCode, mouse codes, gamepad buttons, etc.
Purpose:
1. Potentially allow to set keycodes + mods in an integer and assign to an integer variable/property, such as "skip key", instead of using existing "combo keys"
2. In fact, with InputType flags, this makes it possible to assign a mouse or gamepad button to the same variables.
3. Potentially allow to return keycode + mods from Wait* (currently returns only single key).
From upstream 0203e8feb73b96c501ac2439aa3fe3d6c182c8f4
* 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
Sprite Cache and Managed Objects produce a lot of entries in the log currently.
They use a macro to set if they should be on or not, but this macro may be set =0, with the intent of disabling.
Let's instead use #if when testing these macros.
Additionally
- only define DEBUG_MANAGED_OBJECTS if AGS_DEBUG_MANAGED_OBJECTS is true
- adds a new command line flag AGS_DEBUG_SPRITECACHE, which will only define DEBUG_SPRITECACHE if true
- guard indefinition through core/platform.h
From upstream e8bd58da2e09d844068dc087f1da153a693b7aa8
"Animate^7" was an intermediate API function during 3.6.0 alpha
development, and apparently there are games which used it.
From upstream eb4c0aec426c1501c84e93851e9aa31eaf8e2f27
There's one call in unload_game_file(), which should be called after
all objects that may have been provided by plugins are disposed
(fonts, managed objects).
From upstream 462cabe7353fc75f3cf70222a97028066f12f030
The timeout method introduced by 6f665dfe is not working very well and
gives "false positives", so I'll disable it for the time being.
From upstream e0edb28b6606c360a1ea3fdcc487c2b05929ed02
This code is not used in ScummVM, but since it was still there in
comments it's probably better to keep it in sync with upstream.
The code was updated in upstream 0d1034df1a0e6593e7e61bbdb75d2996b8721b14
(tidy Direct3D renderer code, remove redundant parts, etc)
and 2f04e3b81db598eb7950668ce9d88a145f796f2c
(fixed Ali3DException's message string misuse)
Fixed getting stuck in a render attempt loop, because the window
events are not being processed.
From upstream 25329949f4d4a17ea8e6ad11fc7bd0ecccdfaca7
From upstream e924778ce3f88a4c821a4eecfea8edc353a6807b
In ScummVM they were already bools, but where still assigned values
of 0 and 1 instead of false and true in some places.
* Added `[misc] multitasking=[0,1]` to config, acting as a *starting*
setting, which may be changed by runtime call to `SetMultitaskingMode`;
* Ensure multitasking mode is overridden by connected external debugger
(always on, if possible);
* Let multitasking mode work in "fullscreen desktop" gfx mode (still
disabled in exclusive fullscreen);
* Now correctly reset multitasking mode if gfx mode changes.
From upstream 9f091926e393f75c90c951f9597710bf17395332
This helps kill "hanging" scripts if user closed the window while
there's no real engine update.
From upstream a758fd6de2dccd0c948fc7f9e5b65200df902a65
Was broken by 7a1ee192e2
Fixes bug #13477 AGS: Heroine's Quest intro shows portrait bug
This old commit was trying to fix a problem in old game(s), when
character was set to a loop with no frames. In such case the old
engine would seek for the first loop with frames, starting with 0.
The condition for doing so was made incorrect though: instead of
testing simply for a empty loop, it tested for frame number being
outside of the current loop's frame range.
This broke games where e.g. some walking view's loops were shorter
than the others.
A replacement is a condition that tests exactly for an empty loop
instead. The frame exceeding a loop's frame count is fixed later
along the way, so it's not a problem here.
From upstream ac73a555d737fb3f759cc7da9eeaf488a3bdcb2f