summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a4da798)
raw | patch | inline | side by side (parent: a4da798)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 15 Oct 2019 20:16:42 +0000 (23:16 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 15 Oct 2019 21:10:30 +0000 (00:10 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_net.pas | patch | blob | history | |
src/game/g_netmaster.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 7ad130f20a6b52c6a3029bb81de27ab5cab4c020..a580b32bd703d8161937143602452e9b19513335 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
Exit;
end;
+ // process master server communications
+ g_Net_Slist_Pulse();
+
case gState of
STATE_INTERSINGLE, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
STATE_INTERCUSTOM, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
// send unexpected platform changes
g_Map_NetSendInterestingPanels();
+ g_Net_Slist_ServerUpdate();
+ {
if NetUseMaster then
begin
- {
if (gTime >= NetTimeToMaster) or g_Net_Slist_IsConnectionInProgress then
begin
if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
g_Net_Slist_Update;
NetTimeToMaster := gTime + NetMasterRate;
end;
- }
- g_Net_Slist_Pulse();
end;
+ }
end
else if (NetMode = NET_CLIENT) then
begin
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_PlayerCreate(gPlayer1.UID);
gPlayer1.Respawn(False, True);
-
- if g_Game_IsNet and NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerComes();
end;
Exit;
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_PlayerCreate(gPlayer2.UID);
gPlayer2.Respawn(False, True);
-
- if g_Game_IsNet and NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerComes();
end;
Exit;
Pl.Kill(K_SIMPLEKILL, 0, HIT_DISCON);
g_Console_Add(Format(_lc[I_PLAYER_LEAVE], [Pl.Name]), True);
g_Player_Remove(Pl.UID);
-
- if g_Game_IsNet and NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end else
gPlayer2 := nil;
Exit;
Pl.Kill(K_SIMPLEKILL, 0, HIT_DISCON);
g_Console_Add(Format(_lc[I_PLAYER_LEAVE], [Pl.Name]), True);
g_Player_Remove(Pl.UID);
-
- if g_Game_IsNet and NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end else
begin
gPlayer1 := nil;
IPAddr: LongWord; Port: Word);
begin
g_Game_Free();
+ g_Net_Slist_ServerClosed();
e_WriteLog('Starting net game (server)...', TMsgType.Notify);
g_Net_Slist_Set(NetSlistIP, NetSlistPort);
+ g_Net_Slist_ServerStarted();
+
// Çàãðóçêà è çàïóñê êàðòû:
if not g_Game_StartMap(Map, True) then
begin
+ g_Net_Slist_ServerClosed();
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [Map]));
Exit;
end;
g_Map_GetPointCount(RESPAWNPOINT_RED)+
g_Map_GetPointCount(RESPAWNPOINT_BLUE)) < 1 then
begin
+ g_Net_Slist_ServerClosed();
g_FatalError(_lc[I_GAME_ERROR_GET_SPAWN]);
Exit;
end;
// Íàñòðîéêè èãðîêîâ è áîòîâ:
g_Player_Init();
+ g_Net_Slist_ServerMapStarted();
NetState := NET_STATE_GAME;
end;
MH_SEND_GameEvent(NET_EV_MAPSTART, gGameSettings.GameMode, Map);
// Ìàñòåðñåðâåð
- if NetUseMaster then
- begin
- {
- if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
- g_Net_Slist_Update;
- }
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerMapStarted();
if NetClients <> nil then
for I := 0 to High(NetClients) do
NetServerName := P[1];
if Length(NetServerName) > 64 then
SetLength(NetServerName, 64);
- if g_Game_IsServer and g_Game_IsNet and NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerRenamed();
end;
g_Console_Add(cmd + ' = "' + NetServerName + '"');
NetPassword := P[1];
if Length(NetPassword) > 24 then
SetLength(NetPassword, 24);
- if g_Game_IsServer and g_Game_IsNet and NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerRenamed();
end;
g_Console_Add(cmd + ' = "' + AnsiLowerCase(NetPassword) + '"');
begin
b := 0;
for a := 0 to High(NetClients) do
+ begin
if NetClients[a].Used then
begin
Inc(b);
MH_SEND_GameEvent(NET_EV_PLAYER_KICK, 0, s);
end;
end;
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
end;
+ g_Net_Slist_ServerRenamed();
end;
end;
if (Length(P) > 1) then
begin
NetUseMaster := StrToIntDef(P[1], Byte(NetUseMaster)) > 0;
- if g_Game_IsServer and g_Game_IsNet then
- begin
- if NetUseMaster then
- begin
- {
- if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Connect(false); // non-blocking connection to the master
- g_Net_Slist_Update();
- }
- g_Net_Slist_Pulse();
- end
- else
- begin
- //if (not g_Net_Slist_IsConnectionActive) then g_Net_Slist_Disconnect();
- g_Net_Slist_Private();
- end;
- end;
+ if NetUseMaster then g_Net_Slist_Public() else g_Net_Slist_Private();
end;
g_Console_Add(cmd + ' = ' + IntToStr(Byte(NetUseMaster)));
enet_peer_disconnect(pl^.Peer, NET_DISC_KICK);
g_Console_Add(Format(_lc[I_PLAYER_KICK], [s]));
MH_SEND_GameEvent(NET_EV_PLAYER_KICK, 0, s);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end else if gPlayers <> nil then
for a := Low(gPlayers) to High(gPlayers) do
if gPlayers[a] <> nil then
gPlayers[a].Kill(K_SIMPLEKILL, 0, HIT_DISCON);
g_Console_Add(Format(_lc[I_PLAYER_LEAVE], [gPlayers[a].Name]), True);
g_Player_Remove(gPlayers[a].UID);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
// Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
g_Bot_MixNames();
end;
enet_peer_disconnect(NetClients[a].Peer, NET_DISC_KICK);
g_Console_Add(Format(_lc[I_PLAYER_KICK], [s]));
MH_SEND_GameEvent(NET_EV_PLAYER_KICK, 0, s);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end;
end;
end else
enet_peer_disconnect(pl^.Peer, NET_DISC_TEMPBAN);
g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end else
g_Console_Add(Format(_lc[I_NET_ERR_NAME404], [P[1]]));
end else
enet_peer_disconnect(NetClients[a].Peer, NET_DISC_TEMPBAN);
g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end;
end else
g_Console_Add(_lc[I_MSG_SERVERONLY]);
g_Net_SaveBanList();
g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end else
g_Console_Add(Format(_lc[I_NET_ERR_NAME404], [P[1]]));
end else
g_Net_SaveBanList();
g_Console_Add(Format(_lc[I_PLAYER_BAN], [s]));
MH_SEND_GameEvent(NET_EV_PLAYER_BAN, 0, s);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ g_Net_Slist_ServerPlayerLeaves();
end;
end else
g_Console_Add(_lc[I_MSG_SERVERONLY]);
diff --git a/src/game/g_net.pas b/src/game/g_net.pas
index e6c1fbccb6b19deaec6cbb8e58ec3d41c9681eab..8e76d85e898358ccc56403e5f15977edc1a7b774 100644 (file)
--- a/src/game/g_net.pas
+++ b/src/game/g_net.pas
NetPeer := nil;
NetHost := nil;
- g_Net_Slist_NetworkStopped();
- //g_Net_Slist_Disconnect(false); // do not spam console
+ g_Net_Slist_ServerClosed();
NetMyID := -1;
NetPlrUID1 := -1;
NetPlrUID2 := -1;
end;
clearNetClients(false); // don't clear array
- //if (g_Net_Slist_IsConnectionActive) then g_Net_Slist_Disconnect;
- g_Net_Slist_NetworkStopped();
+ g_Net_Slist_ServerClosed();
if NetPongSock <> ENET_SOCKET_NULL then
enet_socket_destroy(NetPongSock);
NetOut.Write(Byte(Ord('F')));
NetOut.Write(NetPort);
NetOut.Write(ClTime);
- //g_Net_Slist_WriteInfo();
TMasterHost.writeInfo(NetOut);
NPl := 0;
if gPlayer1 <> nil then Inc(NPl);
IP := '';
Result := 0;
- if NetUseMaster then
- begin
- //g_Net_Slist_Check;
- g_Net_Slist_Pulse();
- end;
- g_Net_Host_CheckPings;
+ if NetUseMaster then g_Net_Slist_Pulse();
+ g_Net_Host_CheckPings();
while (enet_host_service(NetHost, @NetEvent, 0) > 0) do
begin
g_Console_Add(_lc[I_NET_MSG] + Format(_lc[I_NET_MSG_HOST_DISC], [ID]));
Dec(NetClientCount);
- if NetUseMaster then
- begin
- //g_Net_Slist_Update;
- g_Net_Slist_Pulse();
- end;
+ if NetUseMaster then g_Net_Slist_ServerPlayerLeaves();
end;
end;
end;
index aee13eb1c2ebb5d027ac02b9dada3af5f44802b7..0b9e546f8100966a36906c5af11c36c986a6e41b 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
// make this server public
procedure g_Net_Slist_Public ();
-// called on network mode init
-procedure g_Net_Slist_NetworkStarted ();
-// called on network mode shutdown
-procedure g_Net_Slist_NetworkStopped ();
+// called while the server is running
+procedure g_Net_Slist_ServerUpdate ();
+// called when the server is started
+procedure g_Net_Slist_ServerStarted ();
+// called when the server is stopped
+procedure g_Net_Slist_ServerClosed ();
+
+// called when new netword player comes
+procedure g_Net_Slist_ServerPlayerComes ();
+// called when new netword player comes
+procedure g_Net_Slist_ServerPlayerLeaves ();
+// started new map
+procedure g_Net_Slist_ServerMapStarted ();
+// this server renamed (or password mode changed, or other params changed)
+procedure g_Net_Slist_ServerRenamed ();
procedure g_Net_Slist_Pulse (timeout: Integer=0);
g_map, g_game, g_sound, g_gui, g_menu, g_options, g_language, g_basic,
wadreader, g_system, utils;
+// if g_Game_IsServer and g_Game_IsNet and NetUseMaster then
+
// make this server private
procedure g_Net_Slist_Private ();
begin
end;
-
// make this server public
procedure g_Net_Slist_Public ();
begin
end;
+// called while the server is running
+procedure g_Net_Slist_ServerUpdate ();
+begin
+end;
+
+// called when the server is started
+procedure g_Net_Slist_ServerStarted ();
+begin
+end;
+
+// called when the server is stopped
+procedure g_Net_Slist_ServerClosed ();
+begin
+end;
+
+// called when new netword player comes
+procedure g_Net_Slist_ServerPlayerComes ();
+begin
+end;
-// called on network mode init
-procedure g_Net_Slist_NetworkStarted ();
+// called when new netword player comes
+procedure g_Net_Slist_ServerPlayerLeaves ();
begin
end;
-// called on network mode shutdown
-procedure g_Net_Slist_NetworkStopped ();
+// started new map
+procedure g_Net_Slist_ServerMapStarted ();
+begin
+end;
+
+// this server renamed (or password mode changed, or other params changed)
+procedure g_Net_Slist_ServerRenamed ();
begin
end;
+// ////////////////////////////////////////////////////////////////////////// //
var
NetMHost: pENetHost = nil;
NetMEvent: ENetEvent;
var
f: Integer;
hasAlive: Boolean;
- stt, ct: Int64;
+ //stt, ct: Int64;
begin
- stt := GetTimerMS();
+ //stt := GetTimerMS();
while (length(mlist) > 0) do
begin
hasAlive := false;
end;
end;
if not hasAlive then break;
+ break;
+ {
g_Net_Slist_Pulse(100);
ct := GetTimerMS();
if (ct < stt) or (ct-stt > 800) then break;
+ }
end;
end;
qm: Boolean;
Srv: TNetServer;
begin
+ g_Net_Slist_Pulse();
+
if gConsoleShow or gChatShow then
Exit;