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] Flashlight indicator bug #388

Open
Matthaiks opened this issue Feb 19, 2013 · 4 comments
Open

[HL] Flashlight indicator bug #388

Matthaiks opened this issue Feb 19, 2013 · 4 comments

Comments

@Matthaiks
Copy link

Save game with fully recharged and switched off flashlight, quit HL, launch HL, load that saved game and look at the flashlight indicator. It says depleted, but it's recharged if you activate it.

Protocol version 48
Exe version 1.1.2.2/Stdio (valve)
Exe build: 12:05:47 Feb 18 2013 (5961)

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 
@ghost ghost self-assigned this Feb 19, 2013
@jimbond
Copy link

jimbond commented Feb 19, 2013

I can also confirm this on the Mac build

@SamVanheer
Copy link

This happens because the server doesn't update the HUD on save game load.

To fix this UpdateClientData needs to send an update.

Add a member bool m_bRestored; to CBasePlayer.

Then before this code:

return status;

Add this:

m_bRestored = true;

Then before this code:

halflife/dlls/player.cpp

Lines 4069 to 4097 in c7240b9

// Update Flashlight
if ((m_flFlashLightTime) && (m_flFlashLightTime <= gpGlobals->time))
{
if (FlashlightIsOn())
{
if (m_iFlashBattery)
{
m_flFlashLightTime = FLASH_DRAIN_TIME + gpGlobals->time;
m_iFlashBattery--;
if (!m_iFlashBattery)
FlashlightTurnOff();
}
}
else
{
if (m_iFlashBattery < 100)
{
m_flFlashLightTime = FLASH_CHARGE_TIME + gpGlobals->time;
m_iFlashBattery++;
}
else
m_flFlashLightTime = 0;
}
MESSAGE_BEGIN( MSG_ONE, gmsgFlashBattery, NULL, pev );
WRITE_BYTE(m_iFlashBattery);
MESSAGE_END();
}

Add this:

if (m_bRestored)
{
	//Tell client the flashlight is on
	if (FlashlightIsOn())
	{
		MESSAGE_BEGIN(MSG_ONE, gmsgFlashlight, NULL, pev);
		WRITE_BYTE(1);
		WRITE_BYTE(m_iFlashBattery);
		MESSAGE_END();
	}
}

And before this code:

Add this:

//Handled anything that needs resetting
m_bRestored = false;

On save game load the server will tell the client that the flashlight is on. This code is designed so any other data that needs resetting can be done inside an if (m_bRestored) check as well.

@SamVanheer
Copy link

This needs one more thing to work properly in all cases:

if (m_bRestored)
{
	//Always tell client about battery state
	MESSAGE_BEGIN(MSG_ONE, gmsgFlashBattery, NULL, pev);
	WRITE_BYTE(m_iFlashBattery);
	MESSAGE_END();

	//Tell client the flashlight is on
	if (FlashlightIsOn())
	{
		MESSAGE_BEGIN(MSG_ONE, gmsgFlashlight, NULL, pev);
		WRITE_BYTE(1);
		WRITE_BYTE(m_iFlashBattery);
		MESSAGE_END();
	}
}

Otherwise the battery value will be whatever it was before, zero if the game has just been launched.

@Matthaiks
Copy link
Author

25th Anniversary Update

Partially fixed, i.e. it displays as turned off instead of depleted:
c1a1d0000

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