mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Allow non-numeric modifiers
This commit is contained in:
@@ -1414,8 +1414,8 @@ export default class Ship {
|
|||||||
for (let slotMod of slot) {
|
for (let slotMod of slot) {
|
||||||
buffer.writeInt8(slotMod.id, curpos++);
|
buffer.writeInt8(slotMod.id, curpos++);
|
||||||
if (isNaN(slotMod.value)) {
|
if (isNaN(slotMod.value)) {
|
||||||
// We need to write the value out as a four-byte string
|
// Need to write the string with a maximum of four characters
|
||||||
buffer.writeInt32LE(slotMod.value, curpos);
|
buffer.write((" " + slotMod.value).slice(-4), curpos, 4);
|
||||||
} else {
|
} else {
|
||||||
buffer.writeInt32LE(slotMod.value, curpos);
|
buffer.writeInt32LE(slotMod.value, curpos);
|
||||||
}
|
}
|
||||||
@@ -1452,7 +1452,13 @@ export default class Ship {
|
|||||||
let blueprint = {};
|
let blueprint = {};
|
||||||
let modificationId = buffer.readInt8(curpos++);
|
let modificationId = buffer.readInt8(curpos++);
|
||||||
while (modificationId != MODIFICATION_ID_DONE) {
|
while (modificationId != MODIFICATION_ID_DONE) {
|
||||||
let modificationValue = buffer.readInt32LE(curpos);
|
let modificationValue;
|
||||||
|
if (modificationId === 40) {
|
||||||
|
// Type is special, in that it's a character string
|
||||||
|
modificationValue = buffer.toString('utf8', curpos, curpos + 4).trim();
|
||||||
|
} else {
|
||||||
|
modificationValue = buffer.readInt32LE(curpos);
|
||||||
|
}
|
||||||
curpos += 4;
|
curpos += 4;
|
||||||
// There are a number of 'special' modification IDs, check for them here
|
// There are a number of 'special' modification IDs, check for them here
|
||||||
if (modificationId === MODIFICATION_ID_BLUEPRINT) {
|
if (modificationId === MODIFICATION_ID_BLUEPRINT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user