Skip to content

Commit

Permalink
Refactor CInfClassHuman::OnCharacterSnap
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Dec 2, 2023
1 parent 33d01c4 commit d12eb21
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/game/server/infclass/classes/humans/human.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,32 +497,39 @@ void CInfClassHuman::OnCharacterSnap(int SnappingClient)

if(SnappingClient != m_pPlayer->GetCID())
{
if(m_pCharacter->GetArmor() < 10)
const CInfClassPlayer *pDestClient = GameController()->GetPlayer(SnappingClient);
if(pDestClient && pDestClient->GetCharacter())
{
const CInfClassPlayer *pDestClient = GameController()->GetPlayer(SnappingClient);
if(pDestClient && pDestClient->GetCharacter() && pDestClient->GetClass() == PLAYERCLASS_MEDIC)
switch(pDestClient->GetClass())
{
if(GetPlayerClass() == PLAYERCLASS_HERO)
case PLAYERCLASS_MEDIC:
if(m_pCharacter->GetArmor() < 10)
{
if(pDestClient->GetCharacter()->GetActiveWeapon() != WEAPON_GRENADE)
if(GetPlayerClass() == PLAYERCLASS_HERO)
{
return;
if(pDestClient->GetCharacter()->GetActiveWeapon() != WEAPON_GRENADE)
{
return;
}
}
}

CNetObj_Pickup *pP = Server()->SnapNewItem<CNetObj_Pickup>(m_pCharacter->GetHeartID());
if(!pP)
return;
CNetObj_Pickup *pP = Server()->SnapNewItem<CNetObj_Pickup>(m_pCharacter->GetHeartID());
if(!pP)
return;

const vec2 Pos = m_pCharacter->GetPos();
pP->m_X = Pos.x;
pP->m_Y = Pos.y - 60.0;
const vec2 Pos = m_pCharacter->GetPos();
pP->m_X = Pos.x;
pP->m_Y = Pos.y - 60.0;

if(m_pCharacter->GetHealth() < 10 && m_pCharacter->GetArmor() == 0)
pP->m_Type = POWERUP_HEALTH;
else
pP->m_Type = POWERUP_ARMOR;
pP->m_Subtype = 0;
if(m_pCharacter->GetHealth() < 10 && m_pCharacter->GetArmor() == 0)
pP->m_Type = POWERUP_HEALTH;
else
pP->m_Type = POWERUP_ARMOR;
pP->m_Subtype = 0;
break;
}
default:
break;
}
}
}
Expand Down

0 comments on commit d12eb21

Please sign in to comment.