Use game ID consts as indexes for gamedata

This commit is contained in:
Vortrex
2022-04-25 12:05:00 -05:00
parent ac20c651bd
commit 43f9aff82e
3 changed files with 390 additions and 855 deletions

View File

@@ -729,7 +729,7 @@ function updateHeadingInVehicleData(client, vehicle, heading) {
// ===========================================================================
function forcePlayerIntoSkinSelect(client) {
if(getGameConfig().skinChangePosition[getServerGame()].length > 0) {
if(typeof getGameConfig().skinChangePosition[getServerGame()] != "undefined") {
getPlayerData(client).returnToPosition = getPlayerPosition(client);
getPlayerData(client).returnToHeading = getPlayerHeading(client);
getPlayerData(client).returnToInterior = getPlayerInterior(client);

View File

@@ -149,27 +149,35 @@ function getFightStyleFromParams(params) {
// ===========================================================================
function getClosestHospital(position) {
let closest = 0;
for(let i in getGameConfig().hospitals[getServerGame()]) {
if(getDistance(getGameConfig().hospitals[getServerGame()][i].position, position) < getDistance(getGameConfig().hospitals[getServerGame()][closest].position, position)) {
closest = i;
if(typeof getGameConfig().hospitals[getServerGame()] == "undefined") {
return {position: getServerConfig().newCharacter.spawnPosition};
} else {
let closest = 0;
for(let i in getGameConfig().hospitals[getServerGame()]) {
if(getDistance(getGameConfig().hospitals[getServerGame()][i].position, position) < getDistance(getGameConfig().hospitals[getServerGame()][closest].position, position)) {
closest = i;
}
}
}
return getGameConfig().hospitals[getServerGame()][closest];
return getGameConfig().hospitals[getServerGame()][closest];
}
}
// ===========================================================================
function getClosestPoliceStation(position) {
let closest = 0;
for(let i in getGameConfig().policeStations[getServerGame()]) {
if(getDistance(getGameConfig().policeStations[getServerGame()][i].position, position) < getDistance(getGameConfig().policeStations[getServerGame()][closest].position, position)) {
closest = i;
if(typeof getGameConfig().policeStations[getServerGame()] == "undefined") {
return {position: getServerConfig().newCharacter.spawnPosition};
} else {
let closest = 0;
for(let i in getGameConfig().policeStations[getServerGame()]) {
if(getDistance(getGameConfig().policeStations[getServerGame()][i].position, position) < getDistance(getGameConfig().policeStations[getServerGame()][closest].position, position)) {
closest = i;
}
}
}
return getGameConfig().policeStations[getServerGame()][closest];
return getGameConfig().policeStations[getServerGame()][closest];
}
}
// ===========================================================================

File diff suppressed because it is too large Load Diff