Revert "Have clients select weapons by ID, rather than by name"

This reverts commit 20b66b95fa.
This commit is contained in:
Sam V 2023-11-12 14:29:03 +01:00
parent 9784339cbb
commit d0f31f3200
7 changed files with 36 additions and 63 deletions

View file

@ -372,7 +372,7 @@ void CHudAmmo::Think()
{
if (gpActiveSel != (WEAPON*)1)
{
// ServerCmd(gpActiveSel->szName);
ServerCmd(gpActiveSel->szName);
g_weaponselect = gpActiveSel->iId;
}
@ -445,7 +445,7 @@ void WeaponsResource::SelectSlot(int iSlot, bool fAdvance, int iDirection)
WEAPON* p2 = GetNextActivePos(p->iSlot, p->iSlotPos);
if (!p2)
{ // only one active item in bucket, so change directly to weapon
// ServerCmd(p->szName);
ServerCmd(p->szName);
g_weaponselect = p->iId;
return;
}

View file

@ -258,8 +258,6 @@ bool CBasePlayer::Restore(CRestore& restore) { return false; }
void CBasePlayer::SelectNextItem(int iItem) {}
bool CBasePlayer::HasWeapons() { return false; }
void CBasePlayer::SelectPrevItem(int iItem) {}
void CBasePlayer::SelectItem(const char* pstr) {}
void CBasePlayer::SelectItem(int iId) {}
bool CBasePlayer::FlashlightIsOn() { return false; }
void CBasePlayer::FlashlightTurnOn() {}
void CBasePlayer::FlashlightTurnOff() {}

View file

@ -256,6 +256,39 @@ Vector CBaseEntity::FireBulletsPlayer(unsigned int cShots, Vector vecSrc, Vector
return Vector(x * vecSpread.x, y * vecSpread.y, 0.0);
}
/*
=====================
CBasePlayer::SelectItem
Switch weapons
=====================
*/
void CBasePlayer::SelectItem(const char* pstr)
{
if (!pstr)
return;
CBasePlayerItem* pItem = NULL;
if (!pItem)
return;
if (pItem == m_pActiveItem)
return;
if (m_pActiveItem)
m_pActiveItem->Holster();
m_pLastItem = m_pActiveItem;
m_pActiveItem = pItem;
if (m_pActiveItem)
{
m_pActiveItem->Deploy();
}
}
/*
=====================
CBasePlayer::Killed

View file

@ -1917,12 +1917,6 @@ void CmdStart(const edict_t* player, const struct usercmd_s* cmd, unsigned int r
if (!pl)
return;
if (cmd->weaponselect != 0)
{
pl->SelectItem(cmd->weaponselect);
((usercmd_t*)cmd)->weaponselect = 0;
}
if (pl->pev->groupinfo != 0)
{
UTIL_SetGroupTrace(pl->pev->groupinfo, GROUP_OP_AND);

View file

@ -3106,56 +3106,6 @@ void CBasePlayer::SelectItem(const char* pstr)
}
}
void CBasePlayer::SelectItem(int iId)
{
if (iId <= WEAPON_NONE)
return;
CBasePlayerItem* pItem = NULL;
for (int i = 0; i < MAX_ITEM_TYPES; i++)
{
if (m_rgpPlayerItems[i])
{
pItem = m_rgpPlayerItems[i];
while (pItem)
{
if (pItem->m_iId == iId)
break;
pItem = pItem->m_pNext;
}
}
if (pItem)
break;
}
if (!pItem)
return;
if (pItem == m_pActiveItem)
return;
ResetAutoaim();
// FIX, this needs to queue them up and delay
if (m_pActiveItem)
m_pActiveItem->Holster();
m_pLastItem = m_pActiveItem;
m_pActiveItem = pItem;
if (m_pActiveItem)
{
m_pActiveItem->m_ForceSendAnimations = true;
m_pActiveItem->Deploy();
m_pActiveItem->m_ForceSendAnimations = false;
m_pActiveItem->UpdateItemInfo();
}
}
//==============================================
// HasWeapons - do I have any weapons at all?
//==============================================

View file

@ -288,7 +288,6 @@ public:
void SelectNextItem(int iItem);
void SelectLastItem();
void SelectItem(const char* pstr);
void SelectItem(int iId);
void ItemPreFrame();
void ItemPostFrame();
void GiveNamedItem(const char* szName);

View file

@ -222,8 +222,7 @@ usercmd_t none
DEFINE_DELTA( impact_index, DT_INTEGER, 6, 1.0 ),
DEFINE_DELTA( impact_position[0], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
DEFINE_DELTA( impact_position[1], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
DEFINE_DELTA( impact_position[2], DT_SIGNED | DT_FLOAT, 16, 8.0 ),
DEFINE_DELTA( weaponselect, DT_BYTE, 6, 1.0 )
DEFINE_DELTA( impact_position[2], DT_SIGNED | DT_FLOAT, 16, 8.0 )
}
weapon_data_t none