1033 Commits

Author SHA1 Message Date
Wikot235
47aa8ac3f4 Update triggers.cpp 2024-11-25 22:16:57 +01:00
samisalreadytaken
7ebb26c996 Fix OOB access on CBaseCombatCharacter::m_hMyWeapons 2024-11-22 16:38:36 +03:00
samisalreadytaken
3aad0f5245 Cleanup SquirrelVM saverestore 2024-11-21 17:24:48 +03:00
Alexander 'z33ky' Hirsch
6297d2b552 Fix ScriptHook_t initialization order
When a ScriptClassDesc_t for is initialized (SCRIPTDESC), it recursively
invokes its parents initializers in order to obtain their pHelper
member.
Initialization is only done once, so repeated initialization is skipped.
Initialization includes assignment of a vector of ScriptHook_t's
(DEFINE_SCRIPTFUNC/BEGIN_SCRIPTHOOK), which must be initialized
beforehand.
Both of these use (static) globals; Within a translation unit,
initialization order is defined to be the same as the order of
declaration. So within a translation unit we must define all
ScriptHook_t's before the ScriptClassDesc_t using them.
A problem occurs with the parent initialization though, since there is
no defined order between translation units, meaning initialization of a
ScriptClassDesc_t can happen before its ScriptHook_t's, despite being
the correct order within its translation unit.

On MSVC it seems this issue is benign. On GCC/Linux however the
initialization of a ScriptHook_t essentially cleared whatever happened
during the initialization of the ScriptClassDesc_t, meaning many hooks
simply didn't work.

This situation is remedied by delaying the initialization of the
ScriptClassDesc_t's ScriptHook_t vector to only when the constructor of
it is invoked from its translation unit. This is accomplished simply by
adding a boolean parameter to the function (GetScriptDesc()) that is
true in the global constructor invocation, and false by default
(including when doing parent ScriptClassDesc_t initialization).
When false, a valid ScriptClassDesc_t pointer is still returned, which
is all that is needed for the initialization of the child
ScriptClassDesc_t. The value of the returned pointer is a fixed memory
location, and does not change due to the delayed initialization.
The script-helper must be initialized eagerly though, for the search of
a base-class helper. This also changes the SCRIPTDESC slightly to
accommodate the eager initialization of helper instance pointer.

