diff options
author | Shauren <none@none> | 2010-12-28 17:56:15 +0100 |
---|---|---|
committer | Shauren <none@none> | 2010-12-28 17:56:15 +0100 |
commit | 4e697869a0fab7f9d9d2a7804ddcc14389c8e620 (patch) | |
tree | 1e6920148421c06121b99ebb93e8c6049bc6ae1c | |
parent | f0db5396f40ab160cfe17eeae8c0bcf75ab03bdc (diff) |
Core/World: Set realm status as invalid during startup and online when initialized
--HG--
branch : trunk
-rw-r--r-- | src/server/worldserver/CMakeLists.txt | 1 | ||||
-rwxr-xr-x | src/server/worldserver/Master.cpp | 86 |
2 files changed, 46 insertions, 41 deletions
diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt index ef1f6bf7be4..479006f44e0 100644 --- a/src/server/worldserver/CMakeLists.txt +++ b/src/server/worldserver/CMakeLists.txt @@ -131,6 +131,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/Tools ${CMAKE_SOURCE_DIR}/src/server/game/Weather ${CMAKE_SOURCE_DIR}/src/server/game/World + ${CMAKE_SOURCE_DIR}/src/server/authserver/Server ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/CommandLine ${CMAKE_CURRENT_SOURCE_DIR}/RemoteAccess diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index ce4b322cb4a..e5374a1b89f 100755 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -40,6 +40,7 @@ #include "TCSoap.h" #include "Timer.h" #include "Util.h" +#include "AuthSocket.h" #include "BigNumber.h" @@ -122,44 +123,47 @@ int Master::Run() BigNumber seed1; seed1.SetRand(16 * 8); - sLog->outString( "%s (core-daemon)", _FULLVERSION ); - sLog->outString( "<Ctrl-C> to stop.\n" ); + sLog->outString("%s (core-daemon)", _FULLVERSION); + sLog->outString("<Ctrl-C> to stop.\n"); - sLog->outString( " ______ __"); - sLog->outString( "/\\__ _\\ __ __/\\ \\__"); - sLog->outString( "\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\ ,_\\ __ __"); - sLog->outString( " \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\"); - sLog->outString( " \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\"); - sLog->outString( " \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\"); - sLog->outString( " \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\"); - sLog->outString( " C O R E /\\___/"); - sLog->outString( "http://TrinityCore.org \\/__/\n"); + sLog->outString(" ______ __"); + sLog->outString("/\\__ _\\ __ __/\\ \\__"); + sLog->outString("\\/_/\\ \\/ _ __ /\\_\\ ___ /\\_\\ \\ ,_\\ __ __"); + sLog->outString(" \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\"); + sLog->outString(" \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\"); + sLog->outString(" \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\"); + sLog->outString(" \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\"); + sLog->outString(" C O R E /\\___/"); + sLog->outString("http://TrinityCore.org \\/__/\n"); #ifdef USE_SFMT_FOR_RNG - sLog->outString( "\n"); - 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( "\n"); + sLog->outString("\n"); + 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("\n"); #endif //USE_SFMT_FOR_RNG /// worldd PID file creation std::string pidfile = sConfig->GetStringDefault("PidFile", ""); - if(!pidfile.empty()) + if (!pidfile.empty()) { 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; } - sLog->outString( "Daemon PID: %u\n", pid ); + sLog->outString("Daemon PID: %u\n", pid); } ///- Start the databases if (!_StartDB()) 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 sWorld->SetInitialWorldSettings(); @@ -183,9 +187,6 @@ int Master::Run() ACE_Based::Thread world_thread(new WorldRunnable); 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; #ifdef _WIN32 @@ -206,25 +207,25 @@ int Master::Run() HANDLE hProcess = GetCurrentProcess(); uint32 Aff = sConfig->GetIntDefault("UseProcessors", 0); - if(Aff > 0) + if (Aff > 0) { ULONG_PTR appAff; ULONG_PTR sysAff; - if(GetProcessAffinityMask(hProcess,&appAff,&sysAff)) + if (GetProcessAffinityMask(hProcess,&appAff,&sysAff)) { 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); } else { - if(SetProcessAffinityMask(hProcess,curAff)) + if (SetProcessAffinityMask(hProcess,curAff)) sLog->outString("Using processors (bitmask, hex): %x", curAff); else - sLog->outError("Can't set used processors (hex): %x",curAff); + sLog->outError("Can't set used processors (hex): %x", curAff); } } sLog->outString(""); @@ -232,8 +233,8 @@ int Master::Run() bool Prio = sConfig->GetBoolDefault("ProcessPriority", false); -// if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/) - if(Prio) + //if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/) + if (Prio) { if(SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS)) sLog->outString("TrinityCore process priority class set to HIGH"); @@ -246,7 +247,7 @@ int Master::Run() //Start soap serving thread ACE_Based::Thread* soap_thread = NULL; - if(sConfig->GetBoolDefault("SOAP.Enabled", false)) + if (sConfig->GetBoolDefault("SOAP.Enabled", false)) { TCSoapRunnable *runnable = new TCSoapRunnable(); 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(); ///- 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(); fdr->SetDelayTime(freeze_delay*1000); @@ -267,31 +268,34 @@ int Master::Run() ///- Launch the world listener socket 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"); World::StopNow(ERROR_EXIT_CODE); // 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); + + sWorldSocketMgr->Wait(); - if(soap_thread) + if (soap_thread) { - soap_thread->wait(); - soap_thread->destroy(); - delete soap_thread; + soap_thread->wait(); + soap_thread->destroy(); + delete soap_thread; } // 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 // since worldrunnable uses them, it will crash if unloaded after master world_thread.wait(); - rar_thread.wait (); + rar_thread.wait(); ///- Clean database before leaving clearOnlineAccounts(); @@ -301,7 +305,7 @@ int Master::Run() WorldDatabase.Close(); LoginDatabase.Close(); - sLog->outString( "Halting process..." ); + sLog->outString("Halting process..."); if (cliThread) { |