mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 00:43:20 +00:00
Merge branch 'master' of github.com:Jackzmc/sourcemod-plugins
This commit is contained in:
commit
f2e2de6ca9
2 changed files with 19 additions and 8 deletions
|
@ -92,7 +92,7 @@ enum PanelSettings {
|
|||
Setting_None = 0,
|
||||
Setting_DisableWithNoViewers = 1
|
||||
}
|
||||
GameState g_gameState = State_Hibernating;
|
||||
GameState g_gameState = State_None;
|
||||
#define BUFFER_SIZE 2048
|
||||
Buffer sendBuffer;
|
||||
Buffer receiveBuffer; // Unfortunately there's no easy way to have this not be the same as BUFFER_SIZE
|
||||
|
@ -324,6 +324,11 @@ void OnSocketError(Socket socket, int errorType, int errorNumber, int attempt) {
|
|||
g_socket.SetArg(attempt + 1);
|
||||
CreateTimer(nextAttempt, Timer_Reconnect);
|
||||
}
|
||||
if(authState == Auth_PendingResponse) {
|
||||
Debug("Got socket error on auth?, retry");
|
||||
g_socket.SetArg(attempt + 1);
|
||||
ConnectSocket(false, attempt);
|
||||
}
|
||||
}
|
||||
|
||||
bool SendFullSync() {
|
||||
|
@ -658,13 +663,14 @@ Action Timer_Reconnect(Handle h, int type) {
|
|||
}
|
||||
|
||||
bool ConnectSocket(bool force = false, int authTry = 0) {
|
||||
if(g_gameState == State_Hibernating) return false; // ignore when hibernating
|
||||
if(g_socket == null) {
|
||||
if(g_gameState == State_Hibernating) {
|
||||
Debug("ConnectSocket: Server is hibernating, ignoring");
|
||||
return false;
|
||||
} else if(g_socket == null) {
|
||||
LogError("Socket is invalid");
|
||||
return false;
|
||||
}
|
||||
if(g_socket.Connected) {
|
||||
Debug("Already connected, disconnecting...");
|
||||
} else if(g_socket.Connected) {
|
||||
Debug("ConnectSocket: Already connected, disconnecting...");
|
||||
g_socket.Disconnect();
|
||||
authState = Auth_Inactive;
|
||||
}
|
||||
|
@ -673,7 +679,10 @@ bool ConnectSocket(bool force = false, int authTry = 0) {
|
|||
return false;
|
||||
}
|
||||
// Do not try to reconnect on auth failure, until token has changed
|
||||
if(!force && authState == Auth_Fail) return false;
|
||||
if(!force && authState == Auth_Fail) {
|
||||
Debug("ConnectSocket: Ignoring request, auth failed");
|
||||
return false;
|
||||
}
|
||||
authState = Auth_Pending;
|
||||
g_socket.Connect(OnSocketConnect, OnSocketReceive, OnSocketDisconnect, serverIp, serverPort);
|
||||
CreateTimer(10.0, Timer_ConnectTimeout, authTry);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue