Open Matthaiks opened 11 years ago
This also applies to ammo counter when you wear your HEV suit but have no weapons.
This happens because the client isn't told when the player has no weapons.
To fix this CBasePlayer::UpdateClientData
needs to tell the ammo hud when there is no weapon selected. This is done as follows.
First add a boolean at the start of this method: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L3949-L3951
const bool fullHUDInitRequired = m_fInitHUD != FALSE;
if (m_fInitHUD)
Then later in the method: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L4164-L4173
// Update all the items
for ( int i = 0; i < MAX_ITEM_TYPES; i++ )
{
if ( m_rgpPlayerItems[i] ) // each item updates it's successors
m_rgpPlayerItems[i]->UpdateClientData( this );
}
//Active item is becoming null, or we're sending all HUD state to client
//Only if we're not in Observer mode, which uses the target player's weapon
if (pev->iuser1 == OBS_NONE && !m_pActiveItem && ((m_pClientActiveItem != m_pActiveItem) || fullHUDInitRequired))
{
//Tell ammo hud that we have no weapon selected
MESSAGE_BEGIN(MSG_ONE, gmsgCurWeapon, NULL, pev);
WRITE_BYTE(0);
WRITE_BYTE(0);
WRITE_BYTE(0);
MESSAGE_END();
}
// Cache and client weapon change
m_pClientActiveItem = m_pActiveItem;
m_iClientFOV = m_iFOV;
This will tell the client the player no longer has any weapon selected if the player's active item is null (weapon just removed) or if the hud is being fully initialized and all state is being updated.
Additionally this code can be removed: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L852-L856
Since UpdateClientData
handles this case now.
The ammo counter issue is tracked at #3063 and has a fix.
Load some save, select a weapon with a crosshair, start a new game. The crosshair is still visible.
http://youtu.be/eT_-c8mgmww
Protocol version 48 Exe version 1.1.2.2/Stdio (valve) Exe build: 11:45:32 Mar 1 2013 (5971)
Processor Information: Vendor: AuthenticAMD Speed: 3214 Mhz 4 logical processors 4 physical processors HyperThreading: Unsupported FCMOV: Supported SSE2: Supported SSE3: Supported SSSE3: Supported SSE4a: Supported SSE41: Unsupported SSE42: Unsupported
Network Information: Network Speed:
Operating System Version: Windows 7 (64 bit) NTFS: Supported Crypto Provider Codes: Supported 311 0x0 0x0 0x0
Video Card: Driver: ATI Radeon HD 5700 Series
Sound card: Audio device: Glosniki (ASUS Xonar DS Audio D
Memory: RAM: 8191 Mb