Draft: Fixed: the client's weapon could desync because they selected it too early if it was done using A_SelectWeapon or the SetWeapon ACS function
This addresses ticket #3491 on the tracker.
From my observations, the underlying issue here is that when a client's weapon is changed via A_SelectWeapon
or SetWeapon
(i.e. not by their doing) and depending on their ping, the server will bring up the new weapon much earlier than the client does on their end. Whatever the client starts doing with the new weapon when it brings it up (e.g. firing it or selecting another weapon) doesn't line up with the server. In the case of the example mentioned in the ticket, when the client has the fists selected and chooses the rocket launcher, it actually takes longer for the fists to lower on the server's end than it does on the client's end because the server started bringing them up much earlier than it should've.
To fix this, I made it so that when the client's weapon is changed in this manner, the server will still lower the old weapon like normal, but won't start bring up the new weapon until the client sends a CLC_WEAPONSELECT
command (only when necessary), indicating that the client has started bringing up the new weapon on its end. This ensures that the weapon remains synced on both ends.
Note: The client now uses player_t::bClientSelectedWeapon
, which was previously used only by the server.