Skip to content

Commit

Permalink
Revert "Have clients select weapons by ID, rather than by name"
Browse files Browse the repository at this point in the history
This reverts commit 20b66b9.
  • Loading branch information
SamVanheer committed Nov 12, 2023
1 parent 9784339 commit d0f31f3
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 63 deletions.
4 changes: 2 additions & 2 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void CHudAmmo::Think()
{
if (gpActiveSel != (WEAPON*)1)
{
// ServerCmd(gpActiveSel->szName);
ServerCmd(gpActiveSel->szName);
g_weaponselect = gpActiveSel->iId;
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down
33 changes: 33 additions & 0 deletions cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
50 changes: 0 additions & 50 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?
//==============================================
Expand Down
1 change: 0 additions & 1 deletion dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class CBasePlayer : public CBaseMonster
void SelectNextItem(int iItem);
void SelectLastItem();
void SelectItem(const char* pstr);
void SelectItem(int iId);
void ItemPreFrame();
void ItemPostFrame();
void GiveNamedItem(const char* szName);
Expand Down
3 changes: 1 addition & 2 deletions network/delta.lst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d0f31f3

Please sign in to comment.