New assoc table usage
This commit is contained in:
@@ -718,26 +718,22 @@ function isAccountPasswordCorrect(accountData, password) {
|
||||
async function loadAccountFromName(accountName, fullLoad = false) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
accountName = escapeDatabaseString(dbConnection, accountName);
|
||||
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_name = '${accountName}' LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountData = new AccountData(dbAssoc[0]);
|
||||
if (fullLoad) {
|
||||
tempAccountData.messages = await loadAccountMessagesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.notes = await loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.contacts = await loadAccountContactsFromDatabase(tempAccountData.databaseId);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return tempAccountData;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempAccountData = new AccountData(dbAssoc[0]);
|
||||
if (fullLoad) {
|
||||
tempAccountData.messages = await loadAccountMessagesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.notes = await loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.contacts = await loadAccountContactsFromDatabase(tempAccountData.databaseId);
|
||||
}
|
||||
return tempAccountData;
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -746,13 +742,12 @@ async function loadAccountFromName(accountName, fullLoad = false) {
|
||||
async function loadAccountFromId(accountId, fullLoad = false) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT acct_main.*, acct_svr.* FROM acct_main INNER JOIN acct_svr ON acct_svr.acct_svr_acct = acct_main.acct_id AND acct_svr.acct_svr_svr = ${getServerId()} WHERE acct_id = ${accountId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempAccountData = new AccountData(dbAssoc[0]);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
if (fullLoad) {
|
||||
tempAccountData.messages = await loadAccountMessagesFromDatabase(tempAccountData.databaseId);
|
||||
tempAccountData.notes = await loadAccountStaffNotesFromDatabase(tempAccountData.databaseId);
|
||||
@@ -1482,8 +1477,7 @@ async function loadAccountKeybindsFromDatabase(accountDatabaseID) {
|
||||
|
||||
let tempAccountKeybinds = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
for (let i in getGlobalConfig().keyBind.defaultKeyBinds) {
|
||||
let tempKeyBindData = new KeyBindData(false);
|
||||
@@ -1496,17 +1490,14 @@ async function loadAccountKeybindsFromDatabase(accountDatabaseID) {
|
||||
|
||||
if (accountDatabaseID != 0 && typeof accountDatabaseId != "undefined") {
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountKeyBindData = new KeyBindData(dbAssoc);
|
||||
tempAccountKeybinds.push(tempAccountKeyBindData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${toUpperCase(getKeyNameFromId(tempAccountKeyBindData.key))}') loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM acct_hotkey WHERE acct_hotkey_enabled = 1 AND acct_hotkey_acct = ${accountDatabaseID} AND acct_hotkey_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountKeyBindData = new KeyBindData(dbAssoc[i]);
|
||||
tempAccountKeybinds.push(tempAccountKeyBindData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account keybind '${tempAccountKeyBindData.databaseId}' (Key ${tempAccountKeyBindData.key} '${toUpperCase(getKeyNameFromId(tempAccountKeyBindData.key))}') loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -1523,21 +1514,17 @@ async function loadAccountStaffNotesFromDatabase(accountDatabaseID) {
|
||||
|
||||
let tempAccountStaffNotes = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_note` WHERE `acct_note_deleted` = 0 AND `acct_note_acct` = " + toString(accountDatabaseID));
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountStaffNoteData = new AccountStaffNoteData(dbAssoc[i]);
|
||||
tempAccountStaffNotes.push(tempAccountStaffNoteData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = "SELECT * FROM `acct_note` WHERE `acct_note_deleted` = 0 AND `acct_note_acct` = " + toString(accountDatabaseID);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountStaffNoteData = new AccountStaffNoteData(dbAssoc[i]);
|
||||
tempAccountStaffNotes.push(tempAccountStaffNoteData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account staff note '${tempAccountStaffNoteData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -1553,21 +1540,17 @@ async function loadAccountContactsFromDatabase(accountDatabaseID) {
|
||||
|
||||
let tempAccountContacts = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_contact` WHERE `acct_contact_deleted` = 0 AND `acct_contact_acct` = " + toString(accountDatabaseID));
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountContactData = new AccountContactData(dbAssoc[i]);
|
||||
tempAccountContacts.push(tempAccountContactData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = "SELECT * FROM `acct_contact` WHERE `acct_contact_deleted` = 0 AND `acct_contact_acct` = " + toString(accountDatabaseID);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountContactData = new AccountContactData(dbAssoc[i]);
|
||||
tempAccountContacts.push(tempAccountContactData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account contact '${tempAccountContactData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -1583,21 +1566,17 @@ async function loadAccountMessagesFromDatabase(accountDatabaseID) {
|
||||
|
||||
let tempAccountMessages = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `acct_msg` WHERE `acct_msg_deleted` = 0 AND `acct_msg_acct` = " + toString(accountDatabaseID));
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountMessageData = new AccountContactData(dbAssoc[i]);
|
||||
tempAccountMessages.push(tempAccountMessageData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = "SELECT * FROM`acct_msg` WHERE `acct_msg_deleted` = 0 AND`acct_msg_acct` = " + toString(accountDatabaseID);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempAccountMessageData = new AccountContactData(dbAssoc[i]);
|
||||
tempAccountMessages.push(tempAccountMessageData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Account]: Account contact '${tempAccountMessageData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -200,11 +200,9 @@ async function loadBusinessFromId(businessId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM biz_main WHERE biz_id = ${businessId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new BusinessData(dbAssoc);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
return new BusinessData(dbAssoc[0]);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -219,24 +217,21 @@ async function loadBusinessesFromDatabase() {
|
||||
|
||||
let tempBusinesses = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM biz_main WHERE biz_deleted = 0 AND biz_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempBusinessData = new BusinessData(dbAssoc[i]);
|
||||
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
|
||||
//tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId);
|
||||
tempBusinesses.push(tempBusinessData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM biz_main WHERE biz_deleted = 0 AND biz_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempBusinessData = new BusinessData(dbAssoc[i]);
|
||||
tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId);
|
||||
//tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId);
|
||||
tempBusinesses.push(tempBusinessData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -251,23 +246,18 @@ async function loadBusinessLocationsFromDatabase(businessId) {
|
||||
|
||||
let tempBusinessLocations = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc = [];
|
||||
let dbQueryString = "";
|
||||
|
||||
if (dbConnection) {
|
||||
dbQueryString = `SELECT * FROM biz_loc WHERE biz_loc_biz = ${businessId}`;
|
||||
dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempBusinessLocationData = new BusinessLocationData(dbAssoc[i]);
|
||||
tempBusinessLocations.push(tempBusinessLocationData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`);
|
||||
}
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempBusinessLocationData = new BusinessLocationData(dbAssoc[i]);
|
||||
tempBusinessLocations.push(tempBusinessLocationData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -290,9 +280,7 @@ async function loadBusinessGameScriptsFromDatabase(businessId) {
|
||||
|
||||
if(dbConnection) {
|
||||
dbQueryString = `SELECT * FROM biz_script WHERE biz_script_biz = ${businessId}`;
|
||||
dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if(dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempBusinessGameScriptData = new BusinessGameScriptData(dbAssoc[i]);
|
||||
@@ -300,8 +288,6 @@ async function loadBusinessGameScriptsFromDatabase(businessId) {
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Business]: Game script '${tempBusinessGameScriptData.name}' loaded from database successfully!`);
|
||||
}
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,19 +125,16 @@ async function loadClansFromDatabase() {
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempClanData = new ClanData(dbAssoc[i]);
|
||||
//tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
|
||||
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
|
||||
tempClans.push(tempClanData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempClanData = new ClanData(dbAssoc[i]);
|
||||
//tempClanData.members = loadClanMembersFromDatabase(tempClanData.databaseId);
|
||||
tempClanData.ranks = loadClanRanksFromDatabase(tempClanData.databaseId);
|
||||
tempClans.push(tempClanData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -153,20 +150,17 @@ async function loadClanMembersFromDatabase() {
|
||||
|
||||
let tempClans = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempClanData = new ClanData(dbAssoc[i]);
|
||||
tempClans.push(tempClanData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM clan_main WHERE clan_deleted = 0 AND clan_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempClanData = new ClanData(dbAssoc[i]);
|
||||
tempClans.push(tempClanData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Clan]: Clan '${tempClanData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -181,21 +175,18 @@ async function loadClanRanksFromDatabase(clanDatabaseId) {
|
||||
logToConsole(LOG_INFO, `[AGRP.Clan]: Loading ranks for clan ${clanDatabaseId} from database ...`);
|
||||
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
let tempClanRanks = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM clan_rank WHERE clan_rank_clan = ${clanDatabaseId}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempClanRankData = new ClanRankData(dbAssoc[i]);
|
||||
tempClanRanks.push(tempClanRankData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Clan]: Clan rank '${tempClanRankData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM clan_rank WHERE clan_rank_clan = ${clanDatabaseId}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempClanRankData = new ClanRankData(dbAssoc[i]);
|
||||
tempClanRanks.push(tempClanRankData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Clan]: Clan rank '${tempClanRankData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -318,13 +318,10 @@ async function loadServerConfigFromGameAndPort(gameId, port) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -337,15 +334,12 @@ async 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) {
|
||||
let dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -356,13 +350,10 @@ async function loadServerConfigFromId(tempServerId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM svr_main WHERE svr_id = ${tempServerId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
|
||||
return tempServerConfigData;
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -551,11 +551,11 @@ function isDevelopmentServer() {
|
||||
|
||||
async function migrateSubAccountsToPerServerData() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
let dbAssoc = false;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM sacct_main`);
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
let dbQueryString = `SELECT * FROM sacct_main`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
createDefaultSubAccountServerData(dbAssoc[0]["sacct_id"]);
|
||||
|
||||
@@ -564,6 +564,7 @@ async function migrateSubAccountsToPerServerData() {
|
||||
freeDatabaseQuery(dbQuery2);
|
||||
}
|
||||
}
|
||||
disconnectFromDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,17 +572,15 @@ async function migrateSubAccountsToPerServerData() {
|
||||
|
||||
async function resetAllAccountsHotkeysToDefault() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = false;
|
||||
let dbAssoc = false;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT acct_id FROM acct_main`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
createDefaultKeybindsForAccount(dbAssoc[0]["acct_id"]);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
let dbQueryString = `SELECT acct_id FROM acct_main`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
createDefaultKeybindsForAccount(dbAssoc[0]["acct_id"]);
|
||||
}
|
||||
disconnectFromDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,17 +243,14 @@ async function loadGatesFromDatabase() {
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempGateData = new GateData(dbAssoc[i]);
|
||||
tempGates.push(tempGateData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM gate_main WHERE gate_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempGateData = new GateData(dbAssoc[i]);
|
||||
tempGates.push(tempGateData);
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Gate]: Gate '${tempGateData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -182,17 +182,14 @@ async function loadHousesFromDatabase() {
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM house_main WHERE house_deleted = 0 AND house_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempHouseData = new HouseData(dbAssoc[i]);
|
||||
tempHouses.push(tempHouseData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM house_main WHERE house_deleted = 0 AND house_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempHouseData = new HouseData(dbAssoc[i]);
|
||||
tempHouses.push(tempHouseData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -292,19 +292,16 @@ async function loadItemsFromDatabase() {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Item]: Loading items from database ...`);
|
||||
let tempItems = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_main WHERE item_deleted = 0 AND item_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempItemData = new ItemData(dbAssoc[i]);
|
||||
tempItems.push(tempItemData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Item]: Loaded item ${tempItemData.databaseId} (type ${tempItemData.itemType})} from database`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM item_main WHERE item_deleted = 0 AND item_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempItemData = new ItemData(dbAssoc[i]);
|
||||
tempItems.push(tempItemData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Item]: Loaded item ${tempItemData.databaseId} (type ${tempItemData.itemType})} from database`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -318,19 +315,17 @@ async function loadItemTypesFromDatabase() {
|
||||
logToConsole(LOG_DEBUG, `[AGRP.Item]: Loading item types from database ...`);
|
||||
let tempItemTypes = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `SELECT * FROM item_type WHERE item_type_deleted = 0 AND item_type_enabled = 1 AND item_type_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempItemTypeData = new ItemTypeData(dbAssoc[i]);
|
||||
tempItemTypes.push(tempItemTypeData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Item]: Loaded item type ${tempItemTypeData.name} (id ${tempItemTypeData.databaseId}} from database`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM item_type WHERE item_type_deleted = 0 AND item_type_enabled = 1 AND item_type_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempItemTypeData = new ItemTypeData(dbAssoc[i]);
|
||||
tempItemTypes.push(tempItemTypeData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Item]: Loaded item type ${tempItemTypeData.name} (id ${tempItemTypeData.databaseId}} from database`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -484,26 +484,22 @@ async function loadJobsFromDatabase() {
|
||||
|
||||
let tempJobs = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_main WHERE job_deleted = 0 AND job_enabled = 1 AND job_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobData = new JobData(dbAssoc[i]);
|
||||
tempJobData.locations = loadJobLocationsFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.equipment = loadJobEquipmentsFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.uniforms = loadJobUniformsFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.routes = loadJobRoutesFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.ranks = loadJobRanksFromDatabase(tempJobData.databaseId);
|
||||
tempJobs.push(tempJobData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job '${tempJobData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM job_main WHERE job_deleted = 0 AND job_enabled = 1 AND job_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobData = new JobData(dbAssoc[i]);
|
||||
tempJobData.locations = loadJobLocationsFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.equipment = loadJobEquipmentsFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.uniforms = loadJobUniformsFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.routes = loadJobRoutesFromDatabase(tempJobData.databaseId);
|
||||
tempJobData.ranks = loadJobRanksFromDatabase(tempJobData.databaseId);
|
||||
tempJobs.push(tempJobData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job '${tempJobData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -551,21 +547,17 @@ async function loadJobRanksFromDatabase(jobDatabaseId) {
|
||||
|
||||
let tempJobRanks = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_rank WHERE job_rank_deleted = 0 AND job_rank_enabled = 1 AND job_rank_job = ${jobDatabaseId}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobRankData = new JobRankData(dbAssoc[i]);
|
||||
tempJobRanks.push(tempJobRankData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job rank '${tempJobRankData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM job_rank WHERE job_rank_deleted = 0 AND job_rank_enabled = 1 AND job_rank_job = ${jobDatabaseId}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobRankData = new JobRankData(dbAssoc[i]);
|
||||
tempJobRanks.push(tempJobRankData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job rank '${tempJobRankData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -581,22 +573,18 @@ async function loadJobRoutesFromDatabase(jobDatabaseId) {
|
||||
|
||||
let tempJobRoutes = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route WHERE job_route_deleted = 0 AND job_route_enabled = 1 AND job_route_job = ${jobDatabaseId}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobRouteData = new JobRouteData(dbAssoc[i]);
|
||||
tempJobRouteData.locations = loadJobRouteLocationsFromDatabase(tempJobRouteData.databaseId);
|
||||
tempJobRoutes.push(tempJobRouteData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job route '${tempJobRouteData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM job_route WHERE job_route_deleted = 0 AND job_route_enabled = 1 AND job_route_job = ${jobDatabaseId}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobRouteData = new JobRouteData(dbAssoc[i]);
|
||||
tempJobRouteData.locations = loadJobRouteLocationsFromDatabase(tempJobRouteData.databaseId);
|
||||
tempJobRoutes.push(tempJobRouteData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job route '${tempJobRouteData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -612,21 +600,17 @@ async function loadJobRouteLocationsFromDatabase(jobRouteId) {
|
||||
|
||||
let tempJobRouteLocations = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_route_loc WHERE job_route_loc_deleted = 0 AND job_route_loc_enabled = 1 AND job_route_loc_route = ${jobRouteId}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobRouteLocationData = new JobRouteLocationData(dbAssoc[i]);
|
||||
tempJobRouteLocations.push(tempJobRouteLocationData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job route location '${tempJobRouteLocationData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM job_route_loc WHERE job_route_loc_deleted = 0 AND job_route_loc_enabled = 1 AND job_route_loc_route = ${jobRouteId}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobRouteLocationData = new JobRouteLocationData(dbAssoc[i]);
|
||||
tempJobRouteLocations.push(tempJobRouteLocationData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job route location '${tempJobRouteLocationData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -642,22 +626,18 @@ async function loadJobEquipmentsFromDatabase(jobDatabaseId) {
|
||||
|
||||
let tempJobEquipments = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_equip WHERE job_equip_deleted = 0 AND job_equip_enabled = 1 AND job_equip_job = ${jobDatabaseId}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobEquipmentData = new JobEquipmentData(dbAssoc[i]);
|
||||
tempJobEquipmentData.items = loadJobEquipmentItemsFromDatabase(tempJobEquipmentData.databaseId);
|
||||
tempJobEquipments.push(tempJobEquipmentData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job equipment '${tempJobEquipmentData.name}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM job_equip WHERE job_equip_deleted = 0 AND job_equip_enabled = 1 AND job_equip_job = ${jobDatabaseId}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobEquipmentData = new JobEquipmentData(dbAssoc[i]);
|
||||
tempJobEquipmentData.items = loadJobEquipmentItemsFromDatabase(tempJobEquipmentData.databaseId);
|
||||
tempJobEquipments.push(tempJobEquipmentData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job equipment '${tempJobEquipmentData.name}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -673,21 +653,17 @@ async function loadJobLocationsFromDatabase(jobDatabaseId) {
|
||||
|
||||
let tempJobLocations = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM job_loc WHERE job_loc_deleted = 0 AND job_loc_enabled = 1 AND job_loc_job = ${jobDatabaseId}`);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobLocationData = new JobLocationData(dbAssoc[i]);
|
||||
tempJobLocations.push(tempJobLocationData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job location '${tempJobLocationData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM job_loc WHERE job_loc_deleted = 0 AND job_loc_enabled = 1 AND job_loc_job = ${jobDatabaseId}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobLocationData = new JobLocationData(dbAssoc[i]);
|
||||
tempJobLocations.push(tempJobLocationData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job location '${tempJobLocationData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -703,21 +679,17 @@ async function loadJobUniformsFromDatabase(jobDatabaseId) {
|
||||
|
||||
let tempJobUniforms = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_uniform` WHERE `job_uniform_enabled` = 1 AND `job_uniform_job` = " + toString(jobDatabaseId));
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobUniformData = new JobUniformData(dbAssoc[i]);
|
||||
tempJobUniforms.push(tempJobUniformData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job uniform '${tempJobUniformData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = "SELECT * FROM `job_uniform` WHERE `job_uniform_enabled` = 1 AND `job_uniform_job` = " + toString(jobDatabaseId);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobUniformData = new JobUniformData(dbAssoc[i]);
|
||||
tempJobUniforms.push(tempJobUniformData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job uniform '${tempJobUniformData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -733,21 +705,17 @@ async function loadJobEquipmentItemsFromDatabase(jobEquipmentDatabaseId) {
|
||||
|
||||
let tempJobEquipmentItems = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, "SELECT * FROM `job_equip_item` WHERE `job_equip_item_enabled` = 1 AND `job_equip_item_equip` = " + toString(jobEquipmentDatabaseId));
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobEquipmentItemData = new JobEquipmentItemData(dbAssoc[i]);
|
||||
tempJobEquipmentItems.push(tempJobEquipmentItemData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job equipment item '${tempJobEquipmentItemData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = "SELECT * FROM `job_equip_item` WHERE `job_equip_item_enabled` = 1 AND `job_equip_item_equip` = " + toString(jobEquipmentDatabaseId)
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempJobEquipmentItemData = new JobEquipmentItemData(dbAssoc[i]);
|
||||
tempJobEquipmentItems.push(tempJobEquipmentItemData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Job]: Job equipment item '${tempJobEquipmentItemData.databaseId}' loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -917,14 +917,16 @@ function freeDatabaseQuery(dbQuery) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function fetchQueryAssoc(dbQuery) {
|
||||
//logToConsole(LOG_DEBUG, dbQueryString);
|
||||
async function fetchQueryAssoc(dbConnection, queryString) {
|
||||
let assocArray = [];
|
||||
let dbAssoc = null;
|
||||
|
||||
while (dbAssoc = dbQuery.fetchAssoc()) {
|
||||
assocArray.push(dbAssoc);
|
||||
//logToConsole(LOG_DEBUG | LOG_WARN, dbAssoc["svr_id"]);
|
||||
let dbQuery = dbConnection.query(queryString);
|
||||
if (dbQuery) {
|
||||
while (dbAssoc = dbQuery.fetchAssoc()) {
|
||||
assocArray.push(dbAssoc);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
|
||||
return assocArray;
|
||||
|
||||
@@ -838,8 +838,10 @@ function freeDatabaseQuery(dbQuery) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function fetchQueryAssoc(dbQuery) {
|
||||
return dbQuery.fetchAssoc();
|
||||
async function fetchQueryAssoc(dbConnection, queryString) {
|
||||
return dbConnection.query(queryString, function (err, result, fields) {
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -253,17 +253,13 @@ async function loadNPCsFromDatabase() {
|
||||
let dbAssoc = [];
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM npc_main WHERE npc_server = ${getServerId()} AND npc_enabled = 1`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCData = new NPCData(dbAssoc[i]);
|
||||
tempNPCData.triggers = loadNPCTriggersFromDatabase(tempNPCData.databaseId);
|
||||
tempNPCs.push(tempNPCData);
|
||||
}
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCData = new NPCData(dbAssoc[i]);
|
||||
tempNPCData.triggers = loadNPCTriggersFromDatabase(tempNPCData.databaseId);
|
||||
tempNPCs.push(tempNPCData);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
|
||||
disconnectFromDatabase(dbConnection);
|
||||
@@ -308,18 +304,14 @@ async function loadNPCTriggerConditionsFromDatabase(npcTriggerDatabaseId) {
|
||||
let dbAssoc;
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM npc_cond WHERE npc_cond_trig = ${npcTriggerDatabaseId} AND npc_cond_enabled = 1`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCTriggerConditionData = new NPCTriggerConditionData(dbAssoc[i]);
|
||||
tempNPCTriggerConditions.push(tempNPCTriggerConditionData);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempNPCTriggerConditionData = new NPCTriggerConditionData(dbAssoc[i]);
|
||||
tempNPCTriggerConditions.push(tempNPCTriggerConditionData);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, `[AGRP.NPC]: ${tempNPCTriggerConditions.length} conditions loaded for trigger ${npcTriggerDatabaseId} from database successfully!`);
|
||||
|
||||
@@ -161,13 +161,12 @@ function initPropertyScript() {
|
||||
|
||||
async function loadPropertyFromId(propertyIndex) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc = [];
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM prop_main WHERE prop_id = ${propertyIndex} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
let dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new PropertyData(dbAssoc);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
return new PropertyData(dbAssoc[0]);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
@@ -182,21 +181,18 @@ async function loadPropertiesFromDatabase() {
|
||||
|
||||
let tempProperties = [];
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbQuery = null;
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
|
||||
if (dbConnection) {
|
||||
dbQuery = queryDatabase(dbConnection, `SELECT * FROM prop_main WHERE prop_deleted = 0 AND prop_server = ${getServerId()}`);
|
||||
if (dbQuery) {
|
||||
if (dbQuery.numRows > 0) {
|
||||
while (dbAssoc = await fetchQueryAssoc(dbQuery)) {
|
||||
let tempPropertyData = new PropertyData(dbAssoc[i]);
|
||||
tempPropertyData.locations = loadPropertyLocationsFromDatabase(tempPropertyData.databaseId);
|
||||
tempProperties.push(tempPropertyData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Property]: Property '${tempPropertyData.name}' (ID ${tempPropertyData.databaseId}) loaded from database successfully!`);
|
||||
}
|
||||
let dbQueryString = `SELECT * FROM prop_main WHERE prop_deleted = 0 AND prop_server = ${getServerId()}`;
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempPropertyData = new PropertyData(dbAssoc[i]);
|
||||
tempPropertyData.locations = loadPropertyLocationsFromDatabase(tempPropertyData.databaseId);
|
||||
tempProperties.push(tempPropertyData);
|
||||
logToConsole(LOG_VERBOSE, `[AGRP.Property]: Property '${tempPropertyData.name}' (ID ${tempPropertyData.databaseId}) loaded from database successfully!`);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,10 @@ async function loadRadioStationsFromDatabase() {
|
||||
logToConsole(LOG_INFO, "[AGRP.Radio]: Loading radio stations from database ...");
|
||||
let dbConnection = connectToDatabase();
|
||||
let tempRadioStations = [];
|
||||
let dbAssoc;
|
||||
let dbAssoc = [];
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM radio_main`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempRadioStationData = new RadioStationData(dbAssoc[i]);
|
||||
|
||||
@@ -137,9 +137,7 @@ async function loadSubAccountFromName(firstName, lastName) {
|
||||
lastName = escapeDatabaseString(dbConnection, lastName);
|
||||
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_name_first = '${firstName}' AND sacct_name_last = '${lastName}' LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
return new SubAccountData(dbAssoc[0]);
|
||||
@@ -157,10 +155,8 @@ async function loadSubAccountFromId(subAccountId) {
|
||||
let dbAssoc = [];
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_id = ${subAccountId} LIMIT 1;`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
return new SubAccountData(dbAssoc[0]);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
@@ -178,75 +174,71 @@ async function loadSubAccountsFromAccount(accountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM sacct_main INNER JOIN sacct_svr ON sacct_svr.sacct_svr_sacct=sacct_main.sacct_id AND sacct_svr.sacct_svr_server=${getServerId()} WHERE sacct_acct = ${accountId} AND sacct_server = ${getServerId()}`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
if (dbQuery) {
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempSubAccount = new SubAccountData(dbAssoc[i]);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempSubAccount = new SubAccountData(dbAssoc[i]);
|
||||
|
||||
// Make sure skin is valid
|
||||
if (tempSubAccount.skin == -1) {
|
||||
tempSubAccount.skin = getServerConfig().newCharacter.skin;
|
||||
}
|
||||
|
||||
// Check if clan and rank are still valid
|
||||
if (tempSubAccount.clan != 0) {
|
||||
let clanIndex = getClanIndexFromDatabaseId(tempSubAccount.clan);
|
||||
if (!getClanData(clanIndex)) {
|
||||
tempSubAccount.clan = 0;
|
||||
tempSubAccount.clanRank = 0;
|
||||
tempSubAccount.clanIndex = -1;
|
||||
tempSubAccount.clanRankIndex = -1;
|
||||
tempSubAccount.clanTitle = "";
|
||||
tempSubAccount.clanFlags = 0;
|
||||
} else {
|
||||
let clanRankIndex = getClanRankIndexFromDatabaseId(clanIndex, tempSubAccount.clanRank);
|
||||
if (!getClanRankData(clanIndex, clanRankIndex)) {
|
||||
let newClanRankIndex = getLowestClanRank(clanIndex);
|
||||
tempSubAccount.clanRank = getClanRankData(clanIndex, newClanRankIndex).databaseId
|
||||
tempSubAccount.clanRankIndex = newClanRankIndex;
|
||||
} else {
|
||||
tempSubAccount.clanRankIndex = clanRankIndex;
|
||||
}
|
||||
|
||||
tempSubAccount.clanIndex = clanIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if job and rank are still valid
|
||||
if (tempSubAccount.job != 0) {
|
||||
let jobIndex = getJobIndexFromDatabaseId(tempSubAccount.job);
|
||||
if (!getJobData(jobIndex)) {
|
||||
tempSubAccount.job = 0;
|
||||
tempSubAccount.jobRank = 0;
|
||||
tempSubAccount.jobIndex = -1;
|
||||
tempSubAccount.jobRankIndex = -1;
|
||||
} else {
|
||||
if (getJobData(jobIndex).ranks.length > 0) {
|
||||
let jobRankIndex = getJobRankIndexFromDatabaseId(jobIndex, tempSubAccount.jobRank);
|
||||
if (!getJobRankData(jobIndex, jobRankIndex)) {
|
||||
let newJobRankIndex = getLowestJobRank(jobIndex);
|
||||
console.log(`[AGRP.SubAccount]: Job ${jobIndex} has no rank ${tempSubAccount.jobRank}! Using lowest rank ${newJobRankIndex} instead.`);
|
||||
tempSubAccount.jobRank = getJobRankData(jobIndex, newJobRankIndex).databaseId;
|
||||
tempSubAccount.jobRankIndex = newJobRankIndex;
|
||||
} else {
|
||||
tempSubAccount.jobRankIndex = jobRankIndex;
|
||||
}
|
||||
} else {
|
||||
tempSubAccount.jobRankIndex = -1;
|
||||
}
|
||||
|
||||
tempSubAccount.jobIndex = jobIndex;
|
||||
}
|
||||
}
|
||||
|
||||
tempSubAccounts.push(tempSubAccount);
|
||||
// Make sure skin is valid
|
||||
if (tempSubAccount.skin == -1) {
|
||||
tempSubAccount.skin = getServerConfig().newCharacter.skin;
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
|
||||
// Check if clan and rank are still valid
|
||||
if (tempSubAccount.clan != 0) {
|
||||
let clanIndex = getClanIndexFromDatabaseId(tempSubAccount.clan);
|
||||
if (!getClanData(clanIndex)) {
|
||||
tempSubAccount.clan = 0;
|
||||
tempSubAccount.clanRank = 0;
|
||||
tempSubAccount.clanIndex = -1;
|
||||
tempSubAccount.clanRankIndex = -1;
|
||||
tempSubAccount.clanTitle = "";
|
||||
tempSubAccount.clanFlags = 0;
|
||||
} else {
|
||||
let clanRankIndex = getClanRankIndexFromDatabaseId(clanIndex, tempSubAccount.clanRank);
|
||||
if (!getClanRankData(clanIndex, clanRankIndex)) {
|
||||
let newClanRankIndex = getLowestClanRank(clanIndex);
|
||||
tempSubAccount.clanRank = getClanRankData(clanIndex, newClanRankIndex).databaseId
|
||||
tempSubAccount.clanRankIndex = newClanRankIndex;
|
||||
} else {
|
||||
tempSubAccount.clanRankIndex = clanRankIndex;
|
||||
}
|
||||
|
||||
tempSubAccount.clanIndex = clanIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if job and rank are still valid
|
||||
if (tempSubAccount.job != 0) {
|
||||
let jobIndex = getJobIndexFromDatabaseId(tempSubAccount.job);
|
||||
if (!getJobData(jobIndex)) {
|
||||
tempSubAccount.job = 0;
|
||||
tempSubAccount.jobRank = 0;
|
||||
tempSubAccount.jobIndex = -1;
|
||||
tempSubAccount.jobRankIndex = -1;
|
||||
} else {
|
||||
if (getJobData(jobIndex).ranks.length > 0) {
|
||||
let jobRankIndex = getJobRankIndexFromDatabaseId(jobIndex, tempSubAccount.jobRank);
|
||||
if (!getJobRankData(jobIndex, jobRankIndex)) {
|
||||
let newJobRankIndex = getLowestJobRank(jobIndex);
|
||||
console.log(`[AGRP.SubAccount]: Job ${jobIndex} has no rank ${tempSubAccount.jobRank}! Using lowest rank ${newJobRankIndex} instead.`);
|
||||
tempSubAccount.jobRank = getJobRankData(jobIndex, newJobRankIndex).databaseId;
|
||||
tempSubAccount.jobRankIndex = newJobRankIndex;
|
||||
} else {
|
||||
tempSubAccount.jobRankIndex = jobRankIndex;
|
||||
}
|
||||
} else {
|
||||
tempSubAccount.jobRankIndex = -1;
|
||||
}
|
||||
|
||||
tempSubAccount.jobIndex = jobIndex;
|
||||
}
|
||||
}
|
||||
|
||||
tempSubAccounts.push(tempSubAccount);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,14 +184,12 @@ async function loadVehiclesFromDatabase() {
|
||||
let dbAssoc;
|
||||
if (dbConnection) {
|
||||
let dbQueryString = `SELECT * FROM veh_main WHERE veh_server = ${getServerId()} AND veh_deleted = 0`;
|
||||
let dbQuery = queryDatabase(dbConnection, dbQueryString);
|
||||
dbAssoc = await fetchQueryAssoc(dbQuery);
|
||||
dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
|
||||
if (dbAssoc.length > 0) {
|
||||
for (let i in dbAssoc) {
|
||||
let tempVehicleData = new VehicleData(dbAssoc);
|
||||
let tempVehicleData = new VehicleData(dbAssoc[i]);
|
||||
tempVehicles.push(tempVehicleData);
|
||||
}
|
||||
freeDatabaseQuery(dbQuery);
|
||||
}
|
||||
disconnectFromDatabase(dbConnection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user