Core/World: Set realm status as invalid during startup and online when initialized
--HG-- branch : trunk
This commit is contained in:
@@ -131,6 +131,7 @@ include_directories(
|
|||||||
${CMAKE_SOURCE_DIR}/src/server/game/Tools
|
${CMAKE_SOURCE_DIR}/src/server/game/Tools
|
||||||
${CMAKE_SOURCE_DIR}/src/server/game/Weather
|
${CMAKE_SOURCE_DIR}/src/server/game/Weather
|
||||||
${CMAKE_SOURCE_DIR}/src/server/game/World
|
${CMAKE_SOURCE_DIR}/src/server/game/World
|
||||||
|
${CMAKE_SOURCE_DIR}/src/server/authserver/Server
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CommandLine
|
${CMAKE_CURRENT_SOURCE_DIR}/CommandLine
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/RemoteAccess
|
${CMAKE_CURRENT_SOURCE_DIR}/RemoteAccess
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "TCSoap.h"
|
#include "TCSoap.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include "AuthSocket.h"
|
||||||
|
|
||||||
#include "BigNumber.h"
|
#include "BigNumber.h"
|
||||||
|
|
||||||
@@ -122,44 +123,47 @@ int Master::Run()
|
|||||||
BigNumber seed1;
|
BigNumber seed1;
|
||||||
seed1.SetRand(16 * 8);
|
seed1.SetRand(16 * 8);
|
||||||
|
|
||||||
sLog->outString( "%s (core-daemon)", _FULLVERSION );
|
sLog->outString("%s (core-daemon)", _FULLVERSION);
|
||||||
sLog->outString( "<Ctrl-C> to stop.\n" );
|
sLog->outString("<Ctrl-C> to stop.\n");
|
||||||
|
|
||||||
sLog->outString( " ______ __");
|
sLog->outString(" ______ __");
|
||||||
sLog->outString( "/\\__ _\\ __ __/\\ \\__");
|
sLog->outString("/\\__ _\\ __ __/\\ \\__");
|
||||||
sLog->outString( "\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\ ,_\\ __ __");
|
sLog->outString("\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\ ,_\\ __ __");
|
||||||
sLog->outString( " \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\");
|
sLog->outString(" \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\");
|
||||||
sLog->outString( " \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\");
|
sLog->outString(" \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\");
|
||||||
sLog->outString( " \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\");
|
sLog->outString(" \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\");
|
||||||
sLog->outString( " \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\");
|
sLog->outString(" \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\");
|
||||||
sLog->outString( " C O R E /\\___/");
|
sLog->outString(" C O R E /\\___/");
|
||||||
sLog->outString( "http://TrinityCore.org \\/__/\n");
|
sLog->outString("http://TrinityCore.org \\/__/\n");
|
||||||
|
|
||||||
#ifdef USE_SFMT_FOR_RNG
|
#ifdef USE_SFMT_FOR_RNG
|
||||||
sLog->outString( "\n");
|
sLog->outString("\n");
|
||||||
sLog->outString( "SFMT has been enabled as the random number generator, if worldserver");
|
sLog->outString("SFMT has been enabled as the random number generator, if worldserver");
|
||||||
sLog->outString( "freezes or crashes randomly, first, try disabling SFMT in CMAKE configuration");
|
sLog->outString("freezes or crashes randomly, first, try disabling SFMT in CMAKE configuration");
|
||||||
sLog->outString( "\n");
|
sLog->outString("\n");
|
||||||
#endif //USE_SFMT_FOR_RNG
|
#endif //USE_SFMT_FOR_RNG
|
||||||
|
|
||||||
/// worldd PID file creation
|
/// worldd PID file creation
|
||||||
std::string pidfile = sConfig->GetStringDefault("PidFile", "");
|
std::string pidfile = sConfig->GetStringDefault("PidFile", "");
|
||||||
if(!pidfile.empty())
|
if (!pidfile.empty())
|
||||||
{
|
{
|
||||||
uint32 pid = CreatePIDFile(pidfile);
|
uint32 pid = CreatePIDFile(pidfile);
|
||||||
if( !pid )
|
if (!pid)
|
||||||
{
|
{
|
||||||
sLog->outError( "Cannot create PID file %s.\n", pidfile.c_str() );
|
sLog->outError("Cannot create PID file %s.\n", pidfile.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog->outString( "Daemon PID: %u\n", pid );
|
sLog->outString("Daemon PID: %u\n", pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
///- Start the databases
|
///- Start the databases
|
||||||
if (!_StartDB())
|
if (!_StartDB())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
// set server offline (not connectable)
|
||||||
|
LoginDatabase.DirectPExecute("UPDATE realmlist SET color = (color & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID);
|
||||||
|
|
||||||
///- Initialize the World
|
///- Initialize the World
|
||||||
sWorld->SetInitialWorldSettings();
|
sWorld->SetInitialWorldSettings();
|
||||||
|
|
||||||
@@ -183,9 +187,6 @@ int Master::Run()
|
|||||||
ACE_Based::Thread world_thread(new WorldRunnable);
|
ACE_Based::Thread world_thread(new WorldRunnable);
|
||||||
world_thread.setPriority(ACE_Based::Highest);
|
world_thread.setPriority(ACE_Based::Highest);
|
||||||
|
|
||||||
// set server online
|
|
||||||
LoginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID);
|
|
||||||
|
|
||||||
ACE_Based::Thread* cliThread = NULL;
|
ACE_Based::Thread* cliThread = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -206,25 +207,25 @@ int Master::Run()
|
|||||||
HANDLE hProcess = GetCurrentProcess();
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
|
|
||||||
uint32 Aff = sConfig->GetIntDefault("UseProcessors", 0);
|
uint32 Aff = sConfig->GetIntDefault("UseProcessors", 0);
|
||||||
if(Aff > 0)
|
if (Aff > 0)
|
||||||
{
|
{
|
||||||
ULONG_PTR appAff;
|
ULONG_PTR appAff;
|
||||||
ULONG_PTR sysAff;
|
ULONG_PTR sysAff;
|
||||||
|
|
||||||
if(GetProcessAffinityMask(hProcess,&appAff,&sysAff))
|
if (GetProcessAffinityMask(hProcess,&appAff,&sysAff))
|
||||||
{
|
{
|
||||||
ULONG_PTR curAff = Aff & appAff; // remove non accessible processors
|
ULONG_PTR curAff = Aff & appAff; // remove non accessible processors
|
||||||
|
|
||||||
if(!curAff )
|
if (!curAff)
|
||||||
{
|
{
|
||||||
sLog->outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for Trinityd. Accessible processors bitmask (hex): %x",Aff,appAff);
|
sLog->outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for Trinityd. Accessible processors bitmask (hex): %x",Aff,appAff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(SetProcessAffinityMask(hProcess,curAff))
|
if (SetProcessAffinityMask(hProcess,curAff))
|
||||||
sLog->outString("Using processors (bitmask, hex): %x", curAff);
|
sLog->outString("Using processors (bitmask, hex): %x", curAff);
|
||||||
else
|
else
|
||||||
sLog->outError("Can't set used processors (hex): %x",curAff);
|
sLog->outError("Can't set used processors (hex): %x", curAff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sLog->outString("");
|
sLog->outString("");
|
||||||
@@ -232,8 +233,8 @@ int Master::Run()
|
|||||||
|
|
||||||
bool Prio = sConfig->GetBoolDefault("ProcessPriority", false);
|
bool Prio = sConfig->GetBoolDefault("ProcessPriority", false);
|
||||||
|
|
||||||
// if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/)
|
//if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/)
|
||||||
if(Prio)
|
if (Prio)
|
||||||
{
|
{
|
||||||
if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
|
if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS))
|
||||||
sLog->outString("TrinityCore process priority class set to HIGH");
|
sLog->outString("TrinityCore process priority class set to HIGH");
|
||||||
@@ -246,7 +247,7 @@ int Master::Run()
|
|||||||
//Start soap serving thread
|
//Start soap serving thread
|
||||||
ACE_Based::Thread* soap_thread = NULL;
|
ACE_Based::Thread* soap_thread = NULL;
|
||||||
|
|
||||||
if(sConfig->GetBoolDefault("SOAP.Enabled", false))
|
if (sConfig->GetBoolDefault("SOAP.Enabled", false))
|
||||||
{
|
{
|
||||||
TCSoapRunnable *runnable = new TCSoapRunnable();
|
TCSoapRunnable *runnable = new TCSoapRunnable();
|
||||||
runnable->setListenArguments(sConfig->GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig->GetIntDefault("SOAP.Port", 7878));
|
runnable->setListenArguments(sConfig->GetStringDefault("SOAP.IP", "127.0.0.1"), sConfig->GetIntDefault("SOAP.Port", 7878));
|
||||||
@@ -257,7 +258,7 @@ int Master::Run()
|
|||||||
realCurrTime = realPrevTime = getMSTime();
|
realCurrTime = realPrevTime = getMSTime();
|
||||||
|
|
||||||
///- Start up freeze catcher thread
|
///- Start up freeze catcher thread
|
||||||
if(uint32 freeze_delay = sConfig->GetIntDefault("MaxCoreStuckTime", 0))
|
if (uint32 freeze_delay = sConfig->GetIntDefault("MaxCoreStuckTime", 0))
|
||||||
{
|
{
|
||||||
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
|
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
|
||||||
fdr->SetDelayTime(freeze_delay*1000);
|
fdr->SetDelayTime(freeze_delay*1000);
|
||||||
@@ -267,31 +268,34 @@ int Master::Run()
|
|||||||
|
|
||||||
///- Launch the world listener socket
|
///- Launch the world listener socket
|
||||||
uint16 wsport = sWorld->getIntConfig(CONFIG_PORT_WORLD);
|
uint16 wsport = sWorld->getIntConfig(CONFIG_PORT_WORLD);
|
||||||
std::string bind_ip = sConfig->GetStringDefault ("BindIP", "0.0.0.0");
|
std::string bind_ip = sConfig->GetStringDefault("BindIP", "0.0.0.0");
|
||||||
|
|
||||||
if (sWorldSocketMgr->StartNetwork (wsport, bind_ip.c_str ()) == -1)
|
if (sWorldSocketMgr->StartNetwork(wsport, bind_ip.c_str ()) == -1)
|
||||||
{
|
{
|
||||||
sLog->outError ("Failed to start network");
|
sLog->outError ("Failed to start network");
|
||||||
World::StopNow(ERROR_EXIT_CODE);
|
World::StopNow(ERROR_EXIT_CODE);
|
||||||
// go down and shutdown the server
|
// go down and shutdown the server
|
||||||
}
|
}
|
||||||
|
|
||||||
sWorldSocketMgr->Wait ();
|
// set server online (allow connecting now)
|
||||||
|
LoginDatabase.DirectPExecute("UPDATE realmlist SET color = color & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_INVALID, realmID);
|
||||||
|
|
||||||
if(soap_thread)
|
sWorldSocketMgr->Wait();
|
||||||
|
|
||||||
|
if (soap_thread)
|
||||||
{
|
{
|
||||||
soap_thread->wait();
|
soap_thread->wait();
|
||||||
soap_thread->destroy();
|
soap_thread->destroy();
|
||||||
delete soap_thread;
|
delete soap_thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set server offline
|
// set server offline
|
||||||
LoginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
|
LoginDatabase.PExecute("UPDATE realmlist SET color = color | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realmID);
|
||||||
|
|
||||||
// when the main thread closes the singletons get unloaded
|
// when the main thread closes the singletons get unloaded
|
||||||
// since worldrunnable uses them, it will crash if unloaded after master
|
// since worldrunnable uses them, it will crash if unloaded after master
|
||||||
world_thread.wait();
|
world_thread.wait();
|
||||||
rar_thread.wait ();
|
rar_thread.wait();
|
||||||
|
|
||||||
///- Clean database before leaving
|
///- Clean database before leaving
|
||||||
clearOnlineAccounts();
|
clearOnlineAccounts();
|
||||||
@@ -301,7 +305,7 @@ int Master::Run()
|
|||||||
WorldDatabase.Close();
|
WorldDatabase.Close();
|
||||||
LoginDatabase.Close();
|
LoginDatabase.Close();
|
||||||
|
|
||||||
sLog->outString( "Halting process..." );
|
sLog->outString("Halting process...");
|
||||||
|
|
||||||
if (cliThread)
|
if (cliThread)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user