mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 15:15:34 +00:00
Tweaks for restoring data from previous builds
This commit is contained in:
@@ -21,7 +21,6 @@ import PowerManagement from '../components/PowerManagement';
|
|||||||
import CostSection from '../components/CostSection';
|
import CostSection from '../components/CostSection';
|
||||||
import ModalExport from '../components/ModalExport';
|
import ModalExport from '../components/ModalExport';
|
||||||
import Slider from '../components/Slider';
|
import Slider from '../components/Slider';
|
||||||
import * as Utils from '../utils/UtilityFunctions';
|
|
||||||
|
|
||||||
const SPEED_SERIES = ['boost', '4 Pips', '2 Pips', '0 Pips'];
|
const SPEED_SERIES = ['boost', '4 Pips', '2 Pips', '0 Pips'];
|
||||||
const SPEED_COLORS = ['#0088d2', '#ff8c0d', '#D26D00', '#c06400'];
|
const SPEED_COLORS = ['#0088d2', '#ff8c0d', '#D26D00', '#c06400'];
|
||||||
@@ -59,7 +58,7 @@ export default class OutfittingPage extends Page {
|
|||||||
_initState(context) {
|
_initState(context) {
|
||||||
let params = context.route.params;
|
let params = context.route.params;
|
||||||
let shipId = params.ship;
|
let shipId = params.ship;
|
||||||
let code = Utils.fromUrlSafe(params.code);
|
let code = params.code;
|
||||||
let buildName = params.bn;
|
let buildName = params.bn;
|
||||||
let data = Ships[shipId]; // Retrieve the basic ship properties, slots and defaults
|
let data = Ships[shipId]; // Retrieve the basic ship properties, slots and defaults
|
||||||
let savedCode = Persist.getBuild(shipId, buildName);
|
let savedCode = Persist.getBuild(shipId, buildName);
|
||||||
|
|||||||
@@ -596,19 +596,17 @@ export default class Ship {
|
|||||||
hardpoints = new Array(this.hardpoints.length),
|
hardpoints = new Array(this.hardpoints.length),
|
||||||
internal = new Array(this.internal.length),
|
internal = new Array(this.internal.length),
|
||||||
modifications = new Array(1 + this.standard.length + this.hardpoints.length + this.internal.length),
|
modifications = new Array(1 + this.standard.length + this.hardpoints.length + this.internal.length),
|
||||||
// Although we un-UrlSafe the serialized string when it comes in as a URL old code used to url-encode
|
parts = serializedString.split('.'),
|
||||||
// the build before it was written to local store so we do it again here to catch that situation
|
|
||||||
parts = Utils.fromUrlSafe(serializedString).split('.'),
|
|
||||||
priorities = null,
|
priorities = null,
|
||||||
enabled = null,
|
enabled = null,
|
||||||
code = parts[0];
|
code = parts[0];
|
||||||
|
|
||||||
if (parts[1]) {
|
if (parts[1]) {
|
||||||
enabled = LZString.decompressFromBase64(parts[1]).split('');
|
enabled = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[1])).split('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts[2]) {
|
if (parts[2]) {
|
||||||
priorities = LZString.decompressFromBase64(parts[2]).split('');
|
priorities = LZString.decompressFromBase64(Utils.fromUrlSafe(parts[2])).split('');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parts[3]) {
|
if (parts[3]) {
|
||||||
@@ -617,7 +615,7 @@ export default class Ship {
|
|||||||
this.decodeModificationsString(modstr, modifications);
|
this.decodeModificationsString(modstr, modifications);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
this.decodeModificationsStruct(zlib.gunzipSync(new Buffer(modstr, 'base64')), modifications);
|
this.decodeModificationsStruct(zlib.gunzipSync(new Buffer(Utils.fromUrlSafe(modstr), 'base64')), modifications);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Could be out-of-date URL; ignore
|
// Could be out-of-date URL; ignore
|
||||||
}
|
}
|
||||||
@@ -1201,7 +1199,7 @@ export default class Ship {
|
|||||||
priorities.push(slot.priority);
|
priorities.push(slot.priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.serialized.priorities = LZString.compressToBase64(priorities.join(''));
|
this.serialized.priorities = Utils.toUrlSafe(LZString.compressToBase64(priorities.join('')));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1222,7 +1220,7 @@ export default class Ship {
|
|||||||
enabled.push(slot.enabled ? 1 : 0);
|
enabled.push(slot.enabled ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.serialized.enabled = LZString.compressToBase64(enabled.join(''));
|
this.serialized.enabled = Utils.toUrlSafe(LZString.compressToBase64(enabled.join('')));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1389,7 +1387,7 @@ export default class Ship {
|
|||||||
buffer.writeInt8(-1, curpos++);
|
buffer.writeInt8(-1, curpos++);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.serialized.modifications = zlib.gzipSync(buffer).toString('base64');
|
this.serialized.modifications = Utils.toUrlSafe(zlib.gzipSync(buffer).toString('base64'));
|
||||||
} else {
|
} else {
|
||||||
this.serialized.modifications = null;
|
this.serialized.modifications = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function outfitURL(shipId, code, buildName) {
|
|||||||
let parts = ['/outfit/', shipId];
|
let parts = ['/outfit/', shipId];
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
parts.push('/', Utils.toUrlSafe(code));
|
parts.push('/', code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildName) {
|
if (buildName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user