diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 55b99b3705acbc0ddbe05e00b04ba3657ea2c9fd..759f4b6bd963964b6c9d76524fd178902881091b 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
implementation
uses
implementation
uses
- Math, ENet, e_input, e_graphics, e_log,
- g_textures, g_gfx, g_sound, g_console, g_basic, g_options, g_main,
- g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys, g_gui,
+ {$IFDEF ENABLE_MENU}
+ g_gui,
+ {$ENDIF}
+ Math, ENet, e_input, e_log, g_base, g_basic,
+ g_textures, g_gfx, g_sound, g_console, g_options,
+ g_game, g_player, g_map, g_panel, g_items, g_weapons, g_phys,
g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
const
g_language, g_monsters, g_netmaster, utils, wadreader, MAPDEF;
const
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_PROTOCOL]);
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_PROTOCOL]);
- enet_peer_disconnect(C^.Peer, NET_DISC_PROTOCOL);
+ g_Net_Host_Kick(C^.ID, NET_DISC_PROTOCOL);
end;
procedure MH_RECV_Chat(C: pTNetClient; var M: TMsg);
end;
procedure MH_RECV_Chat(C: pTNetClient; var M: TMsg);
WeapSwitch: Byte;
TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte;
SwitchEmpty: Byte;
WeapSwitch: Byte;
TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte;
SwitchEmpty: Byte;
+ SkipF: Byte;
PID: Word;
Color: TRGB;
I: Integer;
PID: Word;
Color: TRGB;
I: Integer;
B := M.ReadByte();
T := M.ReadByte();
WeapSwitch := M.ReadByte();
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();
SwitchEmpty := M.ReadByte();
+ SkipF := M.ReadByte();
except
Err := True;
end;
except
Err := True;
end;
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_VERSION]);
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_VERSION]);
- enet_peer_disconnect(C^.Peer, NET_DISC_VERSION);
+ g_Net_Host_Kick(C^.ID, NET_DISC_VERSION);
Exit;
end;
Exit;
end;
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_BAN]);
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_BAN]);
- enet_peer_disconnect(C^.Peer, NET_DISC_BAN);
+ g_Net_Host_Kick(C^.ID, NET_DISC_BAN);
end
else
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_BAN]);
end
else
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_BAN]);
- enet_peer_disconnect(C^.Peer, NET_DISC_TEMPBAN);
+ g_Net_Host_Kick(C^.ID, NET_DISC_TEMPBAN);
end;
Exit;
end;
end;
Exit;
end;
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_PASSWORD]);
begin
g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_MSG_HOST_REJECT] +
_lc[I_NET_DISC_PASSWORD]);
- enet_peer_disconnect(C^.Peer, NET_DISC_PASSWORD);
+ g_Net_Host_Kick(C^.ID, NET_DISC_PASSWORD);
Exit;
end;
Exit;
end;
begin
Name := PName;
WeapSwitchMode := WeapSwitch;
begin
Name := PName;
WeapSwitchMode := WeapSwitch;
- if (WeapSwitch = 2) then
- SetWeaponPrefs(TmpPrefArray);
+ SetWeaponPrefs(TmpPrefArray);
SwitchToEmpty := SwitchEmpty;
SwitchToEmpty := SwitchEmpty;
+ SkipFist := SkipF;
+ if (g_Force_Model_Get() <> 0) then
+ SetModel(g_Forced_Model_GetName());
Reset(True);
end;
Reset(True);
end;
procedure MH_RECV_FullStateRequest(C: pTNetClient; var M: TMsg);
begin
//e_LogWritefln('*** client #%u (cid #%u) full state request', [C.ID, C.Player]);
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)
if gGameOn then
begin
MH_SEND_Everything((C^.State = NET_STATE_AUTH), C^.ID)
TmpWeapSwitch: Byte;
TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte;
TmpSwEmpty: Byte;
TmpWeapSwitch: Byte;
TmpPrefArray: Array [WP_FIRST .. WP_LAST + 1] of Byte;
TmpSwEmpty: Byte;
+ TmpSkipF: Byte;
I: Integer;
Pl: TPlayer;
Err: Boolean;
I: Integer;
Pl: TPlayer;
Err: Boolean;
TmpColor.B := M.ReadByte();
TmpTeam := M.ReadByte();
TmpWeapSwitch := M.ReadByte();
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();
TmpSwEmpty := M.ReadByte();
+ TmpSkipF := M.ReadByte();
except
Err := True;
end;
except
Err := True;
end;
Pl.Name := TmpName;
end;
Pl.Name := TmpName;
end;
- if TmpModel <> Pl.Model.Name then
+ if (g_Force_Model_Get() <> 0) then
+ TmpModel := g_Forced_Model_GetName();
+ if TmpModel <> Pl.Model.GetName() then
Pl.SetModel(TmpModel);
if (TmpWeapSwitch <> Pl.WeapSwitchMode) then
Pl.WeapSwitchMode := TmpWeapSwitch;
Pl.SetModel(TmpModel);
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 (TmpSwEmpty <> Pl.SwitchToEmpty) then
Pl.SwitchToEmpty := TmpSwEmpty;
+
+ if (TmpSkipF <> Pl.SkipFist) then
+ Pl.SkipFist := TmpSkipF;
+
MH_SEND_PlayerSettings(Pl.UID, TmpModel);
end;
MH_SEND_PlayerSettings(Pl.UID, TmpModel);
end;
@@ -890,11 +909,14 @@ procedure MH_SEND_Everything(CreatePlayers: Boolean {= False}; ID: Integer {= NE
var
I: Integer;
begin
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
if gPlayers <> nil then
begin
NetOut.Write(g_ExtractFileName(gMapInfo.Map));
NetOut.Write(gWADHash);
NetOut.Write(gGameSettings.GameMode);
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);
NetOut.Write(gGameSettings.TimeLimit);
NetOut.Write(gGameSettings.MaxLives);
NetOut.Write(gGameSettings.Options);
NetOut.Write(Byte(NET_MSG_SCORE));
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
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
end
else
if gGameSettings.GameMode = GM_COOP then
begin
NetOut.Write(Byte(NET_MSG_GSET));
NetOut.Write(gGameSettings.GameMode);
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);
NetOut.Write(gGameSettings.TimeLimit);
NetOut.Write(gGameSettings.MaxLives);
NetOut.Write(gGameSettings.Options);
NetOut.Write(PID);
NetOut.Write(Pl.Name);
if Mdl = '' then
NetOut.Write(PID);
NetOut.Write(Pl.Name);
if Mdl = '' then
- NetOut.Write(Pl.Model.Name)
+ NetOut.Write(Pl.Model.GetName())
else
NetOut.Write(Mdl);
NetOut.Write(Pl.FColor.R);
else
NetOut.Write(Mdl);
NetOut.Write(Pl.FColor.R);
Kind: Byte;
X, Y: Integer;
Ang: SmallInt;
Kind: Byte;
X, Y: Integer;
Ang: SmallInt;
- Anim: TAnimation;
- ID: LongWord;
begin
if not gGameOn then Exit;
Kind := M.ReadByte();
begin
if not gGameOn then Exit;
Kind := M.ReadByte();
NET_GFX_TELE:
begin
NET_GFX_TELE:
begin
- if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
- begin
- Anim := TAnimation.Create(ID, False, 3);
- g_GFX_OnceAnim(X, Y, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_TELEPORT_FAST, X, Y);
if Ang = 1 then
g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y);
end;
NET_GFX_EXPLODE:
begin
if Ang = 1 then
g_Sound_PlayExAt('SOUND_GAME_TELEPORT', X, Y);
end;
NET_GFX_EXPLODE:
begin
- if g_Frames_Get(ID, 'FRAMES_EXPLODE_ROCKET') then
- begin
- Anim := TAnimation.Create(ID, False, 6);
- Anim.Blending := False;
- g_GFX_OnceAnim(X-64, Y-64, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_EXPLODE_ROCKET, X - 64, Y - 64);
if Ang = 1 then
g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', X, Y);
end;
NET_GFX_BFGEXPL:
begin
if Ang = 1 then
g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEROCKET', X, Y);
end;
NET_GFX_BFGEXPL:
begin
- if g_Frames_Get(ID, 'FRAMES_EXPLODE_BFG') then
- begin
- Anim := TAnimation.Create(ID, False, 6);
- Anim.Blending := False;
- g_GFX_OnceAnim(X-64, Y-64, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_EXPLODE_BFG, X - 64, Y - 64);
if Ang = 1 then
g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', X, Y);
end;
NET_GFX_BFGHIT:
begin
if Ang = 1 then
g_Sound_PlayExAt('SOUND_WEAPON_EXPLODEBFG', X, Y);
end;
NET_GFX_BFGHIT:
begin
- if g_Frames_Get(ID, 'FRAMES_BFGHIT') then
- begin
- Anim := TAnimation.Create(ID, False, 4);
- g_GFX_OnceAnim(X-32, Y-32, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_BFG_HIT, X - 32, Y - 32);
end;
NET_GFX_FIRE:
begin
end;
NET_GFX_FIRE:
begin
- if g_Frames_Get(ID, 'FRAMES_FIRE') then
- begin
- Anim := TAnimation.Create(ID, False, 4);
- g_GFX_OnceAnim(X, Y, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_FIRE, X, Y);
if Ang = 1 then
g_Sound_PlayExAt('SOUND_FIRE', X, Y);
end;
NET_GFX_RESPAWN:
begin
if Ang = 1 then
g_Sound_PlayExAt('SOUND_FIRE', X, Y);
end;
NET_GFX_RESPAWN:
begin
- if g_Frames_Get(ID, 'FRAMES_ITEM_RESPAWN') then
- begin
- Anim := TAnimation.Create(ID, False, 4);
- g_GFX_OnceAnim(X, Y, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_ITEM_RESPAWN, X, Y);
if Ang = 1 then
g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
end;
if Ang = 1 then
g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
end;
begin
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
begin
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
end
else
if gGameSettings.GameMode = GM_COOP then
procedure MC_RECV_GameSettings(var M: TMsg);
begin
gGameSettings.GameMode := M.ReadByte();
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();
gGameSettings.TimeLimit := M.ReadWord();
gGameSettings.MaxLives := M.ReadByte();
gGameSettings.Options := M.ReadLongWord();
if (PID <> NetPlrUID1) and (PID <> NetPlrUID2) then
begin
if (Pl <> nil) then Exit;
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
DID := g_Player_Create(Model, Color, T, False);
with g_Player_Get(DID) do
begin
var
TmpName: string;
TmpModel: string;
var
TmpName: string;
TmpModel: string;
+ CheckModel: string;
TmpColor: TRGB;
TmpTeam: Byte;
TmpColor: TRGB;
TmpTeam: Byte;
- i: Integer;
Pl: TPlayer;
PID: Word;
begin
Pl: TPlayer;
PID: Word;
begin
Pl.Name := TmpName;
end;
Pl.Name := TmpName;
end;
- if TmpModel <> Pl.Model.Name then
+ if (g_Force_Model_Get() <> 0) then
+ TmpModel := g_Forced_Model_GetName();
+ if TmpModel <> Pl.Model.GetName() then
Pl.SetModel(TmpModel);
end;
Pl.SetModel(TmpModel);
end;
procedure MC_RECV_ItemSpawn(var M: TMsg);
var
ID: Word;
procedure MC_RECV_ItemSpawn(var M: TMsg);
var
ID: Word;
- AID: DWord;
X, Y, VX, VY: Integer;
T: Byte;
Quiet, Fall{, Resp}: Boolean;
X, Y, VX, VY: Integer;
T: Byte;
Quiet, Fall{, Resp}: Boolean;
- Anim: TAnimation;
it: PItem;
begin
if not gGameOn then Exit;
it: PItem;
begin
if not gGameOn then Exit;
if not Quiet then
begin
g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
if not Quiet then
begin
g_Sound_PlayExAt('SOUND_ITEM_RESPAWNITEM', X, Y);
- if g_Frames_Get(AID, 'FRAMES_ITEM_RESPAWN') then
- begin
- Anim := TAnimation.Create(AID, False, 4);
- g_GFX_OnceAnim(X+(it.Obj.Rect.Width div 2)-16, Y+(it.Obj.Rect.Height div 2)-16, Anim);
- Anim.Free();
- end;
+ g_GFX_QueueEffect(R_GFX_ITEM_RESPAWN, X+(it.Obj.Rect.Width div 2)-16, Y+(it.Obj.Rect.Height div 2)-16);
end;
end;
end;
end;
NetOut.Write(gPlayer1Settings.Color.B);
NetOut.Write(gPlayer1Settings.Team);
NetOut.Write(gPlayer1Settings.WeaponSwitch);
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.SwitchToEmpty);
+ NetOut.Write(gPlayer1Settings.SkipFist);
g_Net_Client_Send(True, NET_CHAN_SERVICE);
end;
g_Net_Client_Send(True, NET_CHAN_SERVICE);
end;
kByte := 0;
Predict := NetPredictSelf; // and (not NetGotKeys);
kByte := 0;
Predict := NetPredictSelf; // and (not NetGotKeys);
+{$IFDEF DISABLE_MENU}
+ if (not gConsoleShow) and (not gChatShow) then
+{$ELSE}
if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
if (not gConsoleShow) and (not gChatShow) and (g_ActiveWindow = nil) then
+{$ENDIF}
begin
strafeDir := P1MoveButton shr 4;
P1MoveButton := P1MoveButton and $0F;
begin
strafeDir := P1MoveButton shr 4;
P1MoveButton := P1MoveButton and $0F;
NetOut.Write(gPlayer1Settings.Color.B);
NetOut.Write(gPlayer1Settings.Team);
NetOut.Write(gPlayer1Settings.WeaponSwitch);
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.SwitchToEmpty);
+ NetOut.Write(gPlayer1Settings.SkipFist);
+
g_Net_Client_Send(True, NET_CHAN_IMPORTANT);
end;
g_Net_Client_Send(True, NET_CHAN_IMPORTANT);
end;