summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c9b34f)
raw | patch | inline | side by side (parent: 1c9b34f)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 16 Oct 2019 02:47:05 +0000 (05:47 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 16 Oct 2019 02:47:23 +0000 (05:47 +0300) |
src/game/g_language.pas | patch | blob | history | |
src/game/g_netmaster.pas | patch | blob | history |
index 62361f3032e970f191bac3b8d3fced8104e90a17..af65be7947f8374dd5fbf046ba79388446d89ea3 100644 (file)
--- a/src/game/g_language.pas
+++ b/src/game/g_language.pas
('NET SLIST FETCH', 'Fetching server list...',
'Ïîëó÷àåì ñïèñîê ñåðâåðîâ...'),
- ('NET SLIST RETRIEVED', '%d servers retrieved.',
- 'Ïîëó÷åíî ñåðâåðîâ: %d'),
- ('NET SLIST CONN', 'Connected to masterserver.',
- 'Ïîäêëþ÷èëèñü ê ìàñòåðñåðâåðó.'),
- ('NET SLIST WCONN', 'Connecting to masterserver...',
- 'Ïîäêëþ÷àåìñÿ ê ìàñòåðñåðâåðó...'),
- ('NET SLIST DISC', 'Disconnected from masterserver.',
- 'Îòêëþ÷èëèñü îò ìàñòåðñåðâåðà.'),
- ('NET SLIST LOST', 'Lost connection with masterserver.',
- 'Ñîåäèíåíèå ñ ìàñòåðñåðâåðîì ïîòåðÿíî.'),
+ ('NET SLIST RETRIEVED', '%d servers retrieved from [%s].',
+ 'Ïîëó÷åíî ñåðâåðîâ: %d, èñòî÷íèê: [%s]'),
+ ('NET SLIST CONN', 'Connected to masterserver [%s].',
+ 'Ïîäêëþ÷èëèñü ê ìàñòåðñåðâåðó [%s].'),
+ ('NET SLIST WCONN', 'Connecting to masterserver [%s]...',
+ 'Ïîäêëþ÷àåìñÿ ê ìàñòåðñåðâåðó [%s]...'),
+ ('NET SLIST DISC', 'Disconnected from masterserver [%s].',
+ 'Îòêëþ÷èëèñü îò ìàñòåðñåðâåðà [%s].'),
+ ('NET SLIST LOST', 'Lost connection with masterserver [%s].',
+ 'Ñîåäèíåíèå ñ ìàñòåðñåðâåðîì ïîòåðÿíî [%s].'),
('NET SLIST ERROR', 'Could not connect to masterserver.',
'Íå óäàëîñü ñîåäèíèòüñÿ ñ ìàñòåðñåðâåðîì.'),
index c0ef87270eb8dc06d1bab1a91c2d945bddcc1732..393c4e572fc5191271ce324832860541376bfb79 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
// this server renamed (or password mode changed, or other params changed)
procedure g_Net_Slist_ServerRenamed ();
+// non-zero timeout ignores current status (used to fetch server list)
procedure g_Net_Slist_Pulse (timeout: Integer=0);
procedure g_Net_Slist_ShutdownAll ();
Inc(activeCount);
if (mlist[f].isConnected() and mlist[f].updateSent) then
begin
- writeln('unregistering from ', f);
+ writeln('unregistering from [', mlist[f].hostName, ']');
mlist[f].remove();
end;
//mlist[f].disconnect(false);
// DisconnectAll
//
//==========================================================================
-procedure DisconnectAll ();
+procedure DisconnectAll (forced: Boolean=false);
var
f: Integer;
begin
for f := 0 to High(mlist) do
begin
- if (mlist[f].isAlive()) then mlist[f].disconnect(false);
+ if (mlist[f].isAlive()) then mlist[f].disconnect(forced);
end;
end;
if NetHostConnected then exit;
NetHostConnected := true;
e_LogWritefln('connected to master at [%s]', [hostName], TMsgType.Notify);
+ //g_Console_Add(Format(_lc[I_NET_MSG]+_lc[I_NET_SLIST_CONN], [mlist[f].hostName]));
end;
if not isAlive() then exit;
e_LogWritefln('disconnected from master at [%s]', [hostName], TMsgType.Notify);
disconnect(true);
- //if (spamConsole) then g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_SLIST_DISC]);
+ //if (spamConsole) then g_Console_Add(Format(_lc[I_NET_MSG]+_lc[I_NET_SLIST_DISC], [hostName]));
end;
slReadUrgent := true;
// number of items
Cnt := msg.ReadByte();
- g_Console_Add(_lc[I_NET_MSG]+Format(_lc[I_NET_SLIST_RETRIEVED], [Cnt]), True);
+ //g_Console_Add(_lc[I_NET_MSG]+Format(_lc[I_NET_SLIST_RETRIEVED], [Cnt, hostName]), True);
+ e_LogWritefln('got %u server(s) from master at [%s]', [Cnt, hostName], TMsgType.Notify);
if (Cnt > 0) then
begin
SetLength(srvAnswer, Cnt);
if (msg.ReadCount < msg.CurSize) then
begin
slMOTD := b_Text_Format(msg.ReadString());
+ if (slMOTD <> '') then e_LogWritefln('got MOTD from master at [%s]: %s', [hostName, slMOTD], TMsgType.Notify);
s := b_Text_Format(msg.ReadString());
// check if the message has updated and the user has to read it again
if (slUrgent <> s) then slReadUrgent := false;
slUrgent := s;
+ if (s <> '') then e_LogWritefln('got urgent from master at [%s]: %s', [hostName, s], TMsgType.Notify);
end;
end;
end;
//g_Console_Add(_lc[I_NET_MSG_ERROR] + _lc[I_NET_SLIST_ERROR], True);
enet_peer_disconnect(peer, 0);
// main pulse will take care of the rest
+ NetHostConReqTime := -1;
end;
exit;
end;
//updateSent := false;
lastUpdateTime := 0;
//lastConnectTime := 0;
- //if (spamConsole) then g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_SLIST_DISC]);
+ //if (spamConsole) then g_Console_Add(Format(_lc[I_NET_MSG]+_lc[I_NET_SLIST_DISC], [hostName]));
end;
try
netmsg.Write(Byte(NET_MMSG_UPD));
netmsg.Write(NetAddr.port);
+ //writeln(formatstrf('%08x', [NetAddr.host]), ' : ', NetAddr.host);
writeInfo(netmsg);
//
// g_Net_Slist_Pulse
//
+// non-zero timeout ignores current status (used to fetch server list)
+//
//==========================================================================
procedure g_Net_Slist_Pulse (timeout: Integer=0);
var
if (not mlist[f].isValid()) then continue;
if (not mlist[f].isAlive()) then
begin
- if reportsEnabled and g_Game_IsServer() and g_Game_IsNet() and NetUseMaster then
+ if (timeout > 0) or (reportsEnabled and g_Game_IsServer() and g_Game_IsNet() and NetUseMaster) then
begin
if (mlist[f].lastConnectTime = 0) or (ct < mlist[f].lastConnectTime) or (ct-mlist[f].lastConnectTime >= 1000*60*5) then
begin
+ e_LogWritefln('reconnecting to master [%s]', [mlist[f].hostName], TMsgType.Notify);
mlist[f].connect();
end;
end;
end
else
begin
- if not reportsEnabled or not g_Game_IsServer() or not g_Game_IsNet() or not NetUseMaster then
+ if (timeout = 0) and (not reportsEnabled or not g_Game_IsServer() or not g_Game_IsNet() or not NetUseMaster) then
begin
- if (mlist[f].isConnected()) and (mlist[f].updateSent) then mlist[f].remove();
+ if (mlist[f].isConnected()) and (mlist[f].updateSent) then
+ begin
+ e_LogWritefln('removing from master [%s]', [mlist[f].hostName], TMsgType.Notify);
+ mlist[f].remove();
+ end;
+ //e_LogWritefln('disconnecting from master [%s]', [mlist[f].hostName], TMsgType.Notify);
mlist[f].disconnect(false);
end;
end;
mlist[f].pulse();
end;
- while true do
+ sres := enet_host_service(NetMHost, @NetMEvent, timeout);
+ while (sres <> 0) do
begin
- sres := enet_host_service(NetMHost, @NetMEvent, timeout);
if (sres < 0) then
begin
g_Console_Add(_lc[I_NET_MSG_ERROR]+_lc[I_NET_ERR_CLIENT], True);
exit;
end;
- if (sres = 0) then break;
idx := findByPeer(NetMEvent.peer);
if (idx < 0) then
begin
e_LogWriteln('network event from unknown master host. ignored.', TMsgType.Warning);
if (NetMEvent.kind = ENET_EVENT_TYPE_RECEIVE) then enet_packet_destroy(NetMEvent.packet);
- continue;
- end;
-
- if (NetMEvent.kind = ENET_EVENT_TYPE_CONNECT) then
- begin
- mlist[idx].connectedEvent();
- end
- else if (NetMEvent.kind = ENET_EVENT_TYPE_DISCONNECT) then
- begin
- mlist[idx].disconnectedEvent();
end
- else if (NetMEvent.kind = ENET_EVENT_TYPE_RECEIVE) then
+ else
begin
- mlist[idx].receivedEvent(NetMEvent.packet);
- enet_packet_destroy(NetMEvent.packet);
+ if (NetMEvent.kind = ENET_EVENT_TYPE_CONNECT) then
+ begin
+ mlist[idx].connectedEvent();
+ end
+ else if (NetMEvent.kind = ENET_EVENT_TYPE_DISCONNECT) then
+ begin
+ mlist[idx].disconnectedEvent();
+ end
+ else if (NetMEvent.kind = ENET_EVENT_TYPE_RECEIVE) then
+ begin
+ mlist[idx].receivedEvent(NetMEvent.packet);
+ enet_packet_destroy(NetMEvent.packet);
+ end;
end;
+ sres := enet_host_service(NetMHost, @NetMEvent, 0);
end;
end;
g_Net_Slist_Pulse(); // this will create mhost
+ DisconnectAll(true); // forced disconnect
+
NetOut.Clear();
NetOut.Write(Byte(NET_MMSG_GET));
try
e_WriteLog('Fetching serverlist...', TMsgType.Notify);
- g_Console_Add(_lc[I_NET_MSG] + _lc[I_NET_SLIST_FETCH]);
+ g_Console_Add(_lc[I_NET_MSG]+_lc[I_NET_SLIST_FETCH]);
// wait until all servers connected and answered
stt := GetTimerMS();
while true do
begin
- g_Net_Slist_Pulse(300);
aliveCount := 0;
hasUnanswered := false;
for f := 0 to High(mlist) do
mlist[f].connect();
if (mlist[f].isAlive()) then
begin
+ //g_Console_Add(Format(_lc[I_NET_MSG]+_lc[I_NET_SLIST_WCONN], [mlist[f].hostName]));
hasUnanswered := true;
stt := GetTimerMS();
end;
end
else if (mlist[f].isConnected()) then
begin
+ //g_Console_Add(Format(_lc[I_NET_MSG]+_lc[I_NET_SLIST_CONN], [mlist[f].hostName]));
if (mlist[f].srvAnswered = 0) then
begin
pkt := enet_packet_create(NetOut.Data, NetOut.CurSize, Cardinal(ENET_PACKET_FLAG_RELIABLE));
// check for timeout
ct := GetTimerMS();
if (ct < stt) or (ct-stt > 4000) then break;
+ g_Net_Slist_Pulse(300);
end;
if (aliveCount = 0) then