TrinityCore
Loading...
Searching...
No Matches
Main.cpp File Reference
#include "Common.h"
#include "AppenderDB.h"
#include "AsyncAcceptor.h"
#include "AuthenticationPackets.h"
#include "Banner.h"
#include "BattlegroundMgr.h"
#include "BigNumber.h"
#include "CliRunnable.h"
#include "Configuration/Config.h"
#include "DatabaseEnv.h"
#include "DatabaseLoader.h"
#include "DeadlineTimer.h"
#include "GitRevision.h"
#include "InstanceLockMgr.h"
#include "IoContext.h"
#include "IpNetwork.h"
#include "Locales.h"
#include "MapManager.h"
#include "Memory.h"
#include "Metric.h"
#include "MySQLThreading.h"
#include "OpenSSLCrypto.h"
#include "OutdoorPvP/OutdoorPvPMgr.h"
#include "ProcessPriority.h"
#include "RASession.h"
#include "RealmList.h"
#include "ScriptLoader.h"
#include "ScriptMgr.h"
#include "ScriptReloadMgr.h"
#include "SecretMgr.h"
#include "TCSoap.h"
#include "TerrainMgr.h"
#include "ThreadPool.h"
#include "World.h"
#include "WorldSocketMgr.h"
#include "Util.h"
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
#include <boost/asio/signal_set.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/program_options.hpp>
#include <google/protobuf/stubs/common.h>
#include <iostream>
#include <csignal>
#include "Hacks/boost_program_options_with_filesystem_path.h"
#include "ServiceWin32.h"
#include <tchar.h>
#include <boost/dll/shared_library.hpp>
#include <timeapi.h>
+ Include dependency graph for Main.cpp:

Go to the source code of this file.

Classes

class  FreezeDetector
 
struct  ShutdownTCSoapThread
 
struct  ShutdownCLIThread
 

Macros

#define _TRINITY_CORE_CONFIG   "worldserver.conf"
 
#define _TRINITY_CORE_CONFIG_DIR   "worldserver.conf.d"
 

Functions

void SignalHandler (boost::system::error_code const &error, int signalNumber)
 
std::unique_ptr< Trinity::Net::AsyncAcceptor > StartRaSocketAcceptor (Trinity::Asio::IoContext &ioContext)
 
bool StartDB ()
 Initialize connection to the databases.
 
void StopDB ()
 
void WorldUpdateLoop ()
 
void ClearOnlineAccounts (uint32 realmId)
 Clear 'online' status for all accounts with characters in this realm.
 
variables_map GetConsoleArguments (int argc, char **argv, fs::path &configFile, fs::path &configDir, std::string &winServiceAction)
 
int main (int argc, char **argv)
 Launch the Trinity server.
 

Variables

TCHAR serviceName [] = _T("worldserver")
 
TCHAR serviceLongName [] = _T("TrinityCore world service")
 
TCHAR serviceDescription [] = _T("TrinityCore World of Warcraft emulator world service")
 
int m_ServiceStatus = -1
 

Macro Definition Documentation

◆ _TRINITY_CORE_CONFIG

#define _TRINITY_CORE_CONFIG   "worldserver.conf"

Definition at line 70 of file Main.cpp.

◆ _TRINITY_CORE_CONFIG_DIR

#define _TRINITY_CORE_CONFIG_DIR   "worldserver.conf.d"

Definition at line 74 of file Main.cpp.

Function Documentation

◆ ClearOnlineAccounts()

void ClearOnlineAccounts ( uint32  realmId)

Clear 'online' status for all accounts with characters in this realm.

Definition at line 682 of file Main.cpp.

References CharacterDatabase, and LoginDatabase.

Referenced by main().

◆ GetConsoleArguments()

variables_map GetConsoleArguments ( int  argc,
char **  argv,
fs::path &  configFile,
fs::path &  configDir,
std::string &  winServiceAction 
)

Definition at line 694 of file Main.cpp.

