Skip to content

Commit

Permalink
Attempt Fix vehicle filtering for maps with 0 tanks or helicopters
Browse files Browse the repository at this point in the history
2.12 Squad, some layers have no vehicles, so when reading JSON from the wiki team we reject a promise because no data[t].vehicles property, this sets to empty array before we attempt a filter.

Should stop promise rejection during startup
  • Loading branch information
ect0s committed Feb 12, 2022
1 parent 7e40b31 commit c7d8b81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions squad-server/layers/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default class Layer {
constructor(data) {
this.name = data.Name;
this.classname = data.levelName;
this.layerid = data.rawName
this.layerid = data.rawName;
this.map = {
name: data.mapName
};
Expand Down Expand Up @@ -30,10 +30,10 @@ export default class Layer {
spawnDelay: vehicle.delay,
respawnDelay: vehicle.respawnTime
})),
numberOfTanks: data[t].vehicles.filter((v) => {
numberOfTanks: (data[t].vehicles || []).filter((v) => {
return v.icon.match(/tank/);
}).length,
numberOfHelicopters: data[t].vehicles.filter((v) => {
numberOfHelicopters: (data[t].vehicles || []).filter((v) => {
return v.icon.match(/helo/);
}).length
});
Expand Down

0 comments on commit c7d8b81

Please sign in to comment.