Open Matthaiks opened 11 years ago
I can also confirm this on the Mac build
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: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L3066
Add this:
m_bRestored = true;
Then before this code: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L4069-L4097
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: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L4181
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.
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.
25th Anniversary Update
Partially fixed, i.e. it displays as turned off instead of depleted:
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