Commit graph

3214 commits

Author SHA1 Message Date
Walter Agazzi
dc16de544e AGS: Common: Stream::Seek() returns new position
This was done for the IAGSStream in plugin api in the first iteration,
 but lost when fixing the api recently.
 From upstream e248f320074d8430f14c1c4e513e5fb120e55eb2 and
 76b49c0c7a4df46b06aebea86573999f29400809
2024-10-30 18:07:42 +02:00
Walter Agazzi
25e4c703d7 AGS: Common: fixed BufferedStream::WriteByte return value
From upstream 98db4c4527684d872d96c150fd25417514239c78
2024-10-30 18:07:42 +02:00
Walter Agazzi
ae669f262a AGS: Common: replaced few instances of non-portable "long" type
From upstream 22b54df5534bb87c63aff2b8b07774a4a3c2226e
2024-10-30 18:07:42 +02:00
Walter Agazzi
96db95c255 AGS: Engine: fix some minor warnings
From upstream 28693377db7ae242782b313717ec9c476ecaff0f
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
54d22dff15 AGS: Engine: fixed AGSPlatformDriver::GetDiskFreeSpaceMB() return type
From upstream dfdb9fb449817b3d6385d919960e3de0171cea6e
2024-10-30 18:07:42 +02:00
Walter Agazzi
41b5b9edbd AGS: Engine: sync Character's legacy name field in old Str* script functions
Detect when a legacy string function (StrCopy, StrCat, StrFormat, etc) modifies
Character's fixed-sized field, and sync that with the new unrestricted property value.

Also fixed check_strcapacity() which incorrectly use new Character field's size instead
of legacy field size after recent changes.
From upstream ad7d19232bf9d69b6060e0cb20585628a6687c9f and
e1a06c5abf2ae0dd55dedc25404f71ef8c4b2fe5
2024-10-30 18:07:42 +02:00
Walter Agazzi
d0fe6fd80e AGS: Engine: remade writing of non-fixed Character name in game saves
Done for more consistency, so long as CharacterInfo and CharacterExtras are
separated structs.

WARNING: this breaks the saves made in 3.6.1.14 (Beta 15)...

Additionally, done so that legacy scriptnames are not loaded from current saves,
since these are supposed to stay fixed throughout the game (at least unless
characters are created dynamically, which they currently are not).
From upstream c15603adface26d3ea44519f07f4992c3201ad53
2024-10-30 18:07:42 +02:00
Walter Agazzi
e487c2e657 AGS: Common: reverted an unintended function argument rename
From upstream 803abfc540a8fced1e849a60d893c03659a8daf7
2024-10-30 18:07:42 +02:00
Walter Agazzi
d94fde8d3f AGS: Common: in AssetManager replace the libs sorter struct to function ptr
Switch function ptr when priority is set, instead of checking for priority during
sorting process.
From upstream ba05c8e055b12849e99a24ffadda960b442d9f75
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
eefccd3067 AGS: Common: explicit LockSprite/UnlockSprite methods in SpriteCache
Reimplemented From upstream 8e2d2fc9329a393dcdcddbe29dd5cc7094793350
2024-10-30 18:07:42 +02:00
Walter Agazzi
b4f9385a3f AGS: Engine: fixed BufferedStream::Seek return value
It turns out our Stream's Seek return value is not defined, and not documented
either. But judging by the other Stream implementations, it was supposed to return
positive whenever there's NO ERROR, regardless of whether the position is matching
user's request.
I suppose we may also make Seek return the resulting position, similar to how some
other libs do (e.g. see SDL and .NET Framework).
From upstream 208fd913225d0732060744fa3b2377a265ad89a3
2024-10-30 18:07:42 +02:00
Walter Agazzi
d59eeaf4a6 AGS: Common: improved Stream::HasErrors(), renamed to GetError()
Renamed HasErrors to GetError.
Require this method to clear any error flags after reading them, so to actually make
this function practical.
From upstream e62e98a6cf6364d5dba5e90dd7b1ef2c96df2ce6
2024-10-30 18:07:42 +02:00
Walter Agazzi
e82e1708ab AGS: Engine: fix log of uninitialized value in gfx driver base
From upstream f45357edccd8832c17989ef5599aa520fa93a384
2024-10-30 18:07:42 +02:00
Walter Agazzi
bb55a804e0 AGS: Engine: picked voice-over token parsing to a function
From upstream ec70451d88d7bf7eae3a3f0b847e5b57e07fa54b
2024-10-30 18:07:42 +02:00
Walter Agazzi
419e2d7372 AGS: Engine: simplify display_at, and only call it for blocking messagebox
Because _displayspeech() was calling _display_at(), there happen two consecutive
calls to try_auto_play_speech().
If text contains more "&" characters that might lead to an unexpected scripting
error, or even an overriding voice-over.
Instead made _displayspeech() call display_main() directly, and simplified
display_at() to work strictly as a message box starter.
From upstream 1899fad4c4df0e2ddce7eb04699eb262e3638674
2024-10-30 18:07:42 +02:00
Walter Agazzi
47b1ac9edc AGS: Engine: fixed CharacterInfo export to script, after adding new fields
I completely forgot that script has Character array where Character struct is an array
element, not Character pointer.
This means that the registered script struct size must match.

