diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index ddef35df216b9f645023eef3ab3d511aee45fe38..1fd6f7c5a8d3e7a6be8a0dad2ce9ea3980b2b78c 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
// HOST MESSAGES
// HOST MESSAGES
+procedure MH_ProcessFirstSpawn (C: pTNetClient);
+
procedure MH_RECV_Info(C: pTNetClient; var M: TMsg);
procedure MH_RECV_Chat(C: pTNetClient; var M: TMsg);
procedure MH_RECV_FullStateRequest(C: pTNetClient; var M: TMsg);
procedure MH_RECV_Info(C: pTNetClient; var M: TMsg);
procedure MH_RECV_Chat(C: pTNetClient; var M: TMsg);
procedure MH_RECV_FullStateRequest(C: pTNetClient; var M: TMsg);
procedure MH_RECV_Vote(C: pTNetClient; var M: TMsg);
// GAME
procedure MH_RECV_Vote(C: pTNetClient; var M: TMsg);
// GAME
-procedure MH_SEND_Everything(CreatePlayers: Boolean = False; ID: Integer = NET_EVERYONE);
+procedure MH_SEND_Everything(CreatePlayers: Boolean {= False}; ID: Integer {= NET_EVERYONE});
procedure MH_SEND_Info(ID: Byte);
procedure MH_SEND_Chat(Txt: string; Mode: Byte; ID: Integer = NET_EVERYONE);
procedure MH_SEND_Effect(X, Y: Integer; Ang: SmallInt; Kind: Byte; ID: Integer = NET_EVERYONE);
procedure MH_SEND_Info(ID: Byte);
procedure MH_SEND_Chat(Txt: string; Mode: Byte; ID: Integer = NET_EVERYONE);
procedure MH_SEND_Effect(X, Y: Integer; Ang: SmallInt; Kind: Byte; ID: Integer = NET_EVERYONE);
end;
C^.Player := PID;
end;
C^.Player := PID;
+ C^.WaitForFirstSpawn := false;
g_Console_Add(Format(_lc[I_PLAYER_JOIN], [PName]), True);
e_WriteLog('NET: Client ' + PName + ' [' + IntToStr(C^.ID) +
g_Console_Add(Format(_lc[I_PLAYER_JOIN], [PName]), True);
e_WriteLog('NET: Client ' + PName + ' [' + IntToStr(C^.ID) +
FNoRespawn := True;
Spectate;
FWantsInGame := True; // TODO: look into this later
FNoRespawn := True;
Spectate;
FWantsInGame := True; // TODO: look into this later
+ C^.WaitForFirstSpawn := true;
end
else
end
else
- Respawn(gGameSettings.GameType = GT_SINGLE);
+ begin
+ e_LogWritefln('*** client #%u (cid #%u) authenticated...', [C.ID, C.Player]);
+ //e_LogWritefln('spawning player with pid #%u...', [PID]);
+ //Respawn(gGameSettings.GameType = GT_SINGLE);
+ //k8: no, do not spawn a player yet, wait for "request full state" packet
+ Lives := 0;
+ Spectate;
+ FNoRespawn := True;
+ // `FWantsInGame` seems to mean "spawn the player on the next occasion".
+ // that is, if we'll set it to `true`, the player can be spawned after
+ // warmup time ran out, for example, regardless of the real player state.
+ // also, this seems to work only for the initial connection. further
+ // map changes could initiate resource downloading, but the player will
+ // be spawned immediately.
+ // the proper solution will require another player state, "ephemeral".
+ // the player should start any map in "ephemeral" state, and turned into
+ // real mobj only when they sent a special "i am ready" packet. this packet
+ // must be sent after receiving the full state, so the player will get a full
+ // map view before going into game.
+ FWantsInGame := false;
+ C^.WaitForFirstSpawn := true;
+ end;
end;
end;
- for I := Low(NetClients) to High(NetClients) do
+ //if not C^.WaitForFirstSpawn then
begin
begin
- if NetClients[I].ID = C^.ID then Continue;
- MH_SEND_PlayerCreate(PID, NetClients[I].ID);
- MH_SEND_PlayerPos(True, PID, NetClients[I].ID);
- MH_SEND_PlayerStats(PID, NetClients[I].ID);
+ for I := Low(NetClients) to High(NetClients) do
+ begin
+ if NetClients[I].ID = C^.ID then Continue;
+ MH_SEND_PlayerCreate(PID, NetClients[I].ID);
+ MH_SEND_PlayerPos(True, PID, NetClients[I].ID);
+ MH_SEND_PlayerStats(PID, NetClients[I].ID);
+ end;
end;
if gState in [STATE_INTERCUSTOM, STATE_FOLD] then
MH_SEND_GameEvent(NET_EV_MAPEND, 0, 'N', C^.ID);
end;
if gState in [STATE_INTERCUSTOM, STATE_FOLD] then
MH_SEND_GameEvent(NET_EV_MAPEND, 0, 'N', C^.ID);
- if NetUseMaster then g_Net_Slist_Update;
+ if NetUseMaster then
+ begin
+ //g_Net_Slist_Update;
+ g_Net_Slist_Pulse();
+ end;
end;
end;
+
+procedure MH_ProcessFirstSpawn (C: pTNetClient);
+var
+ plr: TPlayer;
+begin
+ if not C.WaitForFirstSpawn then exit;
+ plr := g_Player_Get(C^.Player);
+ if not assigned(plr) then exit;
+ g_Net_Slist_ServerPlayerComes();
+ e_LogWritefln('*** client #%u (cid #%u) first spawn', [C.ID, C.Player]);
+ C.WaitForFirstSpawn := false;
+ plr.FNoRespawn := false;
+ plr.FWantsInGame := true; // TODO: look into this later
+ plr.Respawn(False);
+end;
+
+
procedure MH_RECV_FullStateRequest(C: pTNetClient; var M: TMsg);
begin
procedure MH_RECV_FullStateRequest(C: pTNetClient; var M: TMsg);
begin
+ //e_LogWritefln('*** client #%u (cid #%u) full state request', [C.ID, C.Player]);
if gGameOn then
if gGameOn then
+ begin
MH_SEND_Everything((C^.State = NET_STATE_AUTH), C^.ID)
MH_SEND_Everything((C^.State = NET_STATE_AUTH), C^.ID)
+ end
else
else
+ begin
C^.RequestedFullUpdate := True;
C^.RequestedFullUpdate := True;
+ end;
end;
// PLAYER
end;
// PLAYER
// GAME (SEND)
// GAME (SEND)
-procedure MH_SEND_Everything(CreatePlayers: Boolean = False; ID: Integer = NET_EVERYONE);
+procedure MH_SEND_Everything(CreatePlayers: Boolean {= False}; ID: Integer {= NET_EVERYONE});
function sendItemRespawn (it: PItem): Boolean;
begin
function sendItemRespawn (it: PItem): Boolean;
begin
@@ -698,6 +752,12 @@ procedure MH_SEND_Everything(CreatePlayers: Boolean = False; ID: Integer = NET_E
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 gPlayers <> nil then
begin
for I := Low(gPlayers) to High(gPlayers) do
if gPlayers <> nil then
begin
for I := Low(gPlayers) to High(gPlayers) do
if gLMSRespawn > LMS_RESPAWN_NONE then
begin
if gLMSRespawn > LMS_RESPAWN_NONE then
begin
+ e_LogWritefln('*** client #%u (cid #%u) WARMUP', [ID, NetClients[ID].Player]);
MH_SEND_GameEvent(NET_EV_LMS_WARMUP, (gLMSRespawnTime - gTime) div 1000, 'N', ID);
end;
MH_SEND_GameEvent(NET_EV_LMS_WARMUP, (gLMSRespawnTime - gTime) div 1000, 'N', ID);
end;
end;
procedure MH_SEND_Info(ID: Byte);
end;
procedure MH_SEND_Info(ID: Byte);
-var
- Map: string;
begin
begin
- Map := g_ExtractFileName(gMapInfo.Map);
-
NetOut.Clear();
NetOut.Write(Byte(NET_MSG_INFO));
NetOut.Write(ID);
NetOut.Write(NetClients[ID].Player);
NetOut.Clear();
NetOut.Write(Byte(NET_MSG_INFO));
NetOut.Write(ID);
NetOut.Write(NetClients[ID].Player);
- NetOut.Write(gGameSettings.WAD);
- NetOut.Write(Map);
+ NetOut.Write(ExtractFileName(gGameSettings.WAD));
+ NetOut.Write(g_ExtractFileName(gMapInfo.Map));
NetOut.Write(gWADHash);
NetOut.Write(gGameSettings.GameMode);
NetOut.Write(gGameSettings.GoalLimit);
NetOut.Write(gWADHash);
NetOut.Write(gGameSettings.GameMode);
NetOut.Write(gGameSettings.GoalLimit);
NetOut.Write(Byte(FJetpack));
NetOut.Write(FFireTime);
NetOut.Write(Byte(FFlaming));
NetOut.Write(Byte(FJetpack));
NetOut.Write(FFireTime);
NetOut.Write(Byte(FFlaming));
+ NetOut.Write(FSpawnInvul);
end;
g_Net_Host_Send(ID, True, NET_CHAN_PLAYER);
end;
g_Net_Host_Send(ID, True, NET_CHAN_PLAYER);
gGameSettings.GameMode := gSwitchGameMode;
gWADHash := EvHash;
gGameSettings.GameMode := gSwitchGameMode;
gWADHash := EvHash;
- if not g_Game_StartMap(EvStr, True) then
+ if not g_Game_StartMap(false{asMegawad}, EvStr, True) then
begin
if not isWadPath(EvStr) then
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [gGameSettings.WAD + ':\' + EvStr]))
begin
if not isWadPath(EvStr) then
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [gGameSettings.WAD + ':\' + EvStr]))
if (OldFire <= 0) and (FFireTime > 0) then
g_Sound_PlayExAt('SOUND_IGNITE', Obj.X, Obj.Y);
Flam := M.ReadByte() <> 0;
if (OldFire <= 0) and (FFireTime > 0) then
g_Sound_PlayExAt('SOUND_IGNITE', Obj.X, Obj.Y);
Flam := M.ReadByte() <> 0;
+ FSpawnInvul := M.ReadLongInt();
if OldJet and not FJetpack then
JetpackOff
else if not OldJet and FJetpack then
if OldJet and not FJetpack then
JetpackOff
else if not OldJet and FJetpack then