bool ChatHandler::HandleServerInfoCommand(char* /*args*/) { uint32 activeClientsNum = sWorld.GetActiveSessionCount(); uint32 queuedClientsNum = sWorld.GetQueuedSessionCount(); uint32 maxActiveClientsNum = sWorld.GetMaxActiveSessionCount(); uint32 maxQueuedClientsNum = sWorld.GetMaxQueuedSessionCount(); std::string str = secsToTimeString(sWorld.GetUptime()); uint32 updateTime = sWorld.GetUpdateTime(); char const* full; char const* fullR2; if(m_session) { full = _FULLVERSION(REVISION_NR); fullR2 = _R2FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_R2,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r"); } else { full = _FULLVERSION(REVISION_NR); fullR2 = _R2FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_R2,REVISION_ID); } SendSysMessage(full); SendSysMessage(fullR2); if (sScriptMgr.IsScriptLibraryLoaded()) { char const* ver = sScriptMgr.GetScriptLibraryVersion(); if (ver && *ver) PSendSysMessage(LANG_USING_SCRIPT_LIB, ver); else SendSysMessage(LANG_USING_SCRIPT_LIB_UNKNOWN); } else SendSysMessage(LANG_USING_SCRIPT_LIB_NONE); PSendSysMessage(LANG_USING_WORLD_DB,sWorld.GetDBVersion()); PSendSysMessage(LANG_USING_EVENT_AI,sWorld.GetCreatureEventAIVersion()); PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum); PSendSysMessage(LANG_UPTIME, str.c_str()); PSendSysMessage("Update time diff: %u", updateTime); return true; }
/// Launch the mangos server extern int main(int argc, char **argv) { ///- Command line parsing char const* cfg_file = _MANGOSD_CONFIG; char const *options = ":a:c:s:"; ACE_Get_Opt cmd_opts(argc, argv, options); cmd_opts.long_option("version", 'v', ACE_Get_Opt::NO_ARG); cmd_opts.long_option("ahbot", 'a', ACE_Get_Opt::ARG_REQUIRED); char serviceDaemonMode = '\0'; if (!sConfig.SetSource(cfg_file)) { sLog.outError("Could not find configuration file %s.", cfg_file); Log::WaitBeforeContinueIfNeed(); return 1; } int option; while ((option = cmd_opts()) != EOF) { switch (option) { case 'a': sAuctionBotConfig.SetConfigFileName(cmd_opts.opt_arg()); break; case 'c': cfg_file = cmd_opts.opt_arg(); break; case 'v': printf("%s\n", _FULLVERSION(REVISION_NR)); printf("%s\n", _R2FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_R2,REVISION_ID)); return 0; case 's': { #ifdef WIN32 const char *mode = cmd_opts.opt_arg(); if (!strcmp(mode, "run")) serviceDaemonMode = 'r'; else if (!strcmp(mode, "install")) serviceDaemonMode = 'i'; else if (!strcmp(mode, "uninstall")) serviceDaemonMode = 'u'; else if (!strcmp(mode, "stop")) serviceDaemonMode = 's'; else { sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode); usage(argv[0]); Log::WaitBeforeContinueIfNeed(); return 1; } break; #else const char *mode = cmd_opts.opt_arg(); if (!strcmp(mode, "run")) startDaemon(120); else if (!strcmp(mode, "stop")) stopDaemon(); else { sLog.outError("Runtime-Error: -%c unsupported argument %s", cmd_opts.opt_opt(), mode); usage(argv[0]); Log::WaitBeforeContinueIfNeed(); return 1; } } #endif break; case ':': sLog.outError("Runtime-Error: -%c option requires an input argument", cmd_opts.opt_opt()); usage(argv[0]); Log::WaitBeforeContinueIfNeed(); return 1; default: sLog.outError("Runtime-Error: bad format of commandline arguments"); usage(argv[0]); Log::WaitBeforeContinueIfNeed(); return 1; } } #ifdef WIN32 // windows service command need execute before config read switch (serviceDaemonMode) { case 'i': if (WinServiceInstall()) sLog.outString("Installing service"); return 1; case 'u': if (WinServiceUninstall()) sLog.outString("Uninstalling service"); return 1; case 'r': WinServiceRun(); break; } #endif #ifndef WIN32 // posix daemon commands need apply after config read switch (serviceDaemonMode) { case 'r': startDaemon(); break; case 's': stopDaemon(); break; } #endif sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_NR) ); sLog.outString( "%s [world-daemon]", _R2FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_R2,REVISION_ID) ); sLog.outString( "<Ctrl-C> to stop." ); sLog.outString("\n\n" "MM MM MM MM MMMMM MMMM MMMMM\n" "MM MM MM MM MMM MMM MM MM MMM MMM\n" "MMM MMM MMM MM MMM MMM MM MM MMM\n" "MM M MM MMMM MM MMM MM MM MMM\n" "MM M MM MMMMM MM MMMM MMM MM MM MMM\n" "MM M MM M MMM MM MMM MMMMMMM MM MM MMM\n" "MM MM MMM MM MM MM MMM MM MM MMM\n" "MM MM MMMMMMM MM MM MMM MMM MM MM MMM MMM\n" "MM MM MM MMM MM MM MMMMMM MMMM MMMMM\n" " MM MMM http://getmangos.com\n" " MMMMMM R2 modifications included (https://github.com/mangosR2/mangos)\n\n"); sLog.outString("Using configuration file %s.", cfg_file); DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); if (SSLeay() < 0x009080bfL ) { DETAIL_LOG("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!"); DETAIL_LOG("WARNING: Minimal required version [OpenSSL 0.9.8k]"); } DETAIL_LOG("Using ACE: %s", ACE_VERSION); ///- Set progress bars show mode BarGoLink::SetOutputState(sConfig.GetBoolDefault("ShowProgressBars", true)); ///- and run the 'Master' /// \todo Why do we need this 'Master'? Can't all of this be in the Main as for Realmd? return sMaster.Run(); // at sMaster return function exist with codes // 0 - normal shutdown // 1 - shutdown at error // 2 - restart command used, this code can be used by restarter for restart mangosd }