Raised This Month: $51 Target: $400
 12% 

[TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on clients


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
heavyisgps
Member
Join Date: Aug 2018
Old 02-05-2022 , 18:53   [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on clients
Reply With Quote #1

I've tried to add command listeners for load_itempreset 0,1,2 and 3, but they never fire.

I can't find any serverside commands to override tf_respawn_on_loadoutchanges 0/1 for clients.

Any ideas on how to block or force this?
__________________
Creator of the Hi GPS Balance mod for TF2.

www.higps.no
heavyisgps is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 02-05-2022 , 20:02   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #2

Quote:
Originally Posted by heavyisgps View Post
Any ideas on how to block or force this?
What you posted are client only cvars so you cannot change their values.
You could check their cvar and respond with the code you want. Take a look at this plugin I posted that already does this. https://forums.alliedmods.net/showthread.php?t=334971

Last edited by Sreaper; 02-05-2022 at 23:16.
Sreaper is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 02-05-2022 , 21:58   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #3

The server's CTFPlayer::CheckInstantLoadoutRespawn is responsible for respawning on loadout changes; you can supercede it with a detour.

(The loadout change notification is sent from client → game coordinator → server, so the usual client-server tactics don't apply here.)
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 02-06-2022 at 06:56.
nosoop is offline
throwaway12812391
New Member
Join Date: Sep 2021
Old 04-22-2022 , 21:36   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #4

Quote:
Originally Posted by nosoop View Post
The server's CTFPlayer::CheckInstantLoadoutRespawn is responsible for respawning on loadout changes; you can supercede it with a detour.
Is it possible to change
PHP Code:
if ( !PointInRespawnRoomthisWorldSpaceCenter() ) ) 
to
PHP Code:
if ( !PointInRespawnRoomthisWorldSpaceCenter(), true ) ) 
in CTFPlayer::CheckInstantLoadoutRespawn with a detour to prevent usage in enemy func_respawnroom? I am completely new to DHooks.
throwaway12812391 is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 04-23-2022 , 01:57   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #5

Quote:
Originally Posted by throwaway12812391 View Post
Is it possible to change
PHP Code:
if ( !PointInRespawnRoomthisWorldSpaceCenter() ) ) 
to
PHP Code:
if ( !PointInRespawnRoomthisWorldSpaceCenter(), true ) ) 
in CTFPlayer::CheckInstantLoadoutRespawn with a detour to prevent usage in enemy func_respawnroom? I am completely new to DHooks.
It sounds like you want to patch the function call, specifically one of the params passed to it.

What you can do is detour CTFPlayer::CheckInstantLoadoutRespawn and then patch the function call in pre-hook and restore the original bytes in post-hook. That's only if you want to do it per-player.

If you just want to patch that function call for the server's whole lifespan, then you won't need to detour anything. In that case, you would just need the address of CTFPlayer::CheckInstantLoadoutRespawn and the offset of the "mov" instruction that passes the bool to the PointInRespawnRoom function call.
__________________
Psyk0tik is offline
throwaway12812391
New Member
Join Date: Sep 2021
Old 04-23-2022 , 17:04   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #6

Fixed by the June 21 2022 update.

Quote:
Originally Posted by Psyk0tik View Post
If you just want to patch that function call for the server's whole lifespan, then you won't need to detour anything. In that case, you would just need the address of CTFPlayer::CheckInstantLoadoutRespawn and the offset of the "mov" instruction that passes the bool to the PointInRespawnRoom function call.


Got it working with SourceScramble. My server is on Linux so I did not include Windows signatures. Added @nosoop's findings.
Code:
"Games"
{
    "tf"
    {
        "MemPatches"
        {
            "CTFPlayer::CheckInstantLoadoutRespawn()::SameTeamOnly"
            {
                "signature" "CTFPlayer::CheckInstantLoadoutRespawn()"

                "windows"
                {
                    "offset" "19h"
                    "verify" "\x6A\x00"
                    "patch"  "\x6A\x01"
                }

                "linux"
                {
                    "offset" "33h"
                    "verify" "\xC7\x44\x24\x08"
                    "patch"  "\xC7\x44\x24\x08\x01\x00\x00\x00"
                }
            }
        }

        "Signatures"
        {
            "CTFPlayer::CheckInstantLoadoutRespawn()"
            {
                "library" "server"
                "windows" "\x57\x8B\xF9\x8B\x07\x8B\x80\x04\x01\x00\x00\xFF\xD0\x84\xC0\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07"
                "linux"   "@_ZN9CTFPlayer26CheckInstantLoadoutRespawnEv"
            }
        }
    }
}

Last edited by throwaway12812391; 06-22-2022 at 02:06.
throwaway12812391 is offline
rowedahelicon
Senior Member
Join Date: Feb 2011
Location: The Observatory
Old 04-27-2022 , 09:22   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #7

I don't have anything setup to do memory patching rn but I did investigate this a bit and the information above is correct, I was able to write out a messy patch for it here. https://github.com/rowedahelicon/TF2...ut-Respawn-Fix

There is a better way to do this and I'm sure someone will but if you still want *something* for now, here you go
__________________
SCG, A furry community in the stars - https://www.scg.wtf
rowedahelicon is offline
Send a message via Skype™ to rowedahelicon
nosoop
Veteran Member
Join Date: Aug 2014
Old 04-27-2022 , 11:30   Re: [TF2] Blocking load_itempreset / forcing tf_respawn_on_loadoutchanges 0 on client
Reply With Quote #8

Quote:
Originally Posted by throwaway12812391 View Post
Got it using SourceScramble. My server is on Linux so I did not do Windows signatures.
Minor correction in case others are planning on using this - the patch should be \xC7\x44\x24\x08\x01\x00\x00\x00.

On Windows, CTFPlayer::CheckInstantLoadoutRespawn has a unique signature of \x57\x8B\xF9\x8B\x07\x8B\x80\x04\x01\x00\x00\xFF\xD0\x84\xC0\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07 as of build 7182415, and the offset 19h can be verified as \x6A\x00 and patched to \x6A\x01 to force the parameter to true.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode