Commit Graph
43 Commits
Author SHA1 Message Date
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
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
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 815041ec6a AGS: Engine: store game's ccInstances as unique_ptrs instead
The script handling part of the engine appeared to be too fragile and dependent on
 a precise timing of **deleting** a ccInstance.
For example, restoring a saved game may execute in the midst of the call to
RunScriptFunction(), at the "post script cleanup" stage, while there are still references
to ccInstance on the engine's call stack (and few other places). If anything prevents
 ccInstance's disposal at this moment, that would in turn lead to logical errors due to
  the game scripts "instances" counting. The most outstanding consequence is that the
   script exports are kept pointing into the deleted memory and not re-registered after the save is restored.

Overall, the script handling part of the engine would benefit from a major refactor,
 with a goal to make it safe and consistent, but this is not something I might do at the moment.

From upstream 1f6abf4b678f77825c710d4ae18b57ff8f882c93
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 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 253187f4e2 Revert "AGS: Engine: store game's ccInstances as unique_ptrs instead"
This reverts commit 547cd40186876f17914f6a96261aaf5c4dfc21b4.
2024-10-30 18:07:42 +02:00
Walter Agazzi b1e7617964 AGS: Engine: store game's ccInstances as unique_ptrs instead
From upstream 1f6abf4b678f77825c710d4ae18b57ff8f882c93
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 69327ac20b AGS: Engine: fixed stackptr increment on SCMD_ADD
This fixes 338afc2
From upstream 38a9d7dae7ad7045121e2d6efa65b54a70c5f14b
2024-10-30 18:07:42 +02:00
Walter Agazzi f5c0b75160 AGS: Engine: ccInstance: replaced fixups for loop with a switch
Based on the idea by @ericoporto
This is more code lines, and looks kind of ugly, but proved to be significantly faster enough to justify this change.
Maybe there are more ways to refactor and tidy this in the future.

From upstream 9f255eab2343896928039dbca71576718f5f7380
2024-10-30 18:07:42 +02:00
Walter Agazzi 1040f79782 AGS: Engine: be able to define DEBUG_CC_EXEC explicitly
From upstream 4149d108ebf6045b823b9de96d7fe611bacfac73
2024-10-30 18:07:42 +02:00
Walter Agazzi 4f32ca32cb AGS: Engine: ccInstance: refactored to alloc arg values per opcode
Although this means more code lines, it reduces redundant variable
initialization and assertions, which may lead to slightly optimized execution.
In addition, this change makes argument read explicit, under each individual opcode.
From upstream 777cd4a4effd1c1785582e847f9fcdadef5fe7e0
2024-10-30 18:07:42 +02:00
Walter Agazzi 96ddb49fd0 AGS: Engine: ccInstance: hide DumpInstruction under DEBUG_CC_EXEC flag
from upstream 9735b097abdb58a2d17d58cbe6b45e3b66c9cba8
2024-10-30 18:07:42 +02:00
Walter Agazzi 91b699106f AGS: Engine: ccInstance: minor parameter adjustments
from upstream d9284d8c1a265f0c4b329c27dde2997f465375d4
2024-10-30 18:07:42 +02:00
Walter Agazzi f2ddfc90f5 AGS: Engine: ccInstance: cleaned up old commented code
This was an early attempt to pick out few operations into separate functions,
but IIRC this caused additional slowdown. Maybe was not done in an optimal way.
In any case, it's better to remove the old commented code, as there may be slight
differences between that and current inlined code now.
They may be recreated if necessary for another refactor. Just need to be aware of
potential performance issues, and do tests.
From upstream 961569db426af1c09c7d9da38f5f4e4a0e09b499
2024-10-30 18:07:42 +02:00
Le Philousophe 49b4c1b3c4 AGS: Revert to use std namespace
This allows to minimize changes from upstream
2024-07-08 21:37:28 +02:00
Paul Gilbert c2a476411c AGS: Move std namespace into common/std/ 2024-07-07 15:28:31 -07:00
Walter Agazzi cc6bbd1083 AGS: Engine: hotfix potential exception if cc_error is called during quit()
From upstream a64e3424f70677f9393e4f8c506f03ed628aee47
2024-04-02 23:09:17 +02:00
Walter Agazzi 1bf6a2025f AGS: Engine: improvements to the "timeout" check
* Fixed _lastAliveTs was not reset right after calling sys_evt_process_pending();
this caused events polling called continuously after timeout happened once.
* Set timeout to 60 fps (16.777 ms) instead of random 10ms.
* Do the timeout test only each 1000th loop iteration.
* Few other tiny adjustments in code.

