Compare commits

..
Author SHA1 Message Date
Your Name 0cf8f2b11f update amtl 2023-08-30 22:18:47 +02:00
BotoX 91cc6b300c Add "Restart Current Map" to sm_map menu. 2023-08-30 22:08:46 +02:00
BotoX ec3351a320 Fix GetClientCount(false) 2023-08-30 22:08:46 +02:00
Your Name aa2a71fc67 Add damageCustom argument to SDKHooks_TakeDamage native.
# Conflicts:
#	extensions/sdkhooks/natives.cpp
#	plugins/include/sdkhooks.inc
2023-08-30 22:08:46 +02:00
BotoX 142e76bd92 fix IsMapValid behavior change by a2246af121 2023-08-30 22:08:46 +02:00
BotoX 632429700b Changes on sm_*say 2023-08-30 22:08:46 +02:00
BotoX a8d95ca044 Add GetClientIClient native. 2023-08-30 22:08:46 +02:00
Your Name 28b4b248f7 Extend function calling API for natives and allow catching exceptions.
Change sourcepawn url.

# Conflicts:
#	.gitmodules
#	core/logic/AMBuilder
2023-08-30 22:08:46 +02:00
BotoX 964c9ae835 Fix @spec not targeting clients in unassigned team. 2023-08-30 22:08:46 +02:00
Your Name d099dbb659 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.

