X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fgame%2Fg_netmsg.pas;h=4c67d12504ef9f21e14efae0f5afffa3d7840049;hb=54de73776fff070d5c24b38ac996cd02e76fca61;hp=55b99b3705acbc0ddbe05e00b04ba3657ea2c9fd;hpb=4204edd3c7df01198a2289af4896be0575fff15c;p=d2df-sdl.git diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 55b99b3..4c67d12 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -383,6 +383,7 @@ var WeapSwitch: Byte; TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte; SwitchEmpty: Byte; + SkipF: Byte; PID: Word; Color: TRGB; I: Integer; @@ -399,10 +400,10 @@ 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 Err := True; end; @@ -459,9 +460,9 @@ begin begin Name := PName; WeapSwitchMode := WeapSwitch; - if (WeapSwitch = 2) then - SetWeaponPrefs(TmpPrefArray); + SetWeaponPrefs(TmpPrefArray); SwitchToEmpty := SwitchEmpty; + SkipFist := SkipF; Reset(True); end; @@ -554,6 +555,14 @@ end; procedure MH_RECV_FullStateRequest(C: pTNetClient; var M: TMsg); begin //e_LogWritefln('*** client #%u (cid #%u) full state request', [C.ID, C.Player]); + + if C^.FullUpdateSent then + begin + // FullStateRequest spam? + g_Net_Penalize(C, 'duplicate full state request'); + exit; + end; + if gGameOn then begin MH_SEND_Everything((C^.State = NET_STATE_AUTH), C^.ID) @@ -715,6 +724,7 @@ var TmpWeapSwitch: Byte; TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte; TmpSwEmpty: Byte; + TmpSkipF: Byte; I: Integer; Pl: TPlayer; Err: Boolean; @@ -728,10 +738,10 @@ 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 Err := True; end; @@ -758,11 +768,13 @@ 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; + + if (TmpSkipF <> Pl.SkipFist) then + Pl.SkipFist := TmpSkipF; + MH_SEND_PlayerSettings(Pl.UID, TmpModel); end; @@ -890,11 +902,14 @@ procedure MH_SEND_Everything(CreatePlayers: Boolean {= False}; ID: Integer {= NE var I: Integer; begin - if (ID >= 0) and (ID < length(NetClients)) then - begin - e_LogWritefln('*** client #%u (cid #%u) will get everything', [ID, NetClients[ID].Player]); - MH_ProcessFirstSpawn(@NetClients[ID]); - end; + if (ID < 0) or (ID >= Length(NetClients)) then + exit; // bogus client, this shouldn't happen + + NetClients[ID].FullUpdateSent := True; + + e_LogWritefln('*** client #%u (cid #%u) will get everything', [ID, NetClients[ID].Player]); + + MH_ProcessFirstSpawn(@NetClients[ID]); if gPlayers <> nil then begin @@ -2676,7 +2691,6 @@ var TmpModel: string; TmpColor: TRGB; TmpTeam: Byte; - i: Integer; Pl: TPlayer; PID: Word; begin @@ -3155,10 +3169,10 @@ 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); g_Net_Client_Send(True, NET_CHAN_SERVICE); end; @@ -3308,10 +3322,11 @@ 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); + g_Net_Client_Send(True, NET_CHAN_IMPORTANT); end;