mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Remove unused m_FreezeTime == -1
state
Reduces code complexity. Both `g_Config.m_SvFreezeDelay`[[1]] and `GetSwitchDelay(int Index)`[[2]] can only return non-negative numbers, therefore this is currently dead code and can be removed. The last time it was possible to pass a negative number was removed in561ce64666 (diff-29ffe32916052e1066eed938021aadfeb29f855d7c63d9c1ca3350aceffb79f3L1624)
[1]:c8ea372d98/src/engine/shared/config_variables.h (L213)
[2]:c8ea372d98/src/game/mapitems.h (L467)
This commit is contained in:
parent
c7192d703e
commit
e4157a744b
|
@ -489,7 +489,7 @@ void CCharacter::GiveNinja()
|
|||
{
|
||||
m_Core.m_Ninja.m_ActivationTick = GameWorld()->GameTick();
|
||||
m_Core.m_aWeapons[WEAPON_NINJA].m_Got = true;
|
||||
if(!m_FreezeTime)
|
||||
if(m_FreezeTime > 0)
|
||||
m_Core.m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
|
||||
if(m_Core.m_ActiveWeapon != WEAPON_NINJA)
|
||||
m_LastWeapon = m_Core.m_ActiveWeapon;
|
||||
|
@ -952,12 +952,9 @@ void CCharacter::DDRaceTick()
|
|||
m_Input.m_Jump = 0;
|
||||
//Hook and weapons are possible in live freeze
|
||||
}
|
||||
if(m_FreezeTime > 0 || m_FreezeTime == -1)
|
||||
{
|
||||
if(m_FreezeTime > 0)
|
||||
{
|
||||
m_FreezeTime--;
|
||||
else
|
||||
m_Core.m_Ninja.m_ActivationTick = GameWorld()->GameTick();
|
||||
if(!m_CanMoveInFreeze)
|
||||
{
|
||||
m_Input.m_Direction = 0;
|
||||
|
@ -1046,11 +1043,11 @@ bool CCharacter::Freeze(int Seconds)
|
|||
{
|
||||
if(!GameWorld()->m_WorldConfig.m_PredictFreeze)
|
||||
return false;
|
||||
if((Seconds <= 0 || m_Core.m_Super || m_FreezeTime == -1 || m_FreezeTime > Seconds * GameWorld()->GameTickSpeed()) && Seconds != -1)
|
||||
if(Seconds <= 0 || m_Core.m_Super || m_FreezeTime > Seconds * GameWorld()->GameTickSpeed())
|
||||
return false;
|
||||
if(m_Core.m_FreezeStart < GameWorld()->GameTick() - GameWorld()->GameTickSpeed() || Seconds == -1)
|
||||
if(m_Core.m_FreezeStart < GameWorld()->GameTick() - GameWorld()->GameTickSpeed())
|
||||
{
|
||||
m_FreezeTime = Seconds == -1 ? Seconds : Seconds * GameWorld()->GameTickSpeed();
|
||||
m_FreezeTime = Seconds * GameWorld()->GameTickSpeed();
|
||||
m_Core.m_FreezeStart = GameWorld()->GameTick();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -976,12 +976,12 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
|
|||
}
|
||||
|
||||
// change eyes and use ninja graphic if player is frozen
|
||||
if(m_Core.m_DeepFrozen || m_FreezeTime > 0 || m_FreezeTime == -1 || m_Core.m_LiveFrozen)
|
||||
if(m_Core.m_DeepFrozen || m_FreezeTime > 0 || m_Core.m_LiveFrozen)
|
||||
{
|
||||
if(Emote == EMOTE_NORMAL)
|
||||
Emote = (m_Core.m_DeepFrozen || m_Core.m_LiveFrozen) ? EMOTE_PAIN : EMOTE_BLINK;
|
||||
|
||||
if((m_Core.m_DeepFrozen || m_FreezeTime > 0 || m_FreezeTime == -1) && SnappingClientVersion < VERSION_DDNET_NEW_HUD)
|
||||
if((m_Core.m_DeepFrozen || m_FreezeTime > 0) && SnappingClientVersion < VERSION_DDNET_NEW_HUD)
|
||||
Weapon = WEAPON_NINJA;
|
||||
}
|
||||
|
||||
|
@ -1008,8 +1008,7 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
|
|||
}
|
||||
|
||||
// change eyes, use ninja graphic and set ammo count if player has ninjajetpack
|
||||
if(m_pPlayer->m_NinjaJetpack && m_Core.m_Jetpack && m_Core.m_ActiveWeapon == WEAPON_GUN && !m_Core.m_DeepFrozen &&
|
||||
!(m_FreezeTime > 0 || m_FreezeTime == -1) && !m_Core.m_HasTelegunGun)
|
||||
if(m_pPlayer->m_NinjaJetpack && m_Core.m_Jetpack && m_Core.m_ActiveWeapon == WEAPON_GUN && !m_Core.m_DeepFrozen && m_FreezeTime == 0 && !m_Core.m_HasTelegunGun)
|
||||
{
|
||||
if(Emote == EMOTE_NORMAL)
|
||||
Emote = EMOTE_HAPPY;
|
||||
|
@ -1023,12 +1022,12 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
|
|||
Health = m_Health;
|
||||
Armor = m_Armor;
|
||||
if(m_Core.m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0)
|
||||
AmmoCount = (!m_FreezeTime) ? m_Core.m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo : 0;
|
||||
AmmoCount = (m_FreezeTime > 0) ? m_Core.m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo : 0;
|
||||
}
|
||||
|
||||
if(GetPlayer()->IsAfk() || GetPlayer()->IsPaused())
|
||||
{
|
||||
if(m_FreezeTime > 0 || m_FreezeTime == -1 || m_Core.m_DeepFrozen || m_Core.m_LiveFrozen)
|
||||
if(m_FreezeTime > 0 || m_Core.m_DeepFrozen || m_Core.m_LiveFrozen)
|
||||
Emote = EMOTE_NORMAL;
|
||||
else
|
||||
Emote = EMOTE_BLINK;
|
||||
|
@ -1084,7 +1083,7 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
|
|||
pCharacter->m_Weapon = Weapon;
|
||||
pCharacter->m_AmmoCount = AmmoCount;
|
||||
|
||||
if(m_FreezeTime > 0 || m_FreezeTime == -1 || m_Core.m_DeepFrozen)
|
||||
if(m_FreezeTime > 0 || m_Core.m_DeepFrozen)
|
||||
pCharacter->m_AmmoCount = m_Core.m_FreezeStart + g_Config.m_SvFreezeDelay * Server()->TickSpeed();
|
||||
else if(Weapon == WEAPON_NINJA)
|
||||
pCharacter->m_AmmoCount = m_Core.m_Ninja.m_ActivationTick + g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000;
|
||||
|
@ -1999,7 +1998,7 @@ void CCharacter::SetRescue()
|
|||
void CCharacter::DDRaceTick()
|
||||
{
|
||||
mem_copy(&m_Input, &m_SavedInput, sizeof(m_Input));
|
||||
m_Armor = (m_FreezeTime >= 0) ? clamp(10 - (m_FreezeTime / 15), 0, 10) : 0;
|
||||
m_Armor = clamp(10 - (m_FreezeTime / 15), 0, 10);
|
||||
if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0)
|
||||
m_LastMove = Server()->Tick();
|
||||
|
||||
|
@ -2009,16 +2008,13 @@ void CCharacter::DDRaceTick()
|
|||
m_Input.m_Jump = 0;
|
||||
// Hook is possible in live freeze
|
||||
}
|
||||
if(m_FreezeTime > 0 || m_FreezeTime == -1)
|
||||
if(m_FreezeTime > 0)
|
||||
{
|
||||
if(m_FreezeTime % Server()->TickSpeed() == Server()->TickSpeed() - 1 || m_FreezeTime == -1)
|
||||
if(m_FreezeTime % Server()->TickSpeed() == Server()->TickSpeed() - 1)
|
||||
{
|
||||
GameServer()->CreateDamageInd(m_Pos, 0, (m_FreezeTime + 1) / Server()->TickSpeed(), TeamMask() & GameServer()->ClientsMaskExcludeClientVersionAndHigher(VERSION_DDNET_NEW_HUD));
|
||||
}
|
||||
if(m_FreezeTime > 0)
|
||||
m_FreezeTime--;
|
||||
else
|
||||
m_Core.m_Ninja.m_ActivationTick = Server()->Tick();
|
||||
m_Input.m_Direction = 0;
|
||||
m_Input.m_Jump = 0;
|
||||
m_Input.m_Hook = 0;
|
||||
|
@ -2137,12 +2133,12 @@ void CCharacter::DDRacePostCoreTick()
|
|||
|
||||
bool CCharacter::Freeze(int Seconds)
|
||||
{
|
||||
if((Seconds <= 0 || m_Core.m_Super || m_FreezeTime == -1 || m_FreezeTime > Seconds * Server()->TickSpeed()) && Seconds != -1)
|
||||
if(Seconds <= 0 || m_Core.m_Super || m_FreezeTime > Seconds * Server()->TickSpeed())
|
||||
return false;
|
||||
if(m_Core.m_FreezeStart < Server()->Tick() - Server()->TickSpeed() || Seconds == -1)
|
||||
if(m_Core.m_FreezeStart < Server()->Tick() - Server()->TickSpeed())
|
||||
{
|
||||
m_Armor = 0;
|
||||
m_FreezeTime = Seconds == -1 ? Seconds : Seconds * Server()->TickSpeed();
|
||||
m_FreezeTime = Seconds * Server()->TickSpeed();
|
||||
m_Core.m_FreezeStart = Server()->Tick();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue