FixPlayerGravity: Rework ladder checking logic to be more robust

This commit is contained in:
xen 2023-03-07 19:09:31 +02:00
parent 5c21b1c063
commit 1b2d2e48ff

View File

@ -56,23 +56,29 @@ public void OnGameFrame()
// They're on a ladder, ignore current gravity modifier
if (!g_bLadder[client])
g_bLadder[client] = true;
continue;
}
else
// Now that they're off, restore it
if (g_bLadder[client])
{
if (g_bLadder[client])
{
// Now that they're off, restore it
g_bLadder[client] = false;
SetEntityGravity(client, g_flClientGravity[client]);
}
g_flClientGravity[client] = GetEntityGravity(client);
RequestFrame(RestoreGravity, client);
continue;
}
float flClientActualGravity = g_flClientGravity[client] * flSVGravity;
float flClientGravity = GetEntityGravity(client);
// Gamemovement treats 0.0 gravity as 1.0
if (flClientGravity != 0.0)
g_flClientGravity[client] = flClientGravity;
else
flClientGravity = 1.0;
// Some maps change sv_gravity while clients already have modified gravity
// So we store the actual calculated gravity to catch such cases
float flClientActualGravity = flClientGravity * flSVGravity;
if (flClientActualGravity != g_flClientActualGravity[client])
{
char szGravity[8];
@ -84,6 +90,12 @@ public void OnGameFrame()
}
}
public void RestoreGravity(int client)
{
g_bLadder[client] = false;
SetEntityGravity(client, g_flClientGravity[client]);
}
public void ResetGravityAll()
{
char szGravity[8];