Use new server config class

This commit is contained in:
Vortrex
2020-12-26 02:04:36 -06:00
parent ac05f47f17
commit 0b4ad0a182

View File

@@ -224,8 +224,6 @@ let gameConfig = {
function initConfigScript() { function initConfigScript() {
console.log("[Asshat.Config]: Initializing config script ..."); console.log("[Asshat.Config]: Initializing config script ...");
serverConfig = loadServerConfig(server.game, server.port);
applyConfigToServer(serverConfig);
console.log("[Asshat.Config]: Config script initialized!"); console.log("[Asshat.Config]: Config script initialized!");
} }
@@ -239,14 +237,14 @@ function loadServerConfigFromGameAndPort(gameId, port) {
if(dbQuery) { if(dbQuery) {
if(dbQuery.numRows > 0) { if(dbQuery.numRows > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery); let dbAssoc = fetchQueryAssoc(dbQuery);
let tempServerConfigData = new serverClasses.serverConfigData(dbAssoc);
let tempServerConfigData = serverClasses.serverConfigData(dbAssoc);
freeDatabaseQuery(dbQuery); freeDatabaseQuery(dbQuery);
return tempServerConfigData;
} }
} }
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
} }
return false;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -266,16 +264,17 @@ function loadServerConfigFromId(tempServerId) {
} }
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
} }
return false;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function applyConfigToServer() { function applyConfigToServer(tempServerConfig) {
server.name = getServerConfig().name; server.name = tempServerConfig.name;
server.password = getServerConfig().password; server.password = tempServerConfig.password;
gta.time.hour = getServerConfig().hour; gta.time.hour = tempServerConfig.hour;
gta.time.minute = getServerConfig().minute; gta.time.minute = tempServerConfig.minute;
gta.forceWeather(getServerConfig().weather); gta.forceWeather(tempServerConfig.weather);
updateServerRules(); updateServerRules();
} }