From a9f82b41507c0e593bbefc185bdfda2bfc4eef2d Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 5 Jul 2022 13:02:20 -0500 Subject: [PATCH] Add load svr cfg from game util --- scripts/server/config.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/server/config.js b/scripts/server/config.js index bfc9bdd1..5a365f15 100644 --- a/scripts/server/config.js +++ b/scripts/server/config.js @@ -322,6 +322,26 @@ function loadServerConfigFromGameAndPort(gameId, port) { // =========================================================================== +function loadServerConfigFromGame(gameId) { + let dbConnection = connectToDatabase(); + if (dbConnection) { + let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`; + let dbQuery = queryDatabase(dbConnection, dbQueryString); + if (dbQuery) { + if (dbQuery.numRows > 0) { + let dbAssoc = fetchQueryAssoc(dbQuery); + let tempServerConfigData = new ServerConfigData(dbAssoc); + freeDatabaseQuery(dbQuery); + return tempServerConfigData; + } + } + disconnectFromDatabase(dbConnection); + } + return false; +} + +// =========================================================================== + function loadServerConfigFromId(tempServerId) { let dbConnection = connectToDatabase(); if (dbConnection) { @@ -1096,7 +1116,12 @@ function getDatabaseConfig() { function loadServerConfig() { logToConsole(LOG_DEBUG, "[VRR.Config] Loading server configuration"); try { - serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort()); + if (toInteger(server.getCVar("agrp_devserver")) == 1) { + serverConfig = loadServerConfigFromGame(getGame()); + } else { + serverConfig = loadServerConfigFromGameAndPort(getGame(), getServerPort()); + } + } catch (error) { logToConsole(LOG_ERROR, `[VRR.Config] Could not load server configuration for game ${getGame()} and port ${getServerPort}`); thisResource.stop();