Open SamVanheer opened 3 years ago
Further investigation shows that pev->fov
wasn't referenced in game code in the 1.0 SDK. It was added as part of the prediction upgrade, presumably because parts of the code that now reside in game code were initially added in the engine (where CBasePlayer
can't be accessed from) before being moved to game code to let it take care of updating that stuff (which allows spectator code to work).
Removing all references to pev->fov
and replacing it with m_iFOV
where needed doesn't break anything as far as i can tell, but this would have to be verified before making any changes.
Added an additional line of code required so this fix works when cl_lw
is set to 0.
When saving the game while zoomed in with a weapon and then loading that saved game, the game fails to restore the field of view resulting in the default field of view being used.
In Opposing Force the behavior is slightly different. The crosshair represents the correct field of view because it is dependent on
m_iFOV
fromCBasePlayer
, whereas the actual field of view used to control the zoom level is stored inpev->fov
.pev->fov
isn't saved and restored which leads to this discrepancy.Here's an example:
The first image was taken before loading, the second after loading.
That can be fixed by adding the following lines:
Here: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L3064-L3066
Both variables are supposed to contain the same value at all times so this shouldn't cause any problems.
To fix the crosshair not restoring correctly these lines here need to be commented out: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/cl_dll/hud.cpp#L630-L632
As noted in the function prediction is supposed to handle fov locally, but it doesn't account for restoring non-default fov values.
Opposing Force doesn't have this problem because it has an extra condition in that if check that causes it to only work if the current game is
tfc
, which it would only be if you renamed thegearbox
directory totfc
before running the game.