References _TRINITY_CORE_CONFIG, _TRINITY_CORE_CONFIG_DIR, and GitRevision::GetFullVersion().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Launch the Trinity server.

worldserver PID file creation

  • Get the realm Id from the configuration file
  • Clean the database before starting
  • Clean database before leaving

Definition at line 130 of file Main.cpp.

References _TRINITY_CORE_CONFIG, _TRINITY_CORE_CONFIG_DIR, Trinity::AbortHandler(), AddScripts(), ClearOnlineAccounts(), CliThread(), CONFIG_HIGH_PRIORITY, CONFIG_PORT_WORLD, CONFIG_PROCESSOR_AFFINITY, CreatePIDFile(), CreateSoapThread(), ERROR_EXIT_CODE, GetConsoleArguments(), World::GetExitCode(), GitRevision::GetFullVersion(), Trinity::Locale::Init(), Trinity::Service::Init(), Trinity::Service::Install(), LoginDatabase, m_ServiceStatus, main(), Trinity::make_unique_ptr_with_deleter(), Trinity::Legacy::REALM_FLAG_OFFLINE, Trinity::Service::Run(), sBattlegroundMgr, Trinity::Net::ScanLocalNetworks(), sConfigMgr, SECRET_OWNER_WORLDSERVER, serviceDescription, serviceLongName, serviceName, SetProcessPriority(), BigNumber::SetRand(), Trinity::Banner::Show(), WorldPackets::Auth::ConnectTo::ShutdownEncryption(), WorldPackets::Auth::EnterEncryptedMode::ShutdownEncryption(), SignalHandler(), sInstanceLockMgr, sLog, sMapMgr, sMetric, sOutdoorPvPMgr, sRealmList, sScriptMgr, sScriptReloadMgr, sSecretMgr, FreezeDetector::Start(), StartDB(), StartRaSocketAcceptor(), sTerrainMgr, StopDB(), WorldSocketMgr::StopNetwork(), World::StopNow(), sWorld, sWorldSocketMgr, TC_LOG_ERROR, TC_LOG_INFO, TC_METRIC_EVENT, OpenSSLCrypto::threadsCleanup(), OpenSSLCrypto::threadsSetup(), Trinity::Service::Uninstall(), Metric::Unload(), Trinity::VerifyOsVersion(), and WorldUpdateLoop().

Referenced by main().

◆ SignalHandler()

void SignalHandler ( boost::system::error_code const &  error,
int  signalNumber 
)

Definition at line 586 of file Main.cpp.

References SHUTDOWN_EXIT_CODE, and World::StopNow().

Referenced by main().

◆ StartDB()

bool StartDB ( )

◆ StartRaSocketAcceptor()

std::unique_ptr< Trinity::Net::AsyncAcceptor > StartRaSocketAcceptor ( Trinity::Asio::IoContext &  ioContext)

Definition at line 626 of file Main.cpp.

References sConfigMgr, and TC_LOG_ERROR.

Referenced by main().

◆ StopDB()

void StopDB ( )

Definition at line 671 of file Main.cpp.

References CharacterDatabase, HotfixDatabase, MySQL::Library_End(), LoginDatabase, and WorldDatabase.

Referenced by main().

◆ WorldUpdateLoop()

Variable Documentation

◆ m_ServiceStatus

int m_ServiceStatus = -1

Definition at line 89 of file Main.cpp.

Referenced by main(), and WorldUpdateLoop().

◆ serviceDescription

TCHAR serviceDescription[] = _T("TrinityCore World of Warcraft emulator world service")

Definition at line 82 of file Main.cpp.

Referenced by main().

◆ serviceLongName

TCHAR serviceLongName[] = _T("TrinityCore world service")

Definition at line 81 of file Main.cpp.

Referenced by main().

◆ serviceName

TCHAR serviceName[] = _T("worldserver")

Definition at line 80 of file Main.cpp.

Referenced by main().