# Conflicts:
#	tools/buildbot/PackageScript
2023-08-30 22:08:46 +02:00
BotoX 688e274c30 Add more macros to CDetour. 2023-08-30 22:08:46 +02:00
Mikusch a5ff53f00f TF2: Add TFCond_ImmuneToPushback condition (#2023)
(cherry picked from commit 531b053096)
2023-08-30 22:08:46 +02:00
Mikusch 38fc001a1d TF2: Update StunPlayer signature (#2024) (fixes #2022)
(cherry picked from commit 0dafe04899)
2023-08-30 22:08:46 +02:00
data-bomb 4b949e8228 Add LookupAttachment signature for ND (#1942)
Adds the LookupAttachment signature for Nuclear Dawn

(cherry picked from commit a9a1939f75)
2023-08-30 22:08:46 +02:00
Dysphie 080c4bb8e2 Fix LookupAttachment signature for NMRiH (#1940)
(cherry picked from commit 693e584dcd)
2023-08-30 22:08:46 +02:00
Nick Hastings 149b16cbf3 Enable ShowMenu support for Reactive Drop (see #1938)
Note: Currently only works on beta version of game
(cherry picked from commit 397b70add0)
2023-08-30 22:08:46 +02:00
Corey D b940b01be4 Fix LookupAttachment signature (#1933)
(cherry picked from commit a0eb6a9550)
2023-08-30 22:08:46 +02:00
Poggu 45258b8561 Fix EntityFactoryCaller signature (#1925)
(cherry picked from commit 6e839a95c6)
2023-08-30 22:08:46 +02:00
El Diablo ab7b9b231d Linux [SDKTOOLS] Sigscan for FireOutput FIX (#1923)
Addie said:
test the signatures:
\x55\x89\xE5\x57\x56\x53\x81\xEC\x8C\x01\x00\x00\x8B\x55\x08
or
digby's \x55\x89\xE5\x57\x56\x53\x81\xEC\x8C\x01\x00\x00\x8B\x55\x2A\x65\xA1

\x55\x89\xE5\x57\x56\x53\x81\xEC\x8C\x01\x00\x00\x8B\x55\x08 fixed the issue for linux server.

(cherry picked from commit 2dcee81f22)
2023-08-30 22:08:46 +02:00
GAMMACASE 76c2addeb9 Gamedata update after 2/2/2023 CSGO update (#1921) 2023-08-30 22:08:46 +02:00
nosoop 7cb7703cf9 Update TF2 gamedata for version 7757534 (2023-01-05) (#1901)
(cherry picked from commit 27b1817b10)
2023-08-30 22:08:46 +02:00
clague c2b204e810 Fix ReadMapList ignoring file's last modified time (#1891)
(cherry picked from commit 0d6179299c)
2023-08-30 22:08:46 +02:00
zer0.k 24c92c021c Add missing null pointer check to protobuf messages (#1883)
(cherry picked from commit ef7d3abefd)
2023-08-30 22:08:46 +02:00
nosoop dd370c3904 entitylump: Output separator as spaces instead of tabs
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.
2023-08-30 22:08:46 +02:00
Erin 384fb668d1 Trigger build for TF2 SDK update 2023-08-30 22:08:46 +02:00
Nick Hastings 1903c0bd2b Trigger build against SDK update 2023-08-30 22:08:46 +02:00
nosoop 13034eff05 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.

(cherry picked from commit 34c8220e5d)
2023-08-30 22:08:46 +02:00
Nick Hastings a4703722be Update TF2 gamedata.
(cherry picked from commit 89bd4d7329)
2023-08-30 22:08:46 +02:00
nosoop 2e13460823 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.
2023-08-30 22:08:46 +02:00
nosoop d356d80537 Add functions for working with entity lumps (#1673) 2023-08-30 22:08:45 +02:00
Erin Baker 412759cbc4 Enable CI on release branches (#1854) 2023-08-30 22:08:45 +02:00
Maxim Telezhenko 08841227a4 Fix DHooks jit code stack memory alignment (#1849) 2023-08-30 22:08:45 +02:00
Nick Hastings 18b2ffa786 Trigger build for hl2sdk-csgo update 2023-08-30 22:08:45 +02:00
Vauff 3e9a48c778 Correct missed team offsets in CheckRestartRound (#1844) 2023-08-30 22:08:45 +02:00
Nick Hastings 339fd85c6f Trigger build for hl2sdk-csgo update 2023-08-30 22:08:45 +02:00
Vauff 59144cf868 Update gamedata for 2022/10/21 CS:GO update (#1842) 2023-08-30 22:08:45 +02:00
David Anderson ad3a44427a Update SourcePawn. 2023-08-30 22:08:45 +02:00
David Anderson 737d8c3240 Fix build. 2023-08-30 22:08:45 +02:00
David Anderson 4688783baf Revert "Introduce a pbproxy library to solve macOS linker issues."
This reverts commit e5ddbd9886.
2023-08-30 22:08:45 +02:00
David Anderson ba5c6ad07c Revert "Fix use-after-free when creating custom user messages"
This reverts commit 15450a6d0c.
2023-08-30 22:08:45 +02:00
David Anderson 69045ccd52 Update SourcePawn on 1.11-dev. 2023-08-30 22:08:45 +02:00
42 cf39d4b820 Fix support for SDKCall returning non-networked entity (#1797)
(cherry picked from commit 625c7a98f2)
2023-08-30 22:08:45 +02:00
peace-maker cb218a4911 Log a notice if the geoip database gets too old (#1791)
Since we ship an ancient version of the database, help server operators keep track of the database version.
2023-08-30 22:08:45 +02:00
peace-maker 344284196c Update SQLite library to 3.38.5 (#1792)
Bring in the changes of the last four years of SQLite development.

Fixes #1728
Fixes #1592
2023-08-30 22:08:45 +02:00
Nick Hastings e7c0726acd Trigger build against hl2sdk-csgo changes. 2023-08-30 22:08:45 +02:00
Nick Hastings d0b34e783d Trigger build against hl2sdk-csgo changes.
(cherry picked from commit 5714e7695a653dcade1832cb482855e77b5f13dd)
2023-08-30 22:08:45 +02:00
Deathreus d481e5fcb7 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
2023-08-30 22:08:45 +02:00
dysphie 1459c10112 Add sdktools gamerules support for NMRiH (#1784) 2023-08-30 22:08:45 +02:00
David Anderson 8b9131f6e4 Update SourcePawn. 2023-08-30 22:08:45 +02:00
Margen67 ce1a21ba0b .gitmodules: Make submodules shallow (#1769) 2023-08-30 22:08:45 +02:00
Vauff e2237ce875 Expand ShowHudText message buffer for Protobuf games (#1777)
* Expand ShowHudText message buffer for CS:GO

* Expand buffer on Blade Symphony too
2023-08-30 22:08:45 +02:00
peace-maker 250bbf5955 DHooks: Error on argument passflags for detours (#1773)
The passflags are only supported by SourceHook for virtual hooks and are ignored for detours with DynamicDetours. This caused confusion, so throw an error when trying to set e.g. the DHookPass_ByRef flag on detour arguments.
2023-08-30 22:08:45 +02:00
peace-maker 0478912d73 DHooks: Fix changing of byref vector parameters (#1772)
We always created a new vector object instead of changing the passed in vector directly. This works for the function being called using our changed values - but the caller doesn't see the changed values if it's passing a vector by reference.

Only create a new vector if there isn't one being passed in and set the values directly in the passed in vector otherwise.
2023-08-30 22:08:45 +02:00
Nick Hastings d50e4b7a2f Update TF2 gamedata. 2023-08-30 22:08:45 +02:00
Nick Hastings abf59a4f4b Update Reactive Drop gamedata (closes #1771) 2023-08-30 22:08:45 +02:00
Headline 9b80e46097 Lift raw pointers out of DatabaseConfBuilder (#1637)
* Lift raw pointers out of DatabaseConfBuilder

* Maybe: not
2023-08-30 22:08:45 +02:00
David Anderson bbbaebd32a Update SourcePawn. 2023-08-30 22:08:45 +02:00
Vauff 1204d1fd0f Update WriteBaselines signature for CS:GO update (#1766) 2023-08-30 22:08:45 +02:00
Bone ef34cc67b6 fix WeaponPrice offset on windows (#1765) 2023-08-30 22:08:45 +02:00
Psykotikism 25184aa9c7 Add "DispatchKeyValueInt" stock (#1764) 2023-08-30 22:08:45 +02:00
Arron Vinyard b789d30658 Remove unnecessary timer typeset entry (#1735) 2023-08-30 22:08:45 +02:00
Arron Vinyard 305799b441 NPOTB: Use camel casing for variables in adminhelp.sp (#1750)
This is a stylistic change to ensure more adhered-to consistency throughout base plugins
2023-08-30 22:08:45 +02:00
Sikari 92fc27f67f Prevent workshop prefix from showing in nominations results menu (#1737)
Prevents workshop prefixes from being shown instead of the display names in results menus when items are disabled
2023-08-30 22:08:45 +02:00
domino_ 5292721f0b Add a OnPlayerRunCmdPre forward (#1760)
Adds an OnPlayerRunCmdPre forward in order for plugins to be able to hook OnPlayerRunCmd with the guarantee that none of the parameters have been modified by other plugins. As such, OnPlayerRunCmdPre's parameters cannot be modified and are read-only. 

Plugins that wish to use OnPlayerRunCmdPre can maintain backwards compatibility with SourceMod 1.10 by falling back to OnPlayerRunCmd if the Pre variant was never fired.
2023-08-30 22:08:45 +02:00
Mikusch 4e0c47a1d5 Fix TF2_OnIsHolidayActive forward not getting called after map change (#1752)
* Fix TF2_IsHolidayActive forward not getting called after map change

* Rename function to Unhook
2023-08-30 22:08:45 +02:00
Mikusch 65b6602a19 SDKTools: Clear gamerules pointer on level shutdown (#1755)
* Clear gamerules pointer on level shutdown

* Move LevelShutdown up
2023-08-30 22:08:45 +02:00
Alienmario 1723f97202 Add recent gamedata for BMS, HL2DM (#1756) 2023-08-30 22:08:45 +02:00
Kyle ec92653bb7 Honor AUTOLOAD_EXTENSIONS in clientprefs include (#1718)
* Optional autoload extensions

* revert autoload for cstrike/tf2
2023-08-30 22:08:45 +02:00
peace-maker b25d25890a DHooks: Allow setting CBaseEntity* param to NULL #1751 (#1754)
* DHooks: Allow setting CBaseEntity* param to NULL #1751

The param had to be a valid entity and wasn't allowed to be set to NULL. Behave similar to SetReturn which maps INVALID_ENT_REFERENCE (or -1) to NULL.

* Update include documentation
2023-08-30 22:08:45 +02:00
peace-maker b27243c3ac Add -m flag to checkout-deps to avoid downloading MySQL (#1753)
If you just want to build an extension or SourceMod core and not the MySQL extension, don't download the large MySQL library archive.
2023-08-30 22:08:45 +02:00
XeroX be648382d7 ZPS Update offsets for 3.2.4 (#1746)
* Update offsets for ZPS 3.2

Zombie Panic! Source Version 3.2 released and these are the updated offsets.

* Update offsets for 3.2

ZPS 3.2 has been release and these are the updated offsets / signatures.

* ZPS: Add missing offsets.

Adds support for OnTakeDamage_Alive, GetMaxHealth, Blocked, Reload and GroundEntChanged.
I wasn't aware these were missing entirely or I would have pushed them with the previous PR.

* ZPS Add missing offsets.

Adds support for GivePlayerAmmo.
Wasn't aware these were missing the first place.

* Fix ForcePlayerSuicide not properly working in ZPS

ZPS requires the second bool parameter to be true otherwise it won't do anything for players in the lobby or delayed for players on either team 2 or team 3.

* Fixed breaking code for other mods.

Added bForce which is set to true for zps.

* Update offsets for ZPS 3.2.4

Updates the offset
2023-08-30 22:08:45 +02:00
XeroX b5ed266941 ZPS: Add missing offsets (#1719)
* Update offsets for ZPS 3.2

Zombie Panic! Source Version 3.2 released and these are the updated offsets.

* Update offsets for 3.2

ZPS 3.2 has been release and these are the updated offsets / signatures.

* ZPS: Add missing offsets.

Adds support for OnTakeDamage_Alive, GetMaxHealth, Blocked, Reload and GroundEntChanged.
I wasn't aware these were missing entirely or I would have pushed them with the previous PR.

* ZPS Add missing offsets.

Adds support for GivePlayerAmmo.
Wasn't aware these were missing the first place.

* Fix ForcePlayerSuicide not properly working in ZPS

ZPS requires the second bool parameter to be true otherwise it won't do anything for players in the lobby or delayed for players on either team 2 or team 3.

* Fixed breaking code for other mods.

Added bForce which is set to true for zps.
2023-08-30 22:08:45 +02:00
MartLegion 2ffaa04130 Moved pvkii section for better readbility (#1744)
Moved pvkii section above for better readbility
(requested by psychonic)
2023-08-30 22:08:45 +02:00
MartLegion eddf9cf843 Added PVKII game with related team colors (beacon) (#1743)
Spectators = Yellow
Pirates = Red
Vikings = Green
Knights = Blue
2023-08-30 22:08:45 +02:00
Gaben 7c1095e4e7 Allow h-flag admins to bypass vote delay (#1733) 2023-08-30 22:08:45 +02:00
Arron Vinyard 686e8b4d7e Add GetCmdArgFloat(Ex) stocks (#1742) 2023-08-30 22:08:45 +02:00
David Anderson edc73649ff Update SourcePawn. 2023-08-30 22:08:45 +02:00
Mikusch 1ad8bb4560 Remove misleading note on DynamicHook.RemoveHook docs (#1725) 2023-08-30 22:08:45 +02:00
James Dickens 7eabeaa384 Fix Int64ToString producing incorrect output (#1723) 2023-08-30 22:08:45 +02:00
rtldg 4547270934 Correct some function docs that return char count (#1721) 2023-08-30 22:08:45 +02:00
V 3a2c5cb0f7 Inline one-expression single-use functions (#1700) 2023-08-30 22:08:45 +02:00
XeroX 7648c7fe03 ZPS: Update Offsets & Signatures for 3.2 (#1717)
* Update offsets for ZPS 3.2

Zombie Panic! Source Version 3.2 released and these are the updated offsets.

* Update offsets for 3.2

ZPS 3.2 has been release and these are the updated offsets / signatures.
2023-08-30 22:08:45 +02:00
Corey D ffb6d769e8 Add MAX_AUTHID_LENGTH (#1696) 2023-08-30 22:08:45 +02:00
Erik Minekus 77f999f810 Database.Format destination buffer should not be marked const (#1714) 2023-08-30 22:08:45 +02:00
Corey D c5049990a3 Add bitwise SetBitFlags for AdminId and GroupId (#1677)
* Add bitwise SetFlags for AdminId

* Inline SetFlags natives
2023-08-30 22:08:45 +02:00
XeroX 0e4894e8db ZPS: Add LookupEntityAttachment and GetEntityAttachment Gamedata (#1706)
* Add LookupAttachment and GetAttachment

Offset and Signature for Zombie Panic! Source.

* Fix Gamerules not being available

This fixes the issue that would throw an error when trying to use SDKCall with type SDKCall_GameRules.

* Add SetOwnerEntity offset

Add SetOwnerEntity offset
2023-08-30 22:08:45 +02:00
Asher Baker 19f1ffa401 Stop SQLite results being used before being fetched (#1709)
The DB API requires FetchRow to be called before accessing any values
from a row, but the SQLite driver did not enforce that requirement and
alowed accessing the first row immediately. A plugin developer hit this
when developing against SQLite locally but using MySQL in production,
where the API misuse threw an error as expected.

Resolves #1691
2023-08-30 22:08:45 +02:00
Asher Baker c206ac3099 Fix FindSendPropOffs with SendPropArray props (#1708)
FindSendPropOffs is deprecated and FindSendPropInfo behaves correctly
here, but there are still a lot of old plugins using FindSendPropOffs.
One of the SendPropArray props broken by the changes here is
m_hViewModel which there are known plugins in the wild accessing.
2023-08-30 22:08:45 +02:00
Alienmario e03320c80e Enable nextmap for Black Mesa (#1695) 2023-08-30 22:08:45 +02:00
Ҝℴţأķ 2ae4624344 Remove hardcoded question mark from sm_vote (#1699) 2023-08-30 22:08:45 +02:00
66c8005666 adminhelp.sp -> Switch to the new CommandIterator() (#1388)
* Switch to the new CommandIterator() methodmap

`ReadCommandIterator` 
->
```
CmdIter.GetName(Name, sizeof(Name));
Flags = CmdIter.Flags;
CmdIter.GetDescription(Desc, sizeof(Desc));
```

* PeaceMaker fixes

* Don't fetch unused properties

Co-authored-by: Michael Flaherty <[email protected]>
Co-authored-by: Peace-Maker <[email protected]>
2023-08-30 22:08:45 +02:00
Arron Vinyard 210219030e Update dhooks.inc documentation for consistency (#1658)
* Update dhooks.inc documentation for consistency

- Modifies whitespace (change tabs to spaces for non initial indents, fix alignments, create consistency with rest of SM docs)
- Change `/*` to `/**` for consistency and to indicate comment doc
- Removes incorrect `@noreturn` doc

* Split long comments across multiple lines

* Remove `@noreturn` in IGameConfigs.h

* Remove `@noreturn` from IGameHelpers.h

* Remove `@noreturn` from asm.c

* Add `@noreturn` to ThrowError

* Add `@noreturn` and `@error` to ThrowNativeError
2023-08-30 22:08:45 +02:00
komashchenko 370fa8209b Fix GetGameSoundParams in CSGO (#1631)
* Fix GetGameSoundParams CSGO

* Added preprocessor comments

* Revert InternalPrecacheScriptSound
2023-08-30 22:08:45 +02:00
peace-maker 88a0a458a6 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
2023-08-30 22:08:45 +02:00
dysphie e4afe31fc0 Add NMRiH support for new collision and attachment natives (#1702)
- Add "GetAttachment" offset
- Add "SetOwnerEntity" offset
- Add "LookupAttachment" signature
2023-08-30 22:08:45 +02:00
Corey D fb0144900f Add ArrayStack.Clear native (#1676) 2023-08-30 22:08:45 +02:00
Mikusch 542b7673d6 Add LookupEntityAttachment & GetEntityAttachment natives (#1653)
Using the virtual `CBaseAnimating::GetAttachment(int, matrix3x4_t &)` was a deliberate choice because virtual offsets are generally easier to maintain than signatures. The `matrix3x4_t` is converted to world position and world angles internally.
Some of the other overloads are also inlined on a few games, making this the best choice.

Since this call can only be used on classes inheriting `CBaseAnimating`, we check if the `DT_BaseAnimating` SendTable exists on the entity, throwing a native error if it doesn't.
This safeguard could be greatly improved with a call to `CBaseEntity::GetBaseAnimating`, but would require more gamedata (maybe something to consider for the future?)
2023-08-30 22:08:45 +02:00
Corey D cc1c02e3de Fix ArrayList return types (#1679)
ArrayList.SetString and ArrayList.SetArray both have int return types but their methodmap natives use void.
2023-08-30 22:08:45 +02:00
naydef 4fc0a85581 Fix crash in non-bypass-hooks DropWeapon implementation (#1672)
Fixes #1670
2023-08-30 22:08:45 +02:00
Nick Hastings 6733c4182d Fix helpers module path lookup on newer Perl versions. 2023-08-30 22:08:45 +02:00
Nick Hastings 28ef59ada5 Missing ;s. 2023-08-30 22:08:45 +02:00
Nicholas Hastings 647e320b57 [Buildbot] Delete package after successful upload. (#1665)
* [Buildbot] Delete package after successful upload.

* Use autodie.

* ;
2023-08-30 22:08:45 +02:00
Nick Hastings cdfbdcc29d Remove dead code. 2023-08-30 22:08:45 +02:00
Nick Hastings 4f94b4f900 Use SteamWorks C++ API in CStrike RulesFix, for better interface compatibility. 2023-08-30 22:08:45 +02:00
Asher Baker 53be0e0812 Upload libsourcepawn Breakpad symbols as well 2023-08-30 22:08:45 +02:00
Asher Baker 88dd142f5c Upload libsourcepawn debug symbols 2023-08-30 22:08:45 +02:00
David Anderson 1d5ec7b982 Update SourcePawn/AMTL to fix build. 2023-08-30 22:08:45 +02:00
Fyren f1a71b0d5a Update SP. 2023-08-30 22:08:45 +02:00
Headline 85b8e09e8a Prevent enum shadowing & pin sourcemod for build fixes (#1661) 2023-08-30 22:08:45 +02:00
David Anderson df9b0ef1b3 Update AMTL. 2023-08-30 22:08:45 +02:00
David Anderson f81412b4fa Fix vote menu handler to work with direct arrays. 2023-08-30 22:08:45 +02:00
David Anderson bd478ebdfc Dedent some menu code for readability. 2023-08-30 22:08:45 +02:00
Benoist a57573864a Fix ShouldCollide originalResult behaviour (#1657) 2023-08-30 22:08:45 +02:00
David Anderson 6b6436db17 Update SourcePawn.
Fix fix an hl2sdk-mock build error.
2023-08-30 22:08:45 +02:00
Stanislav Polshyn c88b18e520 gamedata: Add SetEntityOwner L4D1 offset (#1649) 2023-08-30 22:08:45 +02:00
8c001872a8 sdktools: Add EntityCollisionRulesChanged & SetEntityOwner natives (#1620)
* Add EntityCollisionRulesChanged & SetEntityOwner natives

* fix win build, and unpushed changes

* Fixed bad world loop

* Requested changes + csgo offsets

* small copy paste mistake

* Strip the debug log lines

* Tiny clean up in comments

* line

* <dvander> try again

* sdktools: add default Param for owner.

Co-authored-by: Kenzzer <[email protected]>
Co-authored-by: Kyle Sanderson <[email protected]>
2023-08-30 22:08:45 +02:00
Adrián 5db571bbc6 menusys: Correct GetMenuExitBackButton returncode (#1646) 2023-08-30 22:08:45 +02:00
peace-maker 1f561b54f3 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.
2023-08-30 22:08:45 +02:00
Peace-Maker 77a0fb4402 Ignore all build* folders in .gitignore
I frequently have one like `buildwin` and `buildlin` for the different OS in WSL.
2023-08-30 22:08:45 +02:00
Peace-Maker c72736dcfa Use SourceMod's version number 2023-08-30 22:08:45 +02:00
Peace-Maker d16f45c4b6 Print OS errors if mprotect fails
This helped catch a bug in DHooks before, so it's worth adding it in here as well.
2023-08-30 22:08:45 +02:00
Peace-Maker e280d33a28 Use JMP patching of CDetour 2023-08-30 22:08:45 +02:00
Peace-Maker fb1d501c24 Add copyright headers 2023-08-30 22:08:45 +02:00
Peace-Maker 3c0f700a6b Import DHooks + Dynamic Detouring
This is the latest DHooks version from https://github.com/peace-maker/DHooks2/tree/1314f2d1b4d870677a1b9f628c770f2799878f9b
2023-08-30 22:08:45 +02:00
Adrián 45e9da90fc Fix translations getting truncated prematurely (#1640) 2023-08-30 22:08:45 +02:00
Nick Hastings a60c443b29 Update Contagion SDKHooks gamedata. 2023-08-30 22:08:45 +02:00
Nick Hastings b064366169 Disable Reserved Slots plugin on Contagion.
(It doesn't have sv_visiblemaxplayers).
2023-08-30 22:08:45 +02:00
Nick Hastings a06a903989 Make separate copy of makesig script for IDA 7.x. 2023-08-30 22:08:45 +02:00
Mikusch e67fdf2331 Update Team Fortress 2 gamedata
Shift virtual offsets up by 3
2023-08-30 22:08:45 +02:00
Nick Hastings e2ca3a9493 Update Contagion SDKTools gamedata. 2023-08-30 22:08:45 +02:00
dysphie 9099634b95 Fix "ForcePlayerSuicide" linux offset in NMRiH (#1627) 2023-08-30 22:08:45 +02:00
David Anderson f182feed9d Add support for ASAN. 2023-08-30 22:08:45 +02:00
David Anderson 02dd6a9c00 Update SourcePawn.
This fixes a few more regressions found in the new compiler.
2023-08-30 22:08:45 +02:00
David Anderson b421a0c594 Update SourcePawn.
This fixes a recent stability regression.
2023-08-30 22:08:45 +02:00
Nick Hastings 9ec5cb819c Fix server binary name for CRC lookups. 2023-08-30 22:08:45 +02:00
Nick Hastings f8e664b797 Invert CRC to match most popular implementations. 2023-08-30 22:08:45 +02:00
dysphie 42575f7cc3 Update gamedata for NMRiH 1.12 (#1623)
* Fix NMRiH's sdktools gamedata

* Fix NMRiH's sdkhooks gamedata

* Fix GroundEntChanged linux offset
2023-08-30 22:08:45 +02:00
David Anderson aa98f60ca3 Update SourcePawn. 2023-08-30 22:08:45 +02:00
David Anderson d5f47a88e6 Switch to clang-8.
This is the new minimum supported Clang version going forward.
2023-08-30 22:08:45 +02:00
FortyTwoFortyTwo 62f08a31fc Fix compiling with tf2_stocks 2023-08-30 22:08:45 +02:00
David Anderson e565c83494 Fix build. 2023-08-30 22:08:45 +02:00
David Anderson a68ff2a587 Fix error return of FormatNativeString. (#1613) 2023-08-30 22:08:45 +02:00
David Anderson 377888276e 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.
2023-08-30 22:08:45 +02:00
Nick Hastings 52b8e95aae Throw error if unknown SDK call type specified. 2023-08-30 22:08:45 +02:00
Nick Hastings bb6e6fd3b6 Reorder SDKCallType enum for better compatibility with existing plugins. 2023-08-30 22:08:45 +02:00
dragokas 0449342bb0 Exposed SDKCall_Server call type to use CBaseServer methods 2023-08-30 22:08:45 +02:00
David Anderson 3171d4fb7b 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.
2023-08-30 22:08:45 +02:00
Kyle 066818fbec Update TerminateRound signature for CSGO 2023-08-30 22:08:45 +02:00
Vladimir 255f5ea745 Add OnClientLanguageChanged() forward (#1597) 2023-08-30 22:08:45 +02:00
Asher Baker 2e763c287c Fix build against released MM:S branches (#1607)
`SOURCE_ENGINE_MOCK` is part of the MM:S API and only available in 1.12
which is the dev branch of MM:S. We can build the mock SM build without
it anyway, but this is still a little gross as it is just missing loader
support which could be confusing.

This also changes AMBuildScript to first look for a checkout of MM:S
1.11 which has been the stable branch for a while, 1.10 is still allowed
as a fallback as that seems to still build without issue.
2023-08-30 22:08:45 +02:00
Nick Hastings 29c33bfcc9 Fix up OnClientSettingsChange logic order.
- Fixes bot name cache not getting updated (see #1579)
- Fixes IClientListener::OnClientSettingsChanged not being called for bots.
2023-08-30 22:08:45 +02:00
Nick Hastings 88bdbf4866 Add support for other Steam ID formats to admin-sql-threaded (#1520). 2023-08-30 22:08:45 +02:00
Nick Hastings 1559b75ae7 Don't cache replay_enable value when evaling whether to use FileExists hook.
Speculative fix for #1581
2023-08-30 22:08:45 +02:00
Nick Hastings ff00e3d036 Mark unloaded extensions as not fully loaded (fixes #1574). 2023-08-30 22:08:45 +02:00
Charles daa1a4df14 Removed incorrect parameter RemoveChangeHook desc 2023-08-30 22:08:45 +02:00
Charles 4e2ace9d2f Removed incorrect parameter in description 2023-08-30 22:08:45 +02:00
Corey D ee722d778f Use words instead of quotes for better clarity
As suggested by sneak-it
2023-08-30 22:08:45 +02:00
Corey D e82f0acdb8 Missed Database.Escape 2023-08-30 22:08:45 +02:00
Corey D 383cd81be6 Clarify SQL_EscapeString usage
It's hard to see the difference between 2 single-quotes and 1 double-quote unless you highlight it.
2023-08-30 22:08:45 +02:00
Nick Hastings 6250db7dba Add missing parameters for CSWeaponDrop. 2023-08-30 22:08:45 +02:00
GAMMACASE 8ae3be7185 Fix CS_OnCSWeaponDrop after latest CSGO update (21/10/21) (#1602) 2023-08-30 22:08:45 +02:00
Vauff 64b897822f Update HandleCommand_Buy_Internal sig and related offsets for CS:GO Win 2023-08-30 22:08:45 +02:00
Vauff 0ad0d839a0 Update CSWeaponDropBB signature for CS:GO Linux 2023-08-30 22:08:45 +02:00
Nick Hastings 55382e0a0f Add option to not bypass hooks with TakeDamage and DropWeapon natives. 2023-08-30 22:08:45 +02:00
Nick Hastings d8b00675d6 Remove obsolete core-legacy checks. 2023-08-30 22:08:45 +02:00
Nick Hastings 633298b6a9 Fix attempting to link win32 libprotobuf on win64. 2023-08-30 22:08:45 +02:00
Nick Hastings 656a9fa94f Use MM:S master for Windows builds (already doing for Linux/Mac). 2023-08-30 22:08:45 +02:00
Nicholas Hastings bb7929594d Typo fix. 2023-08-30 22:08:45 +02:00
Nick Hastings d4545a105e Fix incorrect param types in CS:GO GNI (otherwise broken for x64). 2023-08-30 22:08:45 +02:00
Nick Hastings 1c788b5c0a Remove manual ptr math in vnatives for params not mapped to cell params. 2023-08-30 22:08:45 +02:00
Nick Hastings 7ce8a80bf6 Fix Blade Symphony GiveNamedItem call on x64. 2023-08-30 22:08:45 +02:00
Nick Hastings d0c4657b75 Add ValveType_Object type.
This is for the few cases where we have function parameters to objects that
don't fit our other predefined types (CBaseEntity, CBasePlayer, string).

Most calls currently pass those as POD (which is incorrect, but works on
x86), or one of the other pointer types (which is also incorrect, and can
lead to confusion, but works on x86 and x86-64).

This type only works when manually buffering the parameter for calls, and
is not supported for return types.
2023-08-30 22:08:45 +02:00
Nick Hastings 167e6d8571 On Linux, link against server libs instead of client (fixes META_CONPRINT). 2023-08-30 22:08:45 +02:00
Nick Hastings b909ea07ec Update multiple SDKTools calls to be x64-safe [sizeof(void*) != sizeof(int)] 2023-08-30 22:08:45 +02:00
Nick Hastings 410eb01f91 Add missing WriteBaselines signatures for Blade Symphony. 2023-08-30 22:08:45 +02:00
Nick Hastings f18c6fb9af Fix crash with IBinTools calls on x64 for functions with void return. 2023-08-30 22:08:45 +02:00
Nick Hastings c66175d64e Use new GetIServer call and updated IServerTools calls on Blade Symphony. 2023-08-30 22:08:45 +02:00
Nick Hastings a3fbbe41f2 Enable more CS:GO engine logic for Blade Symphony. 2023-08-30 22:08:45 +02:00
Nick Hastings ed5713b3fd Blade Symphony gamedata updates, round 1. 2023-08-30 22:08:45 +02:00
Nick Hastings 4b01feea45 Fix CS:GO transposing of GiveNamedItem last param and return. 2023-08-30 22:08:45 +02:00
Nick Hastings 800f613f92 Enable 64-bit builds for Blade Symphony. 2023-08-30 22:08:44 +02:00
Nick Hastings 4c9e856197 Add .vs and .vscode dirs to .gitignore. 2023-08-30 22:08:44 +02:00
dysphie 0cb3fcaed8 Fix NMRiH's 'GivePlayerAmmo' offset on Windows (#1593) 2023-08-30 22:08:44 +02:00
naydef 02e2659ba5 Update float.inc (#1591) 2023-08-30 22:08:44 +02:00
A1m` 507b09c975 Fix 'GiveNamedItem' in the game left4dead2. (#1590)
* Fix 'GiveNamedItem' in the game left4dead2.

The method 'CCSPlayer::GiveNamedItem(char const*, int, CBaseEntity*)' does not work in game left4dead2, any given weapon and object immediately falls to the ground, besides, the code is missing a parameter to call this method (even with the added parameter does not give a weapon to hands). Another method 'CTerrorPlayer::GiveNamedItem(char const*, int, bool, CBaseEntity*)' works great, besides it makes it possible to give out all the items that exist in the game.

* Add x64 support

Add x64 support

* Changed argument type to bool.

Changed argument type to bool.
2023-08-30 22:08:44 +02:00
David Anderson 907fa77381 Update bootstrap.pl 2023-08-30 22:08:44 +02:00
David Anderson c5c302dccc Use master for Metamod:Source builds. 2023-08-30 22:08:44 +02:00
David Anderson c49d51206c Don't require hl2sdk-mock if sdks=all 2023-08-30 22:08:44 +02:00
pedrotski f48cbaab75 Update CS:GO Reload gamedata (#1585) 2023-08-30 22:08:44 +02:00
nosoop 61c634a870 TF2Tools: Prevent CalcIsAttackCriticalHelper* from being called twice (#1573)
* Ensure CalcIsAttackCriticalHelper only gets called once

* fixup: move origReturnValue up
2023-08-30 22:08:44 +02:00
David Anderson fec978afb4 Add support for hl2sdk-mock. 2023-08-30 22:08:44 +02:00
David Anderson 74ad70ba30 Add support for hl2sdk-mock. 2023-08-30 22:08:44 +02:00
GAMMACASE fe27c8810e Update gamedata after latest CSGO update (22/09/21) (#1583) 2023-08-30 22:08:44 +02:00
Nick Hastings b4c5726fc2 Trigger build for TF2 SDK INetChannel changes. 2023-08-30 22:08:44 +02:00
Nick Hastings 53c8d5533a Trigger build for TF2 SDK changes. 2023-08-30 22:08:44 +02:00
Bara 4e66452e58 Update sourcepawn 2023-08-30 22:08:44 +02:00
Vladimir 63545eb741 Fix crash in FindSendPropInfo() when the prop was DPT_DataTable (#1575) 2023-08-30 22:08:44 +02:00
Asher Baker a7af242453 Revert "Switch internal SM concept of frames to use Think (#1540)" (#1572)
This reverts commit b383302128.
2023-08-30 22:08:44 +02:00
873 changed files with 2298 additions and 52101 deletions
-8
View File
@@ -1,8 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
+6 -6
View File
@@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-latest, windows-latest]
os: [ubuntu-18.04, ubuntu-latest, windows-latest]
include:
- os: windows-latest
os_short: win
@@ -21,7 +21,7 @@ jobs:
os_short: linux
compiler_cc: clang
compiler_cxx: clang++
- os: ubuntu-20.04
- os: ubuntu-18.04
os_short: linux
compiler_cc: clang-8
compiler_cxx: clang++-8
@@ -34,15 +34,15 @@ jobs:
DEPENDENCIES_FOLDER: dependencies
DEPENDENCIES_ROOT: ${{ github.workspace }}/dependencies
MYSQL_VERSION: '5.5'
MMSOURCE_VERSION: '1.12'
MMSOURCE_VERSION: '1.10'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
with:
submodules: recursive
path: sourcemod
- name: Cache dependencies
uses: actions/cache@v4
uses: actions/cache@v2
env:
cache-name: hl2sdk-mysql-mmsource
with:
@@ -53,7 +53,7 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-mysql${{ env.MYSQL_VERSION }}-
# Setup Python for AMBuild
- uses: actions/setup-python@v5
- uses: actions/setup-python@v2
name: Setup Python 3.8
with:
python-version: 3.8
-104
View File
@@ -1,104 +0,0 @@
name: hl2sdk-mock tests
on:
push:
branches:
- master
- '[0-9]+.[0-9]+-dev'
pull_request:
branches:
- master
- '[0-9]+.[0-9]+-dev'
jobs:
mock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Clone sourcemod
with:
submodules: recursive
path: sourcemod
- uses: actions/checkout@v4
name: Clone metamod-source
with:
repository: alliedmodders/metamod-source
submodules: recursive
path: metamod-source
- uses: actions/checkout@v4
name: Clone hl2sdk-mock
with:
repository: alliedmodders/hl2sdk-mock
submodules: recursive
path: hl2sdk-mock
- uses: actions/setup-python@v5
name: Setup Python 3.10
with:
python-version: "3.10"
- name: Install AMBuild
run: |
python -m pip install --upgrade pip setuptools wheel
pip install git+https://github.com/alliedmodders/ambuild
- name: Build MetaMod:Source
working-directory: metamod-source
run: |
python configure.py --enable-optimize --sdks=mock --targets=x86_64
ambuild objdir
- name: Build SourceMod
working-directory: sourcemod
run: |
python configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86_64
ambuild objdir
- name: Build hl2sdk-mock
working-directory: hl2sdk-mock
run: |
python configure.py --enable-optimize --targets=x86_64
ambuild objdir
- name: Setup gamedir
working-directory: hl2sdk-mock
shell: bash
run: |
mkdir ../gamedir
./build_gamedir.sh ../gamedir ../metamod-source/objdir/package
./build_gamedir.sh ../gamedir ../sourcemod/objdir/package
- name: Compile testsuite
working-directory: hl2sdk-mock
shell: bash
run: |
mkdir ../gamedir/addons/sourcemod/plugins/optional
for f in ../sourcemod/plugins/testsuite/mock/*.sp; do
echo "Compiling $(basename $f)"
../gamedir/addons/sourcemod/scripting/spcomp64 -i ../gamedir/addons/sourcemod/scripting/include -o "../gamedir/addons/sourcemod/plugins/optional/$(basename $f .sp).smx" -E "$f"
done
- name: Test
working-directory: hl2sdk-mock
shell: bash
run: |
for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do
echo "==================================="
echo "Running $(basename $f)..."
echo "==================================="
timeout 60 ./objdir/dist/x86_64/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 |
{
failed=0
while IFS= read -r line; do
echo "$line"
if [[ "$line" == *"FAIL"* ]]; then
failed=1
fi
done
if [ "$failed" = "1" ]; then
echo "$(basename $f) failed."
exit 1
fi
}
done
+5 -5
View File
@@ -27,12 +27,12 @@ jobs:
env:
ARCH: x86,x86_64
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
with:
submodules: recursive
# Setup Python for AMBuild
- uses: actions/setup-python@v5
- uses: actions/setup-python@v2
name: Setup Python 3.8
with:
python-version: 3.8
@@ -41,9 +41,9 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
pip install git+https://github.com/alliedmodders/ambuild
- name: Build universal x64/arm64 on macOS
- name: Build only for x64 on macOS
if: startsWith(runner.os, 'macOS')
run: echo "ARCH=x86_64,arm64" >> $GITHUB_ENV
run: echo "ARCH=x86_64" >> $GITHUB_ENV
- name: Install Linux dependencies
if: startsWith(runner.os, 'Linux')
@@ -73,7 +73,7 @@ jobs:
echo "SM_VERSION=$(cat ../product.version)" >> $GITHUB_ENV
- name: Archive tooling
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v2
with:
name: sourcemod-tooling-${{ env.SM_VERSION }}-${{ matrix.os_short }}
path: build/package
-42
View File
@@ -1,42 +0,0 @@
name: Update translation project
on:
push:
branches:
- master
paths:
- 'translations/**'
workflow_dispatch:
jobs:
update_translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
name: Setup Python 3.10
with:
python-version: "3.10"
- name: Install Python dependencies
working-directory: tools/language_check
run: |
python -m pip install --upgrade -r requirements.txt
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PEM }}
- name: Update translation project
working-directory: tools/language_check
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ORGANIZATION: alliedmodders
PROJECT_NUMBER: 1
run: |
python ./compare_translation_phrases.py
@@ -1,29 +0,0 @@
name: Sanity check translation phrases
on:
push:
branches:
- master
paths:
- 'translations/**'
pull_request:
branches:
- master
paths:
- 'translations/**'
workflow_dispatch:
jobs:
check_translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Setup Python 3.10
with:
python-version: "3.10"
- name: Check translation phrases syntax
working-directory: tools/language_check
run: |
python ./sanity_check.py
+2 -3
View File
@@ -28,6 +28,7 @@ LIB-Debug/
[Tt]humbs.db
# AMBuild build directories
build*/
obj-*/
*~
*.rej
@@ -36,8 +37,6 @@ obj-*/
*.swp
*.gdb_history
objdir
# Not standardized, but common name for build directories
build*/
.vs/*
.vscode/*
.vscode/*
-6
View File
@@ -6,9 +6,3 @@
path = sourcepawn
url = https://github.com/alliedmodders/sourcepawn
shallow = true
[submodule "hl2sdk-manifests"]
path = hl2sdk-manifests
url = https://github.com/alliedmodders/hl2sdk-manifests.git
[submodule "public/safetyhook"]
path = public/safetyhook
url = https://github.com/alliedmodders/safetyhook
+270 -107
View File
@@ -2,6 +2,81 @@
import collections
import os, sys
import subprocess
import traceback
class SDK(object):
def __init__(self, sdk, ext, aDef, name, platform, dir):
self.folder = 'hl2sdk-' + dir
self.envvar = sdk
self.ext = ext
self.code = aDef
self.define = name
self.platform = platform
self.name = dir
self.path = None # Actual path
self.platformSpec = platform
# By default, nothing supports x64.
if type(platform) is list:
self.platformSpec = {p: ['x86'] for p in platform}
else:
self.platformSpec = platform
def shouldBuild(self, targets):
for cxx in targets:
if cxx.target.platform in self.platformSpec:
if cxx.target.arch in self.platformSpec[cxx.target.platform]:
return True
return False
WinOnly = ['windows']
WinLinux = ['windows', 'linux']
WinLinuxMac = ['windows', 'linux', 'mac']
Blade = {
'windows': ['x86', 'x86_64'],
'linux': ['x86_64'],
'mac': ['x86_64']
}
CSGO = {
'windows': ['x86'],
'linux': ['x86', 'x86_64'],
'mac': ['x86_64']
}
Mock = {
'windows': ['x86', 'x86_64'],
'linux': ['x86', 'x86_64'],
'mac': ['x86_64']
}
SDKMap = {
'episode1': SDK('HL2SDK', '2.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'),
'tf2': SDK('HL2SDKTF2', '2.tf2', '11', 'TF2', WinLinuxMac, 'tf2'),
'l4d': SDK('HL2SDKL4D', '2.l4d', '12', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
'nucleardawn': SDK('HL2SDKND', '2.nd', '13', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '15', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
'swarm': SDK('HL2SDK-SWARM', '2.swarm', '16', 'ALIENSWARM', WinOnly, 'swarm'),
'bgt': SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
'csgo': SDK('HL2SDKCSGO', '2.csgo', '21', 'CSGO', CSGO, 'csgo'),
'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'),
'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', Blade, 'blade'),
'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'),
'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'),
'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'),
'doi': SDK('HL2SDKDOI', '2.doi', '20', 'DOI', WinLinuxMac, 'doi'),
'mock': SDK('HL2SDK-MOCK', '2.mock', '999', 'MOCK', Mock, 'mock'),
}
# Stable sorting for command equivalence in AMBuild.
PossibleSDKs = collections.OrderedDict()
for key in sorted(SDKMap.keys()):
PossibleSDKs[key] = SDKMap[key]
def ResolveEnvPath(env, folder):
if env in os.environ:
@@ -32,15 +107,9 @@ def SetArchFlags(compiler):
if compiler.target.arch == 'x86_64':
compiler.defines += ['WIN64']
SdkHelpers = builder.Eval('hl2sdk-manifests/SdkHelpers.ambuild', {
'Project': 'sourcemod'
})
class SMConfig(object):
def __init__(self):
self.sdk_manifests = []
self.sdks = {}
self.sdk_targets = []
self.binaries = []
self.spvm = []
self.extensions = []
@@ -48,14 +117,13 @@ class SMConfig(object):
self.mms_root = None
self.mysql_root = {}
self.spcomp = None
self.spcomp_bins = []
self.spcomp_bins = None
self.smx_files = {}
self.versionlib = None
self.all_targets = []
self.target_archs = set()
self.enable_asan = getattr(builder.options, 'enable_asan', False)
self.asan_libs = {}
self.libsafetyhook = {}
if builder.options.targets:
target_archs = builder.options.targets.split(',')
@@ -97,38 +165,43 @@ class SMConfig(object):
import re
with open(os.path.join(builder.sourcePath, 'product.version'), 'r') as fp:
productContents = fp.read()
m = re.match(r'(\d+)\.(\d+)\.(\d+).*', productContents)
m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
if m == None:
self.productVersion = '1.0.0'
else:
major, minor, release = m.groups()
self.productVersion = '{0}.{1}.{2}'.format(major, minor, release)
def findSdkPath(self, sdk_name):
dir_name = 'hl2sdk-{}'.format(sdk_name)
if builder.options.hl2sdk_root:
sdk_path = os.path.join(builder.options.hl2sdk_root, dir_name)
if os.path.exists(sdk_path):
return sdk_path
return ResolveEnvPath('HL2SDK{}'.format(sdk_name.upper()), dir_name)
def shouldIncludeSdk(self, sdk):
return not sdk.get('source2', False)
def detectSDKs(self):
sdk_list = [s for s in builder.options.sdks.split(',') if s]
SdkHelpers.sdk_filter = self.shouldIncludeSdk
SdkHelpers.find_sdk_path = self.findSdkPath
SdkHelpers.findSdks(builder, self.all_targets, sdk_list)
sdk_list = builder.options.sdks.split(',')
use_none = sdk_list[0] == 'none'
use_all = sdk_list[0] == 'all'
use_present = sdk_list[0] == 'present'
self.sdks = SdkHelpers.sdks
self.sdk_manifests = SdkHelpers.sdk_manifests
self.sdk_targets = SdkHelpers.sdk_targets
for sdk_name in PossibleSDKs:
sdk = PossibleSDKs[sdk_name]
if sdk.shouldBuild(self.all_targets):
if builder.options.hl2sdk_root:
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
else:
sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
if sdk_path is None or not os.path.isdir(sdk_path):
if (use_all and sdk_name != 'mock') or sdk_name in sdk_list:
raise Exception('Could not find a valid path for {0}'.format(sdk.envvar))
continue
if use_all or use_present or sdk_name in sdk_list:
sdk.path = Normalize(sdk_path)
self.sdks[sdk_name] = sdk
if len(self.sdks) < 1 and len(sdk_list) and not use_none:
raise Exception('No applicable SDKs were found, nothing to do')
if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12')
self.mms_root = ResolveEnvPath('MMSOURCE111', 'mmsource-1.11')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
if not self.mms_root:
@@ -166,14 +239,7 @@ class SMConfig(object):
def configure(self):
builder.AddConfigureFile('pushbuild.txt')
allowed_archs = ['x86_64']
if builder.host.platform == 'mac':
if getattr(builder.options, 'scripting_only', False):
allowed_archs += ['arm64']
else:
allowed_archs += ['x86']
if not set(self.target_archs).issubset(allowed_archs):
if not set(self.target_archs).issubset(['x86', 'x86_64']):
raise Exception('Unknown target architecture: {0}'.format(self.target_archs))
for cxx in self.all_targets:
@@ -181,14 +247,14 @@ class SMConfig(object):
def configure_cxx(self, cxx):
if cxx.family == 'msvc':
if cxx.version < 1914 and builder.options.generator != 'vs':
raise Exception(f'Only MSVC 2017 15.7 and later are supported, full C++17 support is required. ({str(cxx.version)} < 1914)')
elif cxx.family == 'gcc':
if cxx.version < 'gcc-9':
raise Exception('Only GCC versions 9 or later are supported, full C++17 support is required.')
elif cxx.family == 'clang':
if cxx.version < 'clang-5':
raise Exception('Only clang versions 5 or later are supported, full C++17 support is required.')
if cxx.version < 1900:
raise Exception('Only MSVC 2015 and later are supported, c++14 support is required.')
if cxx.family == 'gcc':
if cxx.version < 'gcc-4.9':
raise Exception('Only GCC versions 4.9 or greater are supported, c++14 support is required.')
if cxx.family == 'clang':
if cxx.version < 'clang-3.4':
raise Exception('Only clang versions 3.4 or greater are supported, c++14 support is required.')
if cxx.like('gcc'):
self.configure_gcc(cxx)
@@ -243,18 +309,19 @@ class SMConfig(object):
'-Wno-unused',
'-Wno-switch',
'-Wno-array-bounds',
'-msse',
'-fvisibility=hidden',
]
if cxx.target.arch in ['x86', 'x86_64']:
cxx.cflags += ['-msse']
cxx.cxxflags += ['-std=c++17']
if cxx.version == 'apple-clang-6.0' or cxx.version == 'clang-3.4':
cxx.cxxflags += ['-std=c++1y']
else:
cxx.cxxflags += ['-std=c++14']
cxx.cxxflags += [
'-fno-threadsafe-statics',
'-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual',
'-Wno-register',
'-fvisibility-inlines-hidden',
]
@@ -331,7 +398,6 @@ class SMConfig(object):
'/EHsc',
'/GR-',
'/TP',
'/std:c++17',
]
cxx.linkflags += [
'kernel32.lib',
@@ -383,7 +449,7 @@ class SMConfig(object):
self.asan_libs[cxx.target.arch] = os.path.dirname(output)
def configure_linux(self, cxx):
cxx.defines += ['LINUX', '_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
cxx.linkflags += ['-lm']
if cxx.family == 'gcc':
cxx.linkflags += ['-static-libgcc']
@@ -393,9 +459,9 @@ class SMConfig(object):
def configure_mac(self, cxx):
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
cxx.cflags += ['-mmacosx-version-min=10.15']
cxx.cflags += ['-mmacosx-version-min=10.7']
cxx.linkflags += [
'-mmacosx-version-min=10.15',
'-mmacosx-version-min=10.7',
'-stdlib=libc++',
'-lc++',
]
@@ -439,7 +505,6 @@ class SMConfig(object):
self.AddVersioning(binary)
if binary.compiler.like('msvc'):
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
self.AddCxxCompat(binary)
# Dumb clang behavior means we have to manually find libclang_rt.
if self.enable_asan:
@@ -499,12 +564,6 @@ class SMConfig(object):
self.ConfigureForExtension(context, binary.compiler)
return binary
def AddCxxCompat(self, binary):
if binary.compiler.target.platform == 'linux':
binary.sources += [
os.path.join(builder.sourcePath, 'public', 'amtl', 'compat', 'stdcxx.cpp'),
]
def ConfigureForHL2(self, context, binary, sdk):
compiler = binary.compiler
SetArchFlags(compiler)
@@ -514,24 +573,155 @@ class SMConfig(object):
os.path.join(self.mms_root, 'core', 'sourcehook'),
]
for other_sdk in self.sdk_manifests:
compiler.defines += ['SE_{}={}'.format(other_sdk['define'], other_sdk['code'])]
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
compiler.defines += defines
SdkHelpers.configureCxx(context, binary, sdk)
paths = [
['public'],
['public', 'engine'],
['public', 'mathlib'],
['public', 'vstdlib'],
['public', 'tier0'],
['public', 'tier1']
]
if sdk.name == 'episode1' or sdk.name == 'darkm':
paths.append(['public', 'dlls'])
paths.append(['game_shared'])
else:
paths.append(['public', 'game', 'server'])
paths.append(['public', 'toolframework'])
paths.append(['game', 'shared'])
paths.append(['common'])
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
if sdk.name in ['sdk2013', 'bms'] and compiler.like('gcc'):
# The 2013 SDK already has these in public/tier0/basetypes.h
compiler.defines.remove('stricmp=strcasecmp')
compiler.defines.remove('_stricmp=strcasecmp')
compiler.defines.remove('_snprintf=snprintf')
compiler.defines.remove('_vsnprintf=vsnprintf')
if compiler.like('msvc'):
compiler.defines += ['COMPILER_MSVC']
if compiler.target.arch == 'x86':
compiler.defines += ['COMPILER_MSVC32']
elif compiler.target.arch == 'x86_64':
compiler.defines += ['COMPILER_MSVC64']
compiler.linkflags += ['legacy_stdio_definitions.lib']
else:
compiler.defines += ['COMPILER_GCC']
if compiler.target.arch == 'x86_64':
compiler.defines += ['X64BITS', 'PLATFORM_64BITS']
# For everything after Swarm, this needs to be defined for entity networking
# to work properly with sendprop value changes.
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']:
compiler.defines += ['NETWORK_VARS_ENABLED']
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']:
if compiler.target.platform in ['linux', 'mac']:
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
if compiler.target.platform == 'linux':
if sdk.name in ['csgo', 'blade']:
compiler.linkflags.remove('-static-libstdc++')
compiler.linkflags += ['-lstdc++']
compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
elif compiler.target.platform == 'mac':
if sdk.name in ['csgo']:
# Switch libc++ to libstdc++ for protobuf linkage.
compiler.cxxflags.remove('-stdlib=libc++')
compiler.linkflags.remove('-stdlib=libc++')
compiler.linkflags.remove('-lc++')
compiler.cxxflags += ['-stdlib=libstdc++']
compiler.linkflags += ['-stdlib=libstdc++']
compiler.linkflags += ['-lstdc++']
if 'c++1y' in compiler.cxxflags:
compiler.cxxflags.remove('-std=c++1y')
compiler.cxxflags += ['-std=c++11']
elif 'c++14' in compiler.cxxflags:
compiler.cxxflags.remove('-std=c++14')
compiler.cxxflags += ['-std=c++11']
for path in paths:
compiler.cxxincludes += [os.path.join(sdk.path, *path)]
if compiler.target.platform == 'linux':
if sdk.name == 'episode1':
lib_folder = os.path.join(sdk.path, 'linux_sdk')
elif sdk.name in ['sdk2013', 'bms']:
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32')
elif compiler.target.arch == 'x86_64':
lib_folder = os.path.join(sdk.path, 'lib', 'linux64')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'linux')
elif compiler.target.platform == 'mac':
if sdk.name in ['sdk2013', 'bms']:
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
elif compiler.target.arch == 'x86_64':
lib_folder = os.path.join(sdk.path, 'lib', 'osx64')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
if compiler.target.platform in ['linux', 'mac']:
if sdk.name in ['sdk2013', 'bms'] or compiler.target.arch == 'x86_64':
compiler.postlink += [
os.path.join(lib_folder, 'tier1.a'),
os.path.join(lib_folder, 'mathlib.a')
]
else:
compiler.postlink += [
os.path.join(lib_folder, 'tier1_i486.a'),
os.path.join(lib_folder, 'mathlib_i486.a')
]
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']:
if compiler.target.arch == 'x86_64':
compiler.postlink += [os.path.join(lib_folder, 'interfaces.a')]
else:
compiler.postlink += [os.path.join(lib_folder, 'interfaces_i486.a')]
dynamic_libs = []
if compiler.target.platform == 'linux':
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']:
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
elif compiler.target.arch == 'x86_64' and sdk.name in ['csgo', 'mock']:
dynamic_libs = ['libtier0_client.so', 'libvstdlib_client.so']
elif sdk.name in ['l4d', 'blade', 'insurgency', 'doi', 'csgo']:
dynamic_libs = ['libtier0.so', 'libvstdlib.so']
else:
dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
elif compiler.target.platform == 'mac':
compiler.linkflags.append('-liconv')
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
elif compiler.target.platform == 'windows':
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
if sdk.name in ['swarm', 'blade', 'insurgency', 'doi', 'csgo']:
libs.append('interfaces')
for lib in libs:
if compiler.target.arch == 'x86':
lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
elif compiler.target.arch == 'x86_64':
lib_path = os.path.join(sdk.path, 'lib', 'public', 'win64', lib) + '.lib'
compiler.linkflags.append(lib_path)
for library in dynamic_libs:
source_path = os.path.join(lib_folder, library)
output_path = os.path.join(binary.localFolder, library)
# Ensure the output path exists.
context.AddFolder(binary.localFolder)
output = context.AddSymlink(source_path, output_path)
compiler.weaklinkdeps += [output]
compiler.linkflags[0:0] = [library]
return binary
def AddCDetour(self, binary):
public_path = os.path.join(builder.sourcePath, 'public')
binary.sources += [ os.path.join(public_path, 'CDetour', 'detours.cpp') ]
binary.compiler.cxxincludes += [ os.path.join(public_path, 'safetyhook', 'include') ]
for task in self.libsafetyhook:
if task.target.arch == binary.compiler.target.arch:
binary.compiler.linkflags += [task.binary]
return
raise Exception('No suitable build of safetyhook was found.')
def HL2Library(self, context, compiler, name, sdk):
binary = self.Library(context, compiler, name)
self.ConfigureForExtension(context, binary.compiler)
@@ -539,15 +729,13 @@ class SMConfig(object):
def HL2Config(self, project, context, compiler, name, sdk):
binary = project.Configure(compiler, name,
'{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch))
self.AddCxxCompat(binary)
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
self.AddVersioning(binary)
return self.ConfigureForHL2(context, binary, sdk)
def HL2ExtConfig(self, project, context, compiler, name, sdk):
binary = project.Configure(compiler, name,
'{0} - {1} {2}'.format(self.tag, sdk['name'], compiler.target.arch))
self.AddCxxCompat(binary)
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
self.AddVersioning(binary)
self.ConfigureForHL2(context, binary, sdk)
self.ConfigureForExtension(context, binary.compiler)
@@ -580,19 +768,7 @@ if SM.use_auto_versioning():
{ 'SM': SM }
)
class SafetyHookShim(object):
def __init__(self):
self.all_targets = {}
self.libsafetyhook = {}
SafetyHook = SafetyHookShim()
SafetyHook.all_targets = SM.all_targets
builder.Build('public/safetyhook/AMBuilder', {'SafetyHook': SafetyHook })
SM.libsafetyhook = SafetyHook.libsafetyhook
class SPRoot(object):
def __init__(self):
self.generated_headers = SM.generated_headers
# SourcePawn's build scripts are always one-offs, and attach the current target
# to the builder, so we have to provide a shim to our StaticLibrary() method.
def StaticLibrary(self, builder, name):
@@ -620,24 +796,11 @@ SP = builder.Build('sourcepawn/AMBuildScript', {
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
'external_build': SP_build_parts,
})
def IsBetterDefaultSpcomp(spcomp, other):
if other is None:
return True
if spcomp.target.arch == 'universal':
return True
if other.target.arch == 'universal':
return False
return spcomp.target.arch == 'x86'
for spcomp in SP.spcomp:
if IsBetterDefaultSpcomp(spcomp, SM.spcomp):
SM.spcomp = spcomp
SM.spcomp_bins.append(spcomp)
# If we have a universal binary, ignore all other spcomps.
if SM.spcomp.target.arch == 'universal':
SM.spcomp_bins = [SM.spcomp]
if len(SP.spcomp) > 1:
SM.spcomp = SP.spcomp['x86']
else:
SM.spcomp = SP.spcomp[list(SP.spcomp.keys())[0]]
SM.spcomp_bins = list(SP.spcomp.values())
if not getattr(builder.options, 'scripting_only', False):
for cxx in SM.all_targets:
-1
View File
@@ -16,7 +16,6 @@ Development
- [SourcePawn scripting](https://wiki.alliedmods.net/Category:SourceMod_Scripting): SourcePawn examples and introduction to the language
- [SourceMod plugin API](https://sm.alliedmods.net/new-api): Online SourceMod plugin API reference generated from the include files
- [SourceMod extension development](https://wiki.alliedmods.net/Category:SourceMod_Development): C++ examples and introduction to various extension interfaces
- [Translation project](https://github.com/orgs/alliedmodders/projects/1): Help [translate SourceMod](https://wiki.alliedmods.net/Translations_(SourceMod_Scripting)) into your language
Contact
-------
+3
View File
@@ -86,6 +86,9 @@ public:
const char *gamesuffix;
/* Data */
ServerGlobals *serverGlobals;
void * serverFactory;
void * engineFactory;
void * matchmakingDSFactory;
SMGlobalClass * listeners;
// ConVar functions.
-2
View File
@@ -44,7 +44,6 @@ public:
virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0;
virtual bool EndOfFile(FileHandle_t file) = 0;
virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0;
virtual unsigned int Size(FileHandle_t file) = 0;
virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0;
virtual int Read(void* pOutput, int size, FileHandle_t file) = 0;
virtual int Write(void const* pInput, int size, FileHandle_t file) = 0;
@@ -57,7 +56,6 @@ public:
virtual void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID = 0) = 0;
virtual bool IsDirectory(const char *pFileName, const char *pathID = 0) = 0;
virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0;
virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) = 0;
};
} // namespace SourceMod
+18
View File
@@ -53,6 +53,24 @@
* passwords to work, for security reasons.
*/
"PassInfoVar" "_password"
/**
* Specifies the sound that gets played when an item is selected from a menu.
*/
"MenuItemSound" "buttons/button14.wav"
/**
* Specifies the sound that gets played when an "Exit" button is selected
* from a menu.
*/
"MenuExitSound" "buttons/combine_button7.wav"
/**
* Specifies the sound that gets played when an "Exit Back" button is selected
* from a menu. This is the special "Back" button that is intended to roll back
* to a previous menu.
*/
"MenuExitBackSound" "buttons/combine_button7.wav"
/**
* Enables or disables whether SourceMod reads a client's cl_language cvar to set
+1 -35
View File
@@ -1,38 +1,4 @@
"Languages"
{
"ar" "Arabic" // Arabic
"bg" "Bulgarian" // Bulgarian
"chi" "SChinese" // Chinese (Simplified)
"cze" "Czech" // Czech
"da" "Danish" // Danish
"de" "German" // German
"el" "Greek" // Greek
"en" "English" // English
"es" "Spanish" // Spanish
"fi" "Finnish" // Finnish
"fr" "French" // French
"he" "Hebrew" // Hebrew
"hu" "Hungarian" // Hungarian
"it" "Italian" // Italian
"jp" "Japanese" // Japanese
"ko" "Korean" // Korean
"ko" "KoreanA" // Korean (https://bugs.alliedmods.net/show_bug.cgi?id=4667)
"las" "LatAm" // Latin American Spanish
"lt" "Lithuanian" // Lithuanian
"lv" "Latvian" // Latvian
"nl" "Dutch" // Dutch
"no" "Norwegian" // Norwegian
"pl" "Polish" // Polish
"pt" "Brazilian" // Brazilian Portuguese
"pt_p" "Portuguese" // Portuguese
"ro" "Romanian" // Romanian
"ru" "Russian" // Russian
"sk" "Slovak" // Slovak
"sv" "Swedish" // Swedish
"th" "Thai" // Thai
"tr" "Turkish" // Turkish
"ua" "Ukrainian" // Ukrainian
"vi" "Vietnamese" // Vietnamese
"zho" "TChinese" // Chinese (Traditional)
"en" "English"
}
+79 -85
View File
@@ -42,99 +42,93 @@ project.sources += [
'GameHooks.cpp',
]
# SDK name to shipping gamedir
pb_gamedir_map = {
'csgo': 'csgo',
'blade': 'berimbau',
'mcv': 'vietnam',
}
for sdk_name in SM.sdks:
sdk = SM.sdks[sdk_name]
for cxx in builder.targets:
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
continue
# SDK name to source code gamedir
pb_gamesrcdir_map = {
'csgo': 'cstrike15',
'blade': 'berimbau',
'mcv': 'vietnam',
}
binary_name = 'sourcemod.' + sdk.ext
for sdk_target in SM.sdk_targets:
sdk = sdk_target.sdk
cxx = sdk_target.cxx
binary = SM.HL2Config(project, builder, cxx, binary_name, sdk)
SM.ConfigureForExtension(builder, binary.compiler)
binary_name = 'sourcemod.' + sdk['extension']
needs_protobuf = sdk['name'] in ['csgo', 'blade', 'mcv']
binary = SM.HL2Config(project, builder, cxx, binary_name, sdk)
SM.ConfigureForExtension(builder, binary.compiler)
compiler = binary.compiler
compiler.cxxincludes += [
builder.sourcePath
]
if needs_protobuf:
compiler = binary.compiler
compiler.cxxincludes += [
os.path.join(sdk['path'], 'common', 'protobuf-2.5.0', 'src'),
os.path.join(sdk['path'], 'public', 'engine', 'protobuf'),
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf')
builder.sourcePath
]
if sdk.name == 'csgo':
compiler.cxxincludes += [
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf')
]
elif sdk.name == 'blade':
compiler.cxxincludes += [
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf')
]
if compiler.like('msvc'):
compiler.defines += ['_ALLOW_KEYWORD_MACROS']
if cxx.target.platform == 'linux':
compiler.postlink += ['-lpthread', '-lrt']
if sdk.name in ['csgo', 'blade']:
if compiler.target.platform == 'linux':
if compiler.target.arch == 'x86':
lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a')
elif compiler.target.arch == 'x86_64':
lib_path = os.path.join(sdk.path, 'lib', 'linux64', 'release', 'libprotobuf.a')
compiler.linkflags += ['-Wl,--exclude-libs=libprotobuf.a']
elif compiler.target.platform == 'mac':
if compiler.target.arch == 'x86':
lib_path = os.path.join(sdk.path, 'lib', 'osx32', 'release', 'libprotobuf.a')
elif compiler.target.arch == 'x86_64':
lib_path = os.path.join(sdk.path, 'lib', 'osx64', 'release', 'libprotobuf.a')
elif compiler.target.platform == 'windows':
msvc_ver = compiler.version
vs_year = ''
platform = ''
if compiler.target.arch == 'x86':
platform = 'win32'
elif compiler.target.arch == 'x86_64':
platform = 'win64'
if 1900 <= msvc_ver < 2000:
vs_year = '2015'
else:
raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"')
if 'DEBUG' in compiler.defines:
lib_path = os.path.join(sdk.path, 'lib', platform, 'debug', 'vs' + vs_year, 'libprotobuf.lib')
else:
lib_path = os.path.join(sdk.path, 'lib', platform, 'release', 'vs' + vs_year, 'libprotobuf.lib')
compiler.linkflags.insert(0, lib_path)
if compiler.like('msvc'):
compiler.defines += ['_ALLOW_KEYWORD_MACROS']
if cxx.target.platform == 'linux':
compiler.postlink += ['-lpthread', '-lrt']
if sdk.name in ['csgo', 'blade']:
binary.sources += ['smn_protobuf.cpp']
else:
binary.sources += ['smn_bitbuffer.cpp']
if needs_protobuf:
if compiler.target.platform == 'linux':
if compiler.target.arch == 'x86':
lib_path = os.path.join(sdk['path'], 'lib', 'linux32', 'release', 'libprotobuf.a')
elif compiler.target.arch == 'x86_64':
lib_path = os.path.join(sdk['path'], 'lib', 'linux64', 'release', 'libprotobuf.a')
compiler.linkflags += ['-Wl,--exclude-libs=libprotobuf.a']
elif compiler.target.platform == 'mac':
if compiler.target.arch == 'x86':
lib_path = os.path.join(sdk['path'], 'lib', 'osx32', 'release', 'libprotobuf.a')
elif compiler.target.arch == 'x86_64':
lib_path = os.path.join(sdk['path'], 'lib', 'osx64', 'release', 'libprotobuf.a')
elif compiler.target.platform == 'windows':
msvc_ver = compiler.version
vs_year = ''
platform = ''
if compiler.target.arch == 'x86':
platform = 'win32'
elif compiler.target.arch == 'x86_64':
platform = 'win64'
if 1900 <= msvc_ver < 2000:
vs_year = '2015'
else:
raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"')
if 'DEBUG' in compiler.defines:
lib_path = os.path.join(sdk['path'], 'lib', platform, 'debug', 'vs' + vs_year, 'libprotobuf.lib')
else:
lib_path = os.path.join(sdk['path'], 'lib', platform, 'release', 'vs' + vs_year, 'libprotobuf.lib')
compiler.linkflags.insert(0, lib_path)
if needs_protobuf:
binary.sources += ['smn_protobuf.cpp']
else:
binary.sources += ['smn_bitbuffer.cpp']
if sdk['name'] != 'blade':
binary.sources += [
'vprof_tool.cpp',
]
if needs_protobuf:
binary.sources += [
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_usermessages.pb.cc'),
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_usermessage_helpers.cpp'),
]
if sdk['name'] == 'mcv':
if sdk.name != 'blade':
binary.sources += [
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_gcmessages.pb.cc'),
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'engine_gcmessages.pb.cc'),
'vprof_tool.cpp',
]
if sdk.name == 'csgo':
binary.sources += [
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessages.pb.cc'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessage_helpers.cpp'),
]
elif sdk.name == 'blade':
binary.sources += [
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf', 'berimbau_usermessages.pb.cc'),
os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf', 'berimbau_usermessage_helpers.cpp'),
]
SM.binaries += builder.Add(project)
-20
View File
@@ -461,23 +461,3 @@ bool ChatTriggers::WasFloodedMessage()
{
return m_bWasFloodedMessage;
}
const char *ChatTriggers::GetPublicChatTrigger()
{
if (!m_PubTrigger.length())
{
return NULL;
}
return m_PubTrigger.c_str();
}
const char *ChatTriggers::GetPrivateChatTrigger()
{
if (!m_PrivTrigger.length())
{
return NULL;
}
return m_PrivTrigger.c_str();
}
-2
View File
@@ -63,8 +63,6 @@ public:
unsigned int SetReplyTo(unsigned int reply);
bool IsChatTrigger();
bool WasFloodedMessage();
const char *GetPublicChatTrigger();
const char *GetPrivateChatTrigger();
private:
enum ChatTriggerType {
ChatTrigger_Public,
+1 -1
View File
@@ -115,7 +115,7 @@ void GameHooks::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPla
const char *cvarName, const char *cvarValue){
int client = IndexOfEdict(pPlayer);
# if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
# if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (g_Players.HandleConVarQuery(cookie, client, result, cvarName, cvarValue))
return;
# endif
+23 -72
View File
@@ -47,8 +47,6 @@
#include <cstrike15_usermessages.pb.h>
#elif SOURCE_ENGINE == SE_BLADE
#include <berimbau_usermessages.pb.h>
#elif SOURCE_ENGINE == SE_MCV
#include <vietnam_usermessages.pb.h>
#endif
typedef ICommandLine *(*FakeGetCommandLine)();
@@ -186,8 +184,7 @@ void CHalfLife2::InitLogicalEntData()
|| SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS \
|| SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_NUCLEARDAWN \
|| SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_NUCLEARDAWN
if (g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr))
{
@@ -413,17 +410,6 @@ ServerClass *CHalfLife2::FindServerClass(const char *classname)
return pInfo->sc;
}
ServerClass *CHalfLife2::FindEntityServerClass(CBaseEntity *pEntity)
{
IServerNetworkable* pNetwork = ((IServerUnknown *)pEntity)->GetNetworkable();
if (pNetwork == nullptr)
{
return nullptr;
}
return pNetwork->GetServerClass();
}
DataTableInfo *CHalfLife2::_FindServerClass(const char *classname)
{
DataTableInfo *pInfo = NULL;
@@ -456,25 +442,20 @@ bool CHalfLife2::FindSendPropInfo(const char *classname, const char *offset, sm_
return false;
}
DataTableInfo::SendPropInfo temp;
if (!pInfo->lookup.retrieve(offset, &temp))
if (!pInfo->lookup.retrieve(offset, info))
{
bool found = UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp.info, 0);
temp.name = offset;
sm_sendprop_info_t temp_info;
pInfo->lookup.insert(offset, temp);
if (found)
if (!UTIL_FindInSendTable(pInfo->sc->m_pTable, offset, &temp_info, 0))
{
*info = temp.info;
return false;
}
return found;
pInfo->lookup.insert(offset, temp_info);
*info = temp_info;
}
*info = temp.info;
return info->prop != nullptr;
return true;
}
SendProp *CHalfLife2::FindInSendTable(const char *classname, const char *offset)
@@ -508,25 +489,15 @@ bool CHalfLife2::FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatab
m_Maps.add(i, pMap, new DataMapCache());
DataMapCache *cache = i->value;
DataMapCacheInfo temp;
if (!cache->retrieve(offset, &temp))
if (!cache->retrieve(offset, pDataTable))
{
bool found = UTIL_FindDataMapInfo(pMap, offset, &temp.info);
temp.name = offset;
cache->insert(offset, temp);
if (found)
{
*pDataTable = temp.info;
}
return found;
if (!UTIL_FindDataMapInfo(pMap, offset, pDataTable))
return false;
cache->insert(offset, *pDataTable);
}
*pDataTable = temp.info;
return pDataTable->prop != nullptr;
return true;
}
void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset)
@@ -567,7 +538,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
char buffer[253];
ke::SafeSprintf(buffer, sizeof(buffer), "%s\1\n", msg);
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CCSUsrMsg_SayText *pMsg;
if ((pMsg = (CCSUsrMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
{
@@ -594,7 +565,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg)
}
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CCSUsrMsg_TextMsg *pMsg;
if ((pMsg = (CCSUsrMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
{
@@ -631,7 +602,7 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg)
{
cell_t players[] = {client};
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CCSUsrMsg_HintText *pMsg;
if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, 1, USERMSG_RELIABLE)) == NULL)
{
@@ -661,7 +632,7 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg)
bool CHalfLife2::HintTextMsg(cell_t *players, int count, const char *msg)
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CCSUsrMsg_HintText *pMsg;
if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL)
{
@@ -696,7 +667,7 @@ bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, boo
int count = 0;
cell_t players[] = {client};
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CCSUsrMsg_VGUIMenu *pMsg;
if ((pMsg = (CCSUsrMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL)
{
@@ -721,7 +692,7 @@ bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, boo
SubKey = data->GetFirstSubKey();
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
pMsg->set_name(name);
pMsg->set_show(show);
@@ -1110,26 +1081,8 @@ int CHalfLife2::ReferenceToIndex(cell_t entRef)
return hndl.GetEntryIndex();
}
else
{
CEntInfo *pInfo = LookupEntity(entRef);
if (!pInfo)
{
return INVALID_EHANDLE_INDEX;
}
IServerUnknown *pUnk = static_cast<IServerUnknown *>(pInfo->m_pEntity);
if (!pUnk)
{
return INVALID_EHANDLE_INDEX;
}
CBaseEntity *pEntity = pUnk->GetBaseEntity();
if (!pEntity)
{
return INVALID_EHANDLE_INDEX;
}
return entRef;
}
return entRef;
}
cell_t CHalfLife2::EntityToBCompatRef(CBaseEntity *pEntity)
@@ -1386,7 +1339,7 @@ SMFindMapResult CHalfLife2::FindMap(const char *pMapName, char *pFoundMap, size_
}
#elif SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_HL2DM \
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS
static IVEngineServer *engine23 = (IVEngineServer *)(g_SMAPI->GetEngineFactory()("VEngineServer023", nullptr));
if (engine23)
{
@@ -1573,9 +1526,7 @@ uint64_t CHalfLife2::GetServerSteamId64() const
|| SOURCE_ENGINE == SE_DOI \
|| SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_ALIENSWARM \
|| SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_PVKII \
|| SOURCE_ENGINE == SE_MCV
|| SOURCE_ENGINE == SE_TF2
const CSteamID *sid = engine->GetGameServerSteamID();
if (sid)
{
+9 -26
View File
@@ -74,7 +74,7 @@ using namespace SourceMod;
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI
#define SOURCE_BIN_PREFIX "lib"
#define SOURCE_BIN_SUFFIX "_srv"
#elif SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_PVKII
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
#define SOURCE_BIN_PREFIX "lib"
#define SOURCE_BIN_SUFFIX ""
#else
@@ -89,24 +89,16 @@ using namespace SourceMod;
struct DataTableInfo
{
struct SendPropInfo
struct SendPropPolicy
{
static inline bool matches(const char *name, const SendPropInfo &info)
static inline bool matches(const char *name, const sm_sendprop_info_t &info)
{
return strcmp(name, info.name.c_str()) == 0;
return strcmp(name, info.prop->GetName()) == 0;
}
static inline uint32_t hash(const detail::CharsAndLength &key)
{
return key.hash();
}
SendPropInfo()
: name(), info{nullptr, 0}
{
}
std::string name;
sm_sendprop_info_t info;
};
static inline bool matches(const char *name, const DataTableInfo *info)
@@ -124,30 +116,22 @@ struct DataTableInfo
}
ServerClass *sc;
NameHashSet<SendPropInfo> lookup;
NameHashSet<sm_sendprop_info_t, SendPropPolicy> lookup;
};
struct DataMapCacheInfo
struct DataMapCachePolicy
{
static inline bool matches(const char *name, const DataMapCacheInfo &info)
static inline bool matches(const char *name, const sm_datatable_info_t &info)
{
return strcmp(name, info.name.c_str()) == 0;
return strcmp(name, info.prop->fieldName) == 0;
}
static inline uint32_t hash(const detail::CharsAndLength &key)
{
return key.hash();
}
DataMapCacheInfo()
: name(), info{nullptr, 0}
{
}
std::string name;
sm_datatable_info_t info;
};
typedef NameHashSet<DataMapCacheInfo> DataMapCache;
typedef NameHashSet<sm_datatable_info_t, DataMapCachePolicy> DataMapCache;
struct DelayedFakeCliCmd
{
@@ -221,7 +205,6 @@ public: //IGameHelpers
bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
datamap_t *GetDataMap(CBaseEntity *pEntity);
ServerClass *FindServerClass(const char *classname);
ServerClass *FindEntityServerClass(CBaseEntity *pEntity);
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
bool FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatable_info_t *pDataTable);
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
+26 -29
View File
@@ -38,7 +38,6 @@
#include "sourcemm_api.h"
#include "PlayerManager.h"
#include "MenuStyle_Valve.h"
#include <IGameConfigs.h>
#include "sourcemm_api.h"
#include "logic_bridge.h"
@@ -69,29 +68,6 @@ void MenuManager::OnSourceModAllInitialized()
m_StyleType = handlesys->CreateType("IMenuStyle", this, 0, NULL, &access, g_pCoreIdent, NULL);
}
void MenuManager::OnSourceModAllInitialized_Post()
{
const char* pTmp;
pTmp = g_pGameConf->GetKeyValue("MenuItemSound");
if (nullptr != pTmp)
{
m_SelectSound = pTmp;
}
pTmp = g_pGameConf->GetKeyValue("MenuExitSound");
if (nullptr != pTmp)
{
m_ExitSound = pTmp;
}
pTmp = g_pGameConf->GetKeyValue("MenuExitBackSound");
if (nullptr != pTmp)
{
m_ExitBackSound = pTmp;
}
}
void MenuManager::OnSourceModAllShutdown()
{
handlesys->RemoveType(m_MenuType, g_pCoreIdent);
@@ -723,9 +699,30 @@ bool MenuManager::MenuSoundsEnabled()
return (sm_menu_sounds.GetInt() != 0);
}
std::string *MenuManager::GetMenuSound(ItemSelection sel)
ConfigResult MenuManager::OnSourceModConfigChanged(const char *key,
const char *value,
ConfigSource source,
char *error,
size_t maxlength)
{
std::string *sound = nullptr;
if (strcmp(key, "MenuItemSound") == 0)
{
m_SelectSound.assign(value);
return ConfigResult_Accept;
} else if (strcmp(key, "MenuExitBackSound") == 0) {
m_ExitBackSound.assign(value);
return ConfigResult_Accept;
} else if (strcmp(key, "MenuExitSound") == 0) {
m_ExitSound.assign(value);
return ConfigResult_Accept;
}
return ConfigResult_Ignore;
}
const char *MenuManager::GetMenuSound(ItemSelection sel)
{
const char *sound = NULL;
switch (sel)
{
@@ -735,7 +732,7 @@ std::string *MenuManager::GetMenuSound(ItemSelection sel)
{
if (m_SelectSound.size() > 0)
{
sound = &m_SelectSound;
sound = m_SelectSound.c_str();
}
break;
}
@@ -743,7 +740,7 @@ std::string *MenuManager::GetMenuSound(ItemSelection sel)
{
if (m_ExitBackSound.size() > 0)
{
sound = &m_ExitBackSound;
sound = m_ExitBackSound.c_str();
}
break;
}
@@ -751,7 +748,7 @@ std::string *MenuManager::GetMenuSound(ItemSelection sel)
{
if (m_ExitSound.size() > 0)
{
sound = &m_ExitSound;
sound = m_ExitSound.c_str();
}
break;
}
+10 -6
View File
@@ -36,8 +36,8 @@
#include <sh_vector.h>
#include <sh_stack.h>
#include <sh_list.h>
#include <sh_string.h>
#include "sm_globals.h"
#include <string>
using namespace SourceMod;
using namespace SourceHook;
@@ -55,8 +55,12 @@ public:
MenuManager();
public: //SMGlobalClass
void OnSourceModAllInitialized();
void OnSourceModAllInitialized_Post();
void OnSourceModAllShutdown();
ConfigResult OnSourceModConfigChanged(const char *key,
const char *value,
ConfigSource source,
char *error,
size_t maxlength);
void OnSourceModLevelChange(const char *mapName);
public: //IMenuManager
virtual const char *GetInterfaceName()
@@ -95,7 +99,7 @@ public:
HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
public:
bool MenuSoundsEnabled();
std::string *GetMenuSound(ItemSelection sel);
const char *GetMenuSound(ItemSelection sel);
protected:
Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
Handle_t CreateStyleHandle(IMenuStyle *style);
@@ -105,9 +109,9 @@ private:
CVector<IMenuStyle *> m_Styles;
HandleType_t m_StyleType;
HandleType_t m_MenuType;
std::string m_SelectSound = "";
std::string m_ExitBackSound = "";
std::string m_ExitSound = "";
String m_SelectSound;
String m_ExitBackSound;
String m_ExitSound;
};
extern MenuManager g_Menus;
+21 -77
View File
@@ -8,7 +8,7 @@
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
@@ -99,7 +99,7 @@ void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool
/* Fire callbacks */
mh->OnMenuCancel(menu, client, reason);
/* Only fire end if there's a valid menu */
if (menu)
{
@@ -214,7 +214,7 @@ void BaseMenuStyle::ProcessWatchList()
}
#if defined MENU_DEBUG
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
m_WatchList.m_Size,
m_WatchList.m_FirstLink,
m_WatchList.m_FreeNodes,
@@ -302,7 +302,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
ItemSelection type = states.slots[key_press].type;
/* Check if we should play a sound about the type */
if (g_Menus.MenuSoundsEnabled() &&
if (g_Menus.MenuSoundsEnabled() &&
(!menu || (menu->GetMenuOptionFlags() & MENUFLAG_NO_SOUND) != MENUFLAG_NO_SOUND))
{
CellRecipientFilter filter;
@@ -311,9 +311,9 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
clients[0] = client;
filter.Initialize(clients, 1);
std::string *sound = g_Menus.GetMenuSound(type);
const char *sound = g_Menus.GetMenuSound(type);
if (nullptr != sound && !sound->empty())
if (sound != NULL)
{
edict_t *pEdict = PEntityOfEntIndex(client);
if (pEdict)
@@ -323,23 +323,23 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
if (pCollideable)
{
const Vector & pos = pCollideable->GetCollisionOrigin();
enginesound->EmitSound(filter,
client,
CHAN_AUTO,
enginesound->EmitSound(filter,
client,
CHAN_AUTO,
#if SOURCE_ENGINE >= SE_PORTAL2
sound->c_str(),
-1,
sound,
-1,
#endif
sound->c_str(),
VOL_NORM,
ATTN_NORM,
sound,
VOL_NORM,
ATTN_NORM,
#if SOURCE_ENGINE >= SE_PORTAL2
0,
0,
#endif
0,
PITCH_NORM,
0,
PITCH_NORM,
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2
0,
#endif
&pos);
@@ -604,9 +604,9 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
return true;
}
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
m_pStyle(pStyle), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
m_pStyle(pStyle), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
m_hHandle(BAD_HANDLE), m_pHandler(pHandler), m_nFlags(MENUFLAG_BUTTON_EXIT)
{
}
@@ -754,62 +754,6 @@ unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
return position;
}
void CBaseMenu::ShufflePerClient(int start, int stop)
{
// limit map len to 255 items since it's using uint8
int length = MIN(GetItemCount(), 255);
if (stop >= 0)
length = MIN(length, stop);
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
{
// populate per-client map ...
m_RandomMaps[i].resize(length);
for (int j = 0; j < length; j++)
m_RandomMaps[i][j] = j;
// ... and random shuffle it
for (int j = length - 1; j > start; j--)
{
int x = rand() % (j - start + 1) + start;
uint8_t tmp = m_RandomMaps[i][x];
m_RandomMaps[i][x] = m_RandomMaps[i][j];
m_RandomMaps[i][j] = tmp;
}
}
}
void CBaseMenu::SetClientMapping(int client, int *array, int length)
{
length = MIN(length, 255);
m_RandomMaps[client].resize(length);
for (int i = 0; i < length; i++)
{
m_RandomMaps[client][i] = array[i];
}
}
bool CBaseMenu::IsPerClientShuffled()
{
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
{
if(m_RandomMaps[i].length() > 0)
return true;
}
return false;
}
unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
{
if (client > 0 && position < m_RandomMaps[client].length())
{
position = m_RandomMaps[client][position];
return m_items[position].index;
}
return position;
}
unsigned int CBaseMenu::GetItemCount()
{
return m_items.size();
+6 -6
View File
@@ -8,7 +8,7 @@
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
@@ -98,7 +98,7 @@ public:
class CBaseMenu;
class BaseMenuStyle :
class BaseMenuStyle :
public IMenuStyle,
public IClientListener
{
@@ -113,11 +113,11 @@ public: //IClientListener
public: //what derived must implement
virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
virtual void SendDisplay(int client, IMenuPanel *display) =0;
public: //what derived may implement
virtual bool DoClientMenu(int client,
CBaseMenu *menu,
public: //what derived may implement
virtual bool DoClientMenu(int client,
CBaseMenu *menu,
unsigned int first_item,
IMenuHandler *mh,
IMenuHandler *mh,
unsigned int time);
virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
virtual void AddClientToWatch(int client);
+2 -4
View File
@@ -47,8 +47,6 @@
#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
#elif SOURCE_ENGINE == SE_BLADE
#include <game/shared/berimbau/protobuf/berimbau_usermessages.pb.h>
#elif SOURCE_ENGINE == SE_MCV
#include <game/shared/vietnam/protobuf/vietnam_usermessages.pb.h>
#endif
extern const char *g_RadioNumTable[];
@@ -184,7 +182,7 @@ void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFil
{
int count = pFilter->GetRecipientCount();
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
int c = ((CCSUsrMsg_ShowMenu &)msg).display_time();
#else
bf_read br(bf->GetBasePointer(), 3);
@@ -502,7 +500,7 @@ void CRadioMenuPlayer::Radio_Refresh()
time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
// TODO: find what happens past 240 on CS:GO
CCSUsrMsg_ShowMenu *msg = (CCSUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
if (!msg)
-1
View File
@@ -40,7 +40,6 @@
#include "UserMessages.h"
#include "sm_fastlink.h"
#include <sh_stack.h>
#include <sh_string.h>
#include <compat_wrappers.h>
#include "logic/common_logic.h"
#include "AutoHandleRooter.h"
+1 -20
View File
@@ -109,8 +109,6 @@ bool NextMapManager::SetNextMap(const char *map)
return true;
}
static char g_nextMap[PLATFORM_MAX_PATH];
#if SOURCE_ENGINE != SE_DARKMESSIAH
void NextMapManager::HookChangeLevel(const char *map, const char *unknown)
#else
@@ -124,16 +122,8 @@ void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const
}
const char *newmap = sm_nextmap.GetString();
if (newmap[0] != '\0') {
ke::SafeStrcpy(g_nextMap, sizeof(g_nextMap), newmap);
newmap = g_nextMap;
// Clear the value so that if the map load fails later we don't get stuck in a loop.
// This might cause us to go off-cycle for a map, but nextmap will get us back on track.
sm_nextmap.SetValue("");
}
if (newmap[0] == '\0' || !g_HL2.IsMapValid(newmap))
if (newmap[0] == 0 || !g_HL2.IsMapValid(newmap))
{
RETURN_META(MRES_IGNORED);
}
@@ -152,15 +142,6 @@ void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const
void NextMapManager::OnSourceModLevelChange( const char *mapName )
{
// If we were controlling the map change, reset sm_nextmap to be the name of the map we successfully changed to.
// This maintains an old API contract on the plugin side. We use the real map name even if it was different from
// the expected map name as if the expected map failed to load we let the game take over instead, but the nextmap
// plugin compares the sm_nextmap value to the current map to decide if it should advance the mapcycle.
if (g_nextMap[0] != '\0') {
sm_nextmap.SetValue(mapName);
g_nextMap[0] = '\0';
}
/* Skip the first 'mapchange' when the server starts up */
if (m_tempChangeInfo.startTime != 0)
{
+1 -1
View File
@@ -96,7 +96,7 @@ public:
private:
MapChangeData m_tempChangeInfo;
char lastMap[PLATFORM_MAX_PATH];
char lastMap[32];
};
extern NextMapManager g_NextMap;
+78 -32
View File
@@ -59,8 +59,6 @@ bool g_OnMapStarted = false;
IForward *PreAdminCheck = NULL;
IForward *PostAdminCheck = NULL;
IForward *PostAdminFilter = NULL;
IForward *ServerEnterHibernation = NULL;
IForward *ServerExitHibernation = NULL;
const unsigned int *g_NumPlayersToAuth = NULL;
int lifestate_offset = -1;
@@ -205,8 +203,6 @@ void PlayerManager::OnSourceModAllInitialized()
PreAdminCheck = forwardsys->CreateForward("OnClientPreAdminCheck", ET_Event, 1, p1);
PostAdminCheck = forwardsys->CreateForward("OnClientPostAdminCheck", ET_Ignore, 1, p1);
PostAdminFilter = forwardsys->CreateForward("OnClientPostAdminFilter", ET_Ignore, 1, p1);
ServerEnterHibernation = forwardsys->CreateForward("OnServerEnterHibernation", ET_Ignore, 0, NULL);
ServerExitHibernation = forwardsys->CreateForward("OnServerExitHibernation", ET_Ignore, 0, NULL);
m_bIsListenServer = !engine->IsDedicatedServer();
m_ListenClient = 0;
@@ -261,8 +257,6 @@ void PlayerManager::OnSourceModShutdown()
forwardsys->ReleaseForward(PreAdminCheck);
forwardsys->ReleaseForward(PostAdminCheck);
forwardsys->ReleaseForward(PostAdminFilter);
forwardsys->ReleaseForward(ServerEnterHibernation);
forwardsys->ReleaseForward(ServerExitHibernation);
delete [] m_Players;
@@ -525,7 +519,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
/* Get the client's language */
if (m_QueryLang)
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
pPlayer->m_LangId = translator->GetServerLanguage();
#else
const char *name;
@@ -539,7 +533,6 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
pPlayer->m_LangId = translator->GetServerLanguage();
}
#endif
pPlayer->m_OriginalLangId = pPlayer->m_LangId;
}
List<IClientListener *>::iterator iter;
@@ -657,7 +650,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
int userId = engine->GetPlayerUserId(pEntity);
#if (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_PVKII)
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2)
static ConVar *tv_name = icvar->FindVar("tv_name");
#endif
#if SOURCE_ENGINE == SE_TF2
@@ -680,13 +673,12 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
&& ((!m_bIsReplayActive && newCount == 1)
|| (m_bIsReplayActive && newCount == 2))
&& (m_SourceTVUserId == userId
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_MCV
// It seems likely that MCV will change this at some point, but it's GOTV at the moment.
#if SOURCE_ENGINE == SE_CSGO
|| strcmp(playername, "GOTV") == 0
#elif SOURCE_ENGINE == SE_BLADE
|| strcmp(playername, "BBTV") == 0
#elif (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_PVKII)
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2)
|| (tv_name && strcmp(playername, tv_name->GetString()) == 0) || (tv_name && tv_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0)
#else
|| strcmp(playername, "SourceTV") == 0
@@ -740,7 +732,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
}
pPlayer->Authorize_Post();
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
else if(m_QueryLang)
{
// Not a bot
@@ -789,11 +781,6 @@ void PlayerManager::OnSourceModLevelEnd()
void PlayerManager::OnServerHibernationUpdate(bool bHibernating)
{
cell_t res;
if (bHibernating)
ServerEnterHibernation->Execute(&res);
else
ServerExitHibernation->Execute(&res);
/* If bots were added at map start, but not fully inited before hibernation, there will
* be no OnClientDisconnect for them, despite them getting booted right before this.
*/
@@ -805,7 +792,7 @@ void PlayerManager::OnServerHibernationUpdate(bool bHibernating)
CPlayer *pPlayer = &m_Players[i];
if (pPlayer->IsConnected() && pPlayer->IsFakeClient())
{
#if SOURCE_ENGINE < SE_LEFT4DEAD || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE < SE_LEFT4DEAD || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_NUCLEARDAWN
// These games have the bug fixed where hltv/replay was getting kicked on hibernation
if (pPlayer->IsSourceTV() || pPlayer->IsReplay())
continue;
@@ -991,6 +978,8 @@ void ClientConsolePrint(edict_t *e, const char *fmt, ...)
void ListExtensionsToClient(CPlayer *player, const CCommand &args)
{
char buffer[256];
unsigned int id = 0;
unsigned int start = 0;
AutoExtensionList extensions(extsys);
if (!extensions->size())
@@ -999,6 +988,11 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
return;
}
if (args.ArgC() > 2)
{
start = atoi(args.Arg(2));
}
size_t i = 0;
for (; i < extensions->size(); i++)
{
@@ -1010,6 +1004,17 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
continue;
}
id++;
if (id < start)
{
continue;
}
if (id - start > 10)
{
break;
}
IExtensionInterface *api = ext->GetAPI();
const char *name = api->GetExtensionName();
@@ -1034,14 +1039,31 @@ void ListExtensionsToClient(CPlayer *player, const CCommand &args)
len += ke::SafeSprintf(&buffer[len], sizeof(buffer)-len, ": %s", description);
}
ClientConsolePrint(player->GetEdict(), "%s", buffer);
}
for (; i < extensions->size(); i++)
{
char error[255];
if (extensions->at(i)->IsRunning(error, sizeof(error)))
{
break;
}
}
if (i < extensions->size())
{
ClientConsolePrint(player->GetEdict(), "To see more, type \"sm exts %d\"", id);
}
}
void ListPluginsToClient(CPlayer *player, const CCommand &args)
{
char buffer[256];
unsigned int id = 0;
edict_t *e = player->GetEdict();
unsigned int start = 0;
AutoPluginList plugins(scripts);
if (!plugins->size())
@@ -1050,6 +1072,11 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
return;
}
if (args.ArgC() > 2)
{
start = atoi(args.Arg(2));
}
SourceHook::List<SMPlugin *> m_FailList;
size_t i = 0;
@@ -1062,6 +1089,18 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
continue;
}
/* Count valid plugins */
id++;
if (id < start)
{
continue;
}
if (id - start > 10)
{
break;
}
size_t len;
const sm_plugininfo_t *info = pl->GetPublicInfo();
len = ke::SafeSprintf(buffer, sizeof(buffer), " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
@@ -1079,6 +1118,21 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
}
ClientConsolePrint(e, "%s", buffer);
}
/* See if we can get more plugins */
for (; i < plugins->size(); i++)
{
if (plugins->at(i)->GetStatus() == Plugin_Running)
{
break;
}
}
/* Do we actually have more plugins? */
if (i < plugins->size())
{
ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
}
}
#if SOURCE_ENGINE >= SE_ORANGEBOX
@@ -1164,7 +1218,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
if (g_ConsoleDetours.IsEnabled())
{
cell_t res2 = g_ConsoleDetours.InternalDispatch(client, &cargs);
if (res2 >= Pl_Handled)
if (res2 >= Pl_Stop)
{
RETURN_META(MRES_SUPERCEDE);
}
@@ -1981,7 +2035,7 @@ void CmdMaxplayersCallback()
g_Players.MaxPlayersChanged();
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
{
for (int i = 1; i <= m_maxClients; i++)
@@ -1991,7 +2045,6 @@ bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQue
unsigned int langid;
unsigned int new_langid = (translator->GetLanguageByName(cvarValue, &langid)) ? langid : translator->GetServerLanguage();
m_Players[i].m_LangId = new_langid;
m_Players[i].m_OriginalLangId = new_langid;
OnClientLanguageChanged(i, new_langid);
return true;
@@ -2041,7 +2094,6 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
m_pEdict = pEntity;
m_iIndex = IndexOfEdict(pEntity);
m_LangId = translator->GetServerLanguage();
m_OriginalLangId = m_LangId;
m_Serial.bits.index = m_iIndex;
m_Serial.bits.serial = g_PlayerSerialCount++;
@@ -2063,8 +2115,7 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|| SOURCE_ENGINE == SE_BMS \
|| SOURCE_ENGINE == SE_INSURGENCY \
|| SOURCE_ENGINE == SE_DOI \
|| SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BLADE
m_pIClient = engine->GetIServer()->GetClient(m_iIndex - 1);
#else
#if SOURCE_ENGINE == SE_SDK2013
@@ -2240,7 +2291,7 @@ void CPlayer::Disconnect()
m_bIsSourceTV = false;
m_bIsReplay = false;
m_Serial.value = -1;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
m_LanguageCookie = InvalidQueryCvarCookie;
#endif
ClearNetchannelQueue();
@@ -2462,7 +2513,7 @@ void CPlayer::Kick(const char *str)
}
else
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
pClient->Disconnect(str);
#else
pClient->Disconnect("%s", str);
@@ -2609,11 +2660,6 @@ unsigned int CPlayer::GetLanguageId()
return m_LangId;
}
unsigned int CPlayer::GetOriginalLanguageId()
{
return m_OriginalLangId;
}
void CPlayer::SetLanguageId(unsigned int id)
{
if(m_LangId != id)
+5 -4
View File
@@ -96,7 +96,6 @@ public:
bool IsInKickQueue();
IPlayerInfo *GetPlayerInfo();
unsigned int GetLanguageId();
unsigned int GetOriginalLanguageId();
void SetLanguageId(unsigned int id);
int GetUserId();
bool RunAdminCacheChecks();
@@ -146,14 +145,13 @@ private:
bool m_bAdminCheckSignalled = false;
int m_iIndex;
unsigned int m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
unsigned int m_OriginalLangId = SOURCEMOD_LANGUAGE_ENGLISH;
int m_UserId = -1;
bool m_bFakeClient = false;
bool m_bIsSourceTV = false;
bool m_bIsReplay = false;
serial_t m_Serial;
CSteamID m_SteamId;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
QueryCvarCookie_t m_LanguageCookie = InvalidQueryCvarCookie;
#endif
std::deque<std::string> m_PrintfBuffer;
@@ -219,6 +217,9 @@ public: //IPlayerManager
void RecheckAnyAdmins();
public: // IGameEventListener2
void FireGameEvent(IGameEvent *pEvent);
#if SOURCE_ENGINE >= SE_ALIENSWARM
virtual int GetEventDebugID( void ) { return 42; }
#endif
public:
inline int MaxClients()
{
@@ -242,7 +243,7 @@ public:
{
return m_bInCCKVHook;
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
bool HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue);
#endif
private:
+20
View File
@@ -816,6 +816,9 @@ public:
inline bool GetColor(const char *pszFieldName, Color *out)
{
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
return false;
#else
GETCHECK_FIELD();
CHECK_FIELD_TYPE(MESSAGE);
CHECK_FIELD_NOT_REPEATED();
@@ -829,10 +832,14 @@ public:
);
return true;
#endif
}
inline bool SetColor(const char *pszFieldName, const Color &value)
{
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
return false;
#else
GETCHECK_FIELD();
CHECK_FIELD_TYPE(MESSAGE);
CHECK_FIELD_NOT_REPEATED();
@@ -844,10 +851,14 @@ public:
msgRGBA->set_a(value.a());
return true;
#endif
}
inline bool GetRepeatedColor(const char *pszFieldName, int index, Color *out)
{
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
return false;
#else
GETCHECK_FIELD();
CHECK_FIELD_TYPE(MESSAGE);
CHECK_FIELD_REPEATED();
@@ -862,10 +873,14 @@ public:
);
return true;
#endif
}
inline bool SetRepeatedColor(const char *pszFieldName, int index, const Color &value)
{
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
return false;
#else
GETCHECK_FIELD();
CHECK_FIELD_TYPE(MESSAGE);
CHECK_FIELD_REPEATED();
@@ -878,10 +893,14 @@ public:
msgRGBA->set_a(value.a());
return true;
#endif
}
inline bool AddColor(const char *pszFieldName, const Color &value)
{
#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE
return false;
#else
GETCHECK_FIELD();
CHECK_FIELD_TYPE(MESSAGE);
CHECK_FIELD_REPEATED();
@@ -893,6 +912,7 @@ public:
msgRGBA->set_a(value.a());
return true;
#endif
}
inline bool GetVector2D(const char *pszFieldName, Vector2D *out)
+14 -24
View File
@@ -37,14 +37,12 @@
#include <cstrike15_usermessage_helpers.h>
#elif SOURCE_ENGINE == SE_BLADE
#include <berimbau_usermessage_helpers.h>
#elif SOURCE_ENGINE == SE_MCV
#include <vietnam_usermessage_helpers.h>
#endif
#include <amtl/am-string.h>
UserMessages g_UserMsgs;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
SH_DECL_HOOK3_void(IVEngineServer, SendUserMessage, SH_NOATTRIB, 0, IRecipientFilter &, int, const protobuf::Message &);
#else
#if SOURCE_ENGINE >= SE_LEFT4DEAD
@@ -53,7 +51,7 @@ SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRec
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
#endif
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
#endif // ==SE_CSGO || ==SE_BLADE || ==SE_MCV
#endif // ==SE_CSGO || ==SE_BLADE
UserMessages::UserMessages()
#ifndef USE_PROTOBUF_USERMESSAGES
@@ -97,7 +95,7 @@ void UserMessages::OnSourceModAllShutdown()
{
if (m_HookCount)
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
#else
@@ -117,8 +115,6 @@ int UserMessages::GetMessageIndex(const char *msg)
return g_Cstrike15UsermessageHelpers.GetIndex(msg);
#elif SOURCE_ENGINE == SE_BLADE
return g_BerimbauUsermessageHelpers.GetIndex(msg);
#elif SOURCE_ENGINE == SE_MCV
return g_VietnamUsermessageHelpers.GetIndex(msg);
#else
int msgid;
@@ -158,8 +154,6 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msgid);
#elif SOURCE_ENGINE == SE_BLADE
const char *pszName = g_BerimbauUsermessageHelpers.GetName(msgid);
#elif SOURCE_ENGINE == SE_MCV
const char *pszName = g_VietnamUsermessageHelpers.GetName(msgid);
#endif
if (!pszName)
return false;
@@ -309,7 +303,7 @@ bool UserMessages::EndMessage()
return false;
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (m_CurFlags & USERMSG_BLOCKHOOKS)
{
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(m_CellRecFilter), m_CurId, *m_FakeEngineBuffer);
@@ -339,7 +333,7 @@ bool UserMessages::EndMessage()
} else {
engine->MessageEnd();
}
#endif // SE_CSGO || SE_BLADE || SE_MCV
#endif // SE_CSGO || SE_BLADE
m_InExec = false;
m_CurFlags = 0;
@@ -424,7 +418,7 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene
if (!m_HookCount++)
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
#else
@@ -452,8 +446,6 @@ const protobuf::Message *UserMessages::GetMessagePrototype(int msg_type)
return g_Cstrike15UsermessageHelpers.GetPrototype(msg_type);
#elif SOURCE_ENGINE == SE_BLADE
return g_BerimbauUsermessageHelpers.GetPrototype(msg_type);
#elif SOURCE_ENGINE == SE_MCV
return g_VietnamUsermessageHelpers.GetPrototype(msg_type);
#endif
}
#endif
@@ -503,7 +495,7 @@ void UserMessages::_DecRefCounter()
{
if (--m_HookCount == 0)
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
#else
@@ -515,15 +507,13 @@ void UserMessages::_DecRefCounter()
}
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg)
{
#if SOURCE_ENGINE == SE_CSGO
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msg_type);
#elif SOURCE_ENGINE == SE_BLADE
const char *pszName = g_BerimbauUsermessageHelpers.GetName(msg_type);
#elif SOURCE_ENGINE == SE_MCV
const char *pszName = g_VietnamUsermessageHelpers.GetName(msg_type);
#endif
OnStartMessage_Pre(&filter, msg_type, pszName);
@@ -572,7 +562,7 @@ void UserMessages::OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type
RETURN_META(res)
#endif
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
protobuf::Message *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
@@ -612,7 +602,7 @@ bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_typ
UM_RETURN_META_VALUE(MRES_IGNORED, NULL);
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
protobuf::Message *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
@@ -777,7 +767,7 @@ void UserMessages::OnMessageEnd_Pre()
if (!handled && intercepted)
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(*m_CurRecFilter), m_CurId, *m_InterceptBuffer);
#else
bf_write *engine_bfw;
@@ -789,11 +779,11 @@ void UserMessages::OnMessageEnd_Pre()
m_ReadBuffer.StartReading(m_InterceptBuffer.GetBasePointer(), m_InterceptBuffer.GetNumBytesWritten());
engine_bfw->WriteBitsFromBuffer(&m_ReadBuffer, m_InterceptBuffer.GetNumBitsWritten());
ENGINE_CALL(MessageEnd)();
#endif // SE_CSGO || SE_BLADE || SE_MCV
#endif // SE_CSGO || SE_BLADE
}
{
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
int size = m_OrigBuffer->ByteSize();
uint8 *data = (uint8 *)stackalloc(size);
m_OrigBuffer->SerializePartialToArray(data, size);
@@ -823,7 +813,7 @@ void UserMessages::OnMessageEnd_Pre()
iter++;
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
delete pTempMsg;
#endif
}
+3 -3
View File
@@ -44,7 +44,7 @@
using namespace SourceHook;
using namespace SourceMod;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
#define USE_PROTOBUF_USERMESSAGES
#endif
@@ -102,12 +102,12 @@ public: //IUserMessages
bool intercept=false);
UserMessageType GetUserMessageType() const;
public:
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
void OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
void OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
#endif
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
protobuf::Message *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name);
protobuf::Message *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name);
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
+2 -2
View File
@@ -36,7 +36,7 @@
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
SH_DECL_HOOK2_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *, bool);
#else
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
@@ -82,7 +82,7 @@ public:
#endif
}
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
void LinkConCommandBase(ConCommandBase *pBase, bool unknown)
#else
void LinkConCommandBase(ConCommandBase *pBase)
+1 -1
View File
@@ -16,7 +16,7 @@ for cxx in builder.targets:
'SM_DEFAULT_THREADER',
'SM_LOGIC'
]
if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += ['-lpthread', '-lrt']
elif binary.compiler.target.platform == 'mac':
+5
View File
@@ -395,6 +395,11 @@ void CExtension::AddDependency(const IfaceInfo *pInfo)
}
}
bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
{
return (i1.iface == i2.iface) && (i1.owner == i2.owner);
}
void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
{
IfaceInfo info;
+37 -128
View File
@@ -30,7 +30,6 @@
#include "common_logic.h"
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <sh_list.h>
#include <sh_string.h>
#include "GameConfigs.h"
@@ -47,7 +46,6 @@
#include <am-string.h>
#include <bridge/include/ILogger.h>
#include <bridge/include/CoreProvider.h>
#include <bridge/include/IFileSystemBridge.h>
#if defined PLATFORM_POSIX
#include <dlfcn.h>
@@ -105,6 +103,8 @@ struct TempSigInfo
char sig[1024];
char library[64];
} s_TempSig;
unsigned int s_ServerBinCRC;
bool s_ServerBinCRC_Ok = false;
static bool DoesGameMatch(const char *value)
{
@@ -303,21 +303,38 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n
{
char error[255];
error[0] = '\0';
GameBinaryInfo binInfo;
if (!g_GameConfigs.TryGetGameBinaryInfo(name, &binInfo))
if (strcmp(name, "server") != 0)
{
ke::SafeSprintf(error, sizeof(error), "Unrecognized library \"%s\"", name);
}
else if (!binInfo.m_crcOK)
else if (!s_ServerBinCRC_Ok)
{
ke::SafeSprintf(error, sizeof(error), "Could not get CRC for binary: %s", name);
}
else
{
bCurrentBinCRC_Ok = binInfo.m_crcOK;
bCurrentBinCRC = binInfo.m_crc;
}
FILE *fp;
char path[PLATFORM_MAX_PATH];
char binName[64];
bridge->FormatSourceBinaryName(name, binName, sizeof(binName));
g_pSM->BuildPath(Path_Game, path, sizeof(path), "bin/%s", binName);
if ((fp = fopen(path, "rb")) == NULL)
{
ke::SafeSprintf(error, sizeof(error), "Could not open binary: %s", path);
} else {
size_t size;
void *buffer;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
buffer = malloc(size);
fread(buffer, size, 1, fp);
s_ServerBinCRC = UTIL_CRC32(buffer, size);
free(buffer);
s_ServerBinCRC_Ok = true;
fclose(fp);
}
}
if (error[0] != '\0')
{
m_IgnoreLevel = 1;
@@ -444,12 +461,12 @@ SMCResult CGameConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key
}
} else if (m_ParseState == PSTATE_GAMEDEFS_CRC_BINARY) {
if (DoesPlatformMatch(key)
&& bCurrentBinCRC_Ok
&& s_ServerBinCRC_Ok
&& !bShouldBeReadingDefault)
{
unsigned int crc = 0;
sscanf(value, "%08X", &crc);
if (bCurrentBinCRC == crc)
if (s_ServerBinCRC == crc)
{
bShouldBeReadingDefault = true;
}
@@ -586,12 +603,14 @@ SMCResult CGameConfig::ReadSMC_LeavingSection(const SMCStates *states)
strncopy(s_TempSig.library, "server", sizeof(s_TempSig.library));
}
void *addrInBase = NULL;
GameBinaryInfo binInfo;
if (g_GameConfigs.TryGetGameBinaryInfo(s_TempSig.library, &binInfo))
if (strcmp(s_TempSig.library, "server") == 0)
{
addrInBase = binInfo.m_pAddr;
addrInBase = bridge->serverFactory;
} else if (strcmp(s_TempSig.library, "engine") == 0) {
addrInBase = bridge->engineFactory;
} else if (strcmp(s_TempSig.library, "matchmaking_ds") == 0) {
addrInBase = bridge->matchmakingDSFactory;
}
void *final_addr = NULL;
if (addrInBase == NULL)
{
@@ -1083,42 +1102,6 @@ bool CGameConfig::GetMemSig(const char *key, void **addr)
return m_Sigs.retrieve(key, addr);
}
void GameBinPathManager::Init()
{
char search_path[PLATFORM_MAX_PATH * 8];
bridge->filesystem->GetSearchPath("GAMEBIN", false, search_path, sizeof(search_path));
char addons_folder[12];
ke::SafeSprintf(addons_folder, sizeof(addons_folder), "%caddons%c", PLATFORM_SEP_CHAR, PLATFORM_SEP_CHAR);
std::istringstream iss(search_path);
for (std::string path; std::getline(iss, path, ';');)
{
if (path.length() > 0
&& path.find(addons_folder) == std::string::npos
&& m_lookup.find(path) == m_lookup.cend()
)
{
m_lookup.insert(path);
m_ordered.push_back(path);
}
}
iss.clear();
bridge->filesystem->GetSearchPath("EXECUTABLE_PATH", false, search_path, sizeof(search_path));
iss.str(search_path);
for (std::string path; std::getline(iss, path, ';');)
{
if (m_lookup.find(path) == m_lookup.cend())
{
m_lookup.insert(path);
m_ordered.push_back(path);
}
}
}
GameConfigManager::GameConfigManager()
{
}
@@ -1129,8 +1112,6 @@ GameConfigManager::~GameConfigManager()
void GameConfigManager::OnSourceModStartup(bool late)
{
m_gameBinPathManager.Init();
LoadGameConfigFile("core.games", &g_pGameConf, NULL, 0);
strncopy(g_Game, g_pSM->GetGameFolderName(), sizeof(g_Game));
@@ -1253,75 +1234,3 @@ void GameConfigManager::RemoveCachedConfig(CGameConfig *config)
{
m_Lookup.remove(config->m_File);
}
void GameConfigManager::CacheGameBinaryInfo(const char* pszName)
{
GameBinaryInfo info;
char name[64];
bridge->FormatSourceBinaryName(pszName, name, sizeof(name));
char binary_path[PLATFORM_MAX_PATH];
for (auto it = m_gameBinPathManager.Paths().begin(); it != m_gameBinPathManager.Paths().end(); ++it)
{
ke::SafeSprintf(binary_path, sizeof(binary_path), "%s%s%s", it->c_str(), it->back() == PLATFORM_SEP_CHAR ? "" : PLATFORM_SEP, name);
#if defined PLATFORM_WINDOWS
HMODULE hModule = LoadLibraryA(binary_path);
if (hModule)
{
info.m_pAddr = GetProcAddress(hModule, "CreateInterface");
FreeLibrary(hModule);
}
#else
void *pHandle = dlopen(binary_path, RTLD_NOW);
if (pHandle)
{
info.m_pAddr = dlsym(pHandle, "CreateInterface");
dlclose(pHandle);
}
#endif
if (info.m_pAddr)
break;
}
// Don't bother trying to get CRC if we couldn't find the bin loaded
if (info.m_pAddr)
{
FILE *fp;
if ((fp = fopen(binary_path, "rb")) == 0)
{
info.m_crc = 0;
}
else
{
size_t size;
void* buffer;
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
buffer = malloc(size);
fread(buffer, size, 1, fp);
info.m_crc = UTIL_CRC32(buffer, size);
free(buffer);
info.m_crcOK = true;
fclose(fp);
}
}
// But insert regardless, to cache the first lookup (even as failed)
m_gameBinInfos.insert(pszName, info);
}
bool GameConfigManager::TryGetGameBinaryInfo(const char* pszName, GameBinaryInfo* pDest)
{
if (m_gameBinInfos.retrieve(pszName, pDest))
return pDest->m_pAddr != nullptr;
CacheGameBinaryInfo(pszName);
return m_gameBinInfos.retrieve(pszName, pDest);
}
-32
View File
@@ -38,7 +38,6 @@
#include <am-refcounting.h>
#include <sm_stringhashmap.h>
#include <sm_namehashset.h>
#include <unordered_set>
using namespace SourceMod;
@@ -92,8 +91,6 @@ private:
std::string m_offset;
std::string m_Game;
std::string m_Key;
unsigned int bCurrentBinCRC;
bool bCurrentBinCRC_Ok = false;
bool bShouldBeReadingDefault;
bool had_game;
bool matched_game;
@@ -129,30 +126,6 @@ private:
time_t m_ModTime;
};
struct GameBinaryInfo
{
void *m_pAddr = nullptr;
uint32_t m_crc = 0;
bool m_crcOK = false;
};
class GameBinPathManager
{
public:
GameBinPathManager() {}
~GameBinPathManager() {}
public:
void Init();
inline const std::vector<std::string>& Paths() const
{
return m_ordered;
}
private:
std::unordered_set<std::string> m_lookup;
std::vector<std::string> m_ordered;
};
class GameConfigManager :
public IGameConfigManager,
public SMGlobalClass
@@ -175,16 +148,11 @@ public: //SMGlobalClass
void OnSourceModAllInitialized();
void OnSourceModAllShutdown();
public:
bool TryGetGameBinaryInfo(const char* pszName, GameBinaryInfo* pDest);
void RemoveCachedConfig(CGameConfig *config);
private:
void CacheGameBinaryInfo(const char* pszName);
private:
NameHashSet<CGameConfig *> m_Lookup;
StringHashMap<GameBinaryInfo> m_gameBinInfos;
public:
StringHashMap<ITextListener_SMC *> m_customHandlers;
GameBinPathManager m_gameBinPathManager;
};
extern GameConfigManager g_GameConfigs;
+4 -1
View File
@@ -273,7 +273,10 @@ NativeInvoker::Invoke(cell_t *result)
/* Make the call if we can */
if (ok)
{
*result = native_->func()(context_, _temp_params);
if(native_->native)
*result = native_->native->func(context_, _temp_params);
else
*result = native_->fake->wrapper->Invoke(context_, _temp_params);
}
/* i should be equal to the last valid parameter + 1 */
-1
View File
@@ -14,7 +14,6 @@
#define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
#include <sp_vm_api.h>
#include <amtl/am-autoptr.h>
#include <amtl/am-refcounting.h>
#include "Native.h"
+2 -4
View File
@@ -48,8 +48,6 @@
#include <bridge/include/IVEngineServerBridge.h>
#include <bridge/include/CoreProvider.h>
#define SOURCEMOD_PLUGINAPI_VERSION 7
CPluginManager g_PluginSys;
HandleType_t g_PluginType = 0;
IdentityType_t g_PluginIdent = 0;
@@ -311,12 +309,12 @@ bool CPlugin::ReadInfo()
base->GetPubvarAddrs(idx, &local_addr, (cell_t **)&info);
m_FileVersion = info->version;
if (m_FileVersion >= 5) {
if (m_FileVersion >= 4) {
base->LocalToString(info->date, (char **)&pDate);
base->LocalToString(info->time, (char **)&pTime);
ke::SafeSprintf(m_DateTime, sizeof(m_DateTime), "%s %s", pDate, pTime);
}
if (m_FileVersion > SOURCEMOD_PLUGINAPI_VERSION) {
if (m_FileVersion > 5) {
base->LocalToString(info->filevers, (char **)&pFileVers);
EvictWithError(Plugin_Failed, "Newer SourceMod required (%s or higher)", pFileVers);
return false;
+1 -1
View File
@@ -59,7 +59,7 @@ namespace SourceMod
struct IfaceInfo
{
bool operator ==(const IfaceInfo &info) const
bool operator ==(const IfaceInfo &info)
{
return (info.iface == iface && info.owner == owner);
}
+6 -72
View File
@@ -281,19 +281,7 @@ static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
}
// the blocknumber is not guaranteed to always be passed
size_t blocknumber = 0;
if (params[0] >= 5)
{
blocknumber = (size_t)params[5];
}
if (blocknumber >= array->blocksize())
{
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
}
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
cell_t *blk = array->at(idx);
size_t numWritten = 0;
pContext->StringToLocalUTF8(params[3], params[4], (char *)blk, &numWritten);
@@ -319,19 +307,7 @@ static cell_t GetArrayArray(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
}
// the blocknumber is not guaranteed to always be passed
size_t blocknumber = 0;
if (params[0] >= 5)
{
blocknumber = (size_t)params[5];
}
if (blocknumber >= array->blocksize())
{
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
}
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
cell_t *blk = array->at(idx);
size_t indexes = array->blocksize();
if (params[4] != -1 && (size_t)params[4] <= array->blocksize())
{
@@ -403,30 +379,12 @@ static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
}
// the blocknumber is not guaranteed to always be passed
size_t blocknumber = 0;
if (params[0] >= 5)
{
blocknumber = (size_t)params[5];
}
if (blocknumber >= array->blocksize())
{
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
}
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
cell_t *blk = array->at(idx);
char *str;
pContext->LocalToString(params[3], &str);
size_t maxlength = array->blocksize() * sizeof(cell_t);
if (params[0] >= 4 && params[4] != -1 && (size_t)params[4] <= array->blocksize())
{
maxlength = (size_t)params[4];
}
return strncopy((char*)blk, str, maxlength);
return strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
}
static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
@@ -447,19 +405,7 @@ static cell_t SetArrayArray(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
}
// the blocknumber is not guaranteed to always be passed
size_t blocknumber = 0;
if (params[0] >= 5)
{
blocknumber = (size_t)params[5];
}
if (blocknumber >= array->blocksize())
{
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
}
cell_t *blk = &array->base()[idx * array->blocksize() + blocknumber];
cell_t *blk = array->at(idx);
size_t indexes = array->blocksize();
if (params[4] != -1 && (size_t)params[4] <= array->blocksize())
{
@@ -587,24 +533,12 @@ static cell_t FindStringInArray(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
}
// the blocknumber is not guaranteed to always be passed
size_t blocknumber = 0;
if (params[0] >= 3)
{
blocknumber = (size_t)params[3];
}
if (blocknumber >= array->blocksize())
{
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
}
char *str;
pContext->LocalToString(params[2], &str);
for (unsigned int i = 0; i < array->size(); i++)
{
const char *array_str = (const char *)&array->base()[i * array->blocksize() + blocknumber];
const char *array_str = (const char *)array->at(i);
if (strcmp(str, array_str) == 0)
{
return (cell_t) i;
+4 -93
View File
@@ -240,9 +240,9 @@ static cell_t PopStackCell(IPluginContext *pContext, const cell_t *params)
}
else
{
if (idx >= array->blocksize() * sizeof(cell_t))
if (idx >= array->blocksize() * 4)
{
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * sizeof(cell_t));
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * 4);
}
*buffer = (cell_t)*((char *)blk + idx);
}
@@ -356,8 +356,8 @@ static cell_t ArrayStack_Pop(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", idx, array->blocksize());
rval = blk[idx];
} else {
if (idx >= array->blocksize() * sizeof(cell_t))
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * sizeof(cell_t));
if (idx >= array->blocksize() * 4)
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * 4);
rval = (cell_t)*((char *)blk + idx);
}
@@ -365,32 +365,6 @@ static cell_t ArrayStack_Pop(IPluginContext *pContext, const cell_t *params)
return rval;
}
static cell_t ArrayStack_Top(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
if (!array.Ok())
return 0;
if (array->size() == 0)
return pContext->ThrowNativeError("stack is empty");
cell_t *blk = array->at(array->size() - 1);
size_t idx = (size_t)params[2];
cell_t rval;
if (params[3] == 0) {
if (idx >= array->blocksize())
return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", idx, array->blocksize());
rval = blk[idx];
} else {
if (idx >= array->blocksize() * sizeof(cell_t))
return pContext->ThrowNativeError("Invalid byte %d (blocksize: %d bytes)", idx, array->blocksize() * sizeof(cell_t));
rval = (cell_t)*((char *)blk + idx);
}
return rval;
}
static cell_t ArrayStack_PopString(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
@@ -413,27 +387,6 @@ static cell_t ArrayStack_PopString(IPluginContext *pContext, const cell_t *param
return 1;
}
static cell_t ArrayStack_TopString(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
if (!array.Ok())
return 0;
if (array->size() == 0)
return pContext->ThrowNativeError("stack is empty");
size_t idx = array->size() - 1;
cell_t *blk = array->at(idx);
cell_t *pWritten;
pContext->LocalToPhysAddr(params[4], &pWritten);
size_t numWritten;
pContext->StringToLocalUTF8(params[2], params[3], (char *)blk, &numWritten);
*pWritten = (cell_t)numWritten;
return 1;
}
static cell_t ArrayStack_PopArray(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
@@ -458,29 +411,6 @@ static cell_t ArrayStack_PopArray(IPluginContext *pContext, const cell_t *params
return 0;
}
static cell_t ArrayStack_TopArray(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<CellArray> array(pContext, params[1], htCellStack);
if (!array.Ok())
return 0;
if (array->size() == 0)
return pContext->ThrowNativeError("stack is empty");
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
size_t idx = array->size() - 1;
cell_t *blk = array->at(idx);
size_t indexes = array->blocksize();
if (params[3] != -1 && (size_t)params[3] <= array->blocksize())
indexes = params[3];
memcpy(addr, blk, sizeof(cell_t) * indexes);
return 0;
}
static cell_t GetStackBlockSize(IPluginContext *pContext, const cell_t *params)
{
HandleError err;
@@ -496,21 +426,6 @@ static cell_t GetStackBlockSize(IPluginContext *pContext, const cell_t *params)
return array->blocksize();
}
static cell_t GetStackSize(IPluginContext *pContext, const cell_t *params)
{
HandleError err;
CellArray *array;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = handlesys->ReadHandle(params[1], htCellStack, &sec, (void **)&array))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
}
return array->size();
}
REGISTER_NATIVES(cellStackNatives)
{
{"CreateStack", CreateStack},
@@ -529,17 +444,13 @@ REGISTER_NATIVES(cellStackNatives)
{"ArrayStack.Clear", ClearStack},
{"ArrayStack.Clone", CloneStack},
{"ArrayStack.Pop", ArrayStack_Pop},
{"ArrayStack.Top", ArrayStack_Top},
{"ArrayStack.PopString", ArrayStack_PopString},
{"ArrayStack.TopString", ArrayStack_TopString},
{"ArrayStack.PopArray", ArrayStack_PopArray},
{"ArrayStack.TopArray", ArrayStack_TopArray},
{"ArrayStack.Push", PushStackCell},
{"ArrayStack.PushString", PushStackString},
{"ArrayStack.PushArray", PushStackArray},
{"ArrayStack.Empty.get", IsStackEmpty},
{"ArrayStack.BlockSize.get", GetStackBlockSize},
{"ArrayStack.Length.get", GetStackSize},
{NULL, NULL},
};
-46
View File
@@ -32,8 +32,6 @@
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <sstream>
#include <list>
#include "common_logic.h"
#include "Logger.h"
@@ -275,49 +273,6 @@ static cell_t FormatTime(IPluginContext *pContext, const cell_t *params)
return 1;
}
static int ParseTime(IPluginContext *pContext, const cell_t *params)
{
char *datetime;
char *format;
pContext->LocalToStringNULL(params[1], &datetime);
pContext->LocalToStringNULL(params[2], &format);
if (format == NULL)
{
format = const_cast<char *>(bridge->GetCvarString(g_datetime_format));
}
else if (!format[0])
{
return pContext->ThrowNativeError("Time format string cannot be empty.");
}
if (!datetime || !datetime[0])
{
return pContext->ThrowNativeError("Date/time string cannot be empty.");
}
// https://stackoverflow.com/a/33542189
std::tm t{};
std::istringstream input(datetime);
auto previousLocale = input.imbue(std::locale::classic());
input >> std::get_time(&t, format);
bool failed = input.fail();
input.imbue(previousLocale);
if (failed)
{
return pContext->ThrowNativeError("Invalid date/time string or time format.");
}
#if defined PLATFORM_WINDOWS
return _mkgmtime(&t);
#elif defined PLATFORM_LINUX || defined PLATFORM_APPLE
return timegm(&t);
#else
return pContext->ThrowNativeError("Platform has no implemented UTC conversion for std::tm to std::time_t");
#endif
}
static cell_t GetPluginIterator(IPluginContext *pContext, const cell_t *params)
{
IPluginIterator *iter = scripts->GetPluginIterator();
@@ -1133,7 +1088,6 @@ REGISTER_NATIVES(coreNatives)
{"ThrowError", ThrowError},
{"GetTime", GetTime},
{"FormatTime", FormatTime},
{"ParseTime", ParseTime},
{"GetPluginIterator", GetPluginIterator},
{"MorePlugins", MorePlugins},
{"ReadPlugin", ReadPlugin},
+4 -4
View File
@@ -1787,10 +1787,10 @@ static cell_t SQL_ExecuteTransaction(IPluginContext *pContext, const cell_t *par
IPluginFunction *onSuccess = NULL;
IPluginFunction *onError = NULL;
if (!pContext->GetFunctionByIdOrNull(params[3], &onSuccess))
return 0;
if (!pContext->GetFunctionByIdOrNull(params[4], &onError))
return 0;
if (params[3] != -1 && ((onSuccess = pContext->GetFunctionById(params[3])) == NULL))
return pContext->ThrowNativeError("Function id %x is invalid", params[3]);
if (params[4] != -1 && ((onError = pContext->GetFunctionById(params[4])) == NULL))
return pContext->ThrowNativeError("Function id %x is invalid", params[4]);
cell_t data = params[5];
PrioQueueLevel priority = PrioQueue_Normal;
+2 -19
View File
@@ -244,19 +244,7 @@ static cell_t smn_WritePackFunction(IPluginContext *pContext, const cell_t *para
pDataPack->RemoveItem();
}
cell_t funcid = params[2];
if (pContext->IsNullFunctionId(funcid))
{
pDataPack->PackFunction(0);
}
else if (funcid <= 0)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
}
else
{
pDataPack->PackFunction(funcid);
}
pDataPack->PackFunction(params[2]);
return 1;
}
@@ -377,12 +365,7 @@ static cell_t smn_ReadPackFunction(IPluginContext *pContext, const cell_t *param
return pContext->ThrowNativeError("Invalid data pack type (got %d / expected %d).", pDataPack->GetCurrentType(), CDataPackType::Function);
}
cell_t funcid = pDataPack->ReadFunction();
if (!funcid)
{
return pContext->GetNullFunctionValue();
}
return funcid;
return pDataPack->ReadFunction();
}
static cell_t smn_ReadPackCellArray(IPluginContext *pContext, const cell_t *params)
+1 -28
View File
@@ -366,33 +366,6 @@ static cell_t SetNativeArray(IPluginContext *pContext, const cell_t *params)
return SP_ERROR_NONE;
}
static cell_t GetNativeFunction(IPluginContext *pContext, const cell_t *params)
{
if (!s_curnative || (s_curnative->ctx != pContext))
{
return pContext->ThrowNativeError("Not called from inside a native function");
}
cell_t param = params[1];
if (param < 1 || param > s_curparams[0])
{
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAM, "Invalid parameter number: %d", param);
}
cell_t funcid = s_curparams[param];
if (s_curcaller->IsNullFunctionId(funcid))
{
// see alliedmodders/sourcepawn#912, alliedmodders/sourcemod#2068
// convert null function to receiver's expected value so equality checks against INVALID_FUNCTION pass
return pContext->GetNullFunctionValue();
}
else if (funcid <= 0)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
}
return funcid;
}
static cell_t FormatNativeString(IPluginContext *pContext, const cell_t *params)
{
if (!s_curnative || (s_curnative->ctx != pContext))
@@ -510,7 +483,7 @@ REGISTER_NATIVES(nativeNatives)
{"GetNativeArray", GetNativeArray},
{"GetNativeCell", GetNativeCell},
{"GetNativeCellRef", GetNativeCellRef},
{"GetNativeFunction", GetNativeFunction},
{"GetNativeFunction", GetNativeCell},
{"GetNativeString", GetNativeString},
{"GetNativeStringLength", GetNativeStringLength},
{"FormatNativeString", FormatNativeString},
+1 -78
View File
@@ -73,7 +73,6 @@ class FileObject
public:
virtual ~FileObject()
{}
virtual size_t Size() = 0;
virtual size_t Read(void *pOut, int size) = 0;
virtual char *ReadLine(char *pOut, int size) = 0;
virtual size_t Write(const void *pData, int size) = 0;
@@ -120,10 +119,6 @@ public:
return true;
}
size_t Size() override {
return (size_t)bridge->filesystem->Size(handle_);
}
size_t Read(void *pOut, int size) override {
return (size_t)bridge->filesystem->Read(pOut, size, handle_);
}
@@ -188,30 +183,6 @@ public:
return unlink(path) == 0;
}
size_t Size() override {
#ifdef PLATFORM_WINDOWS
struct _stat s;
int fd = _fileno(fp_);
if (fd == -1)
return -1;
if (_fstat(fd, &s) != 0)
return -1;
if (s.st_mode & S_IFREG)
return static_cast<size_t>(s.st_size);
return -1;
#elif defined PLATFORM_POSIX
struct stat s;
int fd = fileno(fp_);
if (fd == -1)
return -1;
if (fstat(fd, &s) != 0)
return -1;
if (S_ISREG(s.st_mode))
return static_cast<size_t>(s.st_size);
return -1;
#endif
}
size_t Read(void *pOut, int size) override {
return fread(pOut, 1, size, fp_);
}
@@ -317,10 +288,6 @@ public:
}
virtual bool LogPrint(const char *msg)
{
if (!g_pLogHook) {
return false;
}
cell_t result = 0;
g_pLogHook->PushString(msg);
g_pLogHook->Execute(&result);
@@ -643,7 +610,7 @@ static cell_t sm_RenameFile(IPluginContext *pContext, const cell_t *params)
g_pSM->BuildPath(Path_Game, old_realpath, sizeof(old_realpath), "%s", oldpath);
#ifdef PLATFORM_WINDOWS
return (MoveFileExA(old_realpath, new_realpath, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) ? 1 : 0;
return (MoveFileA(old_realpath, new_realpath)) ? 1 : 0;
#elif defined PLATFORM_POSIX
return (rename(old_realpath, new_realpath)) ? 0 : 1;
#endif
@@ -755,39 +722,6 @@ static cell_t sm_SetFilePermissions(IPluginContext *pContext, const cell_t *para
#endif
}
static cell_t sm_GetFilePermissions(IPluginContext *pContext, const cell_t *params)
{
char *name;
char realpath[PLATFORM_MAX_PATH];
pContext->LocalToString(params[1], &name);
g_pSM->BuildPath(Path_Game, realpath, sizeof(realpath), "%s", name);
cell_t *mask;
pContext->LocalToPhysAddr(params[2], &mask);
#if defined PLATFORM_WINDOWS
struct _stat buffer;
cell_t valid = _stat(realpath, &buffer) == 0;
if ((buffer.st_mode & _S_IREAD) != 0) {
*mask |= (FPERM_U_READ|FPERM_G_READ|FPERM_O_READ)|(FPERM_U_EXEC|FPERM_G_EXEC|FPERM_O_EXEC);
}
if ((buffer.st_mode & _S_IWRITE) != 0) {
*mask |= (FPERM_U_WRITE|FPERM_G_WRITE|FPERM_O_WRITE);
}
return valid;
#else
struct stat buffer;
cell_t valid = stat(realpath, &buffer) == 0;
*mask = buffer.st_mode;
return valid;
#endif
}
static cell_t sm_CreateDirectory(IPluginContext *pContext, const cell_t *params)
{
char *name;
@@ -1191,15 +1125,6 @@ static cell_t sm_RemoveGameLogHook(IPluginContext *pContext, const cell_t *param
return 1;
}
static cell_t File_Size(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<FileObject> file(pContext, params[1], g_FileType);
if (!file.Ok())
return -1;
return file->Size();
}
template <typename T>
static cell_t File_ReadTyped(IPluginContext *pContext, const cell_t *params)
{
@@ -1261,7 +1186,6 @@ REGISTER_NATIVES(filesystem)
{"RemoveGameLogHook", sm_RemoveGameLogHook},
{"CreateDirectory", sm_CreateDirectory},
{"SetFilePermissions", sm_SetFilePermissions},
{"GetFilePermissions", sm_GetFilePermissions},
{"File.ReadLine", sm_ReadFileLine},
{"File.Read", sm_ReadFile},
@@ -1273,7 +1197,6 @@ REGISTER_NATIVES(filesystem)
{"File.Seek", sm_FileSeek},
{"File.Flush", sm_FlushFile},
{"File.Position.get", sm_FilePosition},
{"File.Size", File_Size},
{"File.ReadInt8", File_ReadTyped<int8_t>},
{"File.ReadUint8", File_ReadTyped<uint8_t>},
{"File.ReadInt16", File_ReadTyped<int16_t>},
-13
View File
@@ -231,13 +231,6 @@ static cell_t sm_FloatFraction(IPluginContext *pCtx, const cell_t *params)
return sp_ftoc(val);
}
static cell_t sm_FloatMod(IPluginContext* pCtx, const cell_t* params)
{
float val = fmodf(sp_ctof(params[1]), sp_ctof(params[2]));
return sp_ftoc(val);
}
static cell_t sm_Sine(IPluginContext *pCtx, const cell_t *params)
{
float val = sp_ctof(params[1]);
@@ -365,16 +358,10 @@ REGISTER_NATIVES(floatnatives)
{"FloatAdd", sm_FloatAdd},
{"FloatSub", sm_FloatSub},
{"FloatFraction", sm_FloatFraction},
{"FloatMod", sm_FloatMod},
{"RoundToZero", sm_RoundToZero},
{"RoundToCeil", sm_RoundToCeil},
{"RoundToFloor", sm_RoundToFloor},
{"RoundToNearest", sm_RoundToNearest},
{"__FLOAT_MUL__", sm_FloatMul},
{"__FLOAT_DIV__", sm_FloatDiv},
{"__FLOAT_ADD__", sm_FloatAdd},
{"__FLOAT_SUB__", sm_FloatSub},
{"__FLOAT_MOD__", sm_FloatMod},
{"__FLOAT_GT__", sm_FloatGt},
{"__FLOAT_GE__", sm_FloatGe},
{"__FLOAT_LT__", sm_FloatLt},
+13 -26
View File
@@ -8,7 +8,7 @@
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
@@ -36,7 +36,6 @@
#include <IHandleSys.h>
#include <IForwardSys.h>
#include <ISourceMod.h>
#include <amtl/am-autoptr.h>
#include "ShareSys.h"
#include "NativeInvoker.h"
@@ -49,7 +48,7 @@ static IPluginFunction *s_pFunction = NULL;
static IForward *s_pForward = NULL;
static NativeInvoker *s_pInvoker = NULL;
class ForwardNativeHelpers :
class ForwardNativeHelpers :
public SMGlobalClass,
public IHandleTypeDispatch
{
@@ -138,7 +137,7 @@ static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *param
if (pPlugin->GetBaseContext()->FindPublicByName(name, &idx) == SP_ERROR_NOT_FOUND)
{
/* Return INVALID_FUNCTION if not found */
return pContext->GetNullFunctionValue();
return -1;
}
/* Return function ID */
@@ -155,7 +154,7 @@ static cell_t sm_CreateGlobalForward(IPluginContext *pContext, const cell_t *par
{
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, NULL);
}
pContext->LocalToString(params[1], &name);
cell_t *addr;
@@ -235,15 +234,11 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
}
}
cell_t funcid = params[3];
if (funcid <= 0)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
}
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(funcid);
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[3]);
if (!pFunction)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
return pContext->ThrowNativeError("Invalid function id (%X)", params[3]);
}
return pForward->AddFunction(pFunction);
@@ -276,15 +271,11 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
}
}
cell_t funcid = params[3];
if (funcid <= 0)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
}
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(funcid);
IPluginFunction *pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[3]);
if (!pFunction)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
return pContext->ThrowNativeError("Invalid function id (%X)", params[3]);
}
return pForward->RemoveFunction(pFunction);
@@ -342,15 +333,11 @@ static cell_t sm_CallStartFunction(IPluginContext *pContext, const cell_t *param
}
}
cell_t funcid = params[2];
if (funcid <= 0)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
}
s_pFunction = pPlugin->GetBaseContext()->GetFunctionById(funcid);
s_pFunction = pPlugin->GetBaseContext()->GetFunctionById(params[2]);
if (!s_pFunction)
{
return pContext->ThrowNativeError("Invalid function id (%X)", funcid);
return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
}
s_pCallable = static_cast<ICallable *>(s_pFunction);
-2
View File
@@ -119,7 +119,5 @@ REGISTER_NATIVES(handles)
{"CloseHandle", sm_CloseHandle},
{"CloneHandle", sm_CloneHandle},
{"GetMyHandle", sm_GetMyHandle},
{"Handle.Close", sm_CloseHandle},
{"Handle.~Handle", sm_CloseHandle},
{NULL, NULL},
};
-13
View File
@@ -144,18 +144,6 @@ static cell_t sm_SetClientLanguage(IPluginContext *pContext, const cell_t *param
return 1;
}
static cell_t sm_GetClientOriginalLanguage(IPluginContext *pContext, const cell_t *params)
{
IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]);
if (!player || !player->IsConnected())
{
return pContext->ThrowNativeError("Invalid client index %d", params[1]);
}
return player->GetOriginalLanguageId();
}
static cell_t sm_GetLanguageByCode(IPluginContext *pContext, const cell_t *params)
{
char *code;
@@ -193,7 +181,6 @@ REGISTER_NATIVES(langNatives)
{"GetLanguageCount", sm_GetLanguageCount},
{"GetLanguageInfo", sm_GetLanguageInfo},
{"SetClientLanguage", sm_SetClientLanguage},
{"GetClientOriginalLanguage", sm_GetClientOriginalLanguage},
{"GetLanguageByCode", sm_GetLanguageByCode},
{"GetLanguageByName", sm_GetLanguageByName},
{NULL, NULL},
+9 -5
View File
@@ -1568,11 +1568,15 @@ static cell_t InternalShowMenu(IPluginContext *pContext, const cell_t *params)
IMenuHandler *pHandler;
CPanelHandler *pActualHandler = NULL;
IPluginFunction* func;
if (!pContext->GetFunctionByIdOrNull(params[5], &func))
return 0;
if (func)
pActualHandler = g_MenuHelpers.GetPanelHandler(func);
if (params[5] != -1)
{
IPluginFunction *pFunction = pContext->GetFunctionById(params[5]);
if (pFunction == NULL)
{
return pContext->ThrowNativeError("Invalid function index %x", params[5]);
}
pActualHandler = g_MenuHelpers.GetPanelHandler(pFunction);
}
if (pActualHandler == NULL)
{
-29
View File
@@ -29,8 +29,6 @@
* Version: $Id$
*/
#include <string.h>
#include "common_logic.h"
#include <ITextParsers.h>
#include <ISourceMod.h>
@@ -266,32 +264,6 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
return (cell_t)p_err;
}
static cell_t SMC_ParseString(IPluginContext *pContext, const cell_t *params)
{
OpenHandle<ParseInfo> parse(pContext, params[1], g_TypeSMC);
if (!parse.Ok())
return 0;
char *str;
pContext->LocalToString(params[2], &str);
SMCStates states;
SMCError p_err = textparsers->ParseSMCStream(str,
strlen(str),
parse,
&states,
NULL,
0);
cell_t *c_line, *c_col;
pContext->LocalToPhysAddr(params[3], &c_line);
pContext->LocalToPhysAddr(params[4], &c_col);
*c_line = states.line;
*c_col = states.col;
return (cell_t)p_err;
}
static cell_t SMC_GetErrorString(IPluginContext *pContext, const cell_t *params)
{
const char *str = textparsers->GetSMCErrorString((SMCError)params[1]);
@@ -362,7 +334,6 @@ REGISTER_NATIVES(textNatives)
// Transitional syntax support.
{"SMCParser.SMCParser", SMC_CreateParser},
{"SMCParser.ParseFile", SMC_ParseFile},
{"SMCParser.ParseString", SMC_ParseString},
{"SMCParser.OnStart.set", SMC_SetParseStart},
{"SMCParser.OnEnd.set", SMC_SetParseEnd},
{"SMCParser.OnEnterSection.set", SMCParser_OnEnterSection_set},
+31 -42
View File
@@ -102,98 +102,90 @@ public:
class VFileSystem_Logic : public IFileSystemBridge
{
public:
const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) override
const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle)
{
return filesystem->FindFirstEx(pWildCard, pPathID, pHandle);
}
const char *FindNext(FileFindHandle_t handle) override
const char *FindNext(FileFindHandle_t handle)
{
return filesystem->FindNext(handle);
}
bool FindIsDirectory(FileFindHandle_t handle) override
bool FindIsDirectory(FileFindHandle_t handle)
{
return filesystem->FindIsDirectory(handle);
}
void FindClose(FileFindHandle_t handle) override
void FindClose(FileFindHandle_t handle)
{
filesystem->FindClose(handle);
}
FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) override
FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0)
{
return filesystem->Open(pFileName, pOptions, pathID);
}
void Close(FileHandle_t file) override
void Close(FileHandle_t file)
{
filesystem->Close(file);
}
char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) override
char *ReadLine(char *pOutput, int maxChars, FileHandle_t file)
{
return filesystem->ReadLine(pOutput, maxChars, file);
}
bool EndOfFile(FileHandle_t file) override
bool EndOfFile(FileHandle_t file)
{
return filesystem->EndOfFile(file);
}
bool FileExists(const char *pFileName, const char *pPathID = 0) override
bool FileExists(const char *pFileName, const char *pPathID = 0)
{
return filesystem->FileExists(pFileName, pPathID);
}
unsigned int Size(FileHandle_t file) override
{
return filesystem->Size(file);
}
unsigned int Size(const char *pFileName, const char *pPathID = 0) override
unsigned int Size(const char *pFileName, const char *pPathID = 0)
{
return filesystem->Size(pFileName, pPathID);
}
int Read(void* pOutput, int size, FileHandle_t file) override
int Read(void* pOutput, int size, FileHandle_t file)
{
return filesystem->Read(pOutput, size, file);
}
int Write(void const* pInput, int size, FileHandle_t file) override
int Write(void const* pInput, int size, FileHandle_t file)
{
return filesystem->Write(pInput, size, file);
}
void Seek(FileHandle_t file, int pos, int seekType) override
void Seek(FileHandle_t file, int pos, int seekType)
{
filesystem->Seek(file, pos, (FileSystemSeek_t) seekType);
}
unsigned int Tell(FileHandle_t file) override
unsigned int Tell(FileHandle_t file)
{
return filesystem->Tell(file);
}
int FPrint(FileHandle_t file, const char *pData) override
int FPrint(FileHandle_t file, const char *pData)
{
return filesystem->FPrintf(file, "%s", pData);
}
void Flush(FileHandle_t file) override
void Flush(FileHandle_t file)
{
filesystem->Flush(file);
}
bool IsOk(FileHandle_t file) override
bool IsOk(FileHandle_t file)
{
return filesystem->IsOk(file);
}
void RemoveFile(const char *pRelativePath, const char *pathID) override
void RemoveFile(const char *pRelativePath, const char *pathID)
{
filesystem->RemoveFile(pRelativePath, pathID);
}
void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID) override
void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID)
{
filesystem->RenameFile(pOldPath, pNewPath, pathID);
}
bool IsDirectory(const char *pFileName, const char *pathID) override
bool IsDirectory(const char *pFileName, const char *pathID)
{
return filesystem->IsDirectory(pFileName, pathID);
}
void CreateDirHierarchy(const char *path, const char *pathID) override
void CreateDirHierarchy(const char *path, const char *pathID)
{
filesystem->CreateDirHierarchy(path, pathID);
}
int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) override
{
return filesystem->GetSearchPath(pathID, bGetPackFiles, pPath, nMaxLen);
}
} fs_wrapper;
class VPlayerInfo_Logic : public IPlayerInfoBridge
@@ -379,12 +371,6 @@ void UTIL_ConsolePrint(const char *fmt, ...)
#define GAMEFIX "2.csgo"
#elif SOURCE_ENGINE == SE_CONTAGION
#define GAMEFIX "2.contagion"
#elif SOURCE_ENGINE == SE_PVKII
#define GAMEFIX "2.pvkii"
#elif SOURCE_ENGINE == SE_MCV
#define GAMEFIX "2.mcv"
#elif SOURCE_ENGINE == SE_MOCK
#define GAMEFIX "2.mock"
#else
#define GAMEFIX "2.ep1"
#endif
@@ -417,6 +403,9 @@ CoreProviderImpl::CoreProviderImpl()
this->GetGlobalTarget = get_global_target;
this->gamesuffix = GAMEFIX;
this->serverGlobals = &::serverGlobals;
this->serverFactory = nullptr;
this->engineFactory = nullptr;
this->matchmakingDSFactory = nullptr;
this->listeners = nullptr;
}
@@ -506,10 +495,6 @@ const char *CoreProviderImpl::GetSourceEngineName()
return "csgo";
#elif SOURCE_ENGINE == SE_MOCK
return "mock";
#elif SOURCE_ENGINE == SE_PVKII
return "pvkii";
#elif SOURCE_ENGINE == SE_MCV
return "mcv";
#endif
}
@@ -527,9 +512,7 @@ bool CoreProviderImpl::SymbolsAreHidden()
|| (SOURCE_ENGINE == SE_INSURGENCY) \
|| (SOURCE_ENGINE == SE_DOI) \
|| (SOURCE_ENGINE == SE_BLADE) \
|| (SOURCE_ENGINE == SE_CSGO) \
|| (SOURCE_ENGINE == SE_PVKII) \
|| (SOURCE_ENGINE == SE_MCV)
|| (SOURCE_ENGINE == SE_CSGO)
return true;
#else
return false;
@@ -642,8 +625,14 @@ void CoreProviderImpl::InitializeBridge()
::serverGlobals.frametime = &gpGlobals->frametime;
::serverGlobals.interval_per_tick = &gpGlobals->interval_per_tick;
this->engineFactory = (void *)g_SMAPI->GetEngineFactory(false);
this->serverFactory = (void *)g_SMAPI->GetServerFactory(false);
this->listeners = SMGlobalClass::head;
if (auto mmlib = ::filesystem->LoadModule("matchmaking_ds" SOURCE_BIN_SUFFIX, "GAMEBIN")) {
this->matchmakingDSFactory = (void*)Sys_GetFactory(mmlib);
}
logic_init_(this, &logicore);
// Join logic's SMGlobalClass instances.
+9 -57
View File
@@ -51,7 +51,7 @@
#include <bridge/include/ILogger.h>
#include <ITranslator.h>
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
#include <netmessages.pb.h>
#endif
@@ -989,14 +989,11 @@ static cell_t sm_ServerCommandEx(IPluginContext *pContext, const cell_t *params)
}
engine->ServerExecute();
if (!g_ShouldCatchSpew) {
g_ShouldCatchSpew = true;
engine->ServerCommand("sm_conhook_start\n");
engine->ServerCommand(buffer);
engine->ServerCommand("sm_conhook_stop\n");
} else {
engine->ServerCommand(buffer);
}
g_ShouldCatchSpew = true;
engine->ServerCommand("sm_conhook_start\n");
engine->ServerCommand(buffer);
engine->ServerCommand("sm_conhook_stop\n");
engine->ServerExecute();
@@ -1104,26 +1101,6 @@ static cell_t IsChatTrigger(IPluginContext *pContext, const cell_t *params)
return g_ChatTriggers.IsChatTrigger() ? 1 : 0;
}
static cell_t GetPublicChatTriggers(IPluginContext *pContext, const cell_t *params)
{
size_t length;
const char *triggers = g_ChatTriggers.GetPublicChatTrigger();
pContext->StringToLocalUTF8(params[1], params[2], triggers ? triggers : "", &length);
return static_cast<cell_t>(length);
}
static cell_t GetSilentChatTriggers(IPluginContext *pContext, const cell_t *params)
{
size_t length;
const char *triggers = g_ChatTriggers.GetPrivateChatTrigger();
pContext->StringToLocalUTF8(params[1], params[2], triggers ? triggers : "", &length);
return static_cast<cell_t>(length);
}
static cell_t SetCommandFlags(IPluginContext *pContext, const cell_t *params)
{
char *name;
@@ -1242,7 +1219,7 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params)
char data[256];
bf_write buffer(data, sizeof(data));
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CNETMsg_SetConVar msg;
CMsg_CVars_CVar *cvar = msg.mutable_convars()->add_cvars();
@@ -1426,7 +1403,7 @@ static cell_t sm_CommandIteratorNext(IPluginContext *pContext, const cell_t *par
return iter->iter != cmds.end();
}
static cell_t sm_CommandIteratorAdminFlags(IPluginContext *pContext, const cell_t *params)
static cell_t sm_CommandIteratorFlags(IPluginContext *pContext, const cell_t *params)
{
GlobCmdIter *iter;
HandleError err;
@@ -1447,27 +1424,6 @@ static cell_t sm_CommandIteratorAdminFlags(IPluginContext *pContext, const cell_
return pInfo->eflags;
}
static cell_t sm_CommandIteratorConVarFlags(IPluginContext *pContext, const cell_t *params)
{
GlobCmdIter *iter;
HandleError err;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err = handlesys->ReadHandle(params[1], hCmdIterType, &sec, (void **)&iter))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]);
}
const List<ConCmdInfo *> &cmds = g_ConCmds.GetCommandList();
if (!iter->started || iter->iter == cmds.end())
{
return pContext->ThrowNativeError("Invalid CommandIterator position");
}
ConCmdInfo *pInfo = (*(iter->iter));
return pInfo->pCmd->m_nFlags;
}
static cell_t sm_CommandIteratorGetDesc(IPluginContext *pContext, const cell_t *params)
{
GlobCmdIter *iter;
@@ -1569,8 +1525,6 @@ REGISTER_NATIVES(consoleNatives)
{"ReadCommandIterator", ReadCommandIterator},
{"FakeClientCommandEx", FakeClientCommandEx},
{"IsChatTrigger", IsChatTrigger},
{"GetPublicChatTriggers", GetPublicChatTriggers},
{"GetSilentChatTriggers", GetSilentChatTriggers},
{"SetCommandFlags", SetCommandFlags},
{"GetCommandFlags", GetCommandFlags},
{"FindFirstConCommand", FindFirstConCommand},
@@ -1609,9 +1563,7 @@ REGISTER_NATIVES(consoleNatives)
{"CommandIterator.Next", sm_CommandIteratorNext},
{"CommandIterator.GetDescription", sm_CommandIteratorGetDesc},
{"CommandIterator.GetName", sm_CommandIteratorGetName},
{"CommandIterator.Flags.get", sm_CommandIteratorAdminFlags},
{"CommandIterator.AdminFlags.get", sm_CommandIteratorAdminFlags},
{"CommandIterator.ConVarFlags.get", sm_CommandIteratorConVarFlags},
{"CommandIterator.Flags.get", sm_CommandIteratorFlags},
{"CommandIterator.Plugin.get", sm_CommandIteratorPlugin},
{NULL, NULL}
+34 -110
View File
@@ -134,10 +134,12 @@ inline edict_t *BaseEntityToEdict(CBaseEntity *pEntity)
{
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (pNet == nullptr)
if (!pNet)
{
return nullptr;
return NULL;
}
return pNet->GetEdict();
}
@@ -283,11 +285,6 @@ static cell_t RemoveEdict(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Edict %d (%d) is not a valid edict", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
if (g_HL2.ReferenceToIndex(params[1]) == 0)
{
return pContext->ThrowNativeError("Cannot remove worldspawn (edict 0)");
}
engine->RemoveEdict(pEdict);
return 1;
@@ -301,11 +298,6 @@ static cell_t RemoveEntity(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Entity %d (%d) is not a valid entity", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
if (g_HL2.ReferenceToIndex(params[1]) == 0)
{
return pContext->ThrowNativeError("Cannot remove worldspawn (entity 0)");
}
// Some games have UTIL_Remove exposed on IServerTools, but for consistence, we'll
// use this method for all. Results in DeathNotice( this ) being called on parent,
// and parent being cleared (both if any parent) before UTIL_Remove is called.
@@ -361,20 +353,14 @@ static cell_t IsValidEntity(IPluginContext *pContext, const cell_t *params)
static cell_t IsEntNetworkable(IPluginContext *pContext, const cell_t *params)
{
IServerUnknown *pUnknown = (IServerUnknown *)g_HL2.ReferenceToEntity(params[1]);
if (!pUnknown)
edict_t *pEdict = GetEdict(params[1]);
if (!pEdict)
{
return 0;
}
IServerNetworkable *pNet = pUnknown->GetNetworkable();
if (!pNet)
{
return 0;
}
edict_t* edict = pNet->GetEdict();
return (edict && !edict->IsFree()) ? 1 : 0;
return (pEdict->GetNetworkable() != NULL) ? 1 : 0;
}
static cell_t GetEntityCount(IPluginContext *pContext, const cell_t *params)
@@ -440,12 +426,14 @@ static cell_t GetEntityNetClass(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("Invalid entity (%d - %d)", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
ServerClass *pClass = g_HL2.FindEntityServerClass(pEntity);
if (!pClass)
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!pNet)
{
return 0;
}
ServerClass *pClass = pNet->GetServerClass();
pContext->StringToLocal(params[2], params[3], pClass->GetName());
return 1;
@@ -718,36 +706,6 @@ static cell_t GetEntDataEnt2(IPluginContext *pContext, const cell_t *params)
return g_HL2.EntityToBCompatRef(pHandleEntity);
}
//memory addresses below 0x10000 are automatically considered invalid for dereferencing
//this is copied over from smn_core.cpp
#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000
static cell_t LoadEntityFromHandleAddress(IPluginContext *pContext, const cell_t *params)
{
#ifdef PLATFORM_X86
void *addr = reinterpret_cast<void*>(params[1]);
#else
void *addr = g_SourceMod.FromPseudoAddress(params[1]);
#endif
if (addr == NULL)
{
return pContext->ThrowNativeError("Address cannot be null");
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
}
CBaseHandle &hndl = *reinterpret_cast<CBaseHandle*>(addr);
CBaseEntity *pHandleEntity = g_HL2.ReferenceToEntity(hndl.GetEntryIndex());
if (!pHandleEntity || hndl != reinterpret_cast<IHandleEntity *>(pHandleEntity)->GetRefEHandle())
return -1;
return g_HL2.EntityToBCompatRef(pHandleEntity);
}
/* THIS GUY IS DEPRECATED. */
static cell_t SetEntDataEnt(IPluginContext *pContext, const cell_t *params)
{
@@ -833,44 +791,6 @@ static cell_t SetEntDataEnt2(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t StoreEntityToHandleAddress(IPluginContext *pContext, const cell_t *params)
{
#ifdef PLATFORM_X86
void *addr = reinterpret_cast<void*>(params[1]);
#else
void *addr = g_SourceMod.FromPseudoAddress(params[1]);
#endif
if (addr == NULL)
{
return pContext->ThrowNativeError("Address cannot be null");
}
else if (reinterpret_cast<uintptr_t>(addr) < VALID_MINIMUM_MEMORY_ADDRESS)
{
return pContext->ThrowNativeError("Invalid address 0x%x is pointing to reserved memory.", addr);
}
CBaseHandle &hndl = *reinterpret_cast<CBaseHandle*>(addr);
if ((unsigned)params[2] == INVALID_EHANDLE_INDEX)
{
hndl.Set(NULL);
}
else
{
CBaseEntity *pOther = GetEntity(params[2]);
if (!pOther)
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[2]), params[2]);
}
IHandleEntity *pHandleEnt = (IHandleEntity *)pOther;
hndl.Set(pHandleEnt);
}
return 1;
}
static cell_t ChangeEdictState(IPluginContext *pContext, const cell_t *params)
{
edict_t *pEdict = GetEdict(params[1]);
@@ -1272,11 +1192,13 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params)
#define FIND_PROP_SEND(type, type_name) \
sm_sendprop_info_t info;\
SendProp *pProp; \
ServerClass *pServerClass = g_HL2.FindEntityServerClass(pEntity); \
if (pServerClass == nullptr) { \
pContext->ThrowNativeError("Failed to retrieve entity %d (%d) server class!", g_HL2.ReferenceToIndex(params[1]), params[1]); \
IServerUnknown *pUnk = (IServerUnknown *)pEntity; \
IServerNetworkable *pNet = pUnk->GetNetworkable(); \
if (!pNet) \
{ \
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]); \
} \
if (!g_HL2.FindSendPropInfo(pServerClass->GetName(), prop, &info)) \
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info)) \
{ \
const char *class_name = g_HL2.GetEntityClassname(pEntity); \
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)", \
@@ -1434,13 +1356,13 @@ static cell_t GetEntPropArraySize(IPluginContext *pContext, const cell_t *params
{
sm_sendprop_info_t info;
ServerClass *pServerClass = g_HL2.FindEntityServerClass(pEntity);
if (pServerClass == nullptr)
IServerUnknown *pUnk = (IServerUnknown *)pEntity;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!pNet)
{
return pContext->ThrowNativeError("Failed to retrieve entity %d (%d) server class!", g_HL2.ReferenceToIndex(params[1]), params[1]);
return pContext->ThrowNativeError("Edict %d (%d) is not networkable", g_HL2.ReferenceToIndex(params[1]), params[1]);
}
if (!g_HL2.FindSendPropInfo(pServerClass->GetName(), prop, &info))
if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info))
{
const char *class_name = g_HL2.GetEntityClassname(pEntity);
return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
@@ -1536,8 +1458,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params)
// This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_PVKII \
|| SOURCE_ENGINE == SE_MCV
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (pProp->GetFlags() & SPROP_VARINT)
{
bit_count = sizeof(int) * 8;
@@ -1656,8 +1577,7 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params)
// This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_PVKII \
|| SOURCE_ENGINE == SE_MCV
|| SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (pProp->GetFlags() & SPROP_VARINT)
{
bit_count = sizeof(int) * 8;
@@ -2079,7 +1999,13 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
edict_t *pOtherEdict = NULL;
if (pOther)
{
pOtherEdict = BaseEntityToEdict(pOther);
IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable();
if (!pNetworkable)
{
return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]);
}
pOtherEdict = pNetworkable->GetEdict();
if (!pOtherEdict || pOtherEdict->IsFree())
{
return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]);
@@ -2582,7 +2508,7 @@ static int32_t SDKEntFlagToSMEntFlag(int flag)
case FL_FREEZING:
return ENTFLAG_FREEZING;
#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2
case FL_EP2V_UNKNOWN:
return ENTFLAG_EP2V_UNKNOWN1;
#endif
@@ -2661,7 +2587,7 @@ static int32_t SMEntFlagToSDKEntFlag(int32_t flag)
case ENTFLAG_FREEZING:
return FL_FREEZING;
#elif SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2
case ENTFLAG_EP2V_UNKNOWN1:
return FL_EP2V_UNKNOWN;
#endif
@@ -2824,7 +2750,5 @@ REGISTER_NATIVES(entityNatives)
{"SetEntPropVector", SetEntPropVector},
{"GetEntityAddress", GetEntityAddress},
{"FindDataMapInfo", FindDataMapInfo},
{"LoadEntityFromHandleAddress", LoadEntityFromHandleAddress},
{"StoreEntityToHandleAddress", StoreEntityToHandleAddress},
{NULL, NULL}
};
-2
View File
@@ -505,7 +505,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
case SOURCE_ENGINE_TF2:
case SOURCE_ENGINE_BMS:
case SOURCE_ENGINE_SDK2013:
case SOURCE_ENGINE_PVKII:
return 35;
case SOURCE_ENGINE_LEFT4DEAD:
return 40;
@@ -519,7 +518,6 @@ static cell_t GuessSDKVersion(IPluginContext *pContext, const cell_t *params)
return 70;
case SOURCE_ENGINE_CSGO:
return 80;
// Deprecated, and not very useful. Don't bother adding new games
}
return 0;
+3 -18
View File
@@ -41,8 +41,6 @@
#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
#elif SOURCE_ENGINE == SE_BLADE
#include <game/shared/berimbau/protobuf/berimbau_usermessages.pb.h>
#elif SOURCE_ENGINE == SE_MCV
#include <game/shared/vietnam/protobuf/vietnam_usermessages.pb.h>
#endif
#define MAX_HUD_CHANNELS 6
@@ -72,7 +70,6 @@ struct hud_text_parms
float holdTime;
float fxTime;
int channel;
bool isSet = false;
};
class HudMsgHelpers :
@@ -285,7 +282,6 @@ static cell_t SetHudTextParams(IPluginContext *pContext, const cell_t *params)
g_hud_params.g2 = 255;
g_hud_params.b2 = 250;
g_hud_params.a2 = 0;
g_hud_params.isSet = true;
return 1;
}
@@ -312,7 +308,6 @@ static cell_t SetHudTextParamsEx(IPluginContext *pContext, const cell_t *params)
g_hud_params.g2 = static_cast<byte>(color2[1]);
g_hud_params.b2 = static_cast<byte>(color2[2]);
g_hud_params.a2 = static_cast<byte>(color2[3]);
g_hud_params.isSet = true;
return 1;
}
@@ -323,7 +318,7 @@ void UTIL_SendHudText(int client, const hud_text_parms &textparms, const char *p
players[0] = client;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CCSUsrMsg_HudMsg *msg = (CCSUsrMsg_HudMsg *)g_UserMsgs.StartProtobufMessage(g_HudMsgNum, players, 1, 0);
if (!msg)
{
@@ -382,7 +377,7 @@ static cell_t ShowSyncHudText(IPluginContext *pContext, const cell_t *params)
Handle_t err;
CPlayer *pPlayer;
hud_syncobj_t *obj;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
char message_buffer[512];
#else
char message_buffer[255-36];
@@ -393,11 +388,6 @@ static cell_t ShowSyncHudText(IPluginContext *pContext, const cell_t *params)
return -1;
}
if (!g_hud_params.isSet)
{
return pContext->ThrowNativeError("ShowSyncHudText first requires a call to SetHudTextParams or SetHudTextParamsEx");
}
if ((err = s_HudMsgHelpers.ReadHudSyncObj(params[2], pContext->GetIdentity(), &obj)) != HandleError_None)
{
return pContext->ThrowNativeError("Invalid Handle %x (error %d)", params[2], err);
@@ -471,7 +461,7 @@ static cell_t ShowHudText(IPluginContext *pContext, const cell_t *params)
{
int client;
CPlayer *pPlayer;
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
char message_buffer[512];
#else
char message_buffer[255-36];
@@ -482,11 +472,6 @@ static cell_t ShowHudText(IPluginContext *pContext, const cell_t *params)
return -1;
}
if (!g_hud_params.isSet)
{
return pContext->ThrowNativeError("ShowHudText first requires a call to SetHudTextParams or SetHudTextParamsEx");
}
client = params[1];
if ((pPlayer = g_Players.GetPlayerByIndex(client)) == NULL)
{
+2 -14
View File
@@ -669,21 +669,9 @@ static cell_t smn_KvRewind(IPluginContext *pCtx, const cell_t *params)
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
// Older plugins do not have the clearHistory param
if (params[0] < 2 || params[2])
while (pStk->pCurRoot.size() > 1)
{
while (pStk->pCurRoot.size() > 1)
{
pStk->pCurRoot.pop();
}
}
else
{
auto root = pStk->pCurRoot.begin();
if (root != pStk->pCurRoot.end())
{
pStk->pCurRoot.push(*root);
}
pStk->pCurRoot.pop();
}
return 1;
+1 -1
View File
@@ -70,7 +70,7 @@ bool SourceMod_Core::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen
PLUGIN_SAVEVARS();
GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
#if SOURCE_ENGINE == SE_SDK2013
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_SDK2013
// Shim to avoid hooking shims
engine = (IVEngineServer *)ismm->GetEngineFactory()("VEngineServer023", nullptr);
if (!engine)
File diff suppressed because one or more lines are too long
+2 -10
View File
@@ -725,7 +725,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u
ObjectClass classes[MAX_CLASSES];
int numWords = ClassifyObject(smInfo, classes);
if (classes[0] == ObjectClass::Pointer || classes[0] == ObjectClass::Memory)
if (classes[0] == ObjectClass::Pointer)
goto push_byref;
int neededIntRegs = 0;
@@ -787,7 +787,7 @@ inline void Write_PushObject(JitWriter *jit, const SourceHook::PassInfo *info, u
return;
#elif defined PLATFORM_WINDOWS
if (info->size > 8 || (info->size & (info->size - 1)) != 0)
if (info->size < 64 && (info->size & (info->size - 1)) == 0)
goto push_byref;
else {
SourceHook::PassInfo podInfo;
@@ -1055,11 +1055,7 @@ void *JIT_CallCompile(CallWrapper *pWrapper, FuncAddrMethod method)
int numWords;
#endif
#ifdef PLATFORM_POSIX
g_StackUsage = 0;
#elif defined PLATFORM_WINDOWS
g_StackUsage = 32; // Shadow space
#endif
writer.outbase = NULL;
writer.outptr = NULL;
@@ -1159,12 +1155,8 @@ skip_retbuffer:
#endif
/* Clean up the calling stack */
#ifdef PLATFORM_POSIX
if (hasParams && g_StackUsage)
#endif
{
Write_RectifyStack(jit, g_StackAlign);
}
/* Copy the return type to the return buffer if the function is not void */
if (pRet && !Needs_Retbuf)
+1 -1
View File
@@ -398,7 +398,7 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params)
/* User passed a function id for a callback */
if (!pContext->IsNullFunctionId(params[4]))
if (params[4] != -1)
{
pItem->forward = forwards->CreateForwardEx(NULL, ET_Ignore, 5, NULL, Param_Cell, Param_Cell, Param_Cell, Param_String, Param_Cell);
pItem->forward->AddFunction(pContext, static_cast<funcid_t>(params[4]));
+17 -11
View File
@@ -9,7 +9,15 @@ project.sources += [
'timeleft.cpp',
'forwards.cpp',
'util_cstrike.cpp',
'../../public/smsdk_ext.cpp'
'../../public/smsdk_ext.cpp',
'../../public/CDetour/detours.cpp',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
]
for sdk_name in ['css', 'csgo']:
@@ -21,33 +29,31 @@ for sdk_name in ['css', 'csgo']:
project.sources += ['rulesfix.cpp']
for cxx in builder.targets:
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
continue
cxx.defines += ['HAVE_STRING_H']
binary = SM.HL2ExtConfig(project, builder, cxx, 'game.cstrike.ext.' + sdk['extension'], sdk)
SM.AddCDetour(binary)
binary = SM.HL2ExtConfig(project, builder, cxx, 'game.cstrike.ext.' + sdk.ext, sdk)
if sdk_name == 'csgo':
compiler = binary.compiler
compiler.cxxincludes += [os.path.join(sdk['path'], 'public', 'steam')]
compiler.cxxincludes += [os.path.join(sdk.path, 'public', 'steam')]
compiler.defines += ['VERSION_SAFE_STEAM_API_INTERFACES']
library_name = ''
if cxx.target.platform == 'windows':
compiler.linkflags += [os.path.join(sdk['path'], 'lib', 'public', 'steam_api.lib')]
compiler.linkflags += [os.path.join(sdk.path, 'lib', 'public', 'steam_api.lib')]
elif cxx.target.platform == 'linux':
library_name = 'libsteam_api.so'
if cxx.target.arch == 'x86_64':
source_path = os.path.join(sdk['path'], 'lib', 'linux64')
source_path = os.path.join(sdk.path, 'lib', 'linux64')
else:
source_path = os.path.join(sdk['path'], 'lib', 'linux')
source_path = os.path.join(sdk.path, 'lib', 'linux')
elif cxx.target.platform == 'mac':
library_name = 'libsteam_api.dylib'
if cxx.target.arch == 'x86_64':
source_path = os.path.join(sdk['path'], 'lib', 'osx64')
source_path = os.path.join(sdk.path, 'lib', 'osx64')
else:
source_path = os.path.join(sdk['path'], 'lib', 'mac')
source_path = os.path.join(sdk.path, 'lib', 'mac')
if library_name:
source_path = os.path.join(source_path, library_name)
+3 -22
View File
@@ -254,13 +254,10 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
//Psychonic is awesome for this
sm_sendprop_info_t spi;
ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pWeapon);
if (pServerClass == nullptr)
{
return pContext->ThrowNativeError("Failed to retrieve entity %d server class!", params[2]);
}
IServerUnknown *pUnk = (IServerUnknown *)pWeapon;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!UTIL_FindDataTable(pServerClass->m_pTable, "DT_WeaponCSBase", &spi, 0))
if (!UTIL_FindDataTable(pNet->GetServerClass()->m_pTable, "DT_WeaponCSBase", &spi, 0))
return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]);
if (!gamehelpers->FindSendPropInfo("CBaseCombatWeapon", "m_hOwnerEntity", &spi))
@@ -957,21 +954,6 @@ static cell_t CS_WeaponIDToItemDefIndex(IPluginContext *pContext, const cell_t *
#endif
}
static cell_t CS_WeaponIDToLoadoutSlot(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE == SE_CSGO
WeaponIDMap::Result res = g_mapWeaponIDToDefIdx.find((SMCSWeapon)params[1]);
if (!res.found())
return pContext->ThrowNativeError("Invalid weapon id passed.");
return res->value.m_iLoadoutSlot;
#else
return pContext->ThrowNativeError("CS_WeaponIDToLoadoutSlot is not supported on this game");
#endif
}
sp_nativeinfo_t g_CSNatives[] =
{
{"CS_RespawnPlayer", CS_RespawnPlayer},
@@ -996,7 +978,6 @@ sp_nativeinfo_t g_CSNatives[] =
{"CS_IsValidWeaponID", CS_IsValidWeaponID},
{"CS_ItemDefIndexToID", CS_ItemDefIndexToID},
{"CS_WeaponIDToItemDefIndex", CS_WeaponIDToItemDefIndex},
{"CS_WeaponIDToLoadoutSlot", CS_WeaponIDToLoadoutSlot},
{NULL, NULL}
};
+3 -10
View File
@@ -36,7 +36,6 @@
// Grab the convar ref
ConVar *host_rules_show = nullptr;
bool bPatched = false;
int iPatchSize = -1;
RulesFix rulesfix;
@@ -54,7 +53,7 @@ bool SetMTUMax(int iValue)
//If we never changed skip resetting
if (iOriginalValue == -1 && iValue == -1)
return false;
return true;
if (m_pMaxMTU == nullptr)
{
@@ -78,16 +77,10 @@ bool SetMTUMax(int iValue)
void RulesFix::OnLoad()
{
const char *patchSize = g_pGameConf->GetKeyValue("MTUPatchSize");
if (patchSize != NULL)
{
iPatchSize = atoi(patchSize);
}
host_rules_show = g_pCVar->FindVar("host_rules_show");
if (host_rules_show)
{
if (SetMTUMax(iPatchSize))
if (SetMTUMax(5000))
{
// Default to enabled. Explicit disable via cfg will still be obeyed.
host_rules_show->SetValue(true);
@@ -131,7 +124,7 @@ static void OnConVarChanged(IConVar *var, const char *pOldValue, float flOldValu
{
if (!bPatched)
{
if (SetMTUMax(iPatchSize))
if (SetMTUMax(5000))
{
bPatched = true;
NotifyAllCVars();
+7 -12
View File
@@ -19,7 +19,6 @@ for cxx in builder.targets:
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core'),
os.path.join(SM.mms_root, 'core', 'sourcehook'),
os.path.join(builder.sourcePath, 'extensions', 'dhooks'),
os.path.join(builder.sourcePath, 'public', 'jit'),
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
os.path.join(builder.sourcePath, 'sourcepawn', 'include'),
@@ -28,10 +27,6 @@ for cxx in builder.targets:
os.path.join(builder.sourcePath, 'extensions', 'dhooks', 'DynamicHooks'),
]
binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'dhooks')
]
binary.sources += [
'extension.cpp',
'listeners.cpp',
@@ -41,13 +36,13 @@ for cxx in builder.targets:
'util.cpp',
'dynhooks_sourcepawn.cpp',
'../../public/smsdk_ext.cpp',
'asm/asm.c',
'libudis86/decode.c',
'libudis86/itab.c',
'libudis86/syn-att.c',
'libudis86/syn-intel.c',
'libudis86/syn.c',
'libudis86/udis86.c',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
'../../sourcepawn/vm/x86/assembler-x86.cpp',
]
+2 -2
View File
@@ -160,7 +160,7 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
{
ReturnAction_t lastPreReturnAction = m_LastPreReturnAction.back();
m_LastPreReturnAction.pop_back();
if (lastPreReturnAction >= ReturnAction_Override)
if (lastPreReturnAction == ReturnAction_Override)
m_pCallingConvention->RestoreReturnValue(m_pRegisters);
if (lastPreReturnAction < ReturnAction_Supercede)
m_pCallingConvention->RestoreCallArguments(m_pRegisters);
@@ -191,7 +191,7 @@ ReturnAction_t CHook::HookHandler(HookType_t eHookType)
if (eHookType == HOOKTYPE_PRE)
{
m_LastPreReturnAction.push_back(returnAction);
if (returnAction >= ReturnAction_Override)
if (returnAction == ReturnAction_Override)
m_pCallingConvention->SaveReturnValue(m_pRegisters);
if (returnAction < ReturnAction_Supercede)
m_pCallingConvention->SaveCallArguments(m_pRegisters);
+2 -8
View File
@@ -119,10 +119,7 @@ void DHooks::SDK_OnAllLoaded()
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
SM_GET_LATE_IFACE(SDKHOOKS, g_pSDKHooks);
if (g_pSDKHooks)
{
g_pSDKHooks->AddEntityListener(g_pEntityListener);
}
g_pSDKHooks->AddEntityListener(g_pEntityListener);
gameconfs->AddUserConfigHook("Functions", g_pSignatures);
}
@@ -134,10 +131,7 @@ void DHooks::SDK_OnUnload()
{
g_pEntityListener->CleanupListeners();
g_pEntityListener->CleanupRemoveList();
if (g_pSDKHooks)
{
g_pSDKHooks->RemoveEntityListener(g_pEntityListener);
}
g_pSDKHooks->RemoveEntityListener(g_pEntityListener);
delete g_pEntityListener;
}
plsys->RemovePluginsListener(this);
+1 -1
View File
@@ -70,7 +70,7 @@ public:
const DatabaseInfo &GetInfo();
private:
MYSQL *m_mysql;
std::recursive_mutex m_FullLock;
std::mutex m_FullLock;
/* ---------- */
DatabaseInfo m_Info;
+1 -1
View File
@@ -71,7 +71,7 @@ public:
void SetLastIDAndRows(unsigned int insertID, unsigned int affectedRows);
private:
PGconn *m_pgsql;
std::recursive_mutex m_FullLock;
std::mutex m_FullLock;
unsigned int m_lastInsertID;
unsigned int m_lastAffectedRows;
+2 -2
View File
@@ -56,7 +56,7 @@ void RegEx::Clear ()
re = nullptr;
mFree = true;
if (subject)
free(subject);
delete [] subject;
subject = nullptr;
mMatchCount = 0;
}
@@ -173,7 +173,7 @@ void RegEx::ClearMatch()
mErrorCode = 0;
mError = nullptr;
if (subject)
free(subject);
delete [] subject;
subject = nullptr;
mMatchCount = 0;
}
+7 -2
View File
@@ -12,12 +12,17 @@ project.sources += [
for sdk_name in SM.sdks:
sdk = SM.sdks[sdk_name]
if sdk.name == 'mock':
continue
for cxx in builder.targets:
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
continue
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdkhooks.ext.' + sdk['extension'], sdk)
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdkhooks.ext.' + sdk.ext, sdk)
binary.compiler.cxxincludes += [
os.path.join(sdk.path, 'game', 'shared')
]
if binary.compiler.behavior == 'gcc':
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
+35 -99
View File
@@ -152,7 +152,6 @@ CUtlVector<IEntityListener *> *EntListeners()
/**
* IServerGameDLL & IVEngineServer Hooks
*/
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, 0, bool, const char *, const char *, const char *, const char *, bool, bool);
#ifdef GAMEDESC_CAN_CHANGE
SH_DECL_HOOK0(IServerGameDLL, GetGameDescription, SH_NOATTRIB, 0, const char *);
@@ -179,7 +178,7 @@ SH_DECL_MANUALHOOK1_void(StartTouch, 0, 0, 0, CBaseEntity *);
SH_DECL_MANUALHOOK0_void(Think, 0, 0, 0);
SH_DECL_MANUALHOOK1_void(Touch, 0, 0, 0, CBaseEntity *);
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
SH_DECL_MANUALHOOK4_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *, CDmgAccumulator *);
#else
SH_DECL_MANUALHOOK3_void(TraceAttack, 0, 0, 0, CTakeDamageInfoHack &, const Vector &, CGameTrace *);
@@ -232,15 +231,10 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
if (!entListeners)
{
g_pSM->Format(error, maxlength, "Failed to setup entity listeners");
#if SOURCE_ENGINE != SE_MOCK
return false;
#endif
}
else
{
entListeners->AddToTail(this);
}
entListeners->AddToTail(this);
sharesys->AddDependency(myself, "bintools.ext", true, true);
sharesys->AddNatives(myself, g_Natives);
@@ -248,8 +242,7 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
sharesys->AddInterface(myself, &g_Interface);
sharesys->AddCapabilityProvider(myself, this, "SDKHook_DmgCustomInOTD");
sharesys->AddCapabilityProvider(myself, this, "SDKHook_LogicalEntSupport");
SH_ADD_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SDKHooks::LevelShutdown), false);
sharesys->AddCapabilityProvider(myself, this, "SDKHook_OnEntitySpawned");
playerhelpers->AddClientListener(&g_Interface);
@@ -371,19 +364,15 @@ void SDKHooks::SDK_OnUnload()
forwards->ReleaseForward(g_pOnLevelInit);
plsys->RemovePluginsListener(&g_Interface);
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SDKHooks::LevelShutdown), true);
playerhelpers->RemoveClientListener(&g_Interface);
sharesys->DropCapabilityProvider(myself, this, "SDKHook_DmgCustomInOTD");
sharesys->DropCapabilityProvider(myself, this, "SDKHook_LogicalEntSupport");
sharesys->DropCapabilityProvider(myself, this, "SDKHook_OnEntitySpawned");
CUtlVector<IEntityListener *> *entListeners = EntListeners();
if (entListeners)
{
entListeners->FindAndRemove(this);
}
entListeners->FindAndRemove(this);
gameconfs->CloseGameConfigFile(g_pGameConf);
}
@@ -454,24 +443,6 @@ void SDKHooks::OnClientDisconnecting(int client)
HandleEntityDeleted(pEntity);
}
void SDKHooks::LevelShutdown()
{
#if defined PLATFORM_LINUX
for (size_t type = 0; type < SDKHook_MAXHOOKS; ++type)
{
std::vector<CVTableList *> &vtablehooklist = g_HookList[type];
for (size_t listentry = 0; listentry < vtablehooklist.size(); ++listentry)
{
std::vector<HookList> &pawnhooks = vtablehooklist[listentry]->hooks;
pawnhooks.clear();
delete vtablehooklist[listentry];
}
vtablehooklist.clear();
}
#endif
}
void SDKHooks::AddEntityListener(ISMEntityListener *listener)
{
m_EntListeners.push_back(listener);
@@ -618,16 +589,11 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac
if (!!strcmp(g_HookTypes[type].dtReq, ""))
{
ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pEnt);
if (pServerClass == nullptr)
{
return HookRet_BadEntForHookType;
}
IServerUnknown *pUnk = (IServerUnknown *)pEnt;
if (!UTIL_ContainsDataTable(pServerClass->m_pTable, g_HookTypes[type].dtReq))
{
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (pNet && !UTIL_ContainsDataTable(pNet->GetServerClass()->m_pTable, g_HookTypes[type].dtReq))
return HookRet_BadEntForHookType;
}
}
size_t entry;
@@ -823,14 +789,12 @@ void SDKHooks::Unhook(CBaseEntity *pEntity)
entry--;
}
#if !defined PLATFORM_LINUX
if (pawnhooks.size() == 0)
{
delete vtablehooklist[listentry];
vtablehooklist.erase(vtablehooklist.begin() + listentry);
listentry--;
}
#endif
}
}
}
@@ -854,14 +818,12 @@ void SDKHooks::Unhook(IPluginContext *pContext)
entry--;
}
#if !defined PLATFORM_LINUX
if (pawnhooks.size() == 0)
{
delete vtablehooklist[listentry];
vtablehooklist.erase(vtablehooklist.begin() + listentry);
listentry--;
}
#endif
}
}
}
@@ -898,14 +860,12 @@ void SDKHooks::Unhook(int entity, SDKHookType type, IPluginFunction *pCallback)
entry--;
}
#if !defined PLATFORM_LINUX
if (pawnhooks.size() == 0)
{
delete vtablehooklist[listentry];
vtablehooklist.erase(vtablehooklist.begin() + listentry);
listentry--;
}
#endif
break;
}
@@ -1113,7 +1073,7 @@ int SDKHooks::Hook_GetMaxHealth()
int new_max = original_max;
cell_t ret = Pl_Continue;
cell_t res = Pl_Continue;
std::vector<IPluginFunction *> callbackList;
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
@@ -1122,20 +1082,10 @@ int SDKHooks::Hook_GetMaxHealth()
IPluginFunction *callback = callbackList[entry];
callback->PushCell(entity);
callback->PushCellByRef(&new_max);
cell_t res;
callback->Execute(&res);
if (res > ret)
{
ret = res;
}
}
if (ret >= Pl_Handled)
RETURN_META_VALUE(MRES_SUPERCEDE, original_max);
if (ret >= Pl_Changed)
if (res >= Pl_Changed)
RETURN_META_VALUE(MRES_SUPERCEDE, new_max);
break;
@@ -1460,7 +1410,7 @@ void SDKHooks::Hook_Spawn()
}
int entity = gamehelpers->EntityToBCompatRef(pEntity);
cell_t ret = Pl_Continue;
cell_t res = Pl_Continue;
std::vector<IPluginFunction *> callbackList;
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
@@ -1468,17 +1418,10 @@ void SDKHooks::Hook_Spawn()
{
IPluginFunction *callback = callbackList[entry];
callback->PushCell(entity);
cell_t res;
callback->Execute(&res);
if (res > ret)
{
ret = res;
}
}
if (ret >= Pl_Handled)
if (res >= Pl_Handled)
RETURN_META(MRES_SUPERCEDE);
break;
@@ -1539,7 +1482,7 @@ void SDKHooks::Hook_TouchPost(CBaseEntity *pOther)
}
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator)
#else
void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr)
@@ -1620,7 +1563,7 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir,
}
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator)
#else
void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr)
@@ -1689,14 +1632,7 @@ void SDKHooks::Hook_Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
callback->PushCell(caller);
callback->PushCell(useType);
callback->PushFloat(value);
cell_t res;
callback->Execute(&res);
if (res > ret)
{
ret = res;
}
callback->Execute(&ret);
}
if (ret >= Pl_Handled)
@@ -1867,44 +1803,42 @@ bool SDKHooks::Hook_WeaponSwitchPost(CBaseCombatWeapon *pWeapon, int viewmodelin
void SDKHooks::HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref)
{
const char *pName = gamehelpers->GetEntityClassname(pEntity);
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
if (!pName)
pName = "";
// Send OnEntityCreated to SM listeners
SourceHook::List<ISMEntityListener *>::iterator iter;
ISMEntityListener *pListener = NULL;
for (iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
{
pListener = (*iter);
pListener->OnEntityCreated(pEntity, pName ? pName : "");
pListener->OnEntityCreated(pEntity, pName);
}
// Call OnEntityCreated forward
g_pOnEntityCreated->PushCell(bcompatRef);
g_pOnEntityCreated->PushString(pName ? pName : "");
g_pOnEntityCreated->Execute(NULL);
if (g_pOnEntityCreated->GetFunctionCount())
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
g_pOnEntityCreated->PushCell(bcompatRef);
g_pOnEntityCreated->PushString(pName);
g_pOnEntityCreated->Execute(NULL);
}
m_EntityCache[index] = ref;
}
void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
{
if (g_pOnEntitySpawned->GetFunctionCount() || m_EntListeners.size())
if (g_pOnEntitySpawned->GetFunctionCount())
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
const char *pName = gamehelpers->GetEntityClassname(pEntity);
if (!pName)
pName = "";
// Send OnEntitySpawned to SM listeners
for (SourceHook::List<ISMEntityListener *>::iterator iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
{
ISMEntityListener *pListener = (*iter);
pListener->OnEntitySpawned(pEntity, pName);
}
// Call OnEntitySpawned forward
if (g_pOnEntitySpawned->GetFunctionCount())
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
g_pOnEntitySpawned->PushCell(bcompatRef);
g_pOnEntitySpawned->PushString(pName);
g_pOnEntitySpawned->Execute(NULL);
@@ -1914,8 +1848,6 @@ void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
// Send OnEntityDestroyed to SM listeners
SourceHook::List<ISMEntityListener *>::iterator iter;
ISMEntityListener *pListener = NULL;
@@ -1926,8 +1858,12 @@ void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
}
// Call OnEntityDestroyed forward
g_pOnEntityDestroyed->PushCell(bcompatRef);
g_pOnEntityDestroyed->Execute(NULL);
if (g_pOnEntityDestroyed->GetFunctionCount())
{
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
g_pOnEntityDestroyed->PushCell(bcompatRef);
g_pOnEntityDestroyed->Execute(NULL);
}
Unhook(pEntity);
}
+2 -10
View File
@@ -20,9 +20,7 @@
#if SOURCE_ENGINE >= SE_CSS && SOURCE_ENGINE != SE_LEFT4DEAD
#define GETMAXHEALTH_IS_VIRTUAL
#endif
#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && \
SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN && \
SOURCE_ENGINE != SE_BLADE && SOURCE_ENGINE != SE_MCV
#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN && SOURCE_ENGINE != SE_BLADE
#define GAMEDESC_CAN_CHANGE
#endif
@@ -139,15 +137,11 @@ class IEntityListener
{
public:
#if SOURCE_ENGINE == SE_BMS
virtual ~IEntityListener() {};
virtual void OnEntityPreSpawned( CBaseEntity *pEntity ) {};
#endif
virtual void OnEntityCreated( CBaseEntity *pEntity ) {};
virtual void OnEntitySpawned( CBaseEntity *pEntity ) {};
virtual void OnEntityDeleted( CBaseEntity *pEntity ) {};
#if SOURCE_ENGINE == SE_BMS
virtual void OnEntityFlagsChanged( CBaseEntity *pEntity, int nAddedFlags, int nRemovedFlags ) {};
#endif
};
class SDKHooks :
@@ -260,8 +254,6 @@ public: // ISDKHooks
virtual void AddEntityListener(ISMEntityListener *listener);
virtual void RemoveEntityListener(ISMEntityListener *listener);
public: // IServerGameDLL
void LevelShutdown();
private:
SourceHook::List<ISMEntityListener *> m_EntListeners;
@@ -317,7 +309,7 @@ public:
void Hook_Touch(CBaseEntity *pOther);
void Hook_TouchPost(CBaseEntity *pOther);
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013
void Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator);
void Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator);
#else
+33 -36
View File
@@ -9,7 +9,7 @@
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
@@ -60,17 +60,17 @@ cell_t Native_Hook(IPluginContext *pContext, const cell_t *params)
break;
case HookRet_BadEntForHookType:
{
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[1]);
const char *pClassname = pEnt ? gamehelpers->GetEntityClassname(pEnt) : NULL;
if (!pClassname)
{
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity);
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[1]);
const char *pClassname = pEnt ? gamehelpers->GetEntityClassname(pEnt) : NULL;
if (!pClassname)
{
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity);
}
else
{
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
}
else
{
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
}
break;
}
}
@@ -105,7 +105,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
CBaseEntity *pVictim = gamehelpers->ReferenceToEntity(params[1]);
if (!pVictim)
return pContext->ThrowNativeError("Invalid entity index %d for victim", params[1]);
CBaseEntity *pInflictor = gamehelpers->ReferenceToEntity(params[2]);
if (!pInflictor)
return pContext->ThrowNativeError("Invalid entity index %d for inflictor", params[2]);
@@ -181,7 +181,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition, iDamageCustom);
if (params[0] < 10 || params[9] != 0)
if (params[0] < 10 || params[10] != 0)
{
SH_MCALL(pVictim, OnTakeDamage)((CTakeDamageInfoHack&)info);
}
@@ -191,10 +191,10 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
if (!pCall)
{
int offset;
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
{
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
}
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
{
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
}
PassInfo pass[2];
pass[0].type = PassType_Object;
@@ -231,18 +231,15 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
IGamePlayer *pGamePlayer = playerhelpers->GetGamePlayer(gamehelpers->ReferenceToIndex(params[1]));
if (!pGamePlayer || !pGamePlayer->IsInGame())
return pContext->ThrowNativeError("Client index %d not in game", params[1]);
CBaseEntity *pWeapon = gamehelpers->ReferenceToEntity(params[2]);
if (!pWeapon)
return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);
ServerClass *pClass = gamehelpers->FindEntityServerClass(pWeapon);
if (pClass == nullptr)
{
return pContext->ThrowNativeError("Failed to retrieve entity %d server class!", params[2]);
}
if (!UTIL_ContainsDataTable(pClass->m_pTable, "DT_BaseCombatWeapon"))
IServerUnknown *pUnk = (IServerUnknown *)pWeapon;
IServerNetworkable *pNet = pUnk->GetNetworkable();
if (!UTIL_ContainsDataTable(pNet->GetServerClass()->m_pTable, "DT_BaseCombatWeapon"))
return pContext->ThrowNativeError("Entity index %d is not a weapon", params[2]);
sm_sendprop_info_t spi;
@@ -253,12 +250,9 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
if (params[1] != hndl.GetEntryIndex())
return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]);
Vector vecTarget;
cell_t *addr;
int err;
Vector vecTarget;
Vector *pVecTarget = nullptr;
if ((err = pContext->LocalToPhysAddr(params[3], &addr)) != SP_ERROR_NONE)
{
return pContext->ThrowNativeError("Could not read vecTarget vector");
@@ -270,12 +264,15 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
sp_ctof(addr[0]),
sp_ctof(addr[1]),
sp_ctof(addr[2]));
pVecTarget = &vecTarget;
}
else
{
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon *)pWeapon, NULL, NULL);
return 0;
}
Vector vecVelocity;
Vector *pVecVelocity = nullptr;
if ((err = pContext->LocalToPhysAddr(params[4], &addr)) != SP_ERROR_NONE)
{
return pContext->ThrowNativeError("Could not read vecVelocity vector");
@@ -292,7 +289,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
if (params[0] < 5 || params[5] != 0)
{
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon*)pWeapon, pVecTarget, pVecVelocity);
SH_MCALL(pPlayer, Weapon_Drop)((CBaseCombatWeapon*)pWeapon, &vecTarget, pVecVelocity);
}
else
{
@@ -300,9 +297,9 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
if (!pCall)
{
int offset;
if (!g_pGameConf->GetOffset("Weapon_Drop", &offset))
{
return pContext->ThrowNativeError("Could not find Weapon_Drop offset");
if (!g_pGameConf->GetOffset("Weapon_Drop", &offset))
{
return pContext->ThrowNativeError("Could not find Weapon_Drop offset");
}
PassInfo pass[3];
@@ -319,7 +316,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
pCall = g_pBinTools->CreateVCall(offset, 0, 0, nullptr, pass, 3);
}
pCall->Execute(ArgBuffer<CBaseEntity *, CBaseEntity *, Vector *, Vector *>(pPlayer, pWeapon, pVecTarget, pVecVelocity), nullptr);
pCall->Execute(ArgBuffer<CBaseEntity *, CBaseEntity *, Vector *, Vector *>(pPlayer, pWeapon, &vecTarget, pVecVelocity), nullptr);
}
return 0;
+2 -2
View File
@@ -70,7 +70,7 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
#endif
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2
m_iDamagedOtherPlayers = 0;
m_iPlayerPenetrationCount = 0;
m_flDamageBonus = 0.0f;
@@ -89,7 +89,7 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
m_flRadius = 0.0f;
#endif
#if SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
m_iDamagedOtherPlayers = 0;
m_iObjectsPenetrated = 0;
m_uiBulletID = 0;
+2 -2
View File
@@ -9,7 +9,7 @@
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
@@ -58,7 +58,7 @@
class CTakeDamageInfoHack : public CTakeDamageInfo
{
public:
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0);
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0 );
int GetAttacker() const;
void SetAttacker(CBaseEntity *pAttacker);
inline int GetInflictor() const { return m_hInflictor.IsValid() ? m_hInflictor.GetEntryIndex() : -1; }
+16 -21
View File
@@ -24,40 +24,35 @@ project.sources += [
'hooks.cpp',
'gamerulesnatives.cpp',
'vstringtable.cpp',
'../../public/smsdk_ext.cpp'
'../../public/smsdk_ext.cpp',
'../../public/CDetour/detours.cpp',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
]
for sdk_name in SM.sdks:
sdk = SM.sdks[sdk_name]
if sdk['name'] in ['mock']:
continue
for cxx in builder.targets:
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
if not cxx.target.arch in sdk.platformSpec[cxx.target.platform]:
continue
if sdk_name == 'mock':
continue
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdktools.ext.' + sdk['extension'], sdk)
SM.AddCDetour(binary)
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdktools.ext.' + sdk.ext, sdk)
binary.compiler.cxxincludes += [
os.path.join(sdk.path, 'game', 'shared'),
os.path.join(builder.sourcePath, 'public', 'jit'),
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
]
binary.compiler.defines += ['HAVE_STRING_H'];
if sdk['name'] in ('episode1', 'darkm'):
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'game_shared')]
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'dlls')]
else:
binary.compiler.cxxincludes += [
os.path.join(sdk['path'], 'game', 'shared'),
os.path.join(sdk['path'], 'game', 'server'),
]
#binary.sources += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'server', 'variant_t.cpp')]
binary.compiler.defines += ['HAVE_STRING_H']
if sdk['name'] != 'episode1':
if sdk.name != 'episode1':
binary.compiler.defines += ['HOOKING_ENABLED']
if binary.compiler.behavior == 'gcc':
+3 -3
View File
@@ -108,7 +108,7 @@ extern sp_nativeinfo_t g_ClientNatives[];
static void InitSDKToolsAPI();
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
CDetour *g_WriteBaselinesDetour = NULL;
DETOUR_DECL_MEMBER3(CNetworkStringTableContainer__WriteBaselines, void, char const *, mapName, void *, buffer, int, currentTick)
@@ -209,7 +209,7 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
m_CSGOBadList.add("m_bIsQuestEligible");
#endif
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
g_WriteBaselinesDetour = DETOUR_CREATE_MEMBER(CNetworkStringTableContainer__WriteBaselines, "WriteBaselines");
if (g_WriteBaselinesDetour) {
g_WriteBaselinesDetour->EnableDetour();
@@ -247,7 +247,7 @@ void SDKTools::SDK_OnUnload()
g_RegCalls.clear();
ShutdownHelpers();
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (g_WriteBaselinesDetour) {
g_WriteBaselinesDetour->DisableDetour();
g_WriteBaselinesDetour = NULL;
+1 -2
View File
@@ -61,8 +61,7 @@
#include <itoolentity.h>
#endif
#if SOURCE_ENGINE == SE_ALIENSWARM || SOURCE_ENGINE == SE_PORTAL2 || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI \
|| SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_MCV
#if SOURCE_ENGINE == SE_ALIENSWARM || SOURCE_ENGINE == SE_PORTAL2 || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_CSGO
#define CLIENTVOICE_HOOK_SUPPORT
#else
#include <inetmsghandler.h>
+15 -18
View File
@@ -45,27 +45,26 @@ static CBaseEntity *FindEntityByNetClass(int start, const char *classname)
int maxEntities = gpGlobals->maxEntities;
for (int i = start; i < maxEntities; i++)
{
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i);
if (pEntity == nullptr)
{
edict_t *current = gamehelpers->EdictOfIndex(i);
if (current == NULL || current->IsFree())
continue;
}
ServerClass *pServerClass = gamehelpers->FindEntityServerClass(pEntity);
if (pServerClass == nullptr)
{
IServerNetworkable *network = current->GetNetworkable();
if (network == NULL)
continue;
}
const char *name = pServerClass->GetName();
IHandleEntity *pHandleEnt = network->GetEntityHandle();
if (pHandleEnt == NULL)
continue;
ServerClass *sClass = network->GetServerClass();
const char *name = sClass->GetName();
if (!strcmp(name, classname))
{
return pEntity;
}
return gamehelpers->ReferenceToEntity(gamehelpers->IndexOfEdict(current));
}
return nullptr;
return NULL;
}
static CBaseEntity* GetGameRulesProxyEnt()
@@ -214,8 +213,7 @@ static cell_t GameRules_GetProp(IPluginContext *pContext, const cell_t *params)
// This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_PVKII || SOURCE_ENGINE == SE_MCV
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (pProp->GetFlags() & SPROP_VARINT)
{
bit_count = sizeof(int) * 8;
@@ -289,8 +287,7 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params)
FIND_PROP_SEND(DPT_Int, "integer");
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 \
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_PVKII || SOURCE_ENGINE == SE_MCV
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE
if (pProp->GetFlags() & SPROP_VARINT)
{
bit_count = sizeof(int) * 8;
+7 -5
View File
@@ -52,7 +52,7 @@ static bool PVD_used = false;
SH_DECL_MANUALHOOK2_void(PlayerRunCmdHook, 0, 0, 0, CUserCmd *, IMoveHelper *);
SH_DECL_HOOK2(IBaseFileSystem, FileExists, SH_NOATTRIB, 0, bool, const char*, const char *);
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
SH_DECL_HOOK3(INetChannel, SendFile, SH_NOATTRIB, 0, bool, const char *, unsigned int, bool);
#else
SH_DECL_HOOK2(INetChannel, SendFile, SH_NOATTRIB, 0, bool, const char *, unsigned int);
@@ -65,6 +65,9 @@ SH_DECL_HOOK2_void(INetChannel, ProcessPacket, SH_NOATTRIB, 0, struct netpacket_
SourceHook::CallClass<IBaseFileSystem> *basefilesystemPatch = NULL;
CHookManager::CHookManager()
#if SOURCE_ENGINE == SE_TF2
: replay_enabled("replay_enabled", false)
#endif
{
m_usercmdsPreFwd = NULL;
m_usercmdsFwd = NULL;
@@ -443,8 +446,7 @@ void CHookManager::NetChannelHook(int client)
/* Initial Hook */
#if SOURCE_ENGINE == SE_TF2
ConVarRef replay_enable("replay_enable", false);
if (replay_enable.GetBool())
if (replay_enabled.GetBool())
{
if (!m_bFSTranHookWarned)
{
@@ -538,7 +540,7 @@ void CHookManager::ProcessPacket_Post(struct netpacket_s* packet, bool bHasHeade
RETURN_META(MRES_IGNORED);
}
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
bool CHookManager::SendFile(const char *filename, unsigned int transferID, bool isReplayDemo)
#else
bool CHookManager::SendFile(const char *filename, unsigned int transferID)
@@ -570,7 +572,7 @@ bool CHookManager::SendFile(const char *filename, unsigned int transferID)
if (res != Pl_Continue)
{
/* Mimic the Engine. */
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
pNetChannel->DenyFile(filename, transferID, isReplayDemo);
#else
pNetChannel->DenyFile(filename, transferID);
+4 -1
View File
@@ -56,7 +56,7 @@ public:
void OnMapStart();
public: /* NetChannel/Related Hooks */
bool FileExists(const char *filename, const char *pathID);
#if (SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2)
#if SOURCE_ENGINE >= SE_ALIENSWARM || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
bool SendFile(const char *filename, unsigned int transferID, bool isReplayDemo);
#else
bool SendFile(const char *filename, unsigned int transferID);
@@ -90,6 +90,9 @@ private:
#endif
INetChannel *m_pActiveNetChannel;
bool m_bFSTranHookWarned = false;
#if SOURCE_ENGINE == SE_TF2
ConVarRef replay_enabled;
#endif
};
extern CHookManager g_Hooks;
+1 -1
View File
@@ -73,7 +73,7 @@ bool EntityOutputManager::IsEnabled()
return enabled;
}
#if defined PLATFORM_WINDOWS && defined PLATFORM_X86
#ifdef PLATFORM_WINDOWS
DETOUR_DECL_MEMBER8(FireOutput, void, int, what, int, the, int, hell, int, msvc, void *, variant_t, CBaseEntity *, pActivator, CBaseEntity *, pCaller, float, fDelay)
{
bool fireOutput = g_OutputManager.FireEventDetour((void *)this, pActivator, pCaller, fDelay);
+1
View File
@@ -128,6 +128,7 @@ private:
int HookCount;
patch_t info_restore;
void *info_address;
void *info_callback;
};
+1 -1
View File
@@ -311,7 +311,7 @@ static cell_t FireEntityOutput(IPluginContext *pContext, const cell_t *params)
{
return pContext->ThrowNativeError("\"FireEntityOutput\" not supported by this mod");
}
#if defined PLATFORM_WINDOWS && defined PLATFORM_X86
#ifdef PLATFORM_WINDOWS
int iMaxParam = 8;
//Instead of being one param, MSVC broke variant_t param into 5 params..
PassInfo pass[8];
+11 -11
View File
@@ -50,20 +50,19 @@ void InitTeamNatives()
int edictCount = gpGlobals->maxEntities;
for (int i = 0; i < edictCount; i++)
for (int i=0; i<edictCount; i++)
{
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i);
if (pEntity == nullptr)
edict_t *pEdict = PEntityOfEntIndex(i);
if (!pEdict || pEdict->IsFree())
{
continue;
}
if (!pEdict->GetNetworkable())
{
continue;
}
ServerClass *pClass = gamehelpers->FindEntityServerClass(pEntity);
if (pClass == nullptr)
{
continue;
}
ServerClass *pClass = pEdict->GetNetworkable()->GetServerClass();
if (FindNestedDataTable(pClass->m_pTable, "DT_Team"))
{
SendProp *pTeamNumProp = g_pGameHelpers->FindInSendTable(pClass->GetName(), "m_iTeamNum");
@@ -71,14 +70,15 @@ void InitTeamNatives()
if (pTeamNumProp != NULL)
{
int offset = pTeamNumProp->GetOffset();
int TeamIndex = *(int *)((unsigned char *)pEntity + offset);
CBaseEntity *pEnt = pEdict->GetUnknown()->GetBaseEntity();
int TeamIndex = *(int *)((unsigned char *)pEnt + offset);
if (TeamIndex >= (int)g_Teams.size())
{
g_Teams.resize(TeamIndex+1);
}
g_Teams[TeamIndex].ClassName = pClass->GetName();
g_Teams[TeamIndex].pEnt = pEntity;
g_Teams[TeamIndex].pEnt = pEnt;
}
}
}
+1 -40
View File
@@ -30,7 +30,6 @@
*/
#include "tempents.h"
#include <basehandle.h>
TempEntityManager g_TEManager;
ICallWrapper *g_GetServerClass = NULL;
@@ -184,43 +183,6 @@ bool TempEntityInfo::TE_GetEntData(const char *name, int *value)
return true;
}
bool TempEntityInfo::TE_SetEntDataEnt(const char *name, IHandleEntity *value)
{
/* Search for our offset */
int offset = _FindOffset(name);
if (offset < 0)
{
return false;
}
auto *pHndl = (CBaseHandle *)((uint8_t *)m_Me + offset);
pHndl->Set(value);
return true;
}
bool TempEntityInfo::TE_GetEntDataEnt(const char *name, IHandleEntity **value)
{
/* Search for our offset */
int offset = _FindOffset(name);
if (offset < 0)
{
return false;
}
auto *pHndl = (CBaseHandle *)((uint8_t *)m_Me + offset);
auto *pEnt = reinterpret_cast<IHandleEntity *>(gamehelpers->ReferenceToEntity(pHndl->GetEntryIndex()));
if (!pEnt || *pHndl != pEnt->GetRefEHandle())
return false;
*value = pEnt;
return true;
}
bool TempEntityInfo::TE_SetEntDataFloat(const char *name, float value)
{
/* Search for our offset */
@@ -330,8 +292,7 @@ void TempEntityManager::Initialize()
|| SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS \
|| SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_NUCLEARDAWN \
|| SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_NUCLEARDAWN
if (g_SMAPI->GetServerFactory(false)("VSERVERTOOLS003", nullptr))
{
-2
View File
@@ -47,12 +47,10 @@ public:
ServerClass *GetServerClass();
bool IsValidProp(const char *name);
bool TE_SetEntData(const char *name, int value);
bool TE_SetEntDataEnt(const char *name, IHandleEntity *value);
bool TE_SetEntDataFloat(const char *name, float value);
bool TE_SetEntDataVector(const char *name, float vector[3]);
bool TE_SetEntDataFloatArray(const char *name, cell_t *array, int size);
bool TE_GetEntData(const char *name, int *value);
bool TE_GetEntDataEnt(const char *name, IHandleEntity **value);
bool TE_GetEntDataFloat(const char *name, float *value);
bool TE_GetEntDataVector(const char *name, float vector[3]);
void Send(IRecipientFilter &filter, float delay);
-53
View File
@@ -307,57 +307,6 @@ static cell_t smn_TEReadNum(IPluginContext *pContext, const cell_t *params)
return val;
}
static cell_t smn_TEWriteEnt(IPluginContext *pContext, const cell_t *params)
{
if (!g_TEManager.IsAvailable())
{
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
}
if (!g_CurrentTE)
{
return pContext->ThrowNativeError("No TempEntity call is in progress");
}
char *prop;
pContext->LocalToString(params[1], &prop);
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(params[2]);
if (!pEntity && params[2] != -1)
{
return pContext->ThrowNativeError("Entity %d (%d) is invalid", gamehelpers->ReferenceToIndex(params[2]));
}
if (!g_CurrentTE->TE_SetEntDataEnt(prop, reinterpret_cast<IHandleEntity *>(pEntity)))
{
return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
}
return 1;
}
static cell_t smn_TEReadEnt(IPluginContext *pContext, const cell_t *params)
{
if (!g_TEManager.IsAvailable())
{
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
}
if (!g_CurrentTE)
{
return pContext->ThrowNativeError("No TempEntity call is in progress");
}
char *prop;
IHandleEntity *val;
pContext->LocalToString(params[1], &prop);
if (!g_CurrentTE->TE_GetEntDataEnt(prop, &val))
{
return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
}
return gamehelpers->EntityToBCompatRef(reinterpret_cast<CBaseEntity *>(val));
}
static cell_t smn_TE_WriteFloat(IPluginContext *pContext, const cell_t *params)
{
if (!g_TEManager.IsAvailable())
@@ -598,8 +547,6 @@ sp_nativeinfo_t g_TENatives[] =
{"TE_Start", smn_TEStart},
{"TE_WriteNum", smn_TEWriteNum},
{"TE_ReadNum", smn_TEReadNum},
{"TE_WriteEnt", smn_TEWriteEnt},
{"TE_ReadEnt", smn_TEReadEnt},
{"TE_WriteFloat", smn_TE_WriteFloat},
{"TE_ReadFloat", smn_TE_ReadFloat},
{"TE_WriteVector", smn_TEWriteVector},
+2 -59
View File
@@ -51,7 +51,7 @@ private:
cell_t m_EntRef = INVALID_EHANDLE_INDEX;
};
class CSMTraceFilter : public ITraceFilter
class CSMTraceFilter : public CTraceFilter
{
public:
bool ShouldHitEntity(IHandleEntity *pEntity, int contentsMask)
@@ -74,19 +74,10 @@ public:
m_pFunc = pFunc;
m_Data = data;
}
virtual TraceType_t GetTraceType() const
{
return m_TraceType;
}
void SetTraceType(TraceType_t traceType)
{
m_TraceType = traceType;
}
private:
ExceptionHandler *m_pEh;
IPluginFunction *m_pFunc;
cell_t m_Data;
TraceType_t m_TraceType;
};
class CSMTraceEnumerator : public IPartitionEnumerator
@@ -467,7 +458,6 @@ static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *param
cell_t *startaddr, *endaddr;
IPluginFunction *pFunc;
cell_t data;
TraceType_t traceType;
pFunc = pContext->GetFunctionById(params[5]);
if (!pFunc)
@@ -487,17 +477,6 @@ static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *param
DetectExceptions eh(pContext);
g_SMTraceFilter.SetFunctionPtr(&eh, pFunc, data);
if (params[0] >= 7)
{
traceType = (TraceType_t)params[7];
}
else
{
traceType = TRACE_EVERYTHING;
}
g_SMTraceFilter.SetTraceType(traceType);
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
@@ -534,7 +513,6 @@ static cell_t smn_TRTraceHullFilter(IPluginContext *pContext, const cell_t *para
cell_t data;
IPluginFunction *pFunc;
cell_t *startaddr, *endaddr, *mins, *maxs;
TraceType_t traceType;
pFunc = pContext->GetFunctionById(params[6]);
if (!pFunc)
@@ -547,17 +525,6 @@ static cell_t smn_TRTraceHullFilter(IPluginContext *pContext, const cell_t *para
DetectExceptions eh(pContext);
g_SMTraceFilter.SetFunctionPtr(&eh, pFunc, data);
if (params[0] >= 8)
{
traceType = (TraceType_t)params[8];
}
else
{
traceType = TRACE_EVERYTHING;
}
g_SMTraceFilter.SetTraceType(traceType);
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
pContext->LocalToPhysAddr(params[3], &mins);
@@ -783,7 +750,6 @@ static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *par
IPluginFunction *pFunc;
cell_t *startaddr, *endaddr;
cell_t data;
TraceType_t traceType;
pFunc = pContext->GetFunctionById(params[5]);
if (!pFunc)
@@ -808,17 +774,6 @@ static cell_t smn_TRTraceRayFilterEx(IPluginContext *pContext, const cell_t *par
DetectExceptions eh(pContext);
smfilter.SetFunctionPtr(&eh, pFunc, data);
if (params[0] >= 7)
{
traceType = (TraceType_t)params[7];
}
else
{
traceType = TRACE_EVERYTHING;
}
smfilter.SetTraceType(traceType);
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
@@ -863,7 +818,6 @@ static cell_t smn_TRTraceHullFilterEx(IPluginContext *pContext, const cell_t *pa
IPluginFunction *pFunc;
cell_t *startaddr, *endaddr, *mins, *maxs;
cell_t data;
TraceType_t traceType;
pFunc = pContext->GetFunctionById(params[6]);
if (!pFunc)
@@ -883,17 +837,6 @@ static cell_t smn_TRTraceHullFilterEx(IPluginContext *pContext, const cell_t *pa
DetectExceptions eh(pContext);
smfilter.SetFunctionPtr(&eh, pFunc, data);
if (params[0] >= 8)
{
traceType = (TraceType_t)params[8];
}
else
{
traceType = TRACE_EVERYTHING;
}
smfilter.SetTraceType(traceType);
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
vmins.Init(sp_ctof(mins[0]), sp_ctof(mins[1]), sp_ctof(mins[2]));
@@ -1217,7 +1160,7 @@ static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *par
{
mask = enginetrace->GetPointContents(pos);
} else {
#if (SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_BMS)
#if SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_BMS
mask = enginetrace->GetPointContents(pos, MASK_ALL, &hentity);
#else
mask = enginetrace->GetPointContents(pos, &hentity);
+78 -19
View File
@@ -33,14 +33,7 @@
#include "variant-t.h"
#include <datamap.h>
variant_t g_Variant_t;
// copy this definition as the original file includes cbase.h which explodes in a shower of compile errors
void variant_t::SetEntity( CBaseEntity *val )
{
eVal = val;
fieldType = FIELD_EHANDLE;
}
unsigned char g_Variant_t[SIZEOF_VARIANT_T] = {0};
#define ENTINDEX_TO_CBASEENTITY(ref, buffer) \
buffer = gamehelpers->ReferenceToEntity(ref); \
@@ -49,66 +42,132 @@ void variant_t::SetEntity( CBaseEntity *val )
return pContext->ThrowNativeError("Entity %d (%d) is not a CBaseEntity", gamehelpers->ReferenceToIndex(ref), ref); \
}
/* Hack to init the variant_t object for the first time */
class VariantFirstTimeInit
{
public:
VariantFirstTimeInit()
{
*(unsigned int *)(&g_Variant_t[12]) = INVALID_EHANDLE_INDEX;
}
} g_VariantFirstTimeInit;
static cell_t SetVariantBool(IPluginContext *pContext, const cell_t *params)
{
g_Variant_t.SetBool((params[1]) ? true : false);
unsigned char *vptr = g_Variant_t;
*(bool *)vptr = (params[1]) ? true : false;
vptr += sizeof(int)*3 + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_BOOLEAN;
return 1;
}
static cell_t SetVariantString(IPluginContext *pContext, const cell_t *params)
{
char *str;
unsigned char *vptr = g_Variant_t;
pContext->LocalToString(params[1], &str);
g_Variant_t.SetString(MAKE_STRING(str));
*(string_t *)vptr = MAKE_STRING(str);
vptr += sizeof(int)*3 + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_STRING;
return 1;
}
static cell_t SetVariantInt(IPluginContext *pContext, const cell_t *params)
{
g_Variant_t.SetInt(params[1]);
unsigned char *vptr = g_Variant_t;
*(int *)vptr = params[1];
vptr += sizeof(int)*3 + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_INTEGER;
return 1;
}
static cell_t SetVariantFloat(IPluginContext *pContext, const cell_t *params)
{
g_Variant_t.SetFloat(sp_ctof(params[1]));
unsigned char *vptr = g_Variant_t;
*(float *)vptr = sp_ctof(params[1]);
vptr += sizeof(int)*3 + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_FLOAT;
return 1;
}
static cell_t SetVariantVector3D(IPluginContext *pContext, const cell_t *params)
{
cell_t *val;
unsigned char *vptr = g_Variant_t;
pContext->LocalToPhysAddr(params[1], &val);
Vector v(sp_ctof(val[0]), sp_ctof(val[1]), sp_ctof(val[2]));
g_Variant_t.SetVector3D(v);
*(float *)vptr = sp_ctof(val[0]);
vptr += sizeof(float);
*(float *)vptr = sp_ctof(val[1]);
vptr += sizeof(float);
*(float *)vptr = sp_ctof(val[2]);
vptr += sizeof(float) + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_VECTOR;
return 1;
}
static cell_t SetVariantPosVector3D(IPluginContext *pContext, const cell_t *params)
{
cell_t *val;
unsigned char *vptr = g_Variant_t;
pContext->LocalToPhysAddr(params[1], &val);
Vector v(sp_ctof(val[0]), sp_ctof(val[1]), sp_ctof(val[2]));
g_Variant_t.SetPositionVector3D(v);
*(float *)vptr = sp_ctof(val[0]);
vptr += sizeof(float);
*(float *)vptr = sp_ctof(val[1]);
vptr += sizeof(float);
*(float *)vptr = sp_ctof(val[2]);
vptr += sizeof(float) + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_POSITION_VECTOR;
return 1;
}
static cell_t SetVariantColor(IPluginContext *pContext, const cell_t *params)
{
cell_t *val;
unsigned char *vptr = g_Variant_t;
pContext->LocalToPhysAddr(params[1], &val);
g_Variant_t.SetColor32(val[0], val[1], val[2], val[3]);
*(unsigned char *)vptr = val[0];
vptr += sizeof(unsigned char);
*(unsigned char *)vptr = val[1];
vptr += sizeof(unsigned char);
*(unsigned char *)vptr = val[2];
vptr += sizeof(unsigned char);
*(unsigned char *)vptr = val[3];
vptr += sizeof(unsigned char) + sizeof(int)*2 + sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_COLOR32;
return 1;
}
static cell_t SetVariantEntity(IPluginContext *pContext, const cell_t *params)
{
CBaseEntity *pEntity;
unsigned char *vptr = g_Variant_t;
CBaseHandle bHandle;
ENTINDEX_TO_CBASEENTITY(params[1], pEntity);
g_Variant_t.SetEntity(pEntity);
bHandle = reinterpret_cast<IHandleEntity *>(pEntity)->GetRefEHandle();
vptr += sizeof(int)*3;
*(unsigned long *)vptr = (unsigned long)(bHandle.ToInt());
vptr += sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_EHANDLE;
return 1;
}
@@ -124,4 +183,4 @@ sp_nativeinfo_t g_VariantTNatives[] =
{"SetVariantColor", SetVariantColor},
{"SetVariantEntity", SetVariantEntity},
{NULL, NULL},
};
};
+9 -5
View File
@@ -32,22 +32,26 @@
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_VARIANT_T_H_
#define _INCLUDE_SOURCEMOD_EXTENSION_VARIANT_T_H_
#include "variant_t.h"
#define SIZEOF_VARIANT_T sizeof(variant_t)
#define SIZEOF_VARIANT_T 20
/**
* @file variant-t.h
* @brief SDK Tools extension gamerules natives header.
*/
extern variant_t g_Variant_t;
extern unsigned char g_Variant_t[SIZEOF_VARIANT_T];
extern sp_nativeinfo_t g_VariantTNatives[];
inline void _init_variant_t()
{
memset(&g_Variant_t, 0, sizeof(g_Variant_t));
unsigned char *vptr = g_Variant_t;
*(int *)vptr = 0;
vptr += sizeof(int)*3;
*(unsigned long *)vptr = INVALID_EHANDLE_INDEX;
vptr += sizeof(unsigned long);
*(fieldtype_t *)vptr = FIELD_VOID;
}
#endif //_INCLUDE_SOURCEMOD_EXTENSION_VARIANT_T_H_
+10 -22
View File
@@ -151,9 +151,7 @@ static cell_t PrepSDKCall_SetSignature(IPluginContext *pContext, const cell_t *p
|| SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_INSURGENCY \
|| SOURCE_ENGINE == SE_DOI \
|| SOURCE_ENGINE == SE_CSGO \
|| SOURCE_ENGINE == SE_PVKII \
|| SOURCE_ENGINE == SE_MCV
|| SOURCE_ENGINE == SE_CSGO
s_call_addr = memutils->ResolveSymbol(handle, &sig[1]);
#else
s_call_addr = dlsym(handle, &sig[1]);
@@ -338,25 +336,15 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
}
break;
case ValveCall_Server:
{
if (iserver == NULL)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Server unsupported or not available; file a bug report");
}
*(void **)ptr = iserver;
}
break;
case ValveCall_Engine:
{
if (engine == NULL)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Engine unsupported or not available; file a bug report");
}
*(void **)ptr = engine;
}
break;
{
if (iserver == NULL)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Server unsupported or not available; file a bug report");
}
*(void **)ptr = iserver;
}
break;
case ValveCall_GameRules:
{
void *pGameRules = GameRules();
+12 -18
View File
@@ -396,17 +396,15 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
if (index >= 1 && index <= playerhelpers->GetMaxClients())
{
IGamePlayer *player = playerhelpers->GetGamePlayer(index);
if(!player->IsConnected()) {
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
&& !player->IsConnected())
{
pContext->ThrowNativeError("Client %d is not connected", param);
return Data_Fail;
}
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
} else if (!player->IsInGame()) {
pContext->ThrowNativeError("Client %d is not in game", param);
return Data_Fail;
}
pEntity = gamehelpers->ReferenceToEntity(param);
} else if (param == -1) {
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
@@ -443,17 +441,15 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
if (index >= 1 && index <= playerhelpers->GetMaxClients())
{
IGamePlayer *player = playerhelpers->GetGamePlayer(index);
if(!player->IsConnected()) {
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
&& !player->IsConnected())
{
pContext->ThrowNativeError("Client %d is not connected", param);
return Data_Fail;
}
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
} else if (!player->IsInGame()) {
pContext->ThrowNativeError("Client %d is not in game", param);
return Data_Fail;
}
pEntity = gamehelpers->ReferenceToEntity(param);
} else if (param == -1) {
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
@@ -497,17 +493,15 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
if (param >= 1 && param <= playerhelpers->GetMaxClients())
{
IGamePlayer *player = playerhelpers->GetGamePlayer(param);
if(!player->IsConnected()) {
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
&& !player->IsConnected())
{
pContext->ThrowNativeError("Client %d is not connected", param);
return Data_Fail;
}
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
} else if (!player->IsInGame()) {
pContext->ThrowNativeError("Client %d is not in game", param);
return Data_Fail;
}
pEdict = player->GetEdict();
} else if (param == -1) {
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
-1
View File
@@ -83,7 +83,6 @@ enum ValveCallType
ValveCall_EntityList, /**< Thiscall (CGlobalEntityList implicit first paramater) */
ValveCall_Raw, /**< Thiscall (address explicit first parameter) */
ValveCall_Server, /**< Thiscall (CBaseServer implicit first parameter) */
ValveCall_Engine, /**< Thiscall (CVEngineServer implicit first parameter) */
};
/**
+13 -9
View File
@@ -235,8 +235,7 @@ void GetIServer()
|| SOURCE_ENGINE == SE_BMS \
|| SOURCE_ENGINE == SE_DOI \
|| SOURCE_ENGINE == SE_BLADE \
|| SOURCE_ENGINE == SE_INSURGENCY \
|| SOURCE_ENGINE == SE_PVKII
|| SOURCE_ENGINE == SE_INSURGENCY
#if SOURCE_ENGINE == SE_SDK2013
if (g_SMAPI->GetEngineFactory(false)("VEngineServer022", nullptr))
@@ -321,23 +320,28 @@ void GetResourceEntity()
{
int edictCount = gpGlobals->maxEntities;
for (int i = 0; i < edictCount; i++)
for (int i=0; i<edictCount; i++)
{
CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(i);
if (pEntity == nullptr)
edict_t *pEdict = PEntityOfEntIndex(i);
if (!pEdict || pEdict->IsFree())
{
continue;
}
if (!pEdict->GetNetworkable())
{
continue;
}
ServerClass *pClass = gamehelpers->FindEntityServerClass(pEntity);
if (pClass == nullptr)
IHandleEntity *pHandleEnt = pEdict->GetNetworkable()->GetEntityHandle();
if (!pHandleEnt)
{
continue;
}
ServerClass *pClass = pEdict->GetNetworkable()->GetServerClass();
if (FindNestedDataTable(pClass->m_pTable, "DT_PlayerResource"))
{
g_ResourceEntity = ((IHandleEntity *)pEntity)->GetRefEHandle();
g_ResourceEntity = pHandleEnt->GetRefEHandle();
break;
}
}

Some files were not shown because too many files have changed in this diff Show More