Move game ID util to natives + use db config util
This commit is contained in:
@@ -212,4 +212,10 @@ function getPlayerName(client) {
|
|||||||
return client.name;
|
return client.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function getGame() {
|
||||||
|
return game.game;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -748,10 +748,10 @@ function getPlayerWeapon(client) {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function connectToDatabase() {
|
function connectToDatabase() {
|
||||||
if(databaseConfig.usePersistentConnection) {
|
if(getDatabaseConfig().usePersistentConnection) {
|
||||||
if(persistentDatabaseConnection == null) {
|
if(persistentDatabaseConnection == null) {
|
||||||
logToConsole(LOG_DEBUG, "[VRR.Database] Initializing database connection ...");
|
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) {
|
if(persistentDatabaseConnection.error) {
|
||||||
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
|
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
|
||||||
persistentDatabaseConnection = null;
|
persistentDatabaseConnection = null;
|
||||||
@@ -765,7 +765,7 @@ function connectToDatabase() {
|
|||||||
return persistentDatabaseConnection;
|
return persistentDatabaseConnection;
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if(databaseConnection.error) {
|
||||||
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
|
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
|
||||||
return false;
|
return false;
|
||||||
@@ -778,7 +778,7 @@ function connectToDatabase() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function disconnectFromDatabase(dbConnection) {
|
function disconnectFromDatabase(dbConnection) {
|
||||||
if(!databaseConfig.usePersistentConnection) {
|
if(!getDatabaseConfig().usePersistentConnection) {
|
||||||
try {
|
try {
|
||||||
dbConnection.close();
|
dbConnection.close();
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`);
|
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) {
|
function createDatabaseInsertQuery(tableName, data) {
|
||||||
let fields = [];
|
let fields = [];
|
||||||
let values = [];
|
let values = [];
|
||||||
@@ -1202,4 +1195,10 @@ function despawnPlayer(client) {
|
|||||||
client.despawnPlayer();
|
client.despawnPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
function getGame() {
|
||||||
|
return server.game;
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user