Remove all async/await stuff
This commit is contained in:
@@ -802,7 +802,7 @@ function getAccountHashingFunction() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function isNameRegistered(name) {
|
||||
function isNameRegistered(name) {
|
||||
let accountData = loadAccountFromName(name, true);
|
||||
if (accountData.databaseId > 0) {
|
||||
return true;
|
||||
@@ -1732,34 +1732,34 @@ function generateEmailVerificationCode() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function sendEmailVerificationEmail(client, emailVerificationCode) {
|
||||
function sendEmailVerificationEmail(client, emailVerificationCode) {
|
||||
let emailBodyText = getEmailConfig().bodyContent.confirmEmail;
|
||||
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode);
|
||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
||||
|
||||
await sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
|
||||
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function sendPasswordResetEmail(client, verificationCode) {
|
||||
function sendPasswordResetEmail(client, verificationCode) {
|
||||
let emailBodyText = getEmailConfig().bodyContent.confirmPasswordReset;
|
||||
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", verificationCode);
|
||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
||||
|
||||
await sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Reset your password on ${getServerName()}`, emailBodyText);
|
||||
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Reset your password on ${getServerName()}`, emailBodyText);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function verifyAccountEmail(accountData, verificationCode) {
|
||||
function verifyAccountEmail(accountData, verificationCode) {
|
||||
let emailVerificationCode = generateRandomString(10);
|
||||
|
||||
let emailBodyText = getEmailConfig().bodyContent.confirmEmail;
|
||||
emailBodyText = emailBodyText.replace("{VERIFICATIONCODE}", emailVerificationCode);
|
||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
||||
|
||||
await sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
|
||||
sendEmail(getPlayerData(client).accountData.emailAddress, getPlayerData(client).accountData.name, `Confirm email on ${getServerName()}`, emailBodyText);
|
||||
|
||||
getPlayerData(client).accountData.emailAddress = emailAddress;
|
||||
getPlayerData(client).accountData.emailVerificationCode = module.hashing.sha512(emailVerificationCode);
|
||||
@@ -1767,7 +1767,7 @@ async function verifyAccountEmail(accountData, verificationCode) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGame()) {
|
||||
function sendAccountLoginFailedNotification(emailAddress, name, ip, game = getGame()) {
|
||||
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
|
||||
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
|
||||
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
|
||||
@@ -1779,13 +1779,13 @@ async function sendAccountLoginFailedNotification(emailAddress, name, ip, game =
|
||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
||||
emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US'));
|
||||
|
||||
await sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText);
|
||||
sendEmail(emailAddress, name, `Login failed on ${getServerName()}`, emailBodyText);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getGame()) {
|
||||
function sendAccountLoginSuccessNotification(emailAddress, name, ip, game = getGame()) {
|
||||
let countryName = module.geoip.getCountryName(getGlobalConfig().geoIPCountryDatabaseFilePath, ip);
|
||||
let subDivisionName = module.geoip.getSubdivisionName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
|
||||
let cityName = module.geoip.getCityName(getGlobalConfig().geoIPCityDatabaseFilePath, ip);
|
||||
@@ -1797,7 +1797,7 @@ async function sendAccountLoginSuccessNotification(emailAddress, name, ip, game
|
||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
||||
emailBodyText = emailBodyText.replace("{TIMESTAMP}", new Date().toLocaleString('en-US'));
|
||||
|
||||
await sendEmail(emailAddress, name, `Login successful on ${getServerName()}`, emailBodyText);
|
||||
sendEmail(emailAddress, name, `Login successful on ${getServerName()}`, emailBodyText);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1843,13 +1843,13 @@ function isPlayerATester(client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
|
||||
function sendAccountTwoFactorAuthCode(emailAddress, name, twoFactorAuthCode) {
|
||||
let emailBodyText = getEmailConfig().bodyContent.twoFactorAuthentication;
|
||||
emailBodyText = emailBodyText.replace("{2FACODE}", twoFactorAuthCode);
|
||||
emailBodyText = emailBodyText.replace("{GAMENAME}", getGameName(getGame()));
|
||||
emailBodyText = emailBodyText.replace("{SERVERNAME}", getServerName());
|
||||
|
||||
await sendEmail(emailAddress, name, `Login code for ${getServerName()}`, emailBodyText);
|
||||
sendEmail(emailAddress, name, `Login code for ${getServerName()}`, emailBodyText);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ function processPlayerChat(client, messageText) {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
let translatedText;
|
||||
translatedText = await translateMessage(messageText, getPlayerData(client).locale, getPlayerData(clients[i]).locale);
|
||||
translatedText = translateMessage(messageText, getPlayerData(client).locale, getPlayerData(clients[i]).locale);
|
||||
|
||||
let original = (getPlayerData(client).locale == getPlayerData(clients[i]).locale) ? `` : ` {ALTCOLOUR}(${messageText})`;
|
||||
messagePlayerNormal(clients[i], `💬 ${getCharacterFullName(client)}: [#FFFFFF]${translatedText}${original}`, clients[i], getColourByName("mediumGrey"));
|
||||
|
||||
@@ -884,11 +884,11 @@ function processPlayerCommand(command, params, client) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let possibleAlias = getPlayerAliasForCommand(command);
|
||||
if (possibleAlias) {
|
||||
// Just change to the command the alias is for, then continue as normal
|
||||
command = possibleAlias.forCommand;
|
||||
}
|
||||
//let possibleAlias = getPlayerAliasForCommand(client, command);
|
||||
//if (possibleAlias) {
|
||||
// // Just change to the command the alias is for, then continue as normal
|
||||
// command = possibleAlias.forCommand;
|
||||
//}
|
||||
|
||||
let commandData = getCommand(toLowerCase(command));
|
||||
|
||||
@@ -1098,3 +1098,9 @@ function getCommandFromParams(params) {
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getPlayerAliasForCommand(client, command) {
|
||||
return command;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -897,7 +897,7 @@ function setServerRealWorldTimeZoneCommand(command, params, client) {
|
||||
* @return {bool} Whether or not the command was successful
|
||||
*
|
||||
*/
|
||||
async function reloadServerConfigurationCommand(command, params, client) {
|
||||
function reloadServerConfigurationCommand(command, params, client) {
|
||||
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port);
|
||||
applyConfigToServer(serverConfig);
|
||||
updateServerRules();
|
||||
|
||||
@@ -448,7 +448,7 @@ function saveServerDataCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function testEmailCommand(command, params, client) {
|
||||
function testEmailCommand(command, params, client) {
|
||||
sendEmail(params, "Player", "Test email", "Just testing the email system for the server!");
|
||||
|
||||
return true;
|
||||
@@ -548,7 +548,7 @@ function isDevelopmentServer() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function migrateSubAccountsToPerServerData() {
|
||||
function migrateSubAccountsToPerServerData() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc = [];
|
||||
|
||||
@@ -569,7 +569,7 @@ async function migrateSubAccountsToPerServerData() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function resetAllAccountsHotkeysToDefault() {
|
||||
function resetAllAccountsHotkeysToDefault() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let dbAssoc = [];
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ function initEmailScript() {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function sendEmail(toEmail, toName, subject, body) {
|
||||
function sendEmail(toEmail, toName, subject, body) {
|
||||
switch (getEmailConfig().method) {
|
||||
case V_EMAIL_METHOD_SMTP_MODULE:
|
||||
if (!checkForSMTPModule()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
//Promise.resolve().then(() => {
|
||||
module.smtp.send(
|
||||
getEmailConfig().smtp.host,
|
||||
getEmailConfig().smtp.port,
|
||||
@@ -42,7 +42,7 @@ async function sendEmail(toEmail, toName, subject, body) {
|
||||
getEmailConfig().smtp.from,
|
||||
getEmailConfig().smtp.fromName
|
||||
);
|
||||
});
|
||||
//});
|
||||
break;
|
||||
|
||||
case V_EMAIL_METHOD_GET_REQUEST:
|
||||
|
||||
@@ -148,7 +148,7 @@ function onPlayerQuit(event, client, quitReasonId) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function onPlayerChat(event, client, messageText) {
|
||||
function onPlayerChat(event, client, messageText) {
|
||||
event.preventDefault();
|
||||
processPlayerChat(client, messageText);
|
||||
}
|
||||
@@ -451,7 +451,7 @@ function onPedSpawn(ped) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function onPlayerSpawn(client) {
|
||||
function onPlayerSpawn(client) {
|
||||
logToConsole(LOG_WARN | LOG_DEBUG, `[V.RP.Event] Player ${getPlayerDisplayForConsole(client)} spawned!`);
|
||||
//logToConsole(LOG_DEBUG, `[V.RP.Event] Checking for ${getPlayerDisplayForConsole(client)}'s player ped`);
|
||||
//if(getPlayerPed(client) == null) {
|
||||
@@ -462,7 +462,7 @@ async function onPlayerSpawn(client) {
|
||||
//logToConsole(LOG_DEBUG, `[V.RP.Event] ${getPlayerDisplayForConsole(client)}'s player ped is valid. Continuing spawn processing ...`);
|
||||
|
||||
if (areServerElementsSupported()) {
|
||||
await waitUntil(() => client != null && getPlayerPed(client) != null);
|
||||
waitUntil(() => client != null && getPlayerPed(client) != null);
|
||||
}
|
||||
|
||||
stopRadioStreamForPlayer(client);
|
||||
|
||||
@@ -1553,11 +1553,11 @@ function reloadAllJobsCommand(command, params, client) {
|
||||
deleteAllJobPickups();
|
||||
clearArray(getServerData().jobs);
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
//Promise.resolve().then(() => {
|
||||
getServerData().jobs = loadJobsFromDatabase();
|
||||
spawnAllJobPickups();
|
||||
spawnAllJobBlips();
|
||||
});
|
||||
//});
|
||||
|
||||
announceAdminAction("AllJobsReloaded");
|
||||
}
|
||||
|
||||
@@ -264,8 +264,8 @@ function reloadLocaleConfigurationCommand(command, params, client) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function translateMessage(messageText, translateFrom = getGlobalConfig().locale.defaultLanguageId, translateTo = getGlobalConfig().locale.defaultLanguageId) {
|
||||
return new Promise(resolve => {
|
||||
function translateMessage(messageText, translateFrom = getGlobalConfig().locale.defaultLanguageId, translateTo = getGlobalConfig().locale.defaultLanguageId) {
|
||||
//return new Promise(resolve => {
|
||||
if (translateFrom == translateTo) {
|
||||
resolve(messageText);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ async function translateMessage(messageText, translateFrom = getGlobalConfig().l
|
||||
function (data) {
|
||||
}
|
||||
);
|
||||
});
|
||||
//});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -876,10 +876,10 @@ function disconnectFromDatabase(dbConnection, force = false) {
|
||||
function queryDatabase(dbConnection, queryString, useThread = false) {
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query string: ${queryString}`);
|
||||
if (useThread == true) {
|
||||
Promise.resolve().then(() => {
|
||||
//Promise.resolve().then(() => {
|
||||
let queryResult = dbConnection.query(queryString);
|
||||
return queryResult;
|
||||
});
|
||||
//});
|
||||
} else {
|
||||
return dbConnection.query(queryString);
|
||||
}
|
||||
|
||||
@@ -806,10 +806,10 @@ function disconnectFromDatabase(dbConnection) {
|
||||
function queryDatabase(dbConnection, queryString, useThread = false) {
|
||||
logToConsole(LOG_DEBUG, `[V.RP.Database] Query string: ${queryString}`);
|
||||
if (useThread == true) {
|
||||
Promise.resolve().then(() => {
|
||||
//Promise.resolve().then(() => {
|
||||
let queryResult = dbConnection.query(queryString);
|
||||
return queryResult;
|
||||
});
|
||||
//});
|
||||
} else {
|
||||
return dbConnection.query(queryString);
|
||||
}
|
||||
@@ -857,7 +857,7 @@ function freeDatabaseQuery(dbQuery) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function fetchQueryAssoc(dbConnection, queryString) {
|
||||
function fetchQueryAssoc(dbConnection, queryString) {
|
||||
return dbConnection.query(queryString, function (err, result, fields) {
|
||||
return result;
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// TYPE: Server (JavaScript)
|
||||
// ===========================================================================
|
||||
|
||||
async function initServerScripts() {
|
||||
function initServerScripts() {
|
||||
checkForAllRequiredModules();
|
||||
|
||||
initDatabaseScript();
|
||||
@@ -41,7 +41,7 @@ async function initServerScripts() {
|
||||
|
||||
// Load config and stuff
|
||||
loadGlobalConfig();
|
||||
await loadServerConfig();
|
||||
loadServerConfig();
|
||||
applyConfigToServer(getServerConfig());
|
||||
|
||||
// Load all the server data
|
||||
|
||||
@@ -2311,17 +2311,17 @@ function removeSlashesFromString(str) {
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
async function waitUntil(condition) {
|
||||
return new Promise((resolve) => {
|
||||
let interval = setInterval(() => {
|
||||
if (!condition()) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}, 1);
|
||||
});
|
||||
function waitUntil(condition) {
|
||||
//return new Promise((resolve) => {
|
||||
// let interval = setInterval(() => {
|
||||
// if (!condition()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// clearInterval(interval);
|
||||
// resolve();
|
||||
// }, 1);
|
||||
//});
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
Reference in New Issue
Block a user