mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 12:18:27 +00:00
Merge of a monster
This commit is contained in:
+139
-136
@@ -1,19 +1,19 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "../common/global_define.h"
|
||||
|
||||
@@ -41,27 +41,27 @@
|
||||
#include "client.h"
|
||||
#include "worlddb.h"
|
||||
#ifdef _WINDOWS
|
||||
#include <process.h>
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#include <conio.h>
|
||||
#include <process.h>
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#include <conio.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include "../common/unix.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/shm.h>
|
||||
#if not defined (FREEBSD) && not defined (DARWIN)
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
ushort *array;
|
||||
struct seminfo *__buf;
|
||||
void *__pad;
|
||||
};
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include "../common/unix.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/shm.h>
|
||||
#if not defined (FREEBSD) && not defined (DARWIN)
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
ushort *array;
|
||||
struct seminfo *__buf;
|
||||
void *__pad;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -91,7 +91,7 @@ ZSList zoneserver_list;
|
||||
LoginServerList loginserverlist;
|
||||
UCSConnection UCSLink;
|
||||
QueryServConnection QSLink;
|
||||
LauncherList launcher_list;
|
||||
LauncherList launcher_list;
|
||||
AdventureManager adventure_manager;
|
||||
EQEmu::Random emu_random;
|
||||
volatile bool RunLoops = true;
|
||||
@@ -99,20 +99,20 @@ uint32 numclients = 0;
|
||||
uint32 numzones = 0;
|
||||
bool holdzones = false;
|
||||
const WorldConfig *Config;
|
||||
EQEmuLogSys Log;
|
||||
EQEmuLogSys LogSys;
|
||||
WebInterfaceList web_interface;
|
||||
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
RegisterExecutablePlatform(ExePlatformWorld);
|
||||
Log.LoadLogSettingsDefaults();
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
/* Database Version Check */
|
||||
uint32 Database_Version = CURRENT_BINARY_DATABASE_VERSION;
|
||||
uint32 Bots_Database_Version = CURRENT_BINARY_BOTS_DATABASE_VERSION;
|
||||
if (argc >= 2) {
|
||||
if (argc >= 2) {
|
||||
if (strcasecmp(argv[1], "db_version") == 0) {
|
||||
std::cout << "Binary Database Version: " << Database_Version << " : " << Bots_Database_Version << std::endl;
|
||||
return 0;
|
||||
@@ -120,66 +120,67 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
// Load server configuration
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading server configuration..");
|
||||
Log(Logs::General, Logs::World_Server, "Loading server configuration..");
|
||||
if (!WorldConfig::LoadConfig()) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading server configuration failed.");
|
||||
Log(Logs::General, Logs::World_Server, "Loading server configuration failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Config = WorldConfig::get();
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "CURRENT_VERSION: %s", CURRENT_VERSION);
|
||||
Log(Logs::General, Logs::World_Server, "CURRENT_VERSION: %s", CURRENT_VERSION);
|
||||
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
Log(Logs::General, Logs::World_Server, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
|
||||
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
|
||||
Log(Logs::General, Logs::World_Server, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler");
|
||||
#ifndef WIN32
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
Log(Logs::General, Logs::World_Server, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// add login server config to list
|
||||
if (Config->LoginCount == 0) {
|
||||
if (Config->LoginHost.length()) {
|
||||
loginserverlist.Add(Config->LoginHost.c_str(), Config->LoginPort, Config->LoginAccount.c_str(), Config->LoginPassword.c_str(), Config->LoginLegacy);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort);
|
||||
Log(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort);
|
||||
}
|
||||
} else {
|
||||
LinkedList<LoginConfig*> loginlist=Config->loginlist;
|
||||
}
|
||||
else {
|
||||
LinkedList<LoginConfig*> loginlist = Config->loginlist;
|
||||
LinkedListIterator<LoginConfig*> iterator(loginlist);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
while (iterator.MoreElements()) {
|
||||
loginserverlist.Add(iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), iterator.GetData()->LoginPassword.c_str(),
|
||||
iterator.GetData()->LoginLegacy);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort);
|
||||
Log(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort);
|
||||
iterator.Advance();
|
||||
}
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Connecting to MySQL...");
|
||||
Log(Logs::General, Logs::World_Server, "Connecting to MySQL...");
|
||||
if (!database.Connect(
|
||||
Config->DatabaseHost.c_str(),
|
||||
Config->DatabaseUsername.c_str(),
|
||||
Config->DatabasePassword.c_str(),
|
||||
Config->DatabaseDB.c_str(),
|
||||
Config->DatabasePort)) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Cannot continue without a database connection.");
|
||||
Log(Logs::General, Logs::World_Server, "Cannot continue without a database connection.");
|
||||
return 1;
|
||||
}
|
||||
guild_mgr.SetDatabase(&database);
|
||||
|
||||
/* Register Log System and Settings */
|
||||
database.LoadLogSettings(Log.log_settings);
|
||||
Log.StartFileLogs();
|
||||
database.LoadLogSettings(LogSys.log_settings);
|
||||
LogSys.StartFileLogs();
|
||||
|
||||
bool ignore_db = false;
|
||||
if (argc >= 2) {
|
||||
@@ -227,7 +228,7 @@ int main(int argc, char** argv) {
|
||||
if (argc == 4) {
|
||||
if (Seperator::IsNumber(argv[3])) {
|
||||
if (atoi(argv[3]) >= 0 && atoi(argv[3]) <= 255) {
|
||||
if (database.SetAccountStatus(argv[2], atoi(argv[3]))){
|
||||
if (database.SetAccountStatus(argv[2], atoi(argv[3]))) {
|
||||
std::cout << "Account flagged: Username='" << argv[2] << "', status=" << argv[3] << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -266,7 +267,7 @@ int main(int argc, char** argv) {
|
||||
std::cout << "Usage: world startzone zoneshortname" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else if(strcasecmp(argv[1], "ignore_db") == 0) {
|
||||
else if (strcasecmp(argv[1], "ignore_db") == 0) {
|
||||
ignore_db = true;
|
||||
}
|
||||
else {
|
||||
@@ -275,100 +276,102 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!ignore_db) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Checking Database Conversions..");
|
||||
if (!ignore_db) {
|
||||
Log(Logs::General, Logs::World_Server, "Checking Database Conversions..");
|
||||
database.CheckDatabaseConversions();
|
||||
}
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading variables..");
|
||||
Log(Logs::General, Logs::World_Server, "Loading variables..");
|
||||
database.LoadVariables();
|
||||
|
||||
std::string hotfix_name;
|
||||
if(database.GetVariable("hotfix_name", hotfix_name)) {
|
||||
if (database.GetVariable("hotfix_name", hotfix_name)) {
|
||||
if (!hotfix_name.empty()) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str());
|
||||
Log(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading zones..");
|
||||
Log(Logs::General, Logs::World_Server, "Loading zones..");
|
||||
database.LoadZoneNames();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Clearing groups..");
|
||||
Log(Logs::General, Logs::World_Server, "Clearing groups..");
|
||||
database.ClearGroup();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Clearing raids..");
|
||||
Log(Logs::General, Logs::World_Server, "Clearing raids..");
|
||||
database.ClearRaid();
|
||||
database.ClearRaidDetails();
|
||||
database.ClearRaidLeader();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Clearing inventory snapshots..");
|
||||
Log(Logs::General, Logs::World_Server, "Clearing inventory snapshots..");
|
||||
database.ClearInvSnapshots();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading items..");
|
||||
if(!database.LoadItems(hotfix_name))
|
||||
Log.Out(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring");
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading skill caps..");
|
||||
if(!database.LoadSkillCaps(std::string(hotfix_name)))
|
||||
Log.Out(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring");
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading guilds..");
|
||||
Log(Logs::General, Logs::World_Server, "Loading items..");
|
||||
if (!database.LoadItems(hotfix_name))
|
||||
Log(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring");
|
||||
Log(Logs::General, Logs::World_Server, "Loading skill caps..");
|
||||
if (!database.LoadSkillCaps(std::string(hotfix_name)))
|
||||
Log(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring");
|
||||
Log(Logs::General, Logs::World_Server, "Loading guilds..");
|
||||
guild_mgr.LoadGuilds();
|
||||
//rules:
|
||||
{
|
||||
std::string tmp;
|
||||
if (database.GetVariable("RuleSet", tmp)) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading rule set '%s'", tmp.c_str());
|
||||
if(!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str());
|
||||
Log(Logs::General, Logs::World_Server, "Loading rule set '%s'", tmp.c_str());
|
||||
if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) {
|
||||
Log(Logs::General, Logs::World_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str());
|
||||
}
|
||||
} else {
|
||||
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "No rule set configured, using default rules");
|
||||
} else {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loaded default rule set 'default'", tmp.c_str());
|
||||
}
|
||||
else {
|
||||
if (!RuleManager::Instance()->LoadRules(&database, "default")) {
|
||||
Log(Logs::General, Logs::World_Server, "No rule set configured, using default rules");
|
||||
}
|
||||
else {
|
||||
Log(Logs::General, Logs::World_Server, "Loaded default rule set 'default'", tmp.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(RuleB(World, ClearTempMerchantlist)){
|
||||
Log.Out(Logs::General, Logs::World_Server, "Clearing temporary merchant lists..");
|
||||
if (RuleB(World, ClearTempMerchantlist)) {
|
||||
Log(Logs::General, Logs::World_Server, "Clearing temporary merchant lists..");
|
||||
database.ClearMerchantTemp();
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading EQ time of day..");
|
||||
Log(Logs::General, Logs::World_Server, "Loading EQ time of day..");
|
||||
TimeOfDay_Struct eqTime;
|
||||
time_t realtime;
|
||||
eqTime = database.LoadTime(realtime);
|
||||
zoneserver_list.worldclock.SetCurrentEQTimeOfDay(eqTime, realtime);
|
||||
Timer EQTimeTimer(600000);
|
||||
EQTimeTimer.Start(600000);
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading launcher list..");
|
||||
|
||||
Log(Logs::General, Logs::World_Server, "Loading launcher list..");
|
||||
launcher_list.LoadList();
|
||||
|
||||
std::string tmp;
|
||||
database.GetVariable("holdzones",tmp);
|
||||
database.GetVariable("holdzones", tmp);
|
||||
if (tmp.length() == 1 && tmp[0] == '1') {
|
||||
holdzones = true;
|
||||
}
|
||||
Log.Out(Logs::General, Logs::World_Server, "Reboot zone modes %s",holdzones ? "ON" : "OFF");
|
||||
Log(Logs::General, Logs::World_Server, "Reboot zone modes %s", holdzones ? "ON" : "OFF");
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses());
|
||||
Log(Logs::General, Logs::World_Server, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses());
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading adventures...");
|
||||
if(!adventure_manager.LoadAdventureTemplates())
|
||||
Log(Logs::General, Logs::World_Server, "Loading adventures...");
|
||||
if (!adventure_manager.LoadAdventureTemplates())
|
||||
{
|
||||
Log.Out(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
|
||||
Log(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
|
||||
}
|
||||
|
||||
if(!adventure_manager.LoadAdventureEntries())
|
||||
if (!adventure_manager.LoadAdventureEntries())
|
||||
{
|
||||
Log.Out(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
|
||||
Log(Logs::General, Logs::World_Server, "Unable to load adventure templates.");
|
||||
}
|
||||
|
||||
adventure_manager.Load();
|
||||
adventure_manager.LoadLeaderboardInfo();
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Purging expired instances");
|
||||
Log(Logs::General, Logs::World_Server, "Purging expired instances");
|
||||
database.PurgeExpiredInstances();
|
||||
Timer PurgeInstanceTimer(450000);
|
||||
PurgeInstanceTimer.Start(450000);
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading char create info...");
|
||||
Log(Logs::General, Logs::World_Server, "Loading char create info...");
|
||||
database.LoadCharacterCreateAllocations();
|
||||
database.LoadCharacterCreateCombos();
|
||||
|
||||
@@ -380,10 +383,10 @@ int main(int argc, char** argv) {
|
||||
server_opts.ipv6 = false;
|
||||
server_opts.credentials = Config->SharedKey;
|
||||
server_connection->Listen(server_opts);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Server (TCP) listener started.");
|
||||
Log(Logs::General, Logs::World_Server, "Server (TCP) listener started.");
|
||||
|
||||
server_connection->OnConnectionIdentified("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}",
|
||||
LogF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
numzones++;
|
||||
@@ -391,7 +394,7 @@ int main(int argc, char** argv) {
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}",
|
||||
LogF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
numzones--;
|
||||
@@ -399,56 +402,56 @@ int main(int argc, char** argv) {
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}",
|
||||
LogF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
launcher_list.Add(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("Launcher", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}",
|
||||
LogF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
launcher_list.Remove(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}",
|
||||
LogF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
QSLink.AddConnection(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
|
||||
LogF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
QSLink.RemoveConnection(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}",
|
||||
LogF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
UCSLink.SetConnection(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("UCS", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
|
||||
LogF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
UCSLink.SetConnection(nullptr);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New WebInterface Server connection from {2} at {0}:{1}",
|
||||
LogF(Logs::General, Logs::World_Server, "New WebInterface Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
web_interface.AddConnection(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("WebInterface", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed WebInterface Server connection from {0}",
|
||||
LogF(Logs::General, Logs::World_Server, "Removed WebInterface Server connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
web_interface.RemoveConnection(connection);
|
||||
@@ -472,10 +475,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||
stream_identifier.AddStream(stream);
|
||||
Log.OutF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
|
||||
LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
|
||||
});
|
||||
|
||||
while(RunLoops) {
|
||||
while (RunLoops) {
|
||||
Timer::SetCurrentTime();
|
||||
eqs = nullptr;
|
||||
|
||||
@@ -483,33 +486,34 @@ int main(int argc, char** argv) {
|
||||
stream_identifier.Process();
|
||||
|
||||
//check the stream identifier for any now-identified streams
|
||||
while((eqsi = stream_identifier.PopIdentified())) {
|
||||
while ((eqsi = stream_identifier.PopIdentified())) {
|
||||
//now that we know what patch they are running, start up their client object
|
||||
struct in_addr in;
|
||||
in.s_addr = eqsi->GetRemoteIP();
|
||||
if (RuleB(World, UseBannedIPsTable)){ //Lieka: Check to see if we have the responsibility for blocking IPs.
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in));
|
||||
if (!database.CheckBannedIPs(inet_ntoa(in))){ //Lieka: Check inbound IP against banned IP table.
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connection %s PASSED banned IPs check. Processing connection.", inet_ntoa(in));
|
||||
if (RuleB(World, UseBannedIPsTable)) { //Lieka: Check to see if we have the responsibility for blocking IPs.
|
||||
Log(Logs::Detail, Logs::World_Server, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in));
|
||||
if (!database.CheckBannedIPs(inet_ntoa(in))) { //Lieka: Check inbound IP against banned IP table.
|
||||
Log(Logs::Detail, Logs::World_Server, "Connection %s PASSED banned IPs check. Processing connection.", inet_ntoa(in));
|
||||
auto client = new Client(eqsi);
|
||||
// @merth: client->zoneattempt=0;
|
||||
client_list.Add(client);
|
||||
} else {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Connection from %s FAILED banned IPs check. Closing connection.", inet_ntoa(in));
|
||||
}
|
||||
else {
|
||||
Log(Logs::General, Logs::World_Server, "Connection from %s FAILED banned IPs check. Closing connection.", inet_ntoa(in));
|
||||
eqsi->Close(); //Lieka: If the inbound IP is on the banned table, close the EQStream.
|
||||
}
|
||||
}
|
||||
if (!RuleB(World, UseBannedIPsTable)){
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
|
||||
auto client = new Client(eqsi);
|
||||
// @merth: client->zoneattempt=0;
|
||||
client_list.Add(client);
|
||||
if (!RuleB(World, UseBannedIPsTable)) {
|
||||
Log(Logs::Detail, Logs::World_Server, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
|
||||
auto client = new Client(eqsi);
|
||||
// @merth: client->zoneattempt=0;
|
||||
client_list.Add(client);
|
||||
}
|
||||
}
|
||||
|
||||
client_list.Process();
|
||||
|
||||
if(PurgeInstanceTimer.Check())
|
||||
if (PurgeInstanceTimer.Check())
|
||||
{
|
||||
database.PurgeExpiredInstances();
|
||||
}
|
||||
@@ -519,36 +523,36 @@ int main(int argc, char** argv) {
|
||||
TimeOfDay_Struct tod;
|
||||
zoneserver_list.worldclock.GetCurrentEQTimeOfDay(time(0), &tod);
|
||||
if (!database.SaveTime(tod.minute, tod.hour, tod.day, tod.month, tod.year))
|
||||
Log.Out(Logs::General, Logs::World_Server, "Failed to save eqtime.");
|
||||
Log(Logs::General, Logs::World_Server, "Failed to save eqtime.");
|
||||
else
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "EQTime successfully saved.");
|
||||
Log(Logs::Detail, Logs::World_Server, "EQTime successfully saved.");
|
||||
}
|
||||
|
||||
|
||||
zoneserver_list.Process();
|
||||
launcher_list.Process();
|
||||
LFPGroupList.Process();
|
||||
LFPGroupList.Process();
|
||||
adventure_manager.Process();
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
database.ping();
|
||||
}
|
||||
|
||||
|
||||
EQ::EventLoop::Get().Process();
|
||||
Sleep(5);
|
||||
}
|
||||
Log.Out(Logs::General, Logs::World_Server, "World main loop completed.");
|
||||
Log.Out(Logs::General, Logs::World_Server, "Shutting down zone connections (if any).");
|
||||
Log(Logs::General, Logs::World_Server, "World main loop completed.");
|
||||
Log(Logs::General, Logs::World_Server, "Shutting down zone connections (if any).");
|
||||
zoneserver_list.KillAll();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped.");
|
||||
Log.Out(Logs::General, Logs::World_Server, "Signaling HTTP service to stop...");
|
||||
Log.CloseFileLogs();
|
||||
Log(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped.");
|
||||
Log(Logs::General, Logs::World_Server, "Signaling HTTP service to stop...");
|
||||
LogSys.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
Log.Out(Logs::General, Logs::World_Server,"Caught signal %d",sig_num);
|
||||
Log(Logs::General, Logs::World_Server, "Caught signal %d", sig_num);
|
||||
RunLoops = false;
|
||||
}
|
||||
|
||||
@@ -564,4 +568,3 @@ void UpdateWindowTitle(char* iNewTitle) {
|
||||
SetConsoleTitle(tmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user