dumb tf2 scoreboard pb

This commit is contained in:
rtldg 2021-05-17 11:42:20 +00:00
parent 0f37aac00f
commit 9daafaa7fe
2 changed files with 38 additions and 2 deletions

View File

@ -205,6 +205,12 @@
"windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x8B\x86\x2A\x2A\x2A\x2A\xD1\xE8\xA8\x01" "windows" "\x55\x8B\xEC\x51\x56\x8B\xF1\x8B\x86\x2A\x2A\x2A\x2A\xD1\xE8\xA8\x01"
"linux" "@_ZN11CBaseEntity28PhysicsCheckForEntityUntouchEv" "linux" "@_ZN11CBaseEntity28PhysicsCheckForEntityUntouchEv"
} }
// search string: "scoreboard_minigame"
"CTFGameRules::CalcPlayerScore"
{
"windows" "\x55\x8B\xEC\x56\x8B\x75\x2A\x85\xF6\x75\x2A\x33\xC0\x5E\x5D\xC3\x8B\x56"
"linux" "@_ZN12CTFGameRules15CalcPlayerScoreEP12RoundStats_tP9CTFPlayer"
}
} }
} }
} }

View File

@ -152,6 +152,7 @@ Handle gH_Forwards_OnCheckpointMenuSelect = null;
Handle gH_GetPlayerMaxSpeed = null; Handle gH_GetPlayerMaxSpeed = null;
DynamicHook gH_UpdateStepSound = null; DynamicHook gH_UpdateStepSound = null;
DynamicHook gH_IsSpawnPointValid = null; DynamicHook gH_IsSpawnPointValid = null;
DynamicDetour gH_CalcPlayerScore = null;
// modules // modules
bool gB_Eventqueuefix = false; bool gB_Eventqueuefix = false;
@ -410,6 +411,21 @@ void LoadDHooks()
SetFailState("Couldn't get the offset for \"CGameRules::IsSpawnPointValid\" - make sure your gamedata is updated!"); SetFailState("Couldn't get the offset for \"CGameRules::IsSpawnPointValid\" - make sure your gamedata is updated!");
} }
if (null != (gH_CalcPlayerScore = DHookCreateDetour(Address_Null, CallConv_CDECL, ReturnType_Int, ThisPointer_Ignore)))
{
if (DHookSetFromConf(gH_CalcPlayerScore, hGameData, SDKConf_Signature, "CTFGameRules::CalcPlayerScore"))
{
gH_CalcPlayerScore.AddParam(HookParamType_Int);
gH_CalcPlayerScore.AddParam(HookParamType_CBaseEntity);
gH_CalcPlayerScore.Enable(Hook_Pre, Detour_CalcPlayerScore);
}
else
{
LogError("Couldn't get the address for \"CTFGameRules::CalcPlayerScore\" - make sure your gamedata is updated!");
delete gH_CalcPlayerScore;
}
}
delete hGameData; delete hGameData;
} }
@ -432,6 +448,21 @@ public MRESReturn Hook_IsSpawnPointValid(Handle hReturn, Handle hParams)
return MRES_Ignored; return MRES_Ignored;
} }
MRESReturn Detour_CalcPlayerScore(DHookReturn hReturn, DHookParam hParams)
{
if (!gCV_Scoreboard.BoolValue)
{
return MRES_Ignored;
}
int client = hParams.Get(2);
float fPB = Shavit_GetClientPB(client, 0, Track_Main);
int iScore = (fPB != 0.0 && fPB < 2000)? -RoundToFloor(fPB):-2000;
hReturn.Value = iScore;
return MRES_Supercede;
}
public void OnClientCookiesCached(int client) public void OnClientCookiesCached(int client)
{ {
if(IsFakeClient(client)) if(IsFakeClient(client))
@ -1017,7 +1048,7 @@ public Action Timer_Advertisement(Handle timer)
void UpdateScoreboard(int client) void UpdateScoreboard(int client)
{ {
// this doesn't work on tf2 for some reason // this doesn't work on tf2 probably because of CTFGameRules::CalcPlayerScore
if(gEV_Type == Engine_TF2) if(gEV_Type == Engine_TF2)
{ {
return; return;
@ -1031,7 +1062,6 @@ void UpdateScoreboard(int client)
{ {
CS_SetClientContributionScore(client, iScore); CS_SetClientContributionScore(client, iScore);
} }
else else
{ {
SetEntProp(client, Prop_Data, "m_iFrags", iScore); SetEntProp(client, Prop_Data, "m_iFrags", iScore);