Fixes #244.
2024-11-20 23:02:00 +01:00
Alexander 'z33ky' Hirsch
7d78384b26 Fix scriptanimevent_t::SetOption()
The string argument refers to memory managed by the Squirrel VM. It has
no guarantee that the string will continue to exist after the hook, from
which this can be called, has finished executing.
To fix this, allocate memory to copy the string into and manage it as
needed.
2024-11-19 13:26:59 +01:00
Alexander 'z33ky' Hirsch
8e8bdfc371 Optimize void return in squirrel function call stub 2024-11-19 13:26:58 +01:00
Alexander 'z33ky' Hirsch
1ecaa44c49 Release ScriptVariant_t memory in all paths of squirrel function stubs 2024-11-19 13:26:56 +01:00
Alexander 'z33ky' Hirsch
c0e12a2f58 Add type check for script helper assignments from ScriptVariant_t 2024-11-19 13:26:23 +01:00
Alexander 'z33ky' Hirsch
cbb60e1afd Remove VScript Squrrel arithmetic operator helper
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.
2024-11-19 13:26:22 +01:00
Alexander 'z33ky' Hirsch
a2e43a567f Fix (potential?) memory leaks from getVariant() (SquirrelVM)
Free values before assignment.
2024-11-19 13:26:22 +01:00
Alexander 'z33ky' Hirsch
fe82da8f1b Remove unused generic ScriptVariant_t::{Get,AssignTo}()
They wouldn't even work.
2024-11-19 13:26:22 +01:00
Alexander 'z33ky' Hirsch
99858e63f7 Optimize squirrel function_stub() Vector/QAngle return 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. mapbase-source/source-sdk-2013#321
2024-11-19 13:26:19 +01:00
Alexander 'z33ky' Hirsch
879b9e8d25 Fix dubious ScriptVariant_t Free()'s
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.
2024-11-15 15:38:09 +01:00
Alexander 'z33ky' Hirsch
80f19601ee "Fix" ScriptVariant_t::Free()
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.
2024-11-15 15:38:08 +01:00
Alexander 'z33ky' Hirsch
696036219e Prevent signed overflow (UB) in SquirrelVM::GenerateUniqueKey() 2024-11-13 00:25:51 +01:00
Yui
337b58eb3c
Don't network info_null
Reduces potential for entity limit crashes, as it still exists for the first tick.
2024-09-09 10:33:07 -04:00
samisalreadytaken
ead5668dc8 Fix GetPropVector return type 2024-09-07 16:42:37 +03:00
Alexander 'z33ky' Hirsch
359fcb7196 Ditch attempts trying to obtain sound duration of MP3s
Crashes on Linux. Apparently returns incorrect values on Windows.
2024-09-05 23:45:20 +02:00
Alexander 'z33ky' Hirsch
a999c794f7 Fix minor case of const-correctness 2024-09-05 23:44:50 +02:00
Alexander 'z33ky' Hirsch
df6adcc5e9 Fix -Wdelete-incomplete in CDefaultCustomWeaponEntityFactory::ReleaseData()
GCC warns about attempting to delete a void-pointer, since it will not
be able to invoke its destructor. Fix by casing it to the expected
type.
2024-09-05 23:42:16 +02:00
Alexander 'z33ky' Hirsch
e9c45e5235 Implement GetColorForSurface() failure workaround
This function is used to color impact particles.
On Linux I've noticed that this function sometimes is not successful on
retrieving the surface color, leaving an odd color to render the
particles with. The engine function TraceLineMaterialAndLighting() even
has a boolean return value indicating success.
GetModelMaterialColorAndLighting() does not though, but I still observe
failures (the color parameter is not modified). The color is initialized
with an invalid value. If it detects that retrieving the color failed
(engine function said so or the invalid value was left in place), this
now hamfistedly assumes a lightish grey color, but at least still
correctly (presumably) incorporates lighting information.
When this situation is detected, a warning is also printed to the
console. Because why not.
2024-09-05 23:35:46 +02:00
Alexander 'z33ky' Hirsch
c9dd357470 Prevent return of dangling Vector/QAngle to VScript
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.
2024-09-05 23:24:06 +02:00
ALLEN-PC\acj30
abeb035d29 Playermodel legs and other player anim improvements 2024-09-01 01:44:50 -05:00
ALLEN-PC\acj30
309f8019dd Choreography-driven sentence system 2024-08-31 16:13:09 -05:00
ALLEN-PC\acj30
4a701c8bcc Rename singleplayer animstate to Mapbase player animstate 2024-08-10 14:14:14 -05:00
ALLEN-PC\acj30
5d50335c02 New "Destroy" input for func_combine_ball_spawner 2024-08-10 13:51:06 -05:00
ALLEN-PC\acj30
102c7c3015 New "StopActionLoop" input for scripted_sequence 2024-08-10 13:49:19 -05:00
ALLEN-PC\acj30
06596695a3 Fix filter_activator_model issues with save/restore and null activator 2024-08-10 13:48:48 -05:00
ALLEN-PC\acj30
178a262032 Add VScript function for checking last hit group on CBaseCombatCharacter 2024-08-10 13:47:53 -05:00
Wikot235
4f14f0c5cc Fixed the issue. 2024-08-07 13:16:37 +02:00
Wikot235
a736b0f96a Added new spawnflag 2024-07-28 14:11:06 +02:00
Wikot235
41233cb475 Added Melee attack keyvalue 2024-07-27 23:49:31 +02:00
samisalreadytaken
26346bab5c Don't save/restore squirrel class attributes 2024-06-29 18:18:54 +03:00
samisalreadytaken
77f645980e Fix string allocation in SquirrelVM::ReadObject 2024-06-29 18:18:17 +03:00
ALLEN-PC\acj30
5cf63d4eb6 Spotlight "Ignore solid" keyvalue from MP branch 2024-06-28 16:09:37 -05:00
Wikot235
cd6ec90a0f Fixed the issue. 2024-06-24 23:42:07 +02:00
Bronzehawk75
4e7f6338e2
Merge branch 'mapbase-source:develop' into develop 2024-06-22 14:36:47 -04:00
ALLEN-PC\acj30
73988dcc7c Fix maps with multiple sky_cameras not using the correct sky_camera after loading a save 2024-06-22 02:33:19 -05:00
ALLEN-PC\acj30
33e047a442 Primitive chromatic aberration effect for env_screeneffect 2024-06-22 01:44:20 -05:00
ALLEN-PC\acj30
24f3656632 Add capability to +USE serverside ragdolls and toggle cleanup of individual ragdolls 2024-06-21 18:22:04 -05:00
azzy
a49cff34f9
Fix vertex blend swapping in Hammer for SDK_LightmappedGeneric
Out of bounds array index corrupting the stack
2024-04-27 04:31:21 +03:00
SanyaSho
41becf1dc5 vgui_controls: RichText: restore text selection code from 2007 SDK 2024-04-21 12:20:09 +03:00
arbabf
2c001ff259 Change RANDOM_CRAB_TYPE to -1 2024-04-13 16:10:01 +10:00
arbabf
f370074d10 Fix spacing to be more consistent 2024-04-13 00:46:36 +10:00
arbabf
2113410f80 Add random spawn type for env_headcrabcanister 2024-04-13 00:43:14 +10:00
ALLEN-PC\acj30
471a840ed9 Fix soundlevel_t compile error on VS2013 2024-03-09 02:13:59 -06:00
Blixibon
7f0aec4371
Merge pull request #250 from mapbase-source/develop
Mapbase v7.2
mapbase-v7.2
2024-02-25 15:48:08 -06:00
ALLEN-PC\acj30
6bd9bcba5d Increment version numbers to v7.2 2024-02-24 21:19:52 -06:00
rlen
f86a967af2
Merge branch 'mapbase-source:develop' into develop 2024-02-19 21:46:36 +09:00
rlen
f484aa7ebc removed pullDir parameter from OnPhysGunPull 2024-02-19 21:46:04 +09:00