Commit fa2a6374 authored by Neoony's avatar Neoony
Browse files

v0.1 WIP17 -Apply Vanilla server IP fix only on backup lobby server -Added...

v0.1 WIP17 -Apply Vanilla server IP fix only on backup lobby server -Added more messages showing in server console when l_debug is 1
parent ddd739a8
Pipeline #4644 passed with stages
in 3 minutes and 2 seconds
......@@ -21,7 +21,7 @@
//#include <emputils>
#include <socket>
#define PluginVer "v0.1 WIP16"
#define PluginVer "v0.1 WIP17"
public Plugin myinfo =
{
......@@ -108,6 +108,12 @@ Handle l_serverformat = INVALID_HANDLE;
bool PreferredServerActive = false;
char PreferredServerAddr[256];
//ServerIP
char hostname[128];
//Vanilla server Local
bool VanillaLocal = false;
public void OnPluginStart()
{
//LoadTranslations("common.phrases");
......@@ -163,6 +169,28 @@ public void OnPluginStart()
Updater_AddPlugin(UPDATE_URL);
}
//Detect hostname of server
GetConVarString(FindConVar("hostname"), hostname, sizeof(hostname));
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[L]Hostname: %s", hostname);
}
if (StrEqual(hostname, "Empires Backup Lobby") == true)
{
VanillaLocal = true;
}
if (GetConVarInt(l_debug) == 1)
{
if (VanillaLocal == true)
{
PrintToServer("[L]VanillaLocal = true");
}
if (VanillaLocal == false)
{
PrintToServer("[L]VanillaLocal = false");
}
}
//Create or load config files
AutoExecConfig(true, "Lobby");
//Message
......@@ -373,6 +401,10 @@ public void RedirectToPopulatedServerSinglePlayerCallback(Handle hDriver, Handle
{
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
PopulatedServerAlive = false;
if (PreferredServerActive == true)
{
......@@ -458,6 +490,11 @@ public void RedirectToPopulatedServerCallback(Handle hDriver, Handle hResult, co
{
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
PopulatedServerAlive = false;
if (PreferredServerActive == true)
{
......@@ -641,11 +678,19 @@ public void GotDatabase(Database db, const char[] error, any data)
if (db == null)
{
LogError("Database failure: %s", error);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("Database failure: %s", error);
}
}
else
{
hDatabase = db;
LogError("Database loaded!");
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("Database loaded!");
}
}
}
......@@ -675,6 +720,11 @@ public void QNumberOfServers(Handle hDriver, Handle hResult, const char[] sError
if (hResult == INVALID_HANDLE) {
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
PrintToChatAll("\x04[L] \x01Could not connect to Database, Redirecting players to a Backup server in\x073399ff 5\x01 seconds");
BackupRedirectTimer = CreateTimer(5.0, BackupRedirectTmr);
}
......@@ -761,6 +811,10 @@ public void InfoOfServer(Handle hDriver, Handle hResult, const char[] sError, in
if (hResult == INVALID_HANDLE) {
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
PrintToChatAll("\x04[L] \x01Could not connect to Database, Redirecting players to a Backup server in\x073399ff 5\x01 seconds");
BackupRedirectTimer = CreateTimer(5.0, BackupRedirectTmr);
}
......@@ -1073,6 +1127,10 @@ public void RSAllServersAddr(Handle RShDriver, Handle RShResult, const char[] sE
if (RShResult == INVALID_HANDLE) {
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
}
else
{
......@@ -1095,6 +1153,11 @@ public void RSInfoOfServer(Handle RShDriver, Handle RShResult, const char[] sErr
if (RShResult == INVALID_HANDLE) {
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
}
else
{
......@@ -1111,9 +1174,12 @@ public void RSInfoOfServer(Handle RShDriver, Handle RShResult, const char[] sErr
//Vanilla server IP replacement, as it is a local server
//Vanilla IP:
//Vanilla local IP: 192.168.200.81:27016
if (StrEqual(RSaddrx[ServerIndex], "80.112.155.100:27016") == true)
if (VanillaLocal == true)
{
Format(RSaddrx[ServerIndex], 256, "192.168.200.81:27016");
if (StrEqual(RSaddrx[ServerIndex], "80.112.155.100:27016") == true)
{
Format(RSaddrx[ServerIndex], 256, "192.168.200.81:27016");
}
}
char IPPort[2][64];
ExplodeString(RSaddrx[ServerIndex], ":", IPPort, sizeof(IPPort), sizeof(IPPort[]));
......@@ -1175,6 +1241,10 @@ public Action CleanUp(int ServerIndexx)
if (strlen(serverInfo[ServerIndexx]) == 0 && !socketError[ServerIndexx])
{
LogError("Server %s:%s is down: no timely reply received", RSIPaddr[ServerIndexx], RSPort[ServerIndexx]);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("Server %s:%s is down: no timely reply received", RSIPaddr[ServerIndexx], RSPort[ServerIndexx]);
}
CloseHandle(socket[ServerIndexx]);
}
}
......@@ -1297,6 +1367,10 @@ public OnSocketDisconnected(Handle sock, int ServerIndexx)
public OnSocketError(Handle sock, const errorType, const errorNum, int ServerIndexx)
{
LogError("Server %s:%i is down: socket error %d (errno %d)", RSIPaddr[ServerIndexx], RSPort[ServerIndexx], errorType, errorNum);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("Server %s:%i is down: socket error %d (errno %d)", RSIPaddr[ServerIndexx], RSPort[ServerIndexx], errorType, errorNum);
}
socketError[ServerIndexx] = true;
UpdateSQLServerDown(ServerIndexx);
CloseHandle(sock);
......@@ -1308,9 +1382,12 @@ public Action UpdateSQL(int ServerIndexx)
//Vanilla server IP replacement, as it is a local server
//Vanilla IP:
//Vanilla local IP: 192.168.200.81:27016
if (StrEqual(RSaddrx[ServerIndexx], "192.168.200.81:27016") == true)
if (VanillaLocal == true)
{
Format(RSaddrx[ServerIndexx], 256, "80.112.155.100:27016");
if (StrEqual(RSaddrx[ServerIndexx], "192.168.200.81:27016") == true)
{
Format(RSaddrx[ServerIndexx], 256, "80.112.155.100:27016");
}
}
if (GetConVarInt(l_debug) == 1)
{
......@@ -1326,9 +1403,12 @@ public Action UpdateSQLServerDown(int ServerIndexx)
//Vanilla server IP replacement, as it is a local server
//Vanilla IP:
//Vanilla local IP: 192.168.200.81:27016
if (StrEqual(RSaddrx[ServerIndexx], "192.168.200.81:27016") == true)
if (VanillaLocal == true)
{
Format(RSaddrx[ServerIndexx], 256, "80.112.155.100:27016");
if (StrEqual(RSaddrx[ServerIndexx], "192.168.200.81:27016") == true)
{
Format(RSaddrx[ServerIndexx], 256, "80.112.155.100:27016");
}
}
char UpdateServerDown[512];
......@@ -1341,6 +1421,10 @@ public void UpdateServer_Handle(Handle uhDriver, Handle uhResult, const char[] s
if (uhResult == INVALID_HANDLE) {
// The result is invalid -> an error occured
LogError("[Database] SQL-Query failed! Error: %s", sError);
if (GetConVarInt(l_debug) == 1)
{
PrintToServer("[Database] SQL-Query failed! Error: %s", sError);
}
}
else
{
......
......@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "v0.1 WIP16"
"Latest" "v0.1 WIP17"
}
"Notes" "First release"
......@@ -32,6 +32,8 @@
"Notes" "WIP14: Added l_minplayersext for how many players needed on external server / active server"
"Notes" "WIP15: Remove showing current players from voting server list"
"Notes" "WIP16: Show maps in server vote choices"
"Notes" "WIP17: Apply Vanilla server IP fix only on backup lobby server"
"Notes" "WIP17: Added more messages showing in server console when l_debug is 1"
}
"Files"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment