X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_netmaster.pas;h=fa3d1904c29be532f66056f96f9c38c6c9e11961;hb=be2ad7bf5e09b4ee91a0c5ee741503ace8c7887c;hp=1703da27cdcbe44c21bf4f0b6bbc9875c97af211;hpb=8297fcc563a13c747663dc9b050c96eb80295a82;p=d2df-sdl.git diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index 1703da2..fa3d190 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -86,6 +86,7 @@ type slReadUrgent: Boolean; // temporary mark justAdded: Boolean; + connectCount: Integer; private netmsg: TMsg; @@ -132,7 +133,7 @@ var NMASTER_FORCE_UPDATE_TIMEOUT: Integer = 0; // fuck you, fpc, and your idiotic "diagnostics" -procedure g_Net_Slist_Set (IP: AnsiString; Port: Word; list: AnsiString=''); +procedure g_Net_Slist_Set (list: AnsiString); function g_Net_Slist_Fetch (var SL: TNetServerList): Boolean; // make this server private @@ -507,6 +508,8 @@ begin slMOTD := ''; slUrgent := ''; slReadUrgent := true; + justAdded := false; + connectCount := 0; netmsg.Alloc(NET_BUFSIZE); setAddress(ea, ''); end; @@ -779,6 +782,7 @@ begin NetUpdatePending := false; updateSent := false; lastUpdateTime := 0; + Inc(connectCount); peer := enet_host_connect(NetMHost, @enetAddr, NET_MCHANS, 0); if (peer = nil) then @@ -1049,7 +1053,7 @@ end; // g_Net_Slist_Set // //========================================================================== -procedure g_Net_Slist_Set (IP: AnsiString; Port: Word; list: AnsiString=''); +procedure g_Net_Slist_Set (list: AnsiString); var f, dest: Integer; sa: AnsiString; @@ -1060,13 +1064,6 @@ begin for f := 0 to High(mlist) do mlist[f].justAdded := false; - IP := Trim(IP); - if (length(IP) > 0) and (Port > 0) then - begin - sa := IP+':'+IntToStr(Port); - if parseAddressPort(ea, sa) then addMasterRecord(ea, sa); - end; - list := Trim(list); //writeln('list=[', list, ']'); while (length(list) > 0) do @@ -1160,7 +1157,7 @@ begin if (not mlist[f].isAlive()) then begin // not connected; try to reconnect if we're asking for a host list, or we are in netgame, and we are the host - if isListQuery or isMasterReportsEnabled() then + if (not isListQuery) and isMasterReportsEnabled() then begin if (mlist[f].lastDisconnectTime = 0) or (ct < mlist[f].lastDisconnectTime) or (ct-mlist[f].lastDisconnectTime >= 1000*NMASTER_TIMEOUT_RECONNECT) then begin @@ -1383,6 +1380,12 @@ begin DisconnectAll(true); // forced disconnect + for f := 0 to High(mlist) do + begin + mlist[f].connectCount := 0; + mlist[f].srvAnswered := 0; + end; + NetOut.Clear(); NetOut.Write(Byte(NET_MMSG_GET)); @@ -1410,12 +1413,19 @@ begin if (not mlist[f].isValid()) then continue; if (not mlist[f].isAlive()) then begin - mlist[f].connect(); - if (mlist[f].isAlive()) then + if (mlist[f].connectCount = 0) then begin - //g_Console_Add(Format(_lc[I_NET_MSG]+_lc[I_NET_SLIST_WCONN], [mlist[f].hostName])); - hasUnanswered := true; - stt := GetTimerMS(); + 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].srvAnswered > 1) then + begin + Inc(aliveCount); end; end else if (mlist[f].isConnected()) then @@ -1441,6 +1451,7 @@ begin else if (mlist[f].srvAnswered > 1) then begin Inc(aliveCount); + mlist[f].disconnect(false); // not forced end; end else if (mlist[f].isConnecting()) then