Partially from upstream 60aaef003021fec2f75d4dc6db1b24f0b5d2be65
2023-05-14 23:04:38 +02:00
Hubert Maier e5336d1400 AGS: Correct spelling mistake
accomodate -> accommodate
2022-10-27 15:56:08 +02:00
Thierry Crozat 08db4be24c AGS: As a hotfix, restored the old way to test for hung script loops
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
2022-06-23 23:57:49 +01:00
Thierry Crozat 6f665dfe68 AGS: Test for hanging script using timeout instead of while loops
From upstream c34f0c96596f1a7814c15e7a06c2c498cb95ebfc
2022-06-23 23:57:27 +01:00
Paul Gilbert 8e55de7b77 AGS: Changed sccmd_info array from being global objects 2022-05-31 18:33:21 -07:00
Paul Gilbert 8e132f7b3f AGS: cc_error returns stack from all script threads
From upstream 9e76800d668d8d0af7d47d815e6d1b781c7601f6
2022-05-05 22:41:07 -07:00
Paul Gilbert a2a5f2575d AGS: Reorganized few cc_ headers
From upstream ea1f8b9ece69fc7c49c4d3aa7b9af51c4ca736e5
2022-05-05 22:41:07 -07:00
Paul Gilbert 480be2134b AGS: Added script instance thread stack, replacing current_instance
From upstream f3443cb7a4ae5858e5d2d28131aaf6cf138bc0ec
2022-05-05 22:41:06 -07:00
Paul Gilbert 608389c4c5 AGS: made SystemImports index an unsigned value
From upstream 30b8f4016c815f01b49398ddb697b454f1565218
2022-04-24 16:00:05 -07:00
Paul Gilbert fb52856d7e AGS: Reorder function linking steps
From upstream 0f977a56f0b1cf293f711e8380bb9ddaa54d2573
2022-03-29 21:43:59 -07:00
Paul Gilbert 19e7035ded AGS: Replaced few function params from PScript to ccScript*
From upstream 432cbd2ee9fd76f7799336a5daee690ad9609a65
2022-03-19 21:25:10 -07:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Paul Gilbert 701396361c AGS: Import of fresh codebase 2021-06-13 21:08:44 -07:00
Paul Gilbert 5650217194 AGS: Workaround for QFG2 F10 cheat key 2021-04-07 21:21:00 -07: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 f6077152d1 AGS: More standardization of int vs int32_t 2021-02-06 22:22:04 -08:00
Paul Gilbert 69b6cfab29 AGS: Move std/ folder into lib/ 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 76a2e90366 AGS: Wrapping headers in an AGS3 namespace 2021-02-06 16:37:31 -08:00
dreammaster 8026e4bb30 AGS: Run astyle formatting 2021-02-06 16:37:31 -08:00
Paul Gilbert 90ec822f76 AGS: Cleaning up header file guard defines 2021-02-06 16:37:31 -08:00
Paul Gilbert bd6a58d1a1 AGS: Adding ScummVM comment headers 2021-02-06 16:37:31 -08:00
Paul Gilbert a60d290a08 AGS: Initial addition of engine/ and shared/ folders 2021-02-06 16:37:31 -08:00