Skip to content

Add support for TF2's vscript_test branch#1857

Closed
nosoop wants to merge 10 commits intoalliedmodders:masterfrom
nosoop:tf2-vscript-gameconf
Closed

Add support for TF2's vscript_test branch#1857
nosoop wants to merge 10 commits intoalliedmodders:masterfrom
nosoop:tf2-vscript-gameconf

Conversation

@nosoop
Copy link
Contributor

@nosoop nosoop commented Nov 5, 2022

psychonic: If someone submits gamedata that still uses current build as default with overrides by crc for the branch, we could take it

This PR intends to add support for TF2's vscript_test staging branch. This should be current for game version 7682888 (latest as of 2022-11-23).

Since VScripts are likely to be integrated into the game in the future, this also serves as preparation for that change regardless of whether or not the maintainers decide to add support for the branch.

Currently untested and unsure if the syntax is correct. Will review when I'm more awake if nobody confirms this is working.

Do note that Linux servers are not usable at this time as the game itself is missing dependencies. Even stock installations currently fail.

Summary of changes:

  • Account for additions to entity vtables that have shifted entries by up to 4.
  • CTFPlayerShared::m_pOuter was shifted down by 4 bytes, breaking Windows signatures in sm-tf2.games that relied on member offsets. At the moment this is resolved by changing the bytes to match, but we could also wildcard them instead.
  • Account for new location of EntityListeners for SDKHooks.

@nosoop
Copy link
Contributor Author

nosoop commented Nov 5, 2022

Most of the signature breakages are due to shifted member offsets. Could probably mask them out no problem so they work on both branches.

@nosoop
Copy link
Contributor Author

nosoop commented Nov 6, 2022

Looks like SDKHooks is hanging on Windows; will investigate.

@nosoop nosoop marked this pull request as draft November 6, 2022 07:23
@nosoop
Copy link
Contributor Author

nosoop commented Nov 7, 2022

EntityListeners has also changed to 131108. It doesn't look like changing that makes it hang any less, though.

I think it's still hanging on this operation:

entListeners->AddToTail(this);

Stack trace text from WinDbg for reference:

00 008fd0d0 590088f1     sdkhooks_ext_2_tf2!CUtlMemory<IEntityListener *,int>::Grow+0x68 [h:\hl2sdk-tf2\public\tier1\utlmemory.h @ 583] 
01 (Inline) --------     sdkhooks_ext_2_tf2!CUtlVector<IEntityListener *,CUtlMemory<IEntityListener *,int> >::GrowVector+0x17 [h:\hl2sdk-tf2\public\tier1\utlvector.h @ 382] 
02 (Inline) --------     sdkhooks_ext_2_tf2!CUtlVector<IEntityListener *,CUtlMemory<IEntityListener *,int> >::InsertBefore+0x17 [h:\hl2sdk-tf2\public\tier1\utlvector.h @ 546] 
03 008fd0e4 59001a0f     sdkhooks_ext_2_tf2!CUtlVector<IEntityListener *,CUtlMemory<IEntityListener *,int> >::AddToTail+0x21 [h:\hl2sdk-tf2\public\tier1\utlvector.h @ 526] 
04 008fd204 5900ce88     sdkhooks_ext_2_tf2!SDKHooks::SDK_OnLoad+0x1ef [d:\builds\build-sourcemod-msvc12\windows-1.11\build\extensions\sdkhooks\extension.cpp @ 238] 
05 008fd220 59221460     sdkhooks_ext_2_tf2!SDKExtension::OnExtensionLoad+0x268 [d:\builds\build-sourcemod-msvc12\windows-1.11\build\public\smsdk_ext.cpp @ 196] 

@nosoop
Copy link
Contributor Author

nosoop commented Nov 8, 2022

For some reason SDKHooks isn't reading my changes for EntityListeners.

  • Hardcoding the offset makes it load fine.
  • Replacing the offset in sdkhooks.games/common.games.txt makes it load fine.
  • Adding a CRC-specific section below the default section in sdkhooks.games/common.games.txt makes it load fine. Placing it above does not.
  • Adding a CRC-specific section anywhere within sdkhooks.games/engine.ep2v.txt makes it fall back to the default value.

I suspect that the gameconfig parsing just doesn't handle this case well.

@nosoop
Copy link
Contributor Author

nosoop commented Nov 8, 2022

I don't really have the capacity to look into the parsing routine right now to avoid touching common.games.txt, but these should be all the changes required for the new TF2 branch to boot. See separate PR below.

@nosoop nosoop marked this pull request as ready for review November 8, 2022 10:59
nosoop added a commit to nosoop/sourcemod that referenced this pull request Nov 8, 2022
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 alliedmodders#1857.
@Kenzzer
Copy link
Member

Kenzzer commented Nov 24, 2022

Considering the rapid succession of CRC value changes, this is starting to feel like that PR shouldn't land and be marked as a draft at least until tf2's vscript branch becomes 'stable' and/or is merged into main, otherwise this is gonna be a stream of new PRs.

Also this is more of a question towards the repo maintainers but, wouldn't this PR existence be a good argument for a new gamedata config feature that looks up a custom file existence and its optionally its crc as well (I believe the vscript branch has a few files the main one doesn't) ? I'm willing to make a PR for that.

