Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 25 additions & 29 deletions src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ bool CNEO_Player::RequestSetLoadout(int loadoutNumber)
return false;
}

// XP eligibility first, so ineligible requests fall back to the default
// slot without paying for the validation entity below
if (loadoutNumber+1 > CNEOWeaponLoadout::GetNumberOfLoadoutWeapons(CNEOWeaponLoadout::GetEffectiveXP(m_iXP), iLoadoutClass))
{
DevMsg("Insufficient XP for %s\n", pszWepName);
return RequestSetLoadout(0);
}

EHANDLE pEnt;
pEnt = CreateEntityByName(pszWepName);

Expand Down Expand Up @@ -389,13 +397,6 @@ bool CNEO_Player::RequestSetLoadout(int loadoutNumber)
result = false;
}

if (loadoutNumber+1 > CNEOWeaponLoadout::GetNumberOfLoadoutWeapons(CNEOWeaponLoadout::GetEffectiveXP(m_iXP),
sv_neo_dev_loadout.GetBool() ? NEO_LOADOUT_DEV : classChosen))
{
DevMsg("Insufficient XP for %s\n", pszWepName);
result = RequestSetLoadout(0);
}

if (result)
{
m_iLoadoutWepChoice = loadoutNumber;
Expand Down Expand Up @@ -3570,6 +3571,12 @@ void CNEO_Player::GiveLoadoutWeapon(void)
//DevMsg("Loadout slot: %i (\"%s\") for %s\n", m_iLoadoutWepChoice.Get(), szWep, GetPlayerName());
#endif

// XP eligibility first, so ineligible picks don't pay a weapon entity create/destroy cycle
if (m_iLoadoutWepChoice+1 > CNEOWeaponLoadout::GetNumberOfLoadoutWeapons(CNEOWeaponLoadout::GetEffectiveXP(m_iXP), iLoadoutClass))
{
return;
}

// If I already own this type don't create one
const int wepSubType = 0;
if (Weapon_OwnsThisType(szWep, wepSubType))
Expand All @@ -3593,33 +3600,22 @@ void CNEO_Player::GiveLoadoutWeapon(void)
CNEOBaseCombatWeapon *pNeoWeapon = assert_cast<CNEOBaseCombatWeapon*>((CBaseEntity*)pEnt);
if (pNeoWeapon)
{
if (m_iLoadoutWepChoice+1 <= CNEOWeaponLoadout::GetNumberOfLoadoutWeapons(CNEOWeaponLoadout::GetEffectiveXP(m_iXP),
sv_neo_dev_loadout.GetBool() ? NEO_LOADOUT_DEV : m_iNeoClass.Get()))
{
pNeoWeapon->SetSubType(wepSubType);
pNeoWeapon->SetSubType(wepSubType);

DispatchSpawn(pEnt);
DispatchSpawn(pEnt);

if (pEnt != NULL && !(pEnt->IsMarkedForDeletion()))
if (pEnt != NULL && !(pEnt->IsMarkedForDeletion()))
{
RemoveAllItems(false);
GiveDefaultItems();
if (!BumpWeapon(pNeoWeapon))
{
RemoveAllItems(false);
GiveDefaultItems();
if (!BumpWeapon(pNeoWeapon))
{
UTIL_Remove( pNeoWeapon );
}
else
{
pEnt->Touch( this );
Weapon_Switch(Weapon_OwnsThisType(szWep));
}
UTIL_Remove( pNeoWeapon );
}
}
else
{
if (pEnt != NULL && !(pEnt->IsMarkedForDeletion()))
else
{
UTIL_Remove(pEnt);
pEnt->Touch( this );
Weapon_Switch(Weapon_OwnsThisType(szWep));
}
}
}
Expand Down