Add check for invalid house ID

This commit is contained in:
Vortrex
2022-06-17 13:08:39 -05:00
parent 90face486b
commit 87ca42c48a

View File

@@ -774,6 +774,10 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup
// =========================================================================== // ===========================================================================
function getHouseDataFromDatabaseId(databaseId) { function getHouseDataFromDatabaseId(databaseId) {
if (databaseId <= 0) {
return false;
}
let matchingHouses = getServerData().houses.filter(b => b.databaseId == databaseId) let matchingHouses = getServerData().houses.filter(b => b.databaseId == databaseId)
if (matchingHouses.length == 1) { if (matchingHouses.length == 1) {
return matchingHouses[0]; return matchingHouses[0];
@@ -1431,6 +1435,10 @@ function buyHouseCommand(command, params, client) {
* @return {HouseData} The house's data (class instance) * @return {HouseData} The house's data (class instance)
*/ */
function getHouseData(houseId) { function getHouseData(houseId) {
if (houseId == -1) {
return false;
}
if (typeof getServerData().houses[houseId] != "undefined") { if (typeof getServerData().houses[houseId] != "undefined") {
return getServerData().houses[houseId]; return getServerData().houses[houseId];
} }