* Fix forwards accepting arguments of the wrong type
CForward::ProcessArguments returns whether the arguments are valid, but
its error paths return !!SetError(...), which is true for any error
code. Mismatched arguments were therefore accepted and the forward ran
anyway, while m_errstate stayed set and made the next Execute() on that
forward fail with a stale error.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Add Call_PushInt64 and Param_Int64
Since Address became an int64, plugins can no longer pass one through a
forward or Call_StartFunction: an int64 parameter is passed as a
reference to its value, so Call_PushCell hands the callee an invalid
reference and crashes the server, and Call_PushArray hands it the heap
array instead of the value.
Add Call_PushInt64, which pushes the value with CallArgs::PushInt64 the
way DHooks does, and Param_Int64, so forwards can declare and check
64-bit integer parameters.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Move the Call_PushInt64 test to the mock testsuite
Run it in CI with the other hl2sdk-mock tests, on x86 and x86_64,
instead of as a manual test plugin.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Pass int64 arguments to legacy plugins as cells
Plugins compiled before Address became an int64, or with oldspcomp, take
an Address as a single cell and crash when handed an int64 argument.
Like DHooks, check the callee's plugin for __Int64_Address__ and pass
those plugins the low 32 bits instead, so a forward can have both kinds
of listeners.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Document how legacy plugins receive Call_PushInt64 values
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Don't downgrade int64 arguments for legacy plugins
The forward system shouldn't know about the Address convention. Code
that declares a forward parameter as an Address can handle plugins that
take it as a cell.
This reverts commits 345b0dcb4 and 78b7bc14b.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Add Param_SMAddress and Call_PushAddress
Plugins compiled before Address became an int64 take an Address as one
cell. Arguments declared as Param_SMAddress in a forward, or pushed with
Call_PushAddress to a function, are passed to those plugins as the low 32
bits, like DHooks does. Param_Int64 arguments are always passed as int64.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
* Refuse non-Address int64 arguments for plugins compiled before 1.13
Plugins compiled before SourceMod 1.13 have no int64 type, so an int64
argument can only reach them in a parameter they declared as a cell.
Only an Address has a sane value there, its low 32 bits; any other int64
does not. Report an error naming the plugin and skip it instead of
passing it a reference it reads as a cell.
oldspcomp with the 1.13 includes also declares Address as an int64 and
__Int64_Address__, so describe these plugins as compiled before 1.13.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BxFXSTjEk7Dub57XRmVfqU
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
* Build sdktools for hl2sdk-mock
The test_format script requires it.
* Fix test_format %T translation test
%T expects a client index and translation phrase as arguments, the test was passing a language id and a phrase.
It never ran due to sdktools missing on the mock srcds before.
* mocktest: Check for passing tests or exceptions too
When sourcemod wouldn't even load the tests were still green since there was no "FAIL" in the output :D
* Test 32bit x86 srcds too
* Build against MMS 1.12-dev
SourcePawn 2 supports passing the variable arguments through to another function natively.
Instead of using `VFormat` you can just call `Format(buf, sizeof(buf), fmt, ...)` directly with the ellipsis `...`.
This broke plugins using VFormat. Add a macro to transparently replace `VFormat` with `Format` calls when compiling with the SourcePawn 2 compiler to keep the plugins from complaining about a missing `VFormat`.
Preprocessor macros are not affected by `#pragma deprecated` so we cannot warn about this yet.
* Add check for client status before resetting
* Get rid of unnecessary color reset on beacon remove
* Fix firebomb/timebomb resetting color when effect was not active
* Fix firebomb toggling wrong client's active status
---------
Co-authored-by: Nicholas Hastings <[email protected]>
* Fix OOB dereference in PluginIterator methodmap (#1880)
This prevents the native from returning true when the iterator has already reached the end() of the list, which previously led to a crash when accessing the Plugin property.
* Add defense-in-depth safeguards to CMMPluginIterator
* Update PluginIterator.Next() @error documentation
Reflect the new NativeError thrown when calling Next() on an exhausted iterator.
In basebans there are 3 commands for banning: banip,addban,ban
They have required arguments for ban duration and optional arguments for ban reason. However the functions that process the arguments do not properly validate the duration and if reason is provided instead of duration, the functions just convert that string into an integer and use it as the ban duration. This usually results in a permaban with an empty reason. This commit adds a loop for checking duration chars to be numeric before converting them to an int.
In the current ongoing effort for sourcemod to fully support 64 bits, we are introducing "virtual address".
# Explanation
Because SourcePawn does not yet support a 64 bits-wide type it's been impossible for any plugins to hold addresses in regular 32-bits wide variable.
A first attempt at solving this issue was made in commit ce1a4dcac0 therein dubbed "PseudoAddress", however this turned out to be an unsatisfactory solution, as any 'high' address if offsetted could turn invalid (or outright be impossible to map).
This leaves us with three alternatives :
- New type
- Convert Address into a handle
- Virtual Address
A new type is the most destructive solution, as it entails breaking every single Address related method. While that solution is still not off the table, we're reserving it as the last attempt should this commit fail.
Converting into a handle type is a good compromise between a brand new type whilst also preserving the Address methods. However, this comes with two issues: the first being that you can no longer offset Address, the second is that we would require authors to free the handle type which will be very confusing. This will likely not be implemented.
# Virtual address
Under a reasonable assumption, we've noted that the average plugin is unlikely to play with more than 4 GB of memory; this shouldn't be too surprising as all valve games were once 32bits and therefore limited to 4GB. Assuming this stays mostly true and a plugin isn't interested with the mapped memory of lesser known modules (like soundlib or matlib), it is fair to assume plugins are unlikely to access more than 4GB of mapped memory. Working with this in mind, we map the memory the plugins are likely to access to our custom virtual address ranges (from 0 to 4Gb, the values of which can fit on 32bits variable). If any memory was missed and plugins were to try an access it later those ranges will be late-mapped to our virtual address ranges until we run out of them.
In order to use virtual addressing, whether on 32 bits or 64 bits. Plugins must now "#include <virtual_address>", as well as use the new SDKCall_VirtualAddress, SDKType_VirtualAddress, LoadAddressFromAddress & StoreAddressToAddress where it's appropriate to.