From 0e3b30725f606b5db1dc2fd473aad35a94965457 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 26 Apr 2022 10:18:15 -0500 Subject: [PATCH] Move game ID util to natives + use db config util --- scripts/client/native/connected.js | 6 ++++++ scripts/server/native/connected.js | 21 ++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/client/native/connected.js b/scripts/client/native/connected.js index a3a8c00f..bdcf759c 100644 --- a/scripts/client/native/connected.js +++ b/scripts/client/native/connected.js @@ -212,4 +212,10 @@ function getPlayerName(client) { return client.name; } +// =========================================================================== + +function getGame() { + return game.game; +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/server/native/connected.js b/scripts/server/native/connected.js index c5cb542e..d9c2a3d4 100644 --- a/scripts/server/native/connected.js +++ b/scripts/server/native/connected.js @@ -748,10 +748,10 @@ function getPlayerWeapon(client) { // =========================================================================== function connectToDatabase() { - if(databaseConfig.usePersistentConnection) { + if(getDatabaseConfig().usePersistentConnection) { if(persistentDatabaseConnection == null) { logToConsole(LOG_DEBUG, "[VRR.Database] Initializing database connection ..."); - persistentDatabaseConnection = module.mysql.connect(databaseConfig.host, databaseConfig.user, databaseConfig.pass, databaseConfig.name, databaseConfig.port); + persistentDatabaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); if(persistentDatabaseConnection.error) { console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error)); persistentDatabaseConnection = null; @@ -765,7 +765,7 @@ function connectToDatabase() { return persistentDatabaseConnection; } } else { - let databaseConnection = module.mysql.connect(databaseConfig.host, databaseConfig.user, databaseConfig.pass, databaseConfig.name, databaseConfig.port); + let databaseConnection = module.mysql.connect(getDatabaseConfig().host, getDatabaseConfig().user, getDatabaseConfig().pass, getDatabaseConfig().name, getDatabaseConfig().port); if(databaseConnection.error) { console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error)); return false; @@ -778,7 +778,7 @@ function connectToDatabase() { // =========================================================================== function disconnectFromDatabase(dbConnection) { - if(!databaseConfig.usePersistentConnection) { + if(!getDatabaseConfig().usePersistentConnection) { try { dbConnection.close(); logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`); @@ -921,13 +921,6 @@ function setConstantsAsGlobalVariablesInDatabase() { // =========================================================================== -function loadDatabaseConfiguration() { - let databaseConfigFile = loadTextFile("config/database.json"); - return JSON.parse(databaseConfigFile); -} - -// =========================================================================== - function createDatabaseInsertQuery(tableName, data) { let fields = []; let values = []; @@ -1202,4 +1195,10 @@ function despawnPlayer(client) { client.despawnPlayer(); } +// =========================================================================== + +function getGame() { + return server.game; +} + // =========================================================================== \ No newline at end of file