From 1eb8b9c599c59d9cdb36f68bb1ca176b86a0dc80 Mon Sep 17 00:00:00 2001 From: travi$ Date: Sun, 27 Mar 2022 12:32:28 +0300 Subject: [PATCH] Fix preferences sync --- src/game/g_menu.pas | 12 +++++++----- src/game/g_netmsg.pas | 27 ++++++++++----------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 6f35168..c6910e7 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -407,8 +407,7 @@ begin if gPlayer1.Team <> gPlayer1Settings.Team then gPlayer1.SwitchTeam; gPlayer1.WeapSwitchMode := gPlayer1Settings.WeaponSwitch; - if (gPlayer1.WeapSwitchMode = 2) then - gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences); + gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences); gPlayer1.SwitchToEmpty := gPlayer1Settings.SwitchToEmpty; gPlayer1.SkipFist := gPlayer1Settings.SkipFist; if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID); @@ -424,14 +423,17 @@ begin if gPlayer2.Team <> gPlayer2Settings.Team then gPlayer2.SwitchTeam; gPlayer2.WeapSwitchMode := gPlayer2Settings.WeaponSwitch; - if (gPlayer2.WeapSwitchMode = 2) then - gPlayer2.setWeaponPrefs(gPlayer2Settings.WeaponPreferences); + gPlayer2.setWeaponPrefs(gPlayer2Settings.WeaponPreferences); gPlayer2.SwitchToEmpty := gPlayer2Settings.SwitchToEmpty; gPlayer2.SkipFist := gPlayer2Settings.SkipFist; end; end; - if g_Game_IsClient then MC_SEND_PlayerSettings; + if g_Game_IsClient then + begin + MC_SEND_PlayerSettings; + gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences); + end; g_Console_WriteGameConfig; end; diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 910a480..8b42846 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -400,9 +400,8 @@ begin B := M.ReadByte(); T := M.ReadByte(); WeapSwitch := M.ReadByte(); - if (WeapSwitch = 2) then - for I := WP_FIRST to WP_LAST + 1 do - TmpPrefArray[I] := M.ReadByte(); + for I := WP_FIRST to WP_LAST + 1 do + TmpPrefArray[I] := M.ReadByte(); SwitchEmpty := M.ReadByte(); SkipF := M.ReadByte(); except @@ -461,8 +460,7 @@ begin begin Name := PName; WeapSwitchMode := WeapSwitch; - if (WeapSwitch = 2) then - SetWeaponPrefs(TmpPrefArray); + SetWeaponPrefs(TmpPrefArray); SwitchToEmpty := SwitchEmpty; SkipFist := SkipF; Reset(True); @@ -732,9 +730,8 @@ begin TmpColor.B := M.ReadByte(); TmpTeam := M.ReadByte(); TmpWeapSwitch := M.ReadByte(); - if (TmpWeapSwitch = 2) then - for I := WP_FIRST to WP_LAST + 1 do - TmpPrefArray[I] := M.ReadByte(); + for I := WP_FIRST to WP_LAST + 1 do + TmpPrefArray[I] := M.ReadByte(); TmpSwEmpty := M.ReadByte(); TmpSkipF := M.ReadByte(); except @@ -763,9 +760,7 @@ begin if (TmpWeapSwitch <> Pl.WeapSwitchMode) then Pl.WeapSwitchMode := TmpWeapSwitch; - if (TmpWeapSwitch = 2) then - Pl.SetWeaponPrefs(TmpPrefArray); - + Pl.SetWeaponPrefs(TmpPrefArray); if (TmpSwEmpty <> Pl.SwitchToEmpty) then Pl.SwitchToEmpty := TmpSwEmpty; @@ -3164,9 +3159,8 @@ begin NetOut.Write(gPlayer1Settings.Color.B); NetOut.Write(gPlayer1Settings.Team); NetOut.Write(gPlayer1Settings.WeaponSwitch); - if (gPlayer1Settings.WeaponSwitch = 2) then - for i := WP_FIRST to WP_LAST + 1 do - NetOut.Write(gPlayer1Settings.WeaponPreferences[i]); + for i := WP_FIRST to WP_LAST + 1 do + NetOut.Write(gPlayer1Settings.WeaponPreferences[i]); NetOut.Write(gPlayer1Settings.SwitchToEmpty); NetOut.Write(gPlayer1Settings.SkipFist); @@ -3318,9 +3312,8 @@ begin NetOut.Write(gPlayer1Settings.Color.B); NetOut.Write(gPlayer1Settings.Team); NetOut.Write(gPlayer1Settings.WeaponSwitch); - if (gPlayer1Settings.WeaponSwitch = 2) then - for i := WP_FIRST to WP_LAST + 1 do - NetOut.Write(gPlayer1Settings.WeaponPreferences[i]); + for i := WP_FIRST to WP_LAST + 1 do + NetOut.Write(gPlayer1Settings.WeaponPreferences[i]); NetOut.Write(gPlayer1Settings.SwitchToEmpty); NetOut.Write(gPlayer1Settings.SkipFist); -- 2.29.2