diff --git a/cmake/linux/FindOracle.cmake b/cmake/linux/FindOracle.cmake index 0abd11c2..b1468463 100644 --- a/cmake/linux/FindOracle.cmake +++ b/cmake/linux/FindOracle.cmake @@ -52,6 +52,18 @@ if(DEFINED ENV{ORACLE_HOME}) /usr/share/oracle/12.2/client64 /usr/lib/oracle/12.2/client /usr/share/oracle/12.2/client + /usr/include/oracle/18.3/client64 + /usr/include/oracle/18.3/client + /usr/lib/oracle/18.3/client64 + /usr/share/oracle/18.3/client64 + /usr/lib/oracle/18.3/client + /usr/share/oracle/18.3/client + /usr/include/oracle/19.6/client64 + /usr/include/oracle/19.6/client + /usr/lib/oracle/19.6/client64 + /usr/share/oracle/19.6/client64 + /usr/lib/oracle/19.6/client + /usr/share/oracle/19.6/client ${ORACLE_HOME}/rdbms/public ${ORACLE_HOME}/include ${ORACLE_HOME}/sdk/include # Oracle SDK @@ -59,8 +71,8 @@ if(DEFINED ENV{ORACLE_HOME}) set(ORACLE_OCI_NAMES clntsh libclntsh oci) - set(ORACLE_NNZ_NAMES nnz10 libnnz10 nnz11 libnnz11 nnz12 libnnz12 ociw32) - set(ORACLE_OCCI_NAMES libocci occi oraocci10 oraocci11 oraocci12) + set(ORACLE_NNZ_NAMES nnz10 libnnz10 nnz11 libnnz11 nnz12 libnnz12 nnz18 libnnz18 nnz19 libnnz19 ociw32) + set(ORACLE_OCCI_NAMES libocci occi oraocci10 oraocci11 oraocci12 libocci.so.19.1 oraocci19) set(ORACLE_LIB_DIR diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.cpp b/engine/server/application/CentralServer/src/shared/CentralServer.cpp index 065fa9e8..1cdb83bb 100755 --- a/engine/server/application/CentralServer/src/shared/CentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/CentralServer.cpp @@ -275,9 +275,9 @@ m_timeCharacterMatchStatisticsNextRefresh(0) connectToMessage("TaskConnectionOpened"); connectToMessage("RandomNameRequest"); // from connection server connectToMessage("RandomNameResponse"); // from game server - connectToMessage("VerifyAndLockNameRequest"); // from connection server - connectToMessage("VerifyAndLockNameResponse"); // from game server - + connectToMessage("VerifyAndLockNameRequest"); // from connection server + connectToMessage("VerifyAndLockNameResponse"); // from game server + //Object Messages connectToMessage("RequestObjectMessage"); connectToMessage("RequestChunkMessage"); @@ -386,7 +386,7 @@ m_timeCharacterMatchStatisticsNextRefresh(0) connectToMessage("RestartServerByRoleMessage"); connectToMessage("ExcommunicateGameServerMessage"); connectToMessage("RestartPlanetMessage"); - + // Cluster state connectToMessage("UpdateClusterLockedAndSecretState"); @@ -432,7 +432,7 @@ m_timeCharacterMatchStatisticsNextRefresh(0) CentralServer::~CentralServer() { ConsoleManager::remove(); - + CentralCSHandler::remove(); ms_sceneToHostMap.clear(); @@ -1315,7 +1315,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage reply(ri); // If this request has a CS Tool Id associated with it, it is an admin request for the CSTool, - // and so we should send it directly to the connection server, and not depend on a + // and so we should send it directly to the connection server, and not depend on a // transfer server existing. if (reply.getValue().getCSToolId() > 0) { @@ -2634,7 +2634,7 @@ void CentralServer::removeGameServer(GameServerConnection const *gameServer) ExcommunicateGameServerMessage const excommunicateMessage(pid, 0, ""); sendToAllGameServersExceptDBProcess(excommunicateMessage, true); } - else + else { DEBUG_WARNING(true, ("A game server crashed but our process ID ptr is nullptr.")); } @@ -2697,7 +2697,7 @@ void CentralServer::run(void) setup.port = ConfigCentralServer::getCommodityServerServicePort(); setup.bindInterface = ConfigCentralServer::getCommodityServerServiceBindInterface(); s_commodityServerService = new Service(ConnectionAllocator(), setup); - + setup.port = ConfigCentralServer::getLoginServicePort(); if (ConfigCentralServer::getDevelopmentMode()) cserver.connectToLoginServer(); @@ -2709,7 +2709,7 @@ void CentralServer::run(void) // connect to the task manager cserver.m_taskManager = new TaskConnection("127.0.0.1", ConfigCentralServer::getTaskManagerPort()); - + unsigned long startTime = Clock::timeMs(); unsigned long nextLoadingLogTime=0; unsigned long nextPingTime=0; @@ -2743,7 +2743,7 @@ void CentralServer::run(void) { unsigned long lastFrameTime = 0; unsigned long frameStartTime = Clock::timeMs(); - + PROFILER_AUTO_BLOCK_DEFINE("main loop"); bool barrierReached = true; @@ -2847,7 +2847,7 @@ void CentralServer::update() static int shutdownCheckLoopCount = 0; m_curTime = static_cast(time(0)); - + // Tell the LoginServers if necessary if ((++loopCount > ConfigCentralServer::getUpdatePlayerCountFrequency())) { @@ -2877,7 +2877,7 @@ void CentralServer::update() const short port[1] = { (short)ConfigCentralServer::getAuctionPort() }; std::string s_id = ConfigCentralServer::getAuctionIDPrefix(); - s_id += ConfigCentralServer::getClusterName(); + s_id += ConfigCentralServer::getClusterName(); const char *identifier[1]; identifier[ 0 ] = s_id.c_str(); @@ -2914,7 +2914,7 @@ void CentralServer::sendPopulationUpdateToLoginServer() m_totalTutorialSceneCount = 0; m_totalFalconSceneCount = 0; - + ConnectionServerConnectionList::const_iterator i; for (i=m_connectionServerConnections.begin(); i!=m_connectionServerConnections.end(); ++i) { @@ -2939,7 +2939,7 @@ void CentralServer::sendPopulationUpdateToLoginServer() void CentralServer::sendMetricsToWebAPI() { static const std::string metricsURL(ConfigCentralServer::getMetricsDataURL()); - + if (!metricsURL.empty()) { StellaBellum::webAPI api(metricsURL); @@ -2952,23 +2952,25 @@ void CentralServer::sendMetricsToWebAPI() api.addJsonData("lastLoadingStateTime", m_lastLoadingStateTime); api.addJsonData("clusterStartupTime", m_clusterStartupTime); api.addJsonData("timeClusterWentIntoLoadingState", m_timeClusterWentIntoLoadingState); - + api.addJsonData("webUpdateIntervalSeconds", ConfigCentralServer::getWebUpdateIntervalSeconds()); + api.addJsonData("secretKey", ConfigCentralServer::getMetricsSecretKey()); + #ifdef _DEBUG if (api.submit()) { bool status = api.getNullableValue("status"); - + if (status) { std::string message = api.getString("message"); - + if (message.empty()) { message = "No message returned."; } - + WARNING(true, ("Error sending stats: %s", message.c_str())); } - + WARNING(true, ("Success sending server stats to API.")); } else @@ -3200,7 +3202,7 @@ void CentralServer::startPlanetServer(const std::string & host, const std::strin portBase += 100; options += " gameServerDebuggingPortBase="; options += buffer; - + TaskSpawnProcess spawn(host.empty() ? std::string("any") : host, "PlanetServer", options, spawnDelay); CentralServer::getInstance().sendTaskMessage(spawn); m_pendingPlanetServers[sceneId] = std::make_pair(std::make_pair(host, options), ::time(nullptr)); @@ -3218,7 +3220,7 @@ void CentralServer::startPlanetServer(const std::string & host, const std::strin getInstance().m_transferServerConnection = 0; s_retryTransferServerConnection = false; } - + if(getInstance().m_stationPlayersCollectorConnection != nullptr && ! isPreloadFinished()) { getInstance().m_stationPlayersCollectorConnection->disconnect(); @@ -3923,7 +3925,7 @@ void CentralServer::checkShutdownProcess() if( m_curTime>=m_shutdownTotalTime && !warn30 ) { LOG("CentralServerShutdown",("Shutdown Phase %d: Broadcasting 30sec disconnect warning message to players.", m_shutdownPhase)); - ConGenericMessage const msg("game any systemMessage You will be disconnected in 30sec so the server can perform a final save before shutting down. Please find a safe place to logout now.", 0); + ConGenericMessage const msg("game any systemMessage You will be disconnected in 30 seconds so the server can perform a final save before shutting down. Please find a safe place to logout now.", 0); IGNORE_RETURN(sendToRandomGameServer(msg)); warn30 = true; @@ -3931,7 +3933,7 @@ void CentralServer::checkShutdownProcess() else if( m_curTime >= (m_shutdownTotalTime+20) && !warn10 ) { LOG("CentralServerShutdown",("Shutdown Phase %d: Broadcasting 10sec disconnect warning message to players.", m_shutdownPhase)); - ConGenericMessage const msg("game any systemMessage You will be disconnected in 10sec so the server can perform a final save before shutting down. Please find a safe place to logout now.", 0); + ConGenericMessage const msg("game any systemMessage You will be disconnected in 10 seconds so the server can perform a final save before shutting down. Please find a safe place to logout now.", 0); IGNORE_RETURN(sendToRandomGameServer(msg)); warn10 = true; } @@ -4133,7 +4135,7 @@ std::pair > const *, std::mapa = ConfigFile::getKeyInt("CentralServer", #a, b)) -#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("CentralServer", #a, b)) +#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("CentralServer", #a, b)) #define KEY_STRING(a,b) (data->a = ConfigFile::getKeyString("CentralServer", #a, b)) //----------------------------------------------------------------------- @@ -110,7 +110,7 @@ void ConfigCentralServer::install(void) KEY_STRING (transferServerAddress, "127.0.0.1"); KEY_INT (transferServerPort, 0); // TransferServer listens on 50005, default to "off" KEY_STRING (stationPlayersCollectorAddress, "127.0.0.1"); - KEY_INT (stationPlayersCollectorPort, 0); // StationPlayersCollector listens on 50010, default to "off" + KEY_INT (stationPlayersCollectorPort, 0); // StationPlayersCollector listens on 50010, default to "off" KEY_BOOL (allowZeroConnectionServerPort, true); KEY_INT (clusterWideDataLockTimeout, 300); // seconds KEY_STRING (commodityServerServiceBindInterface, ""); @@ -129,6 +129,7 @@ void ConfigCentralServer::install(void) KEY_INT (maxTimeToWaitForPlanetServerStartSeconds, 5*60); // seconds KEY_STRING (metricsDataURL, ""); KEY_INT (webUpdateIntervalSeconds, 5); + KEY_STRING (metricsSecretKey, ""); int index = 0; char const * result = 0; diff --git a/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h b/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h index 79e08d55..bc2769c9 100755 --- a/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h +++ b/engine/server/application/CentralServer/src/shared/ConfigCentralServer.h @@ -74,6 +74,7 @@ public: const char * metricsDataURL; int webUpdateIntervalSeconds; + const char * metricsSecretKey; }; static const unsigned short getChatServicePort (); @@ -137,7 +138,7 @@ public: static const char * getAuctionServer(); static int getAuctionPort(); static const char * getAuctionIDPrefix(); - + static bool getDisconnectDuplicateConnectionsOnOtherGalaxies(); static bool getRequestDbSaveOnPlanetServerCrash(); @@ -146,13 +147,14 @@ public: static const char * getMetricsDataURL(); static int getWebUpdateIntervalSeconds(); + static const char * getMetricsSecretKey(); private: static Data * data; }; //----------------------------------------------------------------------- -inline const unsigned short ConfigCentralServer::getChatServicePort() +inline const unsigned short ConfigCentralServer::getChatServicePort() { return static_cast(data->chatServicePort); } @@ -173,7 +175,7 @@ inline const unsigned short ConfigCentralServer::getConnectionServicePort() //----------------------------------------------------------------------- -inline const unsigned short ConfigCentralServer::getCustomerServicePort() +inline const unsigned short ConfigCentralServer::getCustomerServicePort() { return static_cast(data->customerServicePort); } @@ -529,6 +531,13 @@ inline int ConfigCentralServer::getWebUpdateIntervalSeconds() return data->webUpdateIntervalSeconds; } +// ---------------------------------------------------------------------- + +inline const char * ConfigCentralServer::getMetricsSecretKey() +{ + return data->metricsSecretKey; +} + // ====================================================================== #endif // _ConfigCentralServer_H diff --git a/engine/server/application/CustomerServiceServer/src/shared/CustomerServiceInterface.h b/engine/server/application/CustomerServiceServer/src/shared/CustomerServiceInterface.h index bdb22baf..5e4d7833 100755 --- a/engine/server/application/CustomerServiceServer/src/shared/CustomerServiceInterface.h +++ b/engine/server/application/CustomerServiceServer/src/shared/CustomerServiceInterface.h @@ -9,9 +9,9 @@ #include "sharedFoundation/NetworkId.h" #include "sharedNetworkMessages/CustomerServiceCategory.h" #include - -extern "C" { #include "libxml/parser.h" +extern "C" { + } using namespace CSAssist; diff --git a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp index d88d7a53..3a6175bf 100755 --- a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp @@ -21,6 +21,7 @@ #include "sharedFoundation/CrcConstexpr.hpp" +#include "Session/CommonAPI/CommonAPI.h" #include "webAPI.h" #include "jsonWebAPI.h" @@ -170,7 +171,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string } // hash username into station id - StationId suid = atoi(lcaseId.c_str()); + StationId suid = atoi(lcaseId.c_str()); if (suid == 0) { std::hash h; @@ -181,7 +182,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string int authOK = 0; std::string authURL(ConfigLoginServer::getExternalAuthUrl()); - if (!authURL.empty()) + if (!authURL.empty()) { if(ConfigLoginServer::getUseJsonWebApi()) { @@ -191,6 +192,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string api.addJsonData("user_password", trimmedKey); api.addJsonData("stationID", suid); api.addJsonData("ip", getRemoteAddress()); + api.addJsonData("secretKey", ConfigLoginServer::getExternalAuthSecretKey()); if (api.submit()) { @@ -206,15 +208,15 @@ void ClientConnection::validateClient(const std::string & id, const std::string } } else - { + { ErrorMessage err("Login Failed", "request failed"); this->send(err, true); } - } + } else { std::ostringstream postBuf; - postBuf << "user_name=" << trimmedId << "&user_password=" << trimmedKey << "&stationID=" << suid << "&ip=" << getRemoteAddress(); + postBuf << "user_name=" << trimmedId << "&user_password=" << trimmedKey << "&stationID=" << suid << "&ip=" << getRemoteAddress() << "&secretKey=" << ConfigLoginServer::getExternalAuthSecretKey(); std::string response = webAPI::simplePost(authURL, std::string(postBuf.str()), ""); if (response == "success") { @@ -232,7 +234,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string authOK = 1; } - if (authOK) + if (authOK) { LoginServer::getInstance().onValidateClient(suid, lcaseId, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF); } @@ -285,4 +287,3 @@ StationId ClientConnection::getRequestedAdminSuid() const { } // ====================================================================== - diff --git a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp index 74e4cbd6..9f1ce53f 100755 --- a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp +++ b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp @@ -118,6 +118,7 @@ void ConfigLoginServer::install(void) KEY_BOOL(useJsonWebApi, false); KEY_BOOL(useExternalAuth, false); KEY_STRING(externalAuthURL, ""); + KEY_STRING(externalAuthSecretKey, ""); KEY_BOOL(useOldSuidGenerator, false); int index = 0; diff --git a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h index c7730b8a..1e802330 100755 --- a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h +++ b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h @@ -66,11 +66,12 @@ class ConfigLoginServer int csToolPort; bool requireSecureLoginForCsTool; - + bool useOldSuidGenerator; bool useExternalAuth; bool useJsonWebApi; const char * externalAuthURL; + const char * externalAuthSecretKey; }; static const uint16 getCentralServicePort(); @@ -137,6 +138,7 @@ class ConfigLoginServer static bool getUseExternalAuth(); static bool getUseJsonWebApi(); static const char * getExternalAuthUrl(); + static const char * getExternalAuthSecretKey(); static bool getUseOldSuidGenerator(); // has character creation for this cluster been disabled through config option @@ -502,6 +504,10 @@ inline const char * ConfigLoginServer::getExternalAuthUrl() return data->externalAuthURL; } +inline const char * ConfigLoginServer::getExternalAuthSecretKey() +{ + return data->externalAuthSecretKey; +} inline bool ConfigLoginServer::getUseOldSuidGenerator() { diff --git a/engine/server/application/TaskManager/src/shared/ConfigTaskManager.cpp b/engine/server/application/TaskManager/src/shared/ConfigTaskManager.cpp index 20c68e81..fba9fd8a 100755 --- a/engine/server/application/TaskManager/src/shared/ConfigTaskManager.cpp +++ b/engine/server/application/TaskManager/src/shared/ConfigTaskManager.cpp @@ -82,6 +82,7 @@ void ConfigTaskManager::install(void) KEY_INT (maximumClockDriftToleranceSeconds, 10); // seconds KEY_INT (systemTimeCheckIntervalSeconds, 60); // seconds KEY_INT (clockDriftFatalIntervalSeconds, 1*60*60); // seconds + KEY_BOOL (allowPreferredServerOnMasterNode, false); int index = 0; char const * result = 0; diff --git a/engine/server/application/TaskManager/src/shared/ConfigTaskManager.h b/engine/server/application/TaskManager/src/shared/ConfigTaskManager.h index 16a78225..806744e2 100755 --- a/engine/server/application/TaskManager/src/shared/ConfigTaskManager.h +++ b/engine/server/application/TaskManager/src/shared/ConfigTaskManager.h @@ -39,6 +39,7 @@ class ConfigTaskManager int maximumClockDriftToleranceSeconds; int systemTimeCheckIntervalSeconds; int clockDriftFatalIntervalSeconds; + bool allowPreferredServerOnMasterNode; }; static const bool getAutoStart (); @@ -68,7 +69,7 @@ class ConfigTaskManager static int getMaximumClockDriftToleranceSeconds(); static int getSystemTimeCheckIntervalSeconds(); static int getClockDriftFatalIntervalSeconds(); - + static const bool getAllowPreferredServerOnMasterNode(); static void install (); static void remove (); @@ -270,4 +271,11 @@ inline int ConfigTaskManager::getClockDriftFatalIntervalSeconds() // ---------------------------------------------------------------------- +inline const bool ConfigTaskManager::getAllowPreferredServerOnMasterNode() +{ + return data->allowPreferredServerOnMasterNode; +} + +// ---------------------------------------------------------------------- + #endif // _ConfigTaskManager_H diff --git a/engine/server/application/TaskManager/src/shared/Locator.cpp b/engine/server/application/TaskManager/src/shared/Locator.cpp index 2dac97f8..b9884038 100755 --- a/engine/server/application/TaskManager/src/shared/Locator.cpp +++ b/engine/server/application/TaskManager/src/shared/Locator.cpp @@ -146,19 +146,33 @@ ManagerConnection *LocatorNamespace::getPreferredServer(std::string const &proce { ServerEntry &e = *i; if ((e.m_label != s_masterNodeLabel) && (e.hasAvailableLoad(cost))) - { + { for (std::vector::const_iterator j = s_preferredNodes.begin(); j != s_preferredNodes.end(); ++j) if ((*j).m_nodeLabel == e.m_label && (*j).match(processName, options)) return e.m_connection; - } - } + } + } return 0; } // ---------------------------------------------------------------------- -ManagerConnection *LocatorNamespace::getUnpreferredServer(float cost) +bool Locator::isMasterNodePreferred(std::string const &processName, std::string const &options, float cost) { + if(!ConfigTaskManager::getAllowPreferredServerOnMasterNode()) + return false; + + for (std::vector::const_iterator j = s_preferredNodes.begin(); j != s_preferredNodes.end(); ++j) + if ((*j).m_nodeLabel == s_masterNodeLabel && (*j).match(processName, options)) + return true; + + return false; +} + +// ---------------------------------------------------------------------- + +ManagerConnection *LocatorNamespace::getUnpreferredServer(float cost) +{ // Find a node other than the master node that can afford to run the process // and is a not marked as a preferred node for anything; if more than one // node qualifies, return the node with the lowest load @@ -190,8 +204,8 @@ ManagerConnection *LocatorNamespace::getUnpreferredServer(float cost) // ---------------------------------------------------------------------- ManagerConnection *Locator::getBestServer(std::string const &processName, std::string const &options, float cost) -{ - if (s_serverList.empty()) +{ + if (s_serverList.empty()) return 0; // first, look for a preferred node for this process diff --git a/engine/server/application/TaskManager/src/shared/Locator.h b/engine/server/application/TaskManager/src/shared/Locator.h index 1714a4b5..d0b34505 100755 --- a/engine/server/application/TaskManager/src/shared/Locator.h +++ b/engine/server/application/TaskManager/src/shared/Locator.h @@ -24,6 +24,7 @@ public: static void install(); static void closed(std::string const &label, ManagerConnection const *oldConnection); static ManagerConnection *getBestServer(std::string const &processName, std::string const &options, float cost); + static bool isMasterNodePreferred(std::string const &processName, std::string const &options, float cost); static float getMyLoad(); static float getMyMaximumLoad(); static float getServerLoad(std::string const &label); diff --git a/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp b/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp index 3aa53136..42db2099 100755 --- a/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp +++ b/engine/server/application/TaskManager/src/shared/ManagerConnection.cpp @@ -84,7 +84,7 @@ void ManagerConnection::onConnectionClosed() void ManagerConnection::onConnectionOpened() { - DEBUG_REPORT_LOG(true, ("Manager connection opened\n")); + DEBUG_REPORT_LOG(true, ("Manager connection opened for %s \n", getRemoteAddress().c_str())); TaskConnectionIdMessage id(TaskConnectionIdMessage::TaskManager, TaskManager::getNodeLabel(), ConfigTaskManager::getClusterName()); send(id); s_managerConnectionCount++; diff --git a/engine/server/application/TaskManager/src/shared/TaskManager.cpp b/engine/server/application/TaskManager/src/shared/TaskManager.cpp index 24243de7..f4a9ec31 100755 --- a/engine/server/application/TaskManager/src/shared/TaskManager.cpp +++ b/engine/server/application/TaskManager/src/shared/TaskManager.cpp @@ -613,7 +613,6 @@ unsigned long TaskManager::startServer(const std::string & processName, const st } const ProcessEntry pe = (*f).second; - // does the process run on this box? if(pe.targetHost == "local" || pe.targetHost == getNodeLabel() || nodeLabel == getNodeLabel() || nodeLabel == "local") { @@ -646,10 +645,14 @@ unsigned long TaskManager::startServer(const std::string & processName, const st // select a task manager on which to spawn the server // find the best target float cost = getLoadForProcess(pe.processName); - ManagerConnection * conn = Locator::getBestServer(pe.processName, options, cost); - if(!conn) + if(Locator::isMasterNodePreferred(pe.processName, options, cost)) { - + pid = startServerLocal(pe, options); + } + ManagerConnection * conn = Locator::getBestServer(pe.processName, options, cost); + if(!conn && !pid) + { + if(ManagerConnection::getConnectionCount() < 1) pid = startServerLocal(pe, options); else @@ -666,7 +669,7 @@ unsigned long TaskManager::startServer(const std::string & processName, const st s_queuedSpawnRequests.push_back(r); } } - else + else if(!pid) { std::string label = "uninitialized label"; if(conn->getNodeLabel()) diff --git a/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp b/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp index e42d5eb2..02551b50 100755 --- a/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp +++ b/engine/server/library/serverGame/src/shared/core/ConfigServerGame.cpp @@ -491,6 +491,8 @@ void ConfigServerGame::install(void) KEY_BOOL (useOldSuidGenerator, false); + KEY_STRING (serverLoadLevel, "heavy"); + if (data->baseDecayRate <= 1.0f) data->baseDecayRate = 1.0f; diff --git a/engine/server/library/serverGame/src/shared/core/ConfigServerGame.h b/engine/server/library/serverGame/src/shared/core/ConfigServerGame.h index cf7d8a9c..cc173e35 100755 --- a/engine/server/library/serverGame/src/shared/core/ConfigServerGame.h +++ b/engine/server/library/serverGame/src/shared/core/ConfigServerGame.h @@ -575,6 +575,8 @@ class ConfigServerGame int gcwDaysRequiredForGcwRegionDefenderBonus; bool useOldSuidGenerator; + + const char * serverLoadLevel; }; private: @@ -1061,6 +1063,8 @@ class ConfigServerGame static int getGcwDaysRequiredForGcwRegionDefenderBonus(); static bool getUseOldSuidGenerator(); + + static const char * getServerLoadLevel(); }; //----------------------------------------------------------------------- @@ -3696,6 +3700,11 @@ inline bool ConfigServerGame::getUseOldSuidGenerator() { return data->useOldSuidGenerator; } -// ====================================================================== +// ---------------------------------------------------------------------- + +inline const char *ConfigServerGame::getServerLoadLevel() +{ + return data->serverLoadLevel; +} #endif diff --git a/engine/server/library/serverGame/src/shared/core/ServerBuildoutManager.cpp b/engine/server/library/serverGame/src/shared/core/ServerBuildoutManager.cpp index 6cacac9b..53e6063c 100755 --- a/engine/server/library/serverGame/src/shared/core/ServerBuildoutManager.cpp +++ b/engine/server/library/serverGame/src/shared/core/ServerBuildoutManager.cpp @@ -52,7 +52,7 @@ namespace ServerBuildoutManagerNamespace struct BuildoutRow { BuildoutRow(); - BuildoutRow(int64 id, int64 containerId, int cellIndex, Transform const &transform_p, ServerObjectTemplate const *serverTemplate, std::string const &scripts, std::string const &objvars, std::string const & eventRequired); + BuildoutRow(int64 id, int64 containerId, int cellIndex, Transform const &transform_p, ServerObjectTemplate const *serverTemplate, std::string const &scripts, std::string const &objvars, std::string const & eventRequired, std::string const & requiredLoadLevel); BuildoutRow(BuildoutRow const &rhs); ~BuildoutRow(); BuildoutRow &operator=(BuildoutRow const &rhs); @@ -65,6 +65,7 @@ namespace ServerBuildoutManagerNamespace std::string m_objvars; int m_cellIndex; std::string m_eventRequired; + std::string m_requiredLoadLevel; }; // ---------------------------------------------------------------------- @@ -145,6 +146,7 @@ void ServerBuildoutManager::install() void ServerBuildoutManager::onChunkComplete(int nodeX, int nodeZ) { + std::string configuredLoadLevel = ConfigServerGame::getServerLoadLevel(); for (std::vector::iterator i = s_areas.begin(); i != s_areas.end(); ++i) { AreaInfo &areaInfo = *i; @@ -155,6 +157,24 @@ void ServerBuildoutManager::onChunkComplete(int nodeX, int nodeZ) { if (!areaInfo.loaded) loadArea(areaInfo); + + // Before we decide to instantiate the area, make sure we need to actually load it based on the configured server load level. + std::string areaRequiredLevel = areaInfo.buildoutArea.requiredLoadLevel; + if (configuredLoadLevel != "heavy" && !areaRequiredLevel.empty()) { + if(configuredLoadLevel == "medium"){ + // If our configured level is medium, then our area level must be medium or light. + if(areaRequiredLevel != "medium" && areaRequiredLevel != "light") { + DEBUG_REPORT_LOG(true,("Skipping Area %s (index %d) because its load level is %s and the configured load level is %s\n", areaInfo.buildoutArea.areaName.c_str(), areaInfo.buildoutArea.areaIndex, areaRequiredLevel.c_str(), configuredLoadLevel.c_str())); + continue; + } + } + else if(configuredLoadLevel == "light"){ + if(areaRequiredLevel != "light") { + DEBUG_REPORT_LOG(true,("Skipping Area %s (index %d) because its load level is %s and the configured load level is %s\n", areaInfo.buildoutArea.areaName.c_str(), areaInfo.buildoutArea.areaIndex, areaRequiredLevel.c_str(), configuredLoadLevel.c_str())); + continue; + } + } + } instantiateAreaNode(areaInfo, nodeX, nodeZ); } } @@ -580,6 +600,7 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo) filename[sizeof(filename) - 1] = '\0'; std::string const & eventRequired = areaInfo.buildoutArea.getRequiredEventName(); + std::string const & requiredLoadLevel = areaInfo.buildoutArea.getRequiredLoadLevel(); if (!eventRequired.empty()) { @@ -764,7 +785,8 @@ void ServerBuildoutManagerNamespace::loadArea(AreaInfo &areaInfo) serverTemplate, areaBuildoutTable.getStringValue(scriptsColumn, buildoutRow), areaBuildoutTable.getStringValue(objvarsColumn, buildoutRow), - eventRequired)); + eventRequired, + requiredLoadLevel)); } objects.insert(objId); @@ -1106,7 +1128,7 @@ ServerBuildoutManagerNamespace::BuildoutRow::BuildoutRow() : // ---------------------------------------------------------------------- -ServerBuildoutManagerNamespace::BuildoutRow::BuildoutRow(int64 id, int64 containerId, int cellIndex, Transform const &transform_p, ServerObjectTemplate const *serverTemplate, std::string const &scripts, std::string const &objvars, std::string const & eventRequired) : +ServerBuildoutManagerNamespace::BuildoutRow::BuildoutRow(int64 id, int64 containerId, int cellIndex, Transform const &transform_p, ServerObjectTemplate const *serverTemplate, std::string const &scripts, std::string const &objvars, std::string const & eventRequired, std::string const & requiredLoadLevel) : m_id(id), m_containerId(containerId), m_transform_p(transform_p), @@ -1114,7 +1136,8 @@ ServerBuildoutManagerNamespace::BuildoutRow::BuildoutRow(int64 id, int64 contain m_scripts(scripts), m_objvars(objvars), m_cellIndex(cellIndex), - m_eventRequired(eventRequired) + m_eventRequired(eventRequired), + m_requiredLoadLevel(requiredLoadLevel) { if (serverTemplate) serverTemplate->addReference(); @@ -1130,7 +1153,8 @@ ServerBuildoutManagerNamespace::BuildoutRow::BuildoutRow(BuildoutRow const &rhs) m_scripts(rhs.m_scripts), m_objvars(rhs.m_objvars), m_cellIndex(rhs.m_cellIndex), - m_eventRequired(rhs.m_eventRequired) + m_eventRequired(rhs.m_eventRequired), + m_requiredLoadLevel(rhs.m_requiredLoadLevel) { if (m_serverTemplate) m_serverTemplate->addReference(); @@ -1157,6 +1181,7 @@ ServerBuildoutManagerNamespace::BuildoutRow &ServerBuildoutManagerNamespace::Bui m_objvars = rhs.m_objvars; m_cellIndex = rhs.m_cellIndex; m_eventRequired = rhs.m_eventRequired; + m_requiredLoadLevel = rhs.m_requiredLoadLevel; if (m_serverTemplate) m_serverTemplate->releaseReference(); diff --git a/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp b/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp index 9eaf0211..8e801159 100755 --- a/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp +++ b/engine/server/library/serverGame/src/shared/object/CreatureObject.cpp @@ -13392,18 +13392,11 @@ void CreatureObject::setGroupMissionCriticalObjects(GroupMissionCriticalObjectSe DEBUG_FATAL(!isAuthoritative(), ("CreatureObject::setGroupMissionCriticalObjects: called on non-authoritative object %s", getDebugInformation(true).c_str())); if (isAuthoritative()) { + m_groupMissionCriticalObjectSet.clear(); //-- Anything that is not in our set, we need to add { for (GroupMissionCriticalObjectSet::const_iterator iter = groupMissionCriticalObjectSet.begin(); iter != groupMissionCriticalObjectSet.end(); ++iter) - if (!m_groupMissionCriticalObjectSet.contains(*iter)) - m_groupMissionCriticalObjectSet.insert(*iter); - } - - //-- Anything that is not in the original set, we need to remove - { - for (GroupMissionCriticalObjectSet::const_iterator iter(m_groupMissionCriticalObjectSet.begin()); iter != m_groupMissionCriticalObjectSet.end(); ++iter) - if (groupMissionCriticalObjectSet.find(*iter) == groupMissionCriticalObjectSet.end()) - m_groupMissionCriticalObjectSet.erase(*iter); + m_groupMissionCriticalObjectSet.insert(*iter); } } } diff --git a/engine/server/library/serverUtility/src/CMakeLists.txt b/engine/server/library/serverUtility/src/CMakeLists.txt index 5b7aa219..98a15ec7 100644 --- a/engine/server/library/serverUtility/src/CMakeLists.txt +++ b/engine/server/library/serverUtility/src/CMakeLists.txt @@ -49,7 +49,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMath/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMathArchive/include/public - + ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public @@ -60,6 +60,7 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localizationArchive/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_library(serverUtility STATIC diff --git a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp index 6d30f4f5..2118aa18 100755 --- a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp +++ b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp @@ -3,6 +3,8 @@ //----------------------------------------------------------------------- +#include "ConfigServerUtility.h" + #include "serverUtility/FirstServerUtility.h" #include "serverUtility/AdminAccountManager.h" @@ -10,6 +12,8 @@ #include "sharedUtility/DataTable.h" #include "sharedUtility/DataTableManager.h" +#include "webAPI.h" + #include //----------------------------------------------------------------------- @@ -69,6 +73,14 @@ int AdminAccountManager::getAdminLevel(const std::string & account) int level = 0; DEBUG_FATAL(!ms_installed, ("AdminAccountManager not installed")); + if(ConfigServerUtility::isExternalAdminLevelsEnabled()){ + std::ostringstream postBuffer; + postBuffer << "user_name=" << account << "&secretKey=" << ConfigServerUtility::getExternalAdminLevelsSecretKey(); + std::string response = webAPI::simplePost(ConfigServerUtility::getExternalAdminLevelsURL(), std::string(postBuffer.str()), ""); + level = std::stoi(response); + return level; + } + int columnNumber = ms_adminTable->findColumnNumber("AdminAccounts"); DEBUG_FATAL(columnNumber == -1, ("Error loading admin table...no account column")); int row = ms_adminTable->searchColumnString( columnNumber, account); @@ -113,8 +125,8 @@ bool AdminAccountManager::isInternalIp(const std::string & addr) size_t xpos = ipAddr.find ('x'); //if no X is found, do a straight compare - if ( (xpos == 0 || xpos == std::string::npos) - && ipAddr.compare(addr) == 0 + if ( (xpos == 0 || xpos == std::string::npos) + && ipAddr.compare(addr) == 0 ) { retval = true; @@ -125,7 +137,7 @@ bool AdminAccountManager::isInternalIp(const std::string & addr) else if (xpos - 1 > addr.size()) retval = false; - //compare substring + //compare substring else if (ipAddr.compare(0, xpos - 1, addr, 0, xpos - 1) == 0) { retval = true; @@ -148,6 +160,7 @@ void AdminAccountManager::reload() DEBUG_FATAL(!ms_installed, ("AdminAccountManager not installed")); NOT_NULL(ms_dataTableName); DataTableManager::reload(*ms_dataTableName); + ms_adminTable = DataTableManager::getTable (ms_dataTableName->c_str(), true); } //----------------------------------------------------------------------- diff --git a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp index 83d3230c..4c7db5d9 100755 --- a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp +++ b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.cpp @@ -17,6 +17,9 @@ namespace ConfigServerUtilityNamespace int serverMaxChatLogLines; int playerMaxChatLogLines; bool chatLogManagerLoggingEnabled; + bool externalAdminLevelsEnabled; + const char * externalAdminLevelsURL; + const char * externalAdminLevelsSecretKey; } using namespace ConfigServerUtilityNamespace; @@ -75,6 +78,27 @@ bool ConfigServerUtility::isChatLogManagerLoggingEnabled() //----------------------------------------------------------------------- +bool ConfigServerUtility::isExternalAdminLevelsEnabled() +{ + return externalAdminLevelsEnabled; +} + +//----------------------------------------------------------------------- + +const char * ConfigServerUtility::getExternalAdminLevelsURL() +{ + return externalAdminLevelsURL; +} + +//----------------------------------------------------------------------- + +const char * ConfigServerUtility::getExternalAdminLevelsSecretKey() +{ + return externalAdminLevelsSecretKey; +} + +//----------------------------------------------------------------------- + void ConfigServerUtility::install() { KEY_INT(spawnCookie, 0); @@ -82,6 +106,9 @@ void ConfigServerUtility::install() KEY_INT(serverMaxChatLogLines, 5000); KEY_INT(playerMaxChatLogLines, 200); KEY_BOOL(chatLogManagerLoggingEnabled, false); + KEY_BOOL(externalAdminLevelsEnabled, false); + KEY_STRING(externalAdminLevelsURL, "http://localhost/"); + KEY_STRING(externalAdminLevelsSecretKey, ""); } //----------------------------------------------------------------------- @@ -91,4 +118,3 @@ void ConfigServerUtility::remove() } //----------------------------------------------------------------------- - diff --git a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h index 33f0db04..e2235f0c 100755 --- a/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h +++ b/engine/server/library/serverUtility/src/shared/ConfigServerUtility.h @@ -17,6 +17,9 @@ public: static int getServerMaxChatLogLines(); static int getPlayerMaxChatLogLines(); static bool isChatLogManagerLoggingEnabled(); + static bool isExternalAdminLevelsEnabled(); + static const char * getExternalAdminLevelsURL(); + static const char * getExternalAdminLevelsSecretKey(); static void install(); static void remove(); diff --git a/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.cpp b/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.cpp index 66ddbb64..703ef5b8 100755 --- a/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.cpp +++ b/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.cpp @@ -158,6 +158,13 @@ std::string const & BuildoutArea::getRequiredEventName() const return requiredEventName; } +//---------------------------------------------------------------------- + +std::string const & BuildoutArea::getRequiredLoadLevel() const +{ + return requiredLoadLevel; +} + // ====================================================================== bool SharedBuildoutAreaManager::isBuildoutScene(std::string const & sceneName) @@ -263,6 +270,8 @@ void SharedBuildoutAreaManager::install() buildoutArea.internalBuildoutArea = areaListTable.getIntValue("internal", areaRow) != 0; buildoutArea.requiredEventName = areaListTable.getStringValue("eventRequired", areaRow); + + buildoutArea.requiredLoadLevel = areaListTable.getStringValue("requiredLoadLevel", areaRow); } s_buildoutAreas[buildoutScene] = areasForScene; @@ -347,6 +356,9 @@ Vector SharedBuildoutAreaManager::getRelativePositionInArea(std::string const & if(ignoreNonActiveEvents && !boa.requiredEventName.empty()) // Eventually this needs to query the scheduler system and see if the event is currently active. continue; + + if(ignoreNonActiveEvents && !boa.requiredLoadLevel.empty()) + continue; if(boa.isLocationInside(location_w.x, location_w.z) && boa.areaName == sceneAndArea.second) { @@ -561,6 +573,9 @@ BuildoutArea const * SharedBuildoutAreaManager::findBuildoutAreaAtPosition(std:: if(ignoreNonActiveEvents && !buildoutArea.requiredEventName.empty()) continue; + if(ignoreNonActiveEvents && !buildoutArea.requiredLoadLevel.empty()) + continue; + if (buildoutArea.isLocationInside(x, z)) { return &buildoutArea; @@ -585,6 +600,9 @@ BuildoutArea const * SharedBuildoutAreaManager::findBuildoutAreaAtPosition(float if(ignoreNonActiveEvents && !buildoutArea.requiredEventName.empty()) return nullptr; + if(ignoreNonActiveEvents && !buildoutArea.requiredLoadLevel.empty()) + return nullptr; + if (buildoutArea.isLocationInside(x, z)) { return &buildoutArea; diff --git a/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.h b/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.h index 174cd34e..8d4e56fc 100755 --- a/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.h +++ b/engine/shared/library/sharedGame/src/shared/core/SharedBuildoutAreaManager.h @@ -38,6 +38,7 @@ public: Vector getRelativePosition(Vector const & pos_w, bool allowComposite) const; std::string const & getRequiredEventName() const; + std::string const & getRequiredLoadLevel() const; int areaIndex; std::string areaName; @@ -63,6 +64,9 @@ public: // Required Event name for a particular buildout std::string requiredEventName; + + // Required Server level for a particular buildout + std::string requiredLoadLevel; }; // ----------------------------------------------------------------------