Use fallback if pickup data not available

This commit is contained in:
Vortrex
2022-10-19 22:08:54 -05:00
parent 5eb459b308
commit 1d00adb7e3

View File

@@ -213,12 +213,7 @@ function enterExitPropertyCommand(command, params, client) {
// The player's currentPickup wasn't always being set. This prevented entering/exiting a property. // The player's currentPickup wasn't always being set. This prevented entering/exiting a property.
// Needs further testing and tweaks. // Needs further testing and tweaks.
/*
if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) {
if (!getPlayerData(client).currentPickup) { if (!getPlayerData(client).currentPickup) {
return false;
}
let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type"); let ownerType = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.type");
let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id"); let ownerId = getEntityData(getPlayerData(client).currentPickup, "agrp.owner.id");
@@ -250,37 +245,38 @@ function enterExitPropertyCommand(command, params, client) {
default: default:
return false; return false;
} }
} else { }
*/
// Check business first // Check businesses first
if (closestProperty == null) { if (closestProperty == null) {
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
let businessIndex = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client)); let businessIndex = getClosestBusinessEntrance(getPlayerPosition(client), getPlayerDimension(client));
if (getDistance(getBusinessData(businessIndex).entrancePosition, getPlayerPosition(client)) <= 1.5) { if (getDistance(getBusinessData(businessIndex).entrancePosition, getPlayerPosition(client)) <= 1.5) {
isBusiness = true; isBusiness = true;
isEntrance = true; isEntrance = true;
closestProperty = getServerData().businesses[businessIndex]; closestProperty = getServerData().businesses[businessIndex];
} }
} else { }
let businessIndex = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
if (closestProperty == null) {
let businessIndex = getClosestBusinessExit(getPlayerPosition(client), getPlayerDimension(client));
if (getDistance(getBusinessData(businessIndex).exitPosition, getPlayerPosition(client)) <= 1.5) { if (getDistance(getBusinessData(businessIndex).exitPosition, getPlayerPosition(client)) <= 1.5) {
isBusiness = false; isBusiness = true;
isEntrance = false; isEntrance = false;
closestProperty = getServerData().businesses[businessIndex]; closestProperty = getServerData().businesses[businessIndex];
} }
} }
}
// Check houses second
if (closestProperty == null) { if (closestProperty == null) {
if (getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()] && getPlayerInterior(client) == getGameConfig().mainWorldInterior[getGame()]) {
let houseIndex = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); let houseIndex = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if (getDistance(getHouseData(houseIndex).entrancePosition, getPlayerPosition(client)) <= 1.5) { if (getDistance(getHouseData(houseIndex).entrancePosition, getPlayerPosition(client)) <= 1.5) {
isBusiness = false; isBusiness = false;
isEntrance = true; isEntrance = true;
closestProperty = getServerData().houses[houseIndex]; closestProperty = getServerData().houses[houseIndex];
} }
} else { }
if (closestProperty == null) {
let houseIndex = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client)); let houseIndex = getClosestHouseExit(getPlayerPosition(client), getPlayerDimension(client));
if (getDistance(getHouseData(houseIndex).exitPosition, getPlayerPosition(client)) <= 1.5) { if (getDistance(getHouseData(houseIndex).exitPosition, getPlayerPosition(client)) <= 1.5) {
isBusiness = false; isBusiness = false;
@@ -288,7 +284,6 @@ function enterExitPropertyCommand(command, params, client) {
closestProperty = getServerData().houses[houseIndex]; closestProperty = getServerData().houses[houseIndex];
} }
} }
}
if (closestProperty == null) { if (closestProperty == null) {
logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is null`); logToConsole(LOG_DEBUG, `${getPlayerDisplayForConsole(client)}'s closest door is null`);