X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_netmsg.pas;h=e41eafed8acafacaad3e23967d10eaf806db723d;hb=e280ede742f9a07b2810feec6c3c70a4f4fcadc3;hp=b7a0fdd903cc0fa4c4a1e6bae0f2a2ec333fc8f2;hpb=88999196d89648a7ba4f6367e2a882e0d56bc5b5;p=d2df-sdl.git diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index b7a0fdd..e41eafe 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -380,6 +380,10 @@ procedure MH_RECV_Info(C: pTNetClient; var M: TMsg); var Ver, PName, Model, Pw: string; R, G, B, T: Byte; + WeapSwitch: Byte; + TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte; + SwitchEmpty: Byte; + SkipF: Byte; PID: Word; Color: TRGB; I: Integer; @@ -395,6 +399,11 @@ begin G := M.ReadByte(); B := M.ReadByte(); T := M.ReadByte(); + WeapSwitch := 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; @@ -450,6 +459,12 @@ begin with g_Player_Get(PID) do begin Name := PName; + WeapSwitchMode := WeapSwitch; + SetWeaponPrefs(TmpPrefArray); + SwitchToEmpty := SwitchEmpty; + SkipFist := SkipF; + if (g_Force_Model_Get() <> 0) then + SetModel(g_Forced_Model_GetName()); Reset(True); end; @@ -542,6 +557,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) @@ -700,6 +723,11 @@ var TmpModel: string; TmpColor: TRGB; TmpTeam: Byte; + TmpWeapSwitch: Byte; + TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte; + TmpSwEmpty: Byte; + TmpSkipF: Byte; + I: Integer; Pl: TPlayer; Err: Boolean; begin @@ -711,6 +739,11 @@ begin TmpColor.G := M.ReadByte(); TmpColor.B := M.ReadByte(); TmpTeam := M.ReadByte(); + TmpWeapSwitch := 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; @@ -731,9 +764,21 @@ begin Pl.Name := TmpName; end; + if (g_Force_Model_Get() <> 0) then + TmpModel := g_Forced_Model_GetName(); if TmpModel <> Pl.Model.Name then Pl.SetModel(TmpModel); + if (TmpWeapSwitch <> Pl.WeapSwitchMode) then + Pl.WeapSwitchMode := TmpWeapSwitch; + + 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; @@ -861,11 +906,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 @@ -938,7 +986,7 @@ begin NetOut.Write(g_ExtractFileName(gMapInfo.Map)); NetOut.Write(gWADHash); NetOut.Write(gGameSettings.GameMode); - NetOut.Write(gGameSettings.GoalLimit); + NetOut.Write(gGameSettings.ScoreLimit); NetOut.Write(gGameSettings.TimeLimit); NetOut.Write(gGameSettings.MaxLives); NetOut.Write(gGameSettings.Options); @@ -1092,8 +1140,8 @@ begin NetOut.Write(Byte(NET_MSG_SCORE)); if gGameSettings.GameMode in [GM_TDM, GM_CTF] then begin - NetOut.Write(gTeamStat[TEAM_RED].Goals); - NetOut.Write(gTeamStat[TEAM_BLUE].Goals); + NetOut.Write(gTeamStat[TEAM_RED].Score); + NetOut.Write(gTeamStat[TEAM_BLUE].Score); end else if gGameSettings.GameMode = GM_COOP then @@ -1168,7 +1216,7 @@ procedure MH_SEND_GameSettings(ID: Integer = NET_EVERYONE); begin NetOut.Write(Byte(NET_MSG_GSET)); NetOut.Write(gGameSettings.GameMode); - NetOut.Write(gGameSettings.GoalLimit); + NetOut.Write(gGameSettings.ScoreLimit); NetOut.Write(gGameSettings.TimeLimit); NetOut.Write(gGameSettings.MaxLives); NetOut.Write(gGameSettings.Options); @@ -1855,8 +1903,8 @@ procedure MC_RECV_GameStats(var M: TMsg); begin if gGameSettings.GameMode in [GM_TDM, GM_CTF] then begin - gTeamStat[TEAM_RED].Goals := M.ReadSmallInt(); - gTeamStat[TEAM_BLUE].Goals := M.ReadSmallInt(); + gTeamStat[TEAM_RED].Score := M.ReadSmallInt(); + gTeamStat[TEAM_BLUE].Score := M.ReadSmallInt(); end else if gGameSettings.GameMode = GM_COOP then @@ -2321,7 +2369,7 @@ end; procedure MC_RECV_GameSettings(var M: TMsg); begin gGameSettings.GameMode := M.ReadByte(); - gGameSettings.GoalLimit := M.ReadWord(); + gGameSettings.ScoreLimit := M.ReadWord(); gGameSettings.TimeLimit := M.ReadWord(); gGameSettings.MaxLives := M.ReadByte(); gGameSettings.Options := M.ReadLongWord(); @@ -2351,6 +2399,8 @@ begin if (PID <> NetPlrUID1) and (PID <> NetPlrUID2) then begin if (Pl <> nil) then Exit; + if (g_Force_Model_Get() <> 0) then + Model := g_Forced_Model_GetName(); DID := g_Player_Create(Model, Color, T, False); with g_Player_Get(DID) do begin @@ -2447,7 +2497,6 @@ var PID: Word; Pl: TPlayer; I, OldFire: Integer; - checkWeapon: Boolean; OldJet, Flam: Boolean; NewTeam: Byte; begin @@ -2469,28 +2518,8 @@ begin NewTeam := M.ReadByte(); for I := WP_FIRST to WP_LAST do - begin - checkWeapon := (M.ReadByte() <> 0); - if ( (gPlayer1Settings.WeaponSwitch = 0) and (gPlayer2Settings.WeaponSwitch = 0) ) or ( (I = WEAPON_KASTET) or (I = WEAPON_PISTOL) or (checkWeapon = False) or (FWeapon[I] = True) ) then - FWeapon[I] := checkWeapon - else - begin - if ((PID = gPlayer1.UID) and (gPlayer1Settings.WeaponSwitch <> 0)) or ( (gPlayer2 <> nil) and (PID = gPlayer2.UID) and (gPlayer2Settings.WeaponSwitch <> 0) ) then - begin - FWeapon[I] := True; - if (PID = gPlayer1.UID) then - if (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) and (gPlayer1Settings.WeaponPreferences[I] > gPlayer1Settings.WeaponPreferences[CurrWeap]) ) then - begin - gSelectWeapon[0, I] := True; - end - else - if (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) and (gPlayer2Settings.WeaponPreferences[I] > gPlayer2Settings.WeaponPreferences[CurrWeap]) ) then - gSelectWeapon[1, I] := True; - end - else - FWeapon[I] := checkWeapon; - end; - end; + FWeapon[I] := (M.ReadByte() <> 0); + for I := A_BULLETS to A_HIGH do FAmmo[I] := M.ReadWord(); @@ -2509,28 +2538,8 @@ begin FRulez := FRulez + [R_KEY_GREEN]; if (M.ReadByte() <> 0) then FRulez := FRulez + [R_KEY_BLUE]; - checkWeapon := M.ReadByte() <> 0; - if (checkWeapon) then - begin + if (M.ReadByte() <> 0) then FRulez := FRulez + [R_BERSERK]; - if ((gPlayer2Settings.WeaponSwitch <> 0) and (gPlayer2Settings.WeaponSwitch <> 0)) and ((PID = gPlayer1.UID) or ( (gPlayer2 <> nil) and (PID = gPlayer2.UID) )) then - begin - if (PID = gPlayer1.UID) then - begin - if (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) and (gPlayer1Settings.WeaponPreferences[WP_LAST+1] > gPlayer1Settings.WeaponPreferences[CurrWeap]) ) then - begin - gSelectWeapon[0, WEAPON_KASTET] := True; - end; - end - else - begin - if (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) and (gPlayer2Settings.WeaponPreferences[WP_LAST+1] > gPlayer2Settings.WeaponPreferences[CurrWeap]) ) then - begin - gSelectWeapon[0, WEAPON_KASTET] := True; - end; - end; - end; - end; Frags := M.ReadLongInt(); Death := M.ReadLongInt(); @@ -2686,6 +2695,7 @@ procedure MC_RECV_PlayerSettings(var M: TMsg); var TmpName: string; TmpModel: string; + CheckModel: string; TmpColor: TRGB; TmpTeam: Byte; Pl: TPlayer; @@ -2719,6 +2729,8 @@ begin Pl.Name := TmpName; end; + if (g_Force_Model_Get() <> 0) then + TmpModel := g_Forced_Model_GetName(); if TmpModel <> Pl.Model.Name then Pl.SetModel(TmpModel); end; @@ -3152,6 +3164,7 @@ end; // CLIENT SEND procedure MC_SEND_Info(Password: string); +var i: Integer; begin NetOut.Clear(); @@ -3164,6 +3177,11 @@ begin NetOut.Write(gPlayer1Settings.Color.G); NetOut.Write(gPlayer1Settings.Color.B); NetOut.Write(gPlayer1Settings.Team); + NetOut.Write(gPlayer1Settings.WeaponSwitch); + 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; @@ -3303,6 +3321,7 @@ begin end; procedure MC_SEND_PlayerSettings(); +var i: Integer; begin NetOut.Write(Byte(NET_MSG_PLRSET)); NetOut.Write(gPlayer1Settings.Name); @@ -3311,6 +3330,12 @@ begin NetOut.Write(gPlayer1Settings.Color.G); NetOut.Write(gPlayer1Settings.Color.B); NetOut.Write(gPlayer1Settings.Team); + NetOut.Write(gPlayer1Settings.WeaponSwitch); + 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;