Thankfully we already have a mechanism of dealing with these mismatches
internally, it's done by a CCStaticArray. But it must be configured accordingly

To simplify things, picked out CharacterInfoBase as a parent struct to CharacterInfo,
which contains strictly the original fields. Will use sizeof(CharacterInfoBase) when
setting up StaticCharacterArray.

From upstream 4be15565755bc54f5d8f48be0e6aebc6eee117c1
2024-10-30 18:07:42 +02:00
Walter Agazzi
8dc4dc57c5 AGS: Support extensions offset written into game data
This writes a file offset at which extension blocks are found into one of the reserved
 ints inside main game data block.
If this information is present, the engine will also preread game name and save
folder name from "v361_objnames" block. This will ensure that game name and save
folder info is correct when setting up config, as well as reporting game properties on
"--tell-gameproperties" command.

From upstream 8bf311956edf483030a2ec71c315282751a1de29
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
ead8bd6d57 AGS: Common: added game data extension for unrestricted object names
Extension "v361_objnames" contains scriptnames and descriptions for name
 fields that had fixed length in legacy format:
- Character script name and name;
- InventoryItem name;
- Mouse cursor's script name;
- Audioclip's script name and filename.

From upstream b7024c0c284d65a6cb1b7a0a8594409a0e1cd3b9
2024-10-30 18:07:42 +02:00
Walter Agazzi
8d6ba11854 AGS: Engine: add unrestricted Character name to saves
NOTE: appended this new field to the end of character save chunk for consistency.
But because the field itself is in the CharacterInfo struct, I have to pass CharacterInfo
reference into CharacterExtra::ReadFromSavegame().
This is ugly, but but should be improved when the structs are refactored into having
a distinct runtime Character class.
From upstream 5cedf554b211957d7b413a4ef7608f0748384b0e
2024-10-30 18:07:42 +02:00
Walter Agazzi
103ee6cb87 AGS: Engine: unrestricted script name an filename in ScriptAudioClip
NOTE: we still read the old fields from game data, avoid changing the
data format in the middle (in the sake of both backward and forward compatibility).
These fixed-sized values are assigned to the clip properties first.
For unrestricted values we'll have to add a data extension, appended to the end of data format.
From upstream 0aa62d14cadcb77dfcf1351a962969069c5d1796
2024-10-30 18:07:42 +02:00
Walter Agazzi
98e59c7a93 AGS: Engine: unrestricted script name in MouseCursor
NOTE: we still read the old script name field from game data, avoid changing
the data format in the middle (in the sake of both backward and forward compatibility).
These fixed-sized value is assigned to the item properties first.
For unrestricted value we'll have to add a data extension, appended to the end of data format.
From upstream cda044466a5a79d61f7b536d0b4e17f073d9bfd9
2024-10-30 18:07:42 +02:00
Walter Agazzi
478b46a340 AGS: Engine: unrestricted name in InventoryItemInfo
NOTE: we still read the old name field from game data, avoid changing
the data format in the middle (in the sake of both backward and forward
compatibility). These fixed-sized value is assigned to the item properties
first. For unrestricted value we'll have to add a data extension,
appended to the end of data format.
From upstream 3d700e3c488945945affe51924047efb9561c8d0
2024-10-30 18:07:42 +02:00
Walter Agazzi
bdb34c01cc AGS: Engine: unrestricted scriptname and name in CharacterInfo
NOTE 1: we *must* keep the old fixed-sized fields for the time being,
 for compaibility with the plugin API. Would the plugin API be adjusted
  and have direct access to a character data struct removed, then these
   fields may be removed as well.

NOTE 2: we still read these old fields from game data, avoid changing the
 data format in the middle (in the sake of both backward and forward
 compatibility). These fixed-sized values are assigned to the character
  properties first. For unrestricted values we'll have to add a data extension,
   appended to the end of data format.
From upstream  b02814b8bb3bb7a2cd00110466e2bd3047e772d1
2024-10-30 18:07:42 +02:00
Walter Agazzi
960bccaf86 AGS: Engine: removed my_strncpy() and remade check_strlen() w/o global var
From upstream 28d73ee1d4a8dfbb76c3d53ab5b62cfbed01bcd1
2024-10-30 18:07:42 +02:00
Walter Agazzi
4cdfd7ebba AGS: Engine: in cc_instance, use static_cast where possible
From upstream 13835765706f16affd1e2a43015a967a73fe04f3
2024-10-30 18:07:42 +02:00
Walter Agazzi
5549e5c0c3 AGS: Engine: cc_instance adjust for loop
From upstream e60a7411a0909b3c1b5edbdde3c8f7bf746700b6
2024-10-30 18:07:42 +02:00
Walter Agazzi
032d4e9919 AGS: Engine: in script cc_instance used const when possible
From upstream a27fae178c350451eaaa2cb1d9c46d6aa1dda67f
2024-10-30 18:07:42 +02:00
Walter Agazzi
e710697044 AGS: Engine: tidy script runner remove unused variables
From upstream 0dc1562b075cea3d2bd1c1ad1a4feafe471b2db5
2024-10-30 18:07:42 +02:00
Walter Agazzi
6789d24414 AGS: Fix improper string length calculation in string functions
Broken in 54f8b2bccec35b2c127204e6bebef674ffb6a740
2024-10-30 18:07:42 +02:00
Walter Agazzi
3995f634e9 AGS: Common: fixed pushed textual button not redrawn after mouse up
Was broken by 7989edb
From upstream 1de96521f5fece460a96814cd699c51eed49788d
2024-10-30 18:07:42 +02:00
Walter Agazzi
be382a0a0a AGS: Engine: separated BitmapToVideoMemLinearImpl for convenience
Split BitmapToVideoMemImpl into simpler BitmapToVideoMemImpl and
 BitmapToVideoMemLinearImpl meant for that "linear filter" transparency fix.
This does not seem to make things noticeably faster with non-linear scaling,
 but may make it easier to understand the code.