Edit: late thought, but I also realise adding the ability to negate the CRC gamedata condition (i.e if a mismatch then use this gamedata) would allow us to use the server CRC value of main branch, which hasn't changed since this PR was opened. Ofc, this wouldn't solve anything if a given game had multiple active dev branch, but it's already unlikely as it is.

psychonic pushed a commit that referenced this pull request Nov 25, 2022
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.
@nosoop
Copy link
Contributor Author

nosoop commented Nov 26, 2022

Yeah; I don't expect this to get merged upstream since CRCs by nature change after every build, and vscript_test is moving fast. Other more stable heuristics would be nice though.

Regardless, I'll continue maintaining it for community server operators / developers that are planning ahead (as long as the branch doesn't have require an SDK rebuild, anyways — that would require a separate release of SourceMod). Less so with the former because third-party gamedata is unsupported.

@nosoop
Copy link
Contributor Author

nosoop commented Dec 2, 2022

VScript has been merged upstream, so my work here's done. Gamedata merged in 89bd4d7.

Now I have to process the third-party stuff…

@nosoop nosoop closed this Dec 2, 2022
@psychonic
Copy link
Member

Thank you for doing this. While we ended up not merging it while the update was in flux due to the constant CRC updates it was needing, I'm glad that we finally (almost) had a real potential use for this feature. Your gamedata also made it super easy to fix upstream when the update went live.

psychonic pushed a commit that referenced this pull request Dec 2, 2022
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 34c8220)
@nosoop nosoop deleted the tf2-vscript-gameconf branch January 4, 2023 13:30
StarterX4 pushed a commit to StarterX4/sourcemod that referenced this pull request Aug 1, 2023
…dders#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 alliedmodders#1857.

(cherry picked from commit 34c8220)
SparkyCloudy added a commit to SpectralHive/sourcemod that referenced this pull request Feb 20, 2025
* Fix support for SDKCall returning non-networked entity (alliedmodders#1797)

(cherry picked from commit 625c7a9)

* Update SourcePawn on 1.11-dev.

* Revert "Fix use-after-free when creating custom user messages"

This reverts commit 15450a6.

* Revert "Introduce a pbproxy library to solve macOS linker issues."

This reverts commit e5ddbd9.

* Fix build.

* Update SourcePawn.

* Update gamedata for 2022/10/21 CS:GO update (alliedmodders#1842)

* Trigger build for hl2sdk-csgo update

* Correct missed team offsets in CheckRestartRound (alliedmodders#1844)

* Trigger build for hl2sdk-csgo update

* Fix DHooks jit code stack memory alignment (alliedmodders#1849)

* Enable CI on release branches (alliedmodders#1854)

* Add functions for working with entity lumps (alliedmodders#1673)

* entitylump: Fix behavior of append (alliedmodders#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.

* Update TF2 gamedata.

(cherry picked from commit 89bd4d7)

* Ensure gameconfig file uniqueness when reading master.games (alliedmodders#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 alliedmodders#1857.

(cherry picked from commit 34c8220)

* Trigger build against SDK update

* Trigger build for TF2 SDK update

* 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 alliedmodders#1833.

* Add missing null pointer check to protobuf messages (alliedmodders#1883)

(cherry picked from commit ef7d3ab)

* Fix ReadMapList ignoring file's last modified time (alliedmodders#1891)

(cherry picked from commit 0d61792)

* Update TF2 gamedata for version 7757534 (2023-01-05) (alliedmodders#1901)

(cherry picked from commit 27b1817)

* Gamedata update after 2/2/2023 CSGO update (alliedmodders#1921)

* Linux [SDKTOOLS] Sigscan for FireOutput FIX (alliedmodders#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 2dcee81)

* Fix EntityFactoryCaller signature (alliedmodders#1925)

(cherry picked from commit 6e839a9)

* Fix LookupAttachment signature (alliedmodders#1933)

(cherry picked from commit a0eb6a9)

* Enable ShowMenu support for Reactive Drop (see alliedmodders#1938)

Note: Currently only works on beta version of game
(cherry picked from commit 397b70a)

* Fix LookupAttachment signature for NMRiH (alliedmodders#1940)

(cherry picked from commit 693e584)

* Add LookupAttachment signature for ND (alliedmodders#1942)

Adds the LookupAttachment signature for Nuclear Dawn

(cherry picked from commit a9a1939)

* 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.

* feat(ci): release tar gz

---------

Co-authored-by: 42 <[email protected]>
Co-authored-by: David Anderson <[email protected]>
Co-authored-by: Vauff <[email protected]>
Co-authored-by: Nick Hastings <[email protected]>
Co-authored-by: Maxim Telezhenko <[email protected]>
Co-authored-by: Erin Baker <[email protected]>
Co-authored-by: nosoop <[email protected]>
Co-authored-by: zer0.k <[email protected]>
Co-authored-by: clague <[email protected]>
Co-authored-by: GAMMACASE <[email protected]>
Co-authored-by: El Diablo <[email protected]>
Co-authored-by: Poggu <[email protected]>
Co-authored-by: Corey D <[email protected]>
Co-authored-by: Dysphie <[email protected]>
Co-authored-by: data-bomb <[email protected]>
Co-authored-by: BotoX <[email protected]>
Co-authored-by: maxime1907 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants