Add check for invalid business ID

This commit is contained in:
Vortrex
2022-06-17 13:07:26 -05:00
parent 7373f1454e
commit 70a1520f56
2 changed files with 23 additions and 15 deletions

View File

@@ -1724,7 +1724,11 @@ function moveBusinessExitCommand(command, params, client) {
// ===========================================================================
function getBusinessDataFromDatabaseId(databaseId) {
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == businessId)
if (databaseId <= 0) {
return false;
}
let matchingBusinesses = getServerData().businesses.filter(b => b.databaseId == databaseId)
if (matchingBusinesses.length == 1) {
return matchingBusinesses[0];
}
@@ -2361,6 +2365,10 @@ function getBusinessOwnerTypeText(ownerType) {
* @return {BusinessData} The business's data (class instance)
*/
function getBusinessData(businessId) {
if (businessId == -1) {
return false;
}
if (typeof getServerData().businesses[businessId] != null) {
return getServerData().businesses[businessId];
}