mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-26 05:38:06 +00:00
Merge of a monster
This commit is contained in:
+240
-233
@@ -1,19 +1,19 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org)
|
||||
Copyright (C) 2001-2016 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
|
||||
*/
|
||||
|
||||
#define DONT_SHARED_OPCODES
|
||||
@@ -79,16 +79,16 @@
|
||||
#include <chrono>
|
||||
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#undef new
|
||||
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||
#undef new
|
||||
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <conio.h>
|
||||
#include <process.h>
|
||||
#include <conio.h>
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include "../common/unix.h"
|
||||
#include <pthread.h>
|
||||
#include "../common/unix.h"
|
||||
#endif
|
||||
|
||||
volatile bool RunLoops = true;
|
||||
@@ -105,7 +105,7 @@ TitleManager title_manager;
|
||||
QueryServ *QServ = 0;
|
||||
TaskManager *taskmanager = 0;
|
||||
QuestParserCollection *parse = 0;
|
||||
EQEmuLogSys Log;
|
||||
EQEmuLogSys LogSys;
|
||||
const SPDat_Spell_Struct* spells;
|
||||
int32 SPDAT_RECORDS = -1;
|
||||
const ZoneConfig *Config;
|
||||
@@ -115,10 +115,10 @@ void Shutdown();
|
||||
extern void MapOpcodes();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
RegisterExecutablePlatform(ExePlatformZone);
|
||||
Log.LoadLogSettingsDefaults();
|
||||
RegisterExecutablePlatform(ExePlatformZone);
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
|
||||
set_exception_handler();
|
||||
set_exception_handler();
|
||||
|
||||
#ifdef USE_MAP_MMFS
|
||||
if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) {
|
||||
@@ -135,16 +135,16 @@ int main(int argc, char** argv) {
|
||||
auto success = m->Load(filename, true);
|
||||
delete m;
|
||||
std::cout << mapfile.c_str() << " conversion " << (success ? "succeeded" : "failed") << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /*USE_MAP_MMFS*/
|
||||
|
||||
QServ = new QueryServ;
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading server configuration..");
|
||||
if(!ZoneConfig::LoadConfig()) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading server configuration failed.");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading server configuration..");
|
||||
if (!ZoneConfig::LoadConfig()) {
|
||||
Log(Logs::General, Logs::Error, "Loading server configuration failed.");
|
||||
return 1;
|
||||
}
|
||||
Config = ZoneConfig::get();
|
||||
@@ -152,81 +152,85 @@ int main(int argc, char** argv) {
|
||||
const char *zone_name;
|
||||
uint32 instance_id = 0;
|
||||
std::string z_name;
|
||||
if(argc == 4) {
|
||||
if (argc == 4) {
|
||||
instance_id = atoi(argv[3]);
|
||||
worldserver.SetLauncherName(argv[2]);
|
||||
auto zone_port = SplitString(argv[1], ':');
|
||||
|
||||
if(!zone_port.empty()) {
|
||||
if (!zone_port.empty()) {
|
||||
z_name = zone_port[0];
|
||||
}
|
||||
|
||||
if(zone_port.size() > 1) {
|
||||
if (zone_port.size() > 1) {
|
||||
std::string p_name = zone_port[1];
|
||||
Config->SetZonePort(atoi(p_name.c_str()));
|
||||
}
|
||||
|
||||
worldserver.SetLaunchedName(z_name.c_str());
|
||||
if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
|
||||
if (strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
|
||||
zone_name = ".";
|
||||
}
|
||||
else {
|
||||
zone_name = z_name.c_str();
|
||||
}
|
||||
} else if(argc == 3) {
|
||||
}
|
||||
else if (argc == 3) {
|
||||
worldserver.SetLauncherName(argv[2]);
|
||||
auto zone_port = SplitString(argv[1], ':');
|
||||
|
||||
if(!zone_port.empty()) {
|
||||
if (!zone_port.empty()) {
|
||||
z_name = zone_port[0];
|
||||
}
|
||||
|
||||
if(zone_port.size() > 1) {
|
||||
if (zone_port.size() > 1) {
|
||||
std::string p_name = zone_port[1];
|
||||
Config->SetZonePort(atoi(p_name.c_str()));
|
||||
}
|
||||
|
||||
worldserver.SetLaunchedName(z_name.c_str());
|
||||
if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
|
||||
zone_name = ".";
|
||||
} else {
|
||||
zone_name = z_name.c_str();
|
||||
}
|
||||
} else if (argc == 2) {
|
||||
worldserver.SetLauncherName("NONE");
|
||||
auto zone_port = SplitString(argv[1], ':');
|
||||
|
||||
if(!zone_port.empty()) {
|
||||
z_name = zone_port[0];
|
||||
}
|
||||
|
||||
if(zone_port.size() > 1) {
|
||||
std::string p_name = zone_port[1];
|
||||
Config->SetZonePort(atoi(p_name.c_str()));
|
||||
}
|
||||
|
||||
worldserver.SetLaunchedName(z_name.c_str());
|
||||
if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
|
||||
if (strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
|
||||
zone_name = ".";
|
||||
}
|
||||
else {
|
||||
zone_name = z_name.c_str();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else if (argc == 2) {
|
||||
worldserver.SetLauncherName("NONE");
|
||||
auto zone_port = SplitString(argv[1], ':');
|
||||
|
||||
if (!zone_port.empty()) {
|
||||
z_name = zone_port[0];
|
||||
}
|
||||
|
||||
if (zone_port.size() > 1) {
|
||||
std::string p_name = zone_port[1];
|
||||
Config->SetZonePort(atoi(p_name.c_str()));
|
||||
}
|
||||
|
||||
worldserver.SetLaunchedName(z_name.c_str());
|
||||
if (strncmp(z_name.c_str(), "dynamic_", 8) == 0) {
|
||||
zone_name = ".";
|
||||
}
|
||||
else {
|
||||
zone_name = z_name.c_str();
|
||||
}
|
||||
}
|
||||
else {
|
||||
zone_name = ".";
|
||||
worldserver.SetLaunchedName(".");
|
||||
worldserver.SetLauncherName("NONE");
|
||||
}
|
||||
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Connecting to MySQL...");
|
||||
|
||||
Log(Logs::General, Logs::Zone_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::Error, "Cannot continue without a database connection.");
|
||||
Log(Logs::General, Logs::Error, "Cannot continue without a database connection.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -237,148 +241,150 @@ int main(int argc, char** argv) {
|
||||
Config->DatabasePassword.c_str(),
|
||||
Config->DatabaseDB.c_str(),
|
||||
Config->DatabasePort)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Cannot continue without a bots database connection.");
|
||||
Log(Logs::General, Logs::Error, "Cannot continue without a bots database connection.");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Register Log System and Settings */
|
||||
Log.OnLogHookCallBackZone(&Zone::GMSayHookCallBackProcess);
|
||||
database.LoadLogSettings(Log.log_settings);
|
||||
Log.StartFileLogs();
|
||||
LogSys.OnLogHookCallBackZone(&Zone::GMSayHookCallBackProcess);
|
||||
database.LoadLogSettings(LogSys.log_settings);
|
||||
LogSys.StartFileLogs();
|
||||
|
||||
/* Guilds */
|
||||
guild_mgr.SetDatabase(&database);
|
||||
GuildBanks = nullptr;
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "CURRENT_VERSION: %s", CURRENT_VERSION);
|
||||
Log(Logs::General, Logs::Zone_Server, "CURRENT_VERSION: %s", CURRENT_VERSION);
|
||||
|
||||
/*
|
||||
* Setup nice signal handlers
|
||||
*/
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
Log.Out(Logs::General, Logs::Error, "Could not set signal handler");
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
Log(Logs::General, Logs::Error, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
|
||||
Log.Out(Logs::General, Logs::Error, "Could not set signal handler");
|
||||
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
|
||||
Log(Logs::General, Logs::Error, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
#ifndef WIN32
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
Log.Out(Logs::General, Logs::Error, "Could not set signal handler");
|
||||
#ifndef WIN32
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
Log(Logs::General, Logs::Error, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Mapping Incoming Opcodes");
|
||||
Log(Logs::General, Logs::Zone_Server, "Mapping Incoming Opcodes");
|
||||
MapOpcodes();
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading Variables");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading Variables");
|
||||
database.LoadVariables();
|
||||
|
||||
std::string 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());
|
||||
if (database.GetVariable("hotfix_name", hotfix_name)) {
|
||||
if (!hotfix_name.empty()) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading zone names");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading zone names");
|
||||
database.LoadZoneNames();
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading items");
|
||||
if(!database.LoadItems(hotfix_name)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading items FAILED!");
|
||||
Log.Out(Logs::General, Logs::Error, "Failed. But ignoring error and going on...");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading items");
|
||||
if (!database.LoadItems(hotfix_name)) {
|
||||
Log(Logs::General, Logs::Error, "Loading items FAILED!");
|
||||
Log(Logs::General, Logs::Error, "Failed. But ignoring error and going on...");
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading npc faction lists");
|
||||
if(!database.LoadNPCFactionLists(hotfix_name)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading npc faction lists");
|
||||
if (!database.LoadNPCFactionLists(hotfix_name)) {
|
||||
Log(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!");
|
||||
return 1;
|
||||
}
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading loot tables");
|
||||
if(!database.LoadLoot(hotfix_name)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading loot FAILED!");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading loot tables");
|
||||
if (!database.LoadLoot(hotfix_name)) {
|
||||
Log(Logs::General, Logs::Error, "Loading loot FAILED!");
|
||||
return 1;
|
||||
}
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading skill caps");
|
||||
if(!database.LoadSkillCaps(std::string(hotfix_name))) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading skill caps FAILED!");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading skill caps");
|
||||
if (!database.LoadSkillCaps(std::string(hotfix_name))) {
|
||||
Log(Logs::General, Logs::Error, "Loading skill caps FAILED!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading spells");
|
||||
if(!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading spells FAILED!");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading spells");
|
||||
if (!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) {
|
||||
Log(Logs::General, Logs::Error, "Loading spells FAILED!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading base data");
|
||||
if(!database.LoadBaseData(hotfix_name)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Loading base data FAILED!");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading base data");
|
||||
if (!database.LoadBaseData(hotfix_name)) {
|
||||
Log(Logs::General, Logs::Error, "Loading base data FAILED!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading guilds");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading guilds");
|
||||
guild_mgr.LoadGuilds();
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading factions");
|
||||
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading factions");
|
||||
database.LoadFactionData();
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading titles");
|
||||
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading titles");
|
||||
title_manager.LoadTitles();
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading tributes");
|
||||
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading tributes");
|
||||
database.LoadTributes();
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading corpse timers");
|
||||
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading corpse timers");
|
||||
database.GetDecayTimes(npcCorpseDecayTimes);
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading commands");
|
||||
int retval=command_init();
|
||||
if(retval<0)
|
||||
Log.Out(Logs::General, Logs::Error, "Command loading FAILED");
|
||||
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading commands");
|
||||
int retval = command_init();
|
||||
if (retval<0)
|
||||
Log(Logs::General, Logs::Error, "Command loading FAILED");
|
||||
else
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "%d commands loaded", retval);
|
||||
Log(Logs::General, Logs::Zone_Server, "%d commands loaded", retval);
|
||||
|
||||
//rules:
|
||||
{
|
||||
std::string tmp;
|
||||
if (database.GetVariable("RuleSet", tmp)) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading rule set '%s'", tmp.c_str());
|
||||
if(!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) {
|
||||
Log.Out(Logs::General, Logs::Error, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str());
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading rule set '%s'", tmp.c_str());
|
||||
if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) {
|
||||
Log(Logs::General, Logs::Error, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str());
|
||||
}
|
||||
} else {
|
||||
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "No rule set configured, using default rules");
|
||||
} else {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loaded default rule set 'default'", tmp.c_str());
|
||||
}
|
||||
else {
|
||||
if (!RuleManager::Instance()->LoadRules(&database, "default")) {
|
||||
Log(Logs::General, Logs::Zone_Server, "No rule set configured, using default rules");
|
||||
}
|
||||
else {
|
||||
Log(Logs::General, Logs::Zone_Server, "Loaded default rule set 'default'", tmp.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOTS
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading bot commands");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading bot commands");
|
||||
int botretval = bot_command_init();
|
||||
if (botretval<0)
|
||||
Log.Out(Logs::General, Logs::Error, "Bot command loading FAILED");
|
||||
Log(Logs::General, Logs::Error, "Bot command loading FAILED");
|
||||
else
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "%d bot commands loaded", botretval);
|
||||
Log(Logs::General, Logs::Zone_Server, "%d bot commands loaded", botretval);
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading bot spell casting chances");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading bot spell casting chances");
|
||||
if (!botdb.LoadBotSpellCastingChances())
|
||||
Log.Out(Logs::General, Logs::Error, "Bot spell casting chances loading FAILED");
|
||||
Log(Logs::General, Logs::Error, "Bot spell casting chances loading FAILED");
|
||||
#endif
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
Log.Out(Logs::General, Logs::Tasks, "[INIT] Loading Tasks");
|
||||
if (RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
Log(Logs::General, Logs::Tasks, "[INIT] Loading Tasks");
|
||||
taskmanager = new TaskManager;
|
||||
taskmanager->LoadTasks();
|
||||
}
|
||||
@@ -399,7 +405,7 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
|
||||
//now we have our parser, load the quests
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading quests");
|
||||
Log(Logs::General, Logs::Zone_Server, "Loading quests");
|
||||
parse->ReloadQuests();
|
||||
|
||||
worldserver.Connect();
|
||||
@@ -407,14 +413,15 @@ int main(int argc, char** argv) {
|
||||
Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect
|
||||
#ifdef EQPROFILE
|
||||
#ifdef PROFILE_DUMP_TIME
|
||||
Timer profile_dump_timer(PROFILE_DUMP_TIME*1000);
|
||||
Timer profile_dump_timer(PROFILE_DUMP_TIME * 1000);
|
||||
profile_dump_timer.Start();
|
||||
#endif
|
||||
#endif
|
||||
if (!strlen(zone_name) || !strcmp(zone_name,".")) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Entering sleep mode");
|
||||
} else if (!Zone::Bootup(database.GetZoneID(zone_name), instance_id, true)) {
|
||||
Log.Out(Logs::General, Logs::Error, "Zone Bootup failed :: Zone::Bootup");
|
||||
if (!strlen(zone_name) || !strcmp(zone_name, ".")) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Entering sleep mode");
|
||||
}
|
||||
else if (!Zone::Bootup(database.GetZoneID(zone_name), instance_id, true)) {
|
||||
Log(Logs::General, Logs::Error, "Zone Bootup failed :: Zone::Bootup");
|
||||
zone = 0;
|
||||
}
|
||||
|
||||
@@ -423,7 +430,7 @@ int main(int argc, char** argv) {
|
||||
RegisterAllPatches(stream_identifier);
|
||||
|
||||
#ifndef WIN32
|
||||
Log.Out(Logs::Detail, Logs::None, "Main thread running with thread id %d", pthread_self());
|
||||
Log(Logs::Detail, Logs::None, "Main thread running with thread id %d", pthread_self());
|
||||
#endif
|
||||
|
||||
Timer quest_timers(100);
|
||||
@@ -436,94 +443,94 @@ int main(int argc, char** argv) {
|
||||
std::chrono::time_point<std::chrono::system_clock> frame_prev = std::chrono::system_clock::now();
|
||||
|
||||
EQ::Timer process_timer(32, true, [&](EQ::Timer* t) {
|
||||
//Advance the timer to our current point in time
|
||||
Timer::SetCurrentTime();
|
||||
//Advance the timer to our current point in time
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
//Calculate frame time
|
||||
std::chrono::time_point<std::chrono::system_clock> frame_now = std::chrono::system_clock::now();
|
||||
frame_time = std::chrono::duration_cast<std::chrono::milliseconds>(frame_now - frame_prev).count();
|
||||
frame_prev = frame_now;
|
||||
|
||||
if (!eqsf_open && Config->ZonePort != 0) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort);
|
||||
|
||||
EQ::Net::EQStreamManagerOptions opts(Config->ZonePort, false, false);
|
||||
eqsm.reset(new EQ::Net::EQStreamManager(opts));
|
||||
eqsf_open = true;
|
||||
|
||||
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()));
|
||||
});
|
||||
}
|
||||
|
||||
//give the stream identifier a chance to do its work....
|
||||
stream_identifier.Process();
|
||||
|
||||
//check the stream identifier for any now-identified streams
|
||||
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();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "New client from %s:%d", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
|
||||
auto client = new Client(eqsi);
|
||||
entity_list.AddClient(client);
|
||||
}
|
||||
|
||||
if (worldserver.Connected()) {
|
||||
worldwasconnected = true;
|
||||
}
|
||||
else {
|
||||
if (worldwasconnected && is_zone_loaded)
|
||||
entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost");
|
||||
worldwasconnected = false;
|
||||
}
|
||||
|
||||
if (is_zone_loaded) {
|
||||
{
|
||||
if(net.group_timer.Enabled() && net.group_timer.Check())
|
||||
entity_list.GroupProcess();
|
||||
|
||||
if(net.door_timer.Enabled() && net.door_timer.Check())
|
||||
entity_list.DoorProcess();
|
||||
|
||||
if(net.object_timer.Enabled() && net.object_timer.Check())
|
||||
entity_list.ObjectProcess();
|
||||
|
||||
if(net.corpse_timer.Enabled() && net.corpse_timer.Check())
|
||||
entity_list.CorpseProcess();
|
||||
|
||||
if(net.trap_timer.Enabled() && net.trap_timer.Check())
|
||||
entity_list.TrapProcess();
|
||||
|
||||
if(net.raid_timer.Enabled() && net.raid_timer.Check())
|
||||
entity_list.RaidProcess();
|
||||
|
||||
entity_list.Process();
|
||||
entity_list.MobProcess();
|
||||
entity_list.BeaconProcess();
|
||||
entity_list.EncounterProcess();
|
||||
|
||||
if (zone) {
|
||||
if(!zone->Process()) {
|
||||
Zone::Shutdown();
|
||||
}
|
||||
//Calculate frame time
|
||||
std::chrono::time_point<std::chrono::system_clock> frame_now = std::chrono::system_clock::now();
|
||||
frame_time = std::chrono::duration_cast<std::chrono::milliseconds>(frame_now - frame_prev).count();
|
||||
frame_prev = frame_now;
|
||||
|
||||
if (!eqsf_open && Config->ZonePort != 0) {
|
||||
Log(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort);
|
||||
|
||||
EQ::Net::EQStreamManagerOptions opts(Config->ZonePort, false, true);
|
||||
eqsm.reset(new EQ::Net::EQStreamManager(opts));
|
||||
eqsf_open = true;
|
||||
|
||||
eqsm->OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
|
||||
stream_identifier.AddStream(stream);
|
||||
LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
|
||||
});
|
||||
}
|
||||
|
||||
//give the stream identifier a chance to do its work....
|
||||
stream_identifier.Process();
|
||||
|
||||
//check the stream identifier for any now-identified streams
|
||||
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();
|
||||
Log(Logs::Detail, Logs::World_Server, "New client from %s:%d", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
|
||||
auto client = new Client(eqsi);
|
||||
entity_list.AddClient(client);
|
||||
}
|
||||
|
||||
if (worldserver.Connected()) {
|
||||
worldwasconnected = true;
|
||||
}
|
||||
else {
|
||||
if (worldwasconnected && is_zone_loaded)
|
||||
entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost");
|
||||
worldwasconnected = false;
|
||||
}
|
||||
|
||||
if (is_zone_loaded) {
|
||||
{
|
||||
if (net.group_timer.Enabled() && net.group_timer.Check())
|
||||
entity_list.GroupProcess();
|
||||
|
||||
if (net.door_timer.Enabled() && net.door_timer.Check())
|
||||
entity_list.DoorProcess();
|
||||
|
||||
if (net.object_timer.Enabled() && net.object_timer.Check())
|
||||
entity_list.ObjectProcess();
|
||||
|
||||
if (net.corpse_timer.Enabled() && net.corpse_timer.Check())
|
||||
entity_list.CorpseProcess();
|
||||
|
||||
if (net.trap_timer.Enabled() && net.trap_timer.Check())
|
||||
entity_list.TrapProcess();
|
||||
|
||||
if (net.raid_timer.Enabled() && net.raid_timer.Check())
|
||||
entity_list.RaidProcess();
|
||||
|
||||
entity_list.Process();
|
||||
entity_list.MobProcess();
|
||||
entity_list.BeaconProcess();
|
||||
entity_list.EncounterProcess();
|
||||
|
||||
if (zone) {
|
||||
if (!zone->Process()) {
|
||||
Zone::Shutdown();
|
||||
}
|
||||
|
||||
if(quest_timers.Check())
|
||||
quest_manager.Process();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
entity_list.UpdateWho();
|
||||
if (quest_timers.Check())
|
||||
quest_manager.Process();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
entity_list.UpdateWho();
|
||||
}
|
||||
});
|
||||
|
||||
while(RunLoops) {
|
||||
|
||||
while (RunLoops) {
|
||||
EQ::EventLoop::Get().Process();
|
||||
if (is_zone_loaded) {
|
||||
Sleep(1);
|
||||
@@ -539,7 +546,7 @@ int main(int argc, char** argv) {
|
||||
parse->ClearInterfaces();
|
||||
|
||||
#ifdef EMBPERL
|
||||
safe_delete(perl_parser);
|
||||
safe_delete(perl_parser);
|
||||
#endif
|
||||
|
||||
#ifdef LUA_EQEMU
|
||||
@@ -557,14 +564,14 @@ int main(int argc, char** argv) {
|
||||
bot_command_deinit();
|
||||
#endif
|
||||
safe_delete(parse);
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Proper zone shutdown complete.");
|
||||
Log.CloseFileLogs();
|
||||
Log(Logs::General, Logs::Zone_Server, "Proper zone shutdown complete.");
|
||||
LogSys.CloseFileLogs();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
#ifdef _WINDOWS
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Recieved signal: %i", sig_num);
|
||||
Log(Logs::General, Logs::Zone_Server, "Recieved signal: %i", sig_num);
|
||||
#endif
|
||||
RunLoops = false;
|
||||
}
|
||||
@@ -573,13 +580,13 @@ void Shutdown()
|
||||
{
|
||||
Zone::Shutdown(true);
|
||||
RunLoops = false;
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Shutting down...");
|
||||
Log.CloseFileLogs();
|
||||
Log(Logs::General, Logs::Zone_Server, "Shutting down...");
|
||||
LogSys.CloseFileLogs();
|
||||
}
|
||||
|
||||
uint32 NetConnection::GetIP()
|
||||
{
|
||||
char name[255+1];
|
||||
char name[255 + 1];
|
||||
size_t len = 0;
|
||||
hostent* host = 0;
|
||||
|
||||
@@ -612,7 +619,7 @@ uint32 NetConnection::GetIP(char* name)
|
||||
}
|
||||
|
||||
NetConnection::NetConnection()
|
||||
:
|
||||
:
|
||||
object_timer(5000),
|
||||
door_timer(5000),
|
||||
corpse_timer(2000),
|
||||
@@ -640,20 +647,20 @@ void UpdateWindowTitle(char* iNewTitle) {
|
||||
}
|
||||
else {
|
||||
if (zone) {
|
||||
#if defined(GOTFRAGS) || defined(_EQDEBUG)
|
||||
snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid());
|
||||
#else
|
||||
#if defined(GOTFRAGS) || defined(_EQDEBUG)
|
||||
snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid());
|
||||
#else
|
||||
snprintf(tmp, sizeof(tmp), "%s :: clients: %i inst_id: %i inst_ver: %i :: port: %i", zone->GetShortName(), numclients, zone->GetInstanceID(), zone->GetInstanceVersion(), ZoneConfig::get()->ZonePort);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if defined(GOTFRAGS) || defined(_EQDEBUG)
|
||||
snprintf(tmp, sizeof(tmp), "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid());
|
||||
#else
|
||||
snprintf(tmp, sizeof(tmp), "%i: sleeping", ZoneConfig::get()->ZonePort);
|
||||
#endif
|
||||
#if defined(GOTFRAGS) || defined(_EQDEBUG)
|
||||
snprintf(tmp, sizeof(tmp), "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid());
|
||||
#else
|
||||
snprintf(tmp, sizeof(tmp), "%i: sleeping", ZoneConfig::get()->ZonePort);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
SetConsoleTitle(tmp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user