Commit Graph
550 Commits
Author SHA1 Message Date
BotoX e5fed0051b Fix GetClientCount(false) 2024-06-09 17:45:27 +02:00
BotoX 19019d3a4b Extend function calling API for natives and allow catching exceptions.
Change sourcepawn url.
2024-06-09 17:34:33 +02:00
BotoX 1d999c3984 Added hack to make plugins open a menu with all possible targets on ReplyToTargetError COMMAND_TARGET_AMBIGUOUS.
Explanation:
There are two clients in the server, one named gene, the other one "Ene ~special characters~".
An admin issues "sm_slay Ene" and gets following error message: More than one client matched the given pattern.
What this hack will do is: Use GetCmdArg(0, ...); to get the command name "sm_slay".
Use GetCmdArgString(...); to get the arguments supplied to the command.
Use GetLastProcessTargetString(...); (which was implemented in this commit) to retrieve the arguments that were passed to the last ProcessTargetString call.
It will then pass this data to the DynamicTargeting plugin through its AmbiguousMenu native.
The plugin will open up a menu on the client and list all targets which match the pattern that was supplied to ProcessTargetString.
If the client selects a menu entry, FakeClientCommand will be used to re-execute the command with the correct target.
2024-06-09 17:33:16 +02:00
BenoistandKenzzer 11d3cf94f7 Add GetFilePermissions (#2177)
Co-authored-by: Kenzzer <[email protected]>
2024-06-08 14:17:50 +00:00
BenoistandKenzzer 4e73713fab Fix rare crash with logs (#2161)
* Fix rare crash with logs

* Nullcheck instead

* Update smn_filesystem.cpp

---------

Co-authored-by: Kenzzer <[email protected]>
2024-05-24 13:10:24 +02:00
e07c120cab CDetour safetyhook (#2162)
* Add safetyhook, remove libudis86

Co-authored-by: bottiger1 <[email protected]>

* Add modified CDetour

Co-authored-by: bottiger1 <[email protected]>

* Add CDetour [Safetyhook] to build script

* Re-enable loader/core/corelogic, and fix new C++20 error

* Reenable all extensions (except dhooks)

* Make cstrike compile against new CDetour

* Remove unused variable in sdktools output?

* Make sdktools compile against new cdetour

* Downgrade to C++17

* remove auto

* fix compilation on linux

* Re-enable dhooks

* Re-authorise old compilers

* Fix invalid downgrade of std::optional

* readd libudis86 for dhooks only

---------

Co-authored-by: Kenzzer <[email protected]>
Co-authored-by: bottiger1 <[email protected]>
2024-05-21 01:53:44 +00:00
rtldg 908ffdb523 make RenameFile() on Windows also replace the file (#2060)
* make RenameFile() on Windows also replace the file

* Add MOVEFILE_COPY_ALLOWED to MoveFileExA
2024-05-05 22:20:46 +00:00
Adrian-Stefan Mares af93d819c6 Handle INVALID_FUNCTION mismatches at plugin boundaries, redux (#2136) 2024-04-19 21:56:48 -04:00
Peak 5c507cc35c Implement File.Size (#2131)
* Implement file size method for already open files

* Switch from fseek/ftell to fileno/fstat size reading
2024-04-13 18:14:52 +00:00
Nick Hastings e6a04abc9e Remove unused var 2023-11-20 09:21:00 -05:00
David Anderson 7bfd5e521e Update SourcePawn.
This updates float.inc and smn_float.cpp to compensate for alias
removal.
2023-11-03 17:46:48 -10:00
David Anderson 060c832f89 Update SourcePawn.
This brings in a few breaking changes.

One, INVALID_FUNCTION is now 0 instead of -1. This is long overdue.
Plugins should transparently work except in two cases:

  1. Third-party extensions that have a hardcoded test for -1 will no
     longer work. A new API has been provided for this,
     GetFunctionByIdOrNull.
  2. If a plugin "framework" uses INVALID_FUNCTION anywhere in its
     exported API, then all plugins using that framework need to be
     recompiled together, so they agree on the value of
     INVALID_FUNCTION.

Hopefully the damage here is minimal. The core plugin version has been
bumped to 7 to try and limit conflicts.

Second, braceless functions are no longer supported. There wasn't really
any way around this and it's better to bite the bullet now. This affects
source compatibility, but not binary compatibility.

Third, the "using" keyword is no longer implemented. SourceMod now has a
Handle methodmap again. Plugins compiled against this new methodmap will
require a "Handle.~Handle" native, which 1.12 now provides.
2023-11-02 18:38:30 -10:00
Mikusch 29694ec13b Add block parameter to various ArrayList functions (#1656)
* Add block parameter to FindString

* Add block parameter for GetString & GetArray

* Fix buffer overflow issues

* Fix wrong return

* Add size parameter to SetArrayString
2023-09-27 16:05:43 +02:00
Mikusch 1e8db957bf Add more functions to ArrayStack (#2019)
* Add more functions to ArrayStack

* Make formatting consistent with other functions

* Don't remove the element for TopArray

* Replace 4 with sizeof(cell_t)
2023-09-27 15:43:04 +02:00
Nick Hastings 4c376cbcb7 Update PLAPI version for NormalSHook signature change (MAXPLAYERS increase) 2023-07-27 08:15:02 -04:00
Corey D 5addaffa56 Add ParseTime (strptime) native (#1697)
* Add GetTimeStamp (strptime) native

* Fix description

* Fix typos

* Fix issues

* Rewrite ParseTime

* Fix docstrings

* Fix ParseTime

* Clarify docs
2023-07-04 13:42:45 +02:00
Mikusch 5539484f92 Add support for float modulo operator (#1953) 2023-03-19 16:19:42 +00:00
Nicholas Hastings 30a2160839 Fix gamedata library search order in some cases. (#1914) 2023-01-29 20:24:34 +00:00
Nicholas Hastings ecb707e38d Add support for other engine binaries in game configs (#1414). (#1626)
* Add support for other engine binaries in game configs (#1414).

* Add engine bin path for CRC bin lookup and filter out addons from GAMEBIN.

* MAX_PATH -> PLATFORM_MAX_PATH.

* Fix library lookup on Linux.

Before this, there was a bad assumption that, like on Windows, POSIX module
handle pointers were within the module's address space (and thus usable
with dladdr). That's not true!

Instead, to get a usable address on all platforms, we'll do a lookup of the
CreateInterface function that exists in all modules. This also has the
(arguable) benefit of further locking this implementation to modules owned
by the game.

To get a valid address inside the module now on both p
2022-12-28 22:58:30 +00:00
clague 0d6179299c Fix ReadMapList ignoring file's last modified time (#1891) 2022-12-20 21:26:57 +00:00
nosoop 6c5a3fdaf2 entitylump: Output separator as spaces instead of tabs (#1873)
On NMRiH and possibly other games that use the Maphacks system,
entries that are modified using that system are rendered with tab
characters stripped out - see CNMRiHMapHackManager::GetEntDataString.

That results in there being no separators at all between keys and
values, as Maphacks receives the serialized string from Entity Lump
Manager.

This commit changes the key / value separator character to use
spaces instead.

This discovery upsets me greatly.

Fixes #1833.
2022-12-05 13:14:54 +01:00
Corey D 5d391fda07 Add SMCParser.ParseString (#1817) 2022-12-02 16:55:08 +01:00
nosoop 34c8220e5d Ensure gameconfig file uniqueness when reading master.games (#1859)
The extended gameconfig format reads the master gameconf file twice;
once each for the base engine and actual engine.  The file list
isn't checked for duplicates, so 'common.games.txt' is loaded in
twice, resulting in any 'common' file values potentially overriding
values listed under '#default' in other files due to
bShouldBeReadingDefault.  This happens in the case when matching
game versions by CRC (such as public game branches).

Required for #1857.
2022-11-25 16:47:11 +00:00
nosoop 855ece1d3b entitylump: Fix behavior of append (#1836)
This change ensures that the iterator values used by `std::distance`
is correct.  Having the emplace within leads to the possibility of
`m_Entities.begin()` being invalidated due to reallocations.
2022-09-20 16:24:08 +02:00
Vauff 568da23c96 Allow gamedata to use vscript binary (#1826) 2022-09-20 09:46:03 +02:00
nosoop 21740d9a26 Add functions for working with entity lumps (#1673) 2022-09-05 15:44:58 -07:00
Vladimir 3100e23b87 Add support for gamedata lookups from soundemittersystem library (#1787)
* Add `soundemittersystem` library to game config signatures

* Remove `GAMEBIN` by `soundemittersystem` module load
2022-08-04 16:32:26 +02:00
Corey D 9321229321 Add GetClientOriginalLanguage (#1810)
Creates a native which will return the language the client connected with.
2022-07-28 18:10:51 -07:00
Deathreus 37c2a83523 Add a PluginIterator methodmap (#1779)
* Add a PluginIterator methodmap

* Follow convention

* Update sourcemod.inc

* Turn method ReadPlugin into property Plugin

* Requested change

* Update sourcemod.inc

* Curse you VSC

* Follow behavior of other iterators instead of the natives

* Fix a stray space

* Implement a hacked CPluginIterator

* Oops

Copy paste go brr

* Revert a change made before the custom impl
2022-06-24 11:46:03 +02:00
Headline c570150318 Lift raw pointers out of DatabaseConfBuilder (#1637)
* Lift raw pointers out of DatabaseConfBuilder

* Maybe: not
2022-05-24 11:41:15 +02:00
James Dickens 9df93b0708 Fix Int64ToString producing incorrect output (#1723) 2022-03-04 03:03:35 -08:00
peace-maker f7c54e9027 Fix silent error on large ArrayList startsize (#1705)
If there isn't enough memory to resize the ArrayList to the startsize on construction, throw an error instead of ignoring the OOM.

Fixes #1551
2022-01-31 22:07:32 +01:00
Corey D c471e41dc7 Add ArrayStack.Clear native (#1676) 2022-01-22 03:26:21 -08:00
David Anderson 351ac171d2 Merge branch 'fix-menu-vote-handler' 2021-12-09 18:13:30 -08:00
David Anderson 96c74651db Fix vote menu handler to work with direct arrays. 2021-12-09 18:10:35 -08:00
Adrián 4e4c2a7bb0 menusys: Correct GetMenuExitBackButton returncode (#1646) 2021-11-20 16:52:40 -08:00
peace-maker 1c30b88069 Cache copy of library on first symbol/signature lookup (#1642)
Always perform signature searches on an unaltered copy of the binary. This avoids signature mismatches if the same function is detoured twice and thus the first bytes of the function were replaced by the detour.
2021-11-18 17:55:32 +01:00
David Anderson 31f6c0cb18 Dedent some menu code for readability. 2021-11-17 18:19:40 -08:00
Adrián 18f9d65938 Fix translations getting truncated prematurely (#1640) 2021-11-16 16:09:30 +00:00
Nick Hastings f229badbfc Fix server binary name for CRC lookups. 2021-11-01 13:04:23 -04:00
Nick Hastings 9a6866d14a Invert CRC to match most popular implementations. 2021-11-01 13:04:23 -04:00
David Anderson 94ff26bdf1 Fix error return of FormatNativeString. (#1613) 2021-10-26 22:31:58 -07:00
David Anderson 2a06680252 Update to the new SourcePawn compiler.
This imports the brand new SourcePawn compiler. The new compiler is much
faster to compile and generates significantly improved code around
array generation and array access.

There are a number of compatibility changes in the new compiler. Most of
these are due to improved type checking and error detection. The full
list of notes can be found here:

https://github.com/alliedmodders/sourcepawn/blob/master/docs/upgrading-1.11.md

Additionally, .smx files generated by the new compiler will NOT load on
earlier versions of SourceMod, including earlier versions of 1.11. Old
plugins will continue to load as normal.
2021-10-26 17:45:48 -10:00
David Anderson cab60f7385 Bump handle limit to 1MB.
This bumps the handle bits to 20 and reduces the serial/cookie bits to
12. A warning is emitted if a single owner creates more than 100k
handles.

Tested on mock srcds with sm_dump_handles.
2021-10-26 07:05:34 -10:00
Nick Hastings 636161e183 Mark unloaded extensions as not fully loaded (fixes #1574). 2021-10-24 08:52:32 -05:00
Asher Baker c6917296d3 Fix out of bounds write in CDataPack::Write*Array (#1554)
WriteCellArray and WriteFloatArray were allocating N+1 slots, but due to
a copy-paste error were writing N+2 slots. Much later in the process the
CRT would catch this and cause a crash - this was pretty painful to
debug but thankfully running SRCDS in CRT debug mode caught it much
sooner in CDataPack::RemoveItem.
2021-07-28 22:19:16 +01:00
David Anderson 6928d21bcf Fix crash in FrameIterator. 2021-07-16 18:33:10 -07:00
nosoop 387b85406e logic: Add ability to skip mprotect with StoreToAddress (#1523)
* Implement StoreToAddress param to optionally set memory page permissions

* Update comment
2021-07-10 12:45:00 -07:00
Asher Baker 82c51dbe75 Fix sm_dump_admcache with command group overrides (#1519) 2021-07-01 22:19:50 +01:00
Vladimir f603b7aec3 Add StringToInt64() and Int64ToString() natives (#1511) 2021-06-28 21:51:49 +01:00