Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction for sourcemod use the new teleportation check gamedata registry from now on. #2235

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions extensions/tf2/teleporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,24 @@

#include "teleporter.h"

CDetour *canPlayerTeleportDetour = NULL;
CDetour *canPlayerBeTeleportedDetour = NULL;

IForward *g_teleportForward = NULL;

class CTFPlayer;

#if defined(__linux__) && defined(__i386__)
class CanPlayerBeTeleportedClass
{
public:
__attribute__((regparm(2))) bool CanPlayerBeTeleported(CTFPlayer * pPlayer);
static __attribute__((regparm(2))) bool (CanPlayerBeTeleportedClass::* CanPlayerBeTeleported_Actual)(CTFPlayer *);
};
__attribute__((regparm(2))) bool (CanPlayerBeTeleportedClass::* CanPlayerBeTeleportedClass::CanPlayerBeTeleported_Actual)(CTFPlayer *) = NULL;
__attribute__((regparm(2))) bool CanPlayerBeTeleportedClass::CanPlayerBeTeleported(CTFPlayer* pPlayer)
#else
DETOUR_DECL_MEMBER1(CanPlayerBeTeleported, bool, CTFPlayer *, pPlayer)
#endif
{
bool origCanTeleport = DETOUR_MEMBER_CALL(CanPlayerBeTeleported)(pPlayer);

Expand Down Expand Up @@ -73,11 +84,11 @@ DETOUR_DECL_MEMBER1(CanPlayerBeTeleported, bool, CTFPlayer *, pPlayer)

bool InitialiseTeleporterDetour()
{
canPlayerTeleportDetour = DETOUR_CREATE_MEMBER(CanPlayerBeTeleported, "CanPlayerTeleport");
canPlayerBeTeleportedDetour = DETOUR_CREATE_MEMBER(CanPlayerBeTeleported, "CanPlayerBeTeleported");

if (canPlayerTeleportDetour != NULL)
if (canPlayerBeTeleportedDetour != NULL)
{
canPlayerTeleportDetour->EnableDetour();
canPlayerBeTeleportedDetour->EnableDetour();
return true;
}

Expand All @@ -88,9 +99,9 @@ bool InitialiseTeleporterDetour()

void RemoveTeleporterDetour()
{
if (canPlayerTeleportDetour != NULL)
if (canPlayerBeTeleportedDetour != NULL)
{
canPlayerTeleportDetour->Destroy();
canPlayerTeleportDetour = NULL;
canPlayerBeTeleportedDetour->Destroy();
canPlayerBeTeleportedDetour = NULL;
}
}
13 changes: 13 additions & 0 deletions gamedata/sm-tf2.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@
"linux" "@_Z21DuelMiniGame_IsInDuelP9CTFPlayer"
"linux64" "@_Z21DuelMiniGame_IsInDuelP9CTFPlayer"
}
"CanPlayerBeTeleported"
{
/* String: "bidirectional_teleport" follow the xref, pick the function that doesn't involve another attribute, follow the graph view after 2 virtual function call, the first subroutine call is CanPlayerTeleport*/
"library" "server"
"windows" "\x55\x8B\xEC\x53\x56\x57\x8B\x7D\x08\x8B\xD9\x85\xFF\x0F\x84\x2A\x2A\x2A\x2A"
"windows64" "\x48\x89\x5C\x24\x08\x48\x89\x74\x24\x10\x57\x48\x83\xEC\x20\x48\x8B\xFA\x48\x8B\xF1\x48\x85\xD2\x0F\x84\x2A\x2A\x2A\x2A\x45\x33\xC0"

// Recent updates altered where the teleport check was called in Linux systems.
"linux" "@_ZN17CObjectTeleporter21PlayerCanBeTeleportedEP9CTFPlayer.part.0"
"linux64" "@_ZN17CObjectTeleporter21PlayerCanBeTeleportedEP9CTFPlayer.part.0"
}

// Obsolete
"CanPlayerTeleport"
{
/* String: "bidirectional_teleport" follow the xref, pick the function that doesn't involve another attribute, follow the graph view after 2 virtual function call, the first subroutine call is CanPlayerTeleport*/
Expand Down
Loading