Commit Graph
53 Commits
Author SHA1 Message Date
Walter Agazzi 5ce015027f AGS: Add const_casts, comment out unneeded bindings 2024-10-30 18:07:42 +02:00
Walter Agazzi 87c0bcdf7f AGS: Engine: fixed CharacterInfo breaking script compatibility again
This fixes a mistake introduced in commit 4be1556, which in turn followed b02814b

The problem is, that CCStaticArray does not work as intended, and seems won't (at
least not without some extra workarounds).

When the script compiler is told to get an Nth element of a global struct array, such
as character[n], it calculates the memory address as
    Character* ptr = (array address + sizeof(Character) * n).
If this address is used for the read/write operations, these ops can be intercepted by
interpreter and remapped into the real fields (see IScriptObject::ReadN, WriteN
interface).
But if this address is used IN POINTER COMPARISON BY VALUE, then we cannot do
anything. And if our real struct in the engine is stored on a different relative memory
offset than one expected by compiler, then this pointer comparison will fail.
This breaks script expressions like e.g.:
      if (player == character[n])
From upstream 97ed18e95b587544ae47497f0a5f1d1ba00a7e29
2024-10-30 18:07:42 +02:00
Walter Agazzi 31d95ec1e3 AGS: Engine: fixed pointer math in check_scstrcapacity, commit_scstr_update
This fixes ad7d192
From upstream 9cc72e49301120fc2e1a8bd672cc1328f7e5a600
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 bb55a804e0 AGS: Engine: picked voice-over token parsing to a function
From upstream ec70451d88d7bf7eae3a3f0b847e5b57e07fa54b
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 6789d24414 AGS: Fix improper string length calculation in string functions
Broken in 54f8b2bccec35b2c127204e6bebef674ffb6a740
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 c00522563a AGS: Engine: store ScriptUserObject in memory similar to DynamicArrays
I realized this recently that SUOs were not registered in the script exports
properly. In AGS standards the object having a memory buffer should
register that buffer's address directly, so that it could be read and written
to directly. That is how strings, arrays, and any other structs are exported.
This also how the engine plugins can access the data if they use script API
to retrieve it.

There have not been any script API working with custom structs earlier,
but there is since 3.5.0 (few functions returning managed Point struct).
Plugins won't be able to use them correctly without this fix.

