diff --git a/client.cs b/client.cs index 460a0b9..698b2c1 100644 --- a/client.cs +++ b/client.cs @@ -6,6 +6,8 @@ $RPGClient::Version = 2; $RPGClient::Active = 0; $RPGClient::Yaw = 0; $RPGClient::Dist = 14; +$RPGClient::HelloPending = 0; +$RPGClient::HelloLast = ""; function RPGClient_NormPos(%ctrl, %pos) { @@ -204,10 +206,20 @@ function RPGClient_ZoomOut(%val) function RPGClient_SendHello() { + if ($RPGClient::Server) + { + return; + } if (!isObject(ServerConnection)) { return; } + %now = getSimTime(); + if ($RPGClient::HelloLast !$= "" && %now - $RPGClient::HelloLast < 900) + { + return; + } + $RPGClient::HelloLast = %now; commandToServer('RPG_Hello', $RPGClient::Version); } @@ -221,10 +233,12 @@ function clientCmdRPG_Welcome(%serverProto, %accepted) if (%accepted && %serverProto == $RPGClient::Version) { $RPGClient::Server = 1; + $RPGClient::HelloPending = 0; } else if (!%accepted) { echo("Client_RPG: server rejected handshake (server proto " @ %serverProto @ ")"); + schedule(1500, 0, RPGClient_SendHello); } } @@ -367,6 +381,9 @@ package RPGClient_Cleanup { RPGClient_DisableOverlay(); RPGClient_UnbindKeys(); + $RPGClient::Server = 0; + $RPGClient::HelloPending = 0; + $RPGClient::HelloLast = ""; Parent::disconnectedCleanup(%doReconnect); } }; @@ -377,8 +394,7 @@ package RPGClient_Mission function onMissionDownloadComplete() { Parent::onMissionDownloadComplete(); - schedule(200, 0, RPGClient_SendHello); - schedule(2000, 0, RPGClient_SendHello); + schedule(250, 0, RPGClient_SendHello); } }; activatePackage(RPGClient_Mission);