Also in case we'd like to remove/replace this hack someday.
From upstream 5c2129b8f176e8d95b0f26132bf1749d7dabdc29
2024-10-30 18:07:42 +02:00
Walter Agazzi
76ebe97d9e AGS: Updated build version (3.6.1.11)
Partially from upstream 72ef9111da060044c5ecae351932ba5201ed589f
2024-10-30 18:07:42 +02:00
Walter Agazzi
51de20d796 AGS; Engine: drop support of pre-3.5.0-alpha movelist format version
This version was in public pre-alpha release and stayed for 3 months
before being replaced by an updated format along with the new A* pathfinder.
From upstream ac41f53a9c40f2ceb9e3f80eb219faabfeb3da43
2024-10-30 18:07:42 +02:00
Walter Agazzi
796796e8f3 AGS: Engine: cleanup some mentions of AlignedStream
From upstream 1ba008ae8260e614d2d2506ee04a02e4dabfbfc8
2024-10-30 18:07:42 +02:00
Walter Agazzi
8964231e73 AGS: Common: completely removed AlignedStream and ProxyStream classes
From upstream 3de497d6623a177645c01822da0144376b6d08f7
2024-10-30 18:07:42 +02:00
Walter Agazzi
8b4e30fa35 AGS: Engine: hardcode alignment padding in remaining legacy save parts
From upstream b3951c9d8c8cfdd75c4a1f412735de76e1476ceb
2024-10-30 18:07:42 +02:00
Walter Agazzi
498a3cb270 AGS: Engine: hardcode alignment padding in GameState's legacy save
From upstream f8e9958f29922adde20ed16ad7135deece2a6190
2024-10-30 18:07:42 +02:00
Walter Agazzi
eca9b3d239 AGS: Engine: hardcode alignment padding in RoomStruct's legacy save
From upstream fe13f614c8e8cbe63b24602b0a781b7341e643a0
2024-10-30 18:07:42 +02:00
Walter Agazzi
bfed6e06e5 AGS: Engine: separate CharacterInfo read/write for saves, no padding
From upstream c9d48a1c8da3dbcc49d483973b8a478925ea195a
2024-10-30 18:07:42 +02:00
Walter Agazzi
aaa8ccb38b AGS: Common: hardcode alignment padding in Interaction structs
This complements a task of removing AlignedStream in favor of explicit padding read/write.
From upstream d0c2e4147bef4a53c63d9018906348464900bebc
2024-10-30 18:07:42 +02:00
Walter Agazzi
47c095545b AGS: Common: don't use AlignedStream, hardcode padding in read/write funcs
AlignedStream was used initially in attempt to automate reading legacy formats,
where structs were dumped from memory into filestream directly,
resulting in alignment padding inserted into the file format.

While using AlignedStream made working with old formats easier, this approach also has certain problems:
1. This makes extra padding in file formats implicit and non-obvious.
2. Object Read/Write functions will depend on the type of the passed stream.
3. Adding anything into Read/Write functions will also be affected by AlignedStream,
and in theory may lead to additional unnecessary padding inserted simply by keeping same serialization logic.
4. AlignedStream does not support Seek, and in general you cannot trivially skip parts of struct by skipping
or reading N bytes, you'll have to read it out step by step to keep alignment calculation working.

These concerns made me make the decision to remove AlignedStream, and restore hardcoded padding instead.
It's explicit and honest.
From upstream ffc59e82029bed4da9dd595dac015374681fd2e4
2024-10-30 18:07:42 +02:00
Walter Agazzi
db73bb6b68 AGS: Moved "antialias" config option to "graphics" section
From upstream 32958c6cb5e247c54de6c9d581beae7b2b31675b
2024-10-30 18:07:42 +02:00
Walter Agazzi
f641445c70 Common: add AGS_PLATFORM_WINDOWS_MINGW
From upstream e4440d804984313d858e10c68a76e07caaeae11a
2024-10-30 18:07:42 +02:00
Walter Agazzi
4e41e60781 AGS: Engine: store ScriptString in memory similarly to dynamic array
This potentially allows to access any metadata while passing string pointer around the script functions.

As a consequence: never wrap external buffer, always allocate your own.
From upstream 043758b1bb5116f038c5c597d17fe9524b92b3c2
2024-10-30 18:07:42 +02:00
Walter Agazzi
63b36e594a AGS: Engine: in BitmapToVideoMemOpaque() cut out "HasAlpha" branch
Handling alpha channel is meaningless in BitmapToVideoMemOpaque(),
because the whole point of this function is to produce fully opaque texture.
Alpha + opaque combination had never been a case in practice.

From upstream ead7d5974bce25d507134ec98e8c055039d00e41
2024-10-30 18:07:42 +02:00
Walter Agazzi
ed76e769c2 AGS: Updated build version (3.6.1.10)
Partially From upstream c20a5c533fd36d8f27010e81cd5cece46fcf1cef
2024-10-30 18:07:42 +02:00