From upstream 9658c71528676acb386e2c638e782cc4e7d2afe5
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 cec77078f6 AGS: Convert several files to new API registering 2024-10-30 18:07:42 +02:00
Walter Agazzi c05a1c4134 AGS: Engine: apply text direction based on guicontrol flags and game version
* If controls have "translated" flags
* For Buttons and ListBoxes: if game is >= 3.6.1
2024-10-30 18:07:42 +02:00
Walter Agazzi a90e5b7dd7 AGS: Engine: added missing exclusive variadic api impls for plugins
from upstream a61392135e734898b93d73db42942dc881250ef2
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 86f8ab5bef AGS: Engine: use usetc instead of manual check of get_uformat()
From upstream 3f109d2aa2195656d6ae04a751a0b58c71acd198
2024-10-30 18:07:42 +02:00
Paul Gilbert c2a476411c AGS: Move std namespace into common/std/ 2024-07-07 15:28:31 -07:00
Walter Agazzi 64edc1cdc2 AGS: Engine: restored faster String.Chars and Length variants for ASCII mode
The purpose is to at least keep string iteration relatively fast in ASCII
game mode, for backwards compatibility.
Also fixed String.Length for plugins in Unicode mode.
From upstream 052def762633796b5565fd0e79295392e5e43b52
2023-11-02 20:06:27 +01:00
Le Philousophe ab0854d81a AGS: Don't use unsafe sprintf and vsprintf 2022-10-23 22:46:19 +02:00
Le Philousophe 7f90669bdd AGS: Don't use unsafe strcat and strcpy 2022-10-23 22:46:19 +02:00
Paweł Kołodziejski 9b95bfd218 AGS: Silence const casts 2022-05-30 16:38:11 +02:00
Paul Gilbert b1649597d7 AGS: Replaced Math/std Min/Max with ScummVM macros
Inspired by 6dee5ee6f271c600e30879d892295ea6069e8cc9
2022-05-05 22:41:10 -07:00
Paul Gilbert 63c42d42c3 AGS: Fixed ScriptString could be serialized with wrong length
From upstream c00be4f9ee9501aebb0abc81ebbe5b4f2ffb0c0c
2022-05-05 22:41:09 -07:00
Paul Gilbert 0e0063bb6b AGS: String.AppendChar, ReplaceChar, Chars[] support unicode
From upstream 072ed5716639e2b65a16037dd81e2a332a78611b
2022-04-13 21:55:19 -07:00
Paul Gilbert 094879ed48 AGS: Fix some remaining MAXSTRLEN to point to Globals 2022-03-23 20:30:46 -07:00
Paul Gilbert dc3ce9f70a AGS: Renamed few font functions for consistent naming style
From upstream 9c355da410b734edc79212009a5e1be0b502c3b0
2022-03-22 22:30:13 -07:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Paul Gilbert 0274540d47 AGS: Implement remaining plugin core export classes 2021-07-17 15:52:11 -07:00
aviloria 09ed7592bd AGS: Pointers should not be casted to long
New string arithmetic is using pointers diff casted to long...
Trying to avoid C++11 features, the best option is to cast them to intptr_t instead of long
2021-07-11 20:41:39 -07:00
Paul Gilbert 0084d53aeb AGS: Another gcc warning fix 2021-07-11 20:34:43 -07:00
Paul Gilbert 9c909afd10 AGS: gcc warning fix 2021-07-11 20:18:45 -07:00
Paul Gilbert 656659d488 AGS: Unicode-aware script String API implementation
From upstream f658f6316dd562b28e8b206f3ef3cedebf3626c0
2021-07-10 14:33:36 -07:00
Paul Gilbert f1711431f6 AGS: Unicode-aware line splitting and right-to-left text mode
From upstream 00fee7e61e5746fe3c8722028f4f497b1949559e
2021-07-10 14:33:35 -07:00
Thierry Crozat 5745ea1cfb AGS: Fix compilation with precision loss when casting pointer to long 2021-06-14 14:14:43 +01:00
Paul Gilbert eb1e337edd AGS: Removed String's "const char*" conversion operator
From upstream 7c426674e7e53bffe9120f8ffc059b77fa03a606
2021-06-13 21:08:59 -07:00
Paul Gilbert 701396361c AGS: Import of fresh codebase 2021-06-13 21:08:44 -07:00
Paul Gilbert a18be9c938 AGS: Move miscellaneous engine/ac/ globals to Globals 2021-03-12 21:30:58 -08:00
Paul Gilbert 81976cb994 AGS: Move dialog.cpp globals to Globals 2021-03-08 19:22:34 -08:00
Paul Gilbert 34c86ce1a1 AGS: Removal of commented out includes 2021-03-06 19:43:13 -08:00
Paul Gilbert 887472c8c1 AGS: Moved a lot of game.cpp globals to Globals 2021-02-28 13:27:21 -08:00
Paul Gilbert 334b2a9d48 AGS: Move play to Globals 2021-02-27 15:31:34 -08:00
Paul Gilbert 1a8ae27b58 AGS: Move game & spriteset into Globals 2021-02-26 21:28:53 -08:00
Paul Gilbert cd017a73c7 AGS: Revert Standardization of number types
This reverts commit a96422af52.
2021-02-16 19:45:02 -08:00
Paul Gilbert a96422af52 AGS: Standardization of number types
This not only simplifies all the use of _t types to the
ScummVM equivalents, it gets rid of the int32 usage in
favor of just int, solving common type clashes with the
Amiga, for which int doesn't match int32
2021-02-13 11:38:55 -08:00
Paul Gilbert 03c7491e18 AGS: Fix compilation of VS 64-bit builds 2021-02-06 16:37:31 -08:00
Paul Gilbert 1b86461eda AGS: Fix const warnings in macro expansions 2021-02-06 16:37:31 -08:00
Paul Gilbert 739c02d5c0 AGS: Fix a bunch of warnings about const loss
Some of these are legitimate, because the AGS source did some
nasty code sharing a char * buffer for both reading and writing
stuff to savegames. Will need to refactor it at some point to
use the Common::Serializer
2021-02-06 16:37:31 -08:00
Paul Gilbert c51cc1dd76 AGS: Add missing files from engine/ac/ to project 2021-02-06 16:37:31 -08:00
Paul Gilbert fe46be9223 AGS: Added engine/ac/ folder 2021-02-06 16:37:31 -08:00
Paul Gilbert 9a78e04039 AGS: Beginnings of engine/ inclusion 2021-02-06 16:37:31 -08:00
Paul Gilbert a7a9ca0543 AGS: Adding AGS3 namespace to cpp files 2021-02-06 16:37:31 -08:00