Skip to content

Conversation

@Blixibon
Copy link
Member

@Blixibon Blixibon commented Jun 1, 2025

Large update with a focus on player model support, VScript fixes, and a new generation of saves.

After Mapbase mods started getting released on Steam (e.g. Entropy : Zero 2), preserving existing saves after updates became a major concern. This led to some important changes being put off due to perceived or confirmed lack of save compatibility, most notably #221, which fixes save/restore issues that have severely undermined Mapbase's singleplayer VScript since it was first released.

Mapbase v8.0 is the first update since v7.0 that definitively breaks saves, and it does so by design. This means there are much larger changes included here compared to the last few updates.


samisalreadytaken and others added 30 commits December 5, 2022 14:01
On every save on a load, these functions would keep reference to their old versions
from the previous save which kept stacking up on each load-save
When a Vector or QAngle rvalue reference is returned from a VScript
function, the constructed ScriptVariant_t must not store the pointer to
it since it is, per convention, a temporary reference. Only do that for
lvalue-references, but do a copy when constructing from or assigning a
rvalue reference.
Type FIELD_HSCRIPT is removed, it never sets SV_FREE.

All dynamic memory is now free`d via free(). For strdup(), this would be
the conformant way in standard C++. It matters not in Source, since both
use the same global allocator of the engine, but it is tidier.
Vector and QAngle are now allocated via malloc() instead of new to
provide symmetry.
When assigning a null value in getVariant(), make sure a previous
SV_FREE is not carried over.

In SqurrelVM::ReleaseValue(), make sure SV_FREE is not kept after
Free()ing a value.
Instead of temporary allocating dynamic memory, which subsequently is
copied into another dynamically allocated piece of memory, provide a
temporary buffer on the stack.
The script value inserted into the VM still needs to allocate
dynamically though...

A few sites are adapted to not create a ScriptVariant_t from a temporary
Vector to avoid dynamic allocation there too.

cf. #321
They were broken, and only add for Quaternions was implemented, for
which there is a working QuaternionAdd() script function instead.
Fixing it seems like unnecessary work.
Blixibon and others added 25 commits June 3, 2025 09:48
… has userpointer type

This prevents memory errors when incorrectly invoking native member
functions from Squirrel.
…on call

This enhances the ScriptFuncDescriptor_t to record the ScriptClassDesc_t
of the class for which it gets invoked.
The ScriptClassDesc_t are traversed in the function_stub() for native
function calls for member functions, to ensure the passed in instance
has a compatible type.
This prevents memory errors when incorrectly invoking native member
functions from Squirrel.
This prevents manual invocations of the Vector.constructor with an
invalid value.
…meters

This prevents manual invocations of the native class constructor for
non-class values or non-native classes.
This prevents manual invocations of the native class constructor with an
invalid value.
The function_stub() resets it when used.
Also streamline SQUserPointer usage in sq_getinstanceup() and
sq_getuserpointer() calls to write directly to a pointer of the expected
type.
vscript saverestore and debugger fixes
Fallback if IScriptInstanceHelper::Get/Set are not implemented
@Blixibon Blixibon marked this pull request as ready for review July 27, 2025 18:13
@Blixibon Blixibon merged commit 6cc2937 into master Jul 29, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment