FixPlayerGravity: Rework ladder checking logic to be more robust
This commit is contained in:
parent
5c21b1c063
commit
1b2d2e48ff
@ -56,23 +56,29 @@ public void OnGameFrame()
|
|||||||
// They're on a ladder, ignore current gravity modifier
|
// They're on a ladder, ignore current gravity modifier
|
||||||
if (!g_bLadder[client])
|
if (!g_bLadder[client])
|
||||||
g_bLadder[client] = true;
|
g_bLadder[client] = true;
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Now that they're off, restore it
|
||||||
|
if (g_bLadder[client])
|
||||||
{
|
{
|
||||||
if (g_bLadder[client])
|
RequestFrame(RestoreGravity, client);
|
||||||
{
|
continue;
|
||||||
// Now that they're off, restore it
|
|
||||||
g_bLadder[client] = false;
|
|
||||||
SetEntityGravity(client, g_flClientGravity[client]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_flClientGravity[client] = GetEntityGravity(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Some maps change sv_gravity while clients already have modified gravity
|
||||||
// So we store the actual calculated gravity to catch such cases
|
// So we store the actual calculated gravity to catch such cases
|
||||||
|
float flClientActualGravity = flClientGravity * flSVGravity;
|
||||||
|
|
||||||
if (flClientActualGravity != g_flClientActualGravity[client])
|
if (flClientActualGravity != g_flClientActualGravity[client])
|
||||||
{
|
{
|
||||||
char szGravity[8];
|
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()
|
public void ResetGravityAll()
|
||||||
{
|
{
|
||||||
char szGravity[8];
|
char szGravity[8];
|
||||||
|
Loading…
Reference in New Issue
Block a user