Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HL] Permanent crosshair #692

Open
Matthaiks opened this issue Mar 3, 2013 · 2 comments
Open

[HL] Permanent crosshair #692

Matthaiks opened this issue Mar 3, 2013 · 2 comments

Comments

@Matthaiks
Copy link

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

DirectX Driver Name:  aticfx32.dll
Driver Version:  9.12.0.0
DirectX Driver Version:  8.17.10.1172
Driver Date: 19 Dec 2012
Desktop Color Depth: 32 bits per pixel
Monitor Refresh Rate: 60 Hz
DirectX Card: ATI Radeon HD 5700 Series
VendorID:  0x1002
DeviceID:  0x68b8
Number of Monitors:  1
Number of Logical Video Cards:  1
No SLI or Crossfire Detected
Primary Display Resolution:  1920 x 1200
Desktop Resolution: 1920 x 1200
Primary Display Size: 26.65" x 16.65"  (31.42" diag)
                                        67.7cm x 42.3cm  (79.8cm diag)
Primary Bus Type Not Detected
Primary VRAM: 1024 MB
Supported MSAA Modes:  2x 4x 8x 

Sound card:
Audio device: Glosniki (ASUS Xonar DS Audio D

Memory:
RAM: 8191 Mb

@ghost ghost self-assigned this Mar 3, 2013
@UCyborg
Copy link

UCyborg commented Mar 3, 2013

This also applies to ammo counter when you wear your HEV suit but have no weapons.

@SamVanheer
Copy link

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:

halflife/dlls/player.cpp

Lines 3949 to 3951 in c7240b9

void CBasePlayer :: UpdateClientData( void )
{
if (m_fInitHUD)

const bool fullHUDInitRequired = m_fInitHUD != FALSE;

if (m_fInitHUD)

Then later in the method:

halflife/dlls/player.cpp

Lines 4164 to 4173 in c7240b9

// 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 );
}
// Cache and client weapon change
m_pClientActiveItem = m_pActiveItem;
m_iClientFOV = m_iFOV;

// 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:

halflife/dlls/player.cpp

Lines 852 to 856 in c7240b9

MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev );
WRITE_BYTE(0);
WRITE_BYTE(0);
WRITE_BYTE(0);
MESSAGE_END();

Since UpdateClientData handles this case now.

The ammo counter issue is tracked at #3063 and has a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants