Add antiping_grenade

This commit is contained in:
def 2013-10-15 18:08:06 +02:00
parent 40569651fb
commit 9f45368225
3 changed files with 26 additions and 27 deletions

View file

@ -98,31 +98,23 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 32, 32);
if (g_Config.m_ClAntiPing)
if (g_Config.m_ClAntiPingGrenade)
{
static int Average_Offset = -1;
static float Offset_Count = 0;
static float Offset_Sum = 0;
// Draw shadows of grenades
bool LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Team != -1;
static float Offset = 1;
Offset = mix(Offset, (float)(Client()->PredGameTick() - Client()->GameTick()), 0.05);
// Calculate average prediction offset, because client_predtick() gets varial values :(((
// Must be there is a normal way to realize it, but I'm too lazy to find it. ^)
if (Average_Offset == -1)
if(LocalPlayerInGame && !m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
{
int Offset = Client()->PredGameTick() - Client()->GameTick();
Offset_Sum += Offset;
Offset_Count++;
// Draw shadow only if grenade directed to local player
CNetObj_CharacterCore& CurChar = m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Cur;
CNetObj_CharacterCore& PrevChar = m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Prev;
vec2 ServerPos = mix(vec2(PrevChar.m_X, PrevChar.m_Y), vec2(CurChar.m_X, CurChar.m_Y), Client()->IntraGameTick());
if (Offset_Count >= 100)
{
Average_Offset = round(Offset_Sum / Offset_Count);
}
}
int PredictedTick = Client()->PrevGameTick() + Average_Offset;
int PredictedTick = Client()->PrevGameTick() + Offset;
float PredictedCt = (PredictedTick - pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + Client()->GameTickTime();
if (PredictedCt >= 0)
{
int shadow_type = pCurrent->m_Type;
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[clamp(shadow_type, 0, NUM_WEAPONS-1)].m_pSpriteProj);

View file

@ -1084,11 +1084,17 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView)
}
MainView.HSplitTop(20.0f, &Button, &MainView);
if(DoButton_CheckBox(&g_Config.m_ClAntiPing, Localize("AntiPing (predict grenades and other players)"), g_Config.m_ClAntiPing, &Button))
if(DoButton_CheckBox(&g_Config.m_ClAntiPing, Localize("AntiPing (predict other players)"), g_Config.m_ClAntiPing, &Button))
{
g_Config.m_ClAntiPing ^= 1;
}
MainView.HSplitTop(20.0f, &Button, &MainView);
if(DoButton_CheckBox(&g_Config.m_ClAntiPingGrenade, Localize("AntiPing (predict grenades)"), g_Config.m_ClAntiPingGrenade, &Button))
{
g_Config.m_ClAntiPingGrenade ^= 1;
}
CUIRect aRects[2];
CUIRect Label;
MainView.HSplitTop(5.0f, 0, &MainView);

View file

@ -7,7 +7,8 @@
// client
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements")
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements")
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements)")
MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict grenades)")
MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates")
MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show name plates disregarding of distance")
MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Use team colors for name plates")