mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Catch undefined values in ship build parsing
This commit is contained in:
@@ -198,12 +198,12 @@ export default class OutfittingPage extends Page {
|
|||||||
if (parts.length >= 5) {
|
if (parts.length >= 5) {
|
||||||
// We have control information in the code
|
// We have control information in the code
|
||||||
const control = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[4])).split('/');
|
const control = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[4])).split('/');
|
||||||
sys = parseFloat(control[0]);
|
sys = parseFloat(control[0]) || sys;
|
||||||
eng = parseFloat(control[1]);
|
eng = parseFloat(control[1]) || eng;
|
||||||
wep = parseFloat(control[2]);
|
wep = parseFloat(control[2]) || wep;
|
||||||
boost = control[3] == 1 ? true : false;
|
boost = control[3] == 1 ? true : false;
|
||||||
fuel = parseFloat(control[4]);
|
fuel = parseFloat(control[4]) || fuel;
|
||||||
cargo = parseInt(control[5]);
|
cargo = parseInt(control[5]) || cargo;
|
||||||
if (control[6]) {
|
if (control[6]) {
|
||||||
const shipId = control[6];
|
const shipId = control[6];
|
||||||
opponent = new Ship(shipId, Ships[shipId].properties, Ships[shipId].slots);
|
opponent = new Ship(shipId, Ships[shipId].properties, Ships[shipId].slots);
|
||||||
@@ -217,9 +217,9 @@ export default class OutfittingPage extends Page {
|
|||||||
const opponentParts = opponentCode.split('.');
|
const opponentParts = opponentCode.split('.');
|
||||||
if (opponentParts.length >= 5) {
|
if (opponentParts.length >= 5) {
|
||||||
const opponentControl = LZString.decompressFromBase64(Utils.fromUrlSafe(opponentParts[4])).split('/');
|
const opponentControl = LZString.decompressFromBase64(Utils.fromUrlSafe(opponentParts[4])).split('/');
|
||||||
opponentSys = parseFloat(opponentControl[0]);
|
opponentSys = parseFloat(opponentControl[0]) || opponentSys;
|
||||||
opponentEng = parseFloat(opponentControl[1]);
|
opponentEng = parseFloat(opponentControl[1]) || opponentEng;
|
||||||
opponentWep = parseFloat(opponentControl[2]);
|
opponentWep = parseFloat(opponentControl[2]) || opponentWep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -227,7 +227,7 @@ export default class OutfittingPage extends Page {
|
|||||||
opponent.buildWith(Ships[shipId].defaults);
|
opponent.buildWith(Ships[shipId].defaults);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
engagementRange = parseInt(control[8]);
|
engagementRange = parseInt(control[8]) || engagementRange;
|
||||||
|
|
||||||
// Multi-crew pips were introduced later on so assign default values
|
// Multi-crew pips were introduced later on so assign default values
|
||||||
// because those values might not be present.
|
// because those values might not be present.
|
||||||
|
|||||||
Reference in New Issue
Block a user