mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-11 16:53:02 +00:00
fix hardpoints / internals having the wrong mod applied
This commit is contained in:
@@ -70,8 +70,9 @@ export function shipFromLoadoutJSON (json) {
|
|||||||
let ship = new Ship(shipModel, shipTemplate.properties, shipTemplate.slots)
|
let ship = new Ship(shipModel, shipTemplate.properties, shipTemplate.slots)
|
||||||
ship.buildWith(null)
|
ship.buildWith(null)
|
||||||
// Initial Ship building, don't do engineering yet.
|
// Initial Ship building, don't do engineering yet.
|
||||||
|
let opts = [];
|
||||||
|
|
||||||
for (const module of json.Modules) {
|
for (const module of json.Modules) {
|
||||||
if (!module.Engineering) module.Engineering = {};
|
|
||||||
switch (module.Slot) {
|
switch (module.Slot) {
|
||||||
// Cargo Hatch.
|
// Cargo Hatch.
|
||||||
case 'CargoHatch':
|
case 'CargoHatch':
|
||||||
@@ -94,49 +95,49 @@ export function shipFromLoadoutJSON (json) {
|
|||||||
throw 'Unknown bulkheads "' + module.Item + '"'
|
throw 'Unknown bulkheads "' + module.Item + '"'
|
||||||
}
|
}
|
||||||
ship.bulkheads.enabled = true
|
ship.bulkheads.enabled = true
|
||||||
_addModifications(ship.bulkheads.m, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(ship.bulkheads.m, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'PowerPlant':
|
case 'PowerPlant':
|
||||||
const powerplant = _moduleFromFdName(module.Item)
|
const powerplant = _moduleFromFdName(module.Item)
|
||||||
ship.use(ship.standard[0], powerplant, true)
|
ship.use(ship.standard[0], powerplant, true)
|
||||||
ship.standard[0].enabled = module.On
|
ship.standard[0].enabled = module.On
|
||||||
ship.standard[0].priority = module.Priority
|
ship.standard[0].priority = module.Priority
|
||||||
_addModifications(powerplant, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(powerplant, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'MainEngines':
|
case 'MainEngines':
|
||||||
const thrusters = _moduleFromFdName(module.Item)
|
const thrusters = _moduleFromFdName(module.Item)
|
||||||
ship.use(ship.standard[1], thrusters, true)
|
ship.use(ship.standard[1], thrusters, true)
|
||||||
ship.standard[1].enabled = module.On
|
ship.standard[1].enabled = module.On
|
||||||
ship.standard[1].priority = module.Priority
|
ship.standard[1].priority = module.Priority
|
||||||
_addModifications(thrusters, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(thrusters, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'FrameShiftDrive':
|
case 'FrameShiftDrive':
|
||||||
const frameshiftdrive = _moduleFromFdName(module.Item)
|
const frameshiftdrive = _moduleFromFdName(module.Item)
|
||||||
ship.use(ship.standard[2], frameshiftdrive, true)
|
ship.use(ship.standard[2], frameshiftdrive, true)
|
||||||
ship.standard[2].enabled = module.On
|
ship.standard[2].enabled = module.On
|
||||||
ship.standard[2].priority = module.Priority
|
ship.standard[2].priority = module.Priority
|
||||||
_addModifications(frameshiftdrive, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(frameshiftdrive, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'LifeSupport':
|
case 'LifeSupport':
|
||||||
const lifesupport = _moduleFromFdName(module.Item)
|
const lifesupport = _moduleFromFdName(module.Item)
|
||||||
ship.use(ship.standard[3], lifesupport, true)
|
ship.use(ship.standard[3], lifesupport, true)
|
||||||
ship.standard[3].enabled = module.On === true
|
ship.standard[3].enabled = module.On === true
|
||||||
ship.standard[3].priority = module.Priority
|
ship.standard[3].priority = module.Priority
|
||||||
_addModifications(lifesupport, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(lifesupport, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'PowerDistributor':
|
case 'PowerDistributor':
|
||||||
const powerdistributor = _moduleFromFdName(module.Item)
|
const powerdistributor = _moduleFromFdName(module.Item)
|
||||||
ship.use(ship.standard[4], powerdistributor, true)
|
ship.use(ship.standard[4], powerdistributor, true)
|
||||||
ship.standard[4].enabled = module.On
|
ship.standard[4].enabled = module.On
|
||||||
ship.standard[4].priority = module.Priority
|
ship.standard[4].priority = module.Priority
|
||||||
_addModifications(powerdistributor, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(powerdistributor, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'Radar':
|
case 'Radar':
|
||||||
const sensors = _moduleFromFdName(module.Item)
|
const sensors = _moduleFromFdName(module.Item)
|
||||||
ship.use(ship.standard[5], sensors, true)
|
ship.use(ship.standard[5], sensors, true)
|
||||||
ship.standard[5].enabled = module.On
|
ship.standard[5].enabled = module.On
|
||||||
ship.standard[5].priority = module.Priority
|
ship.standard[5].priority = module.Priority
|
||||||
_addModifications(sensors, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
if (module.Engineering) _addModifications(sensors, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
||||||
break
|
break
|
||||||
case 'FuelTank':
|
case 'FuelTank':
|
||||||
const fueltank = _moduleFromFdName(module.Item)
|
const fueltank = _moduleFromFdName(module.Item)
|
||||||
@@ -146,80 +147,86 @@ export function shipFromLoadoutJSON (json) {
|
|||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
if (module.Slot.search(/Hardpoint/) !== -1) {
|
for (const module of json.Modules) {
|
||||||
// Add hardpoints
|
if (module.Slot.search(/Hardpoint/) !== -1) {
|
||||||
let hardpointClassNum = -1
|
// Add hardpoints
|
||||||
let hardpointSlotNum = -1
|
let hardpoint;
|
||||||
let hardpointArrayNum = 0
|
let hardpointClassNum = -1
|
||||||
for (let i in shipTemplate.slots.hardpoints) {
|
let hardpointSlotNum = -1
|
||||||
if (shipTemplate.slots.hardpoints[i] === hardpointClassNum) {
|
let hardpointArrayNum = 0
|
||||||
// Another slot of the same class
|
for (let i in shipTemplate.slots.hardpoints) {
|
||||||
hardpointSlotNum++
|
if (shipTemplate.slots.hardpoints[i] === hardpointClassNum) {
|
||||||
} else {
|
// Another slot of the same class
|
||||||
// The first slot of a new class
|
hardpointSlotNum++
|
||||||
hardpointClassNum = shipTemplate.slots.hardpoints[i]
|
} else {
|
||||||
hardpointSlotNum = 1
|
// The first slot of a new class
|
||||||
}
|
hardpointClassNum = shipTemplate.slots.hardpoints[i]
|
||||||
|
hardpointSlotNum = 1
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we know what we're looking for, find it
|
// Now that we know what we're looking for, find it
|
||||||
const hardpointName = HARDPOINT_NUM_TO_CLASS[hardpointClassNum] + 'Hardpoint' + hardpointSlotNum
|
const hardpointName = HARDPOINT_NUM_TO_CLASS[hardpointClassNum] + 'Hardpoint' + hardpointSlotNum
|
||||||
const hardpointSlot = json.Modules.find(elem => elem.Slot === hardpointName)
|
const hardpointSlot = json.Modules.find(elem => elem.Slot === hardpointName)
|
||||||
if (!hardpointSlot) {
|
if (!hardpointSlot) {
|
||||||
// This can happen with old imports that don't contain new hardpoints
|
// This can happen with old imports that don't contain new hardpoints
|
||||||
} else if (!hardpointSlot) {
|
} else if (!hardpointSlot) {
|
||||||
// No module
|
// No module
|
||||||
} else {
|
} else {
|
||||||
const hardpoint = _moduleFromFdName(hardpointSlot.Item)
|
hardpoint = _moduleFromFdName(hardpointSlot.Item)
|
||||||
ship.use(ship.hardpoints[hardpointArrayNum], hardpoint, true)
|
ship.use(ship.hardpoints[hardpointArrayNum], hardpoint, true)
|
||||||
ship.hardpoints[hardpointArrayNum].enabled = hardpointSlot.On
|
ship.hardpoints[hardpointArrayNum].enabled = hardpointSlot.On
|
||||||
ship.hardpoints[hardpointArrayNum].priority = hardpointSlot.Priority
|
ship.hardpoints[hardpointArrayNum].priority = hardpointSlot.Priority
|
||||||
_addModifications(hardpoint, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
opts.push({coriolisMod: hardpoint, json: hardpointSlot});
|
||||||
|
}
|
||||||
|
hardpointArrayNum++
|
||||||
}
|
}
|
||||||
hardpointArrayNum++
|
|
||||||
}
|
}
|
||||||
}
|
if (module.Slot.search(/Slot\d/) !== -1) {
|
||||||
if (module.Slot.search(/Slot\d/) !== -1) {
|
let internalSlotNum = 1
|
||||||
let internalSlotNum = 1
|
let militarySlotNum = 1
|
||||||
let militarySlotNum = 1
|
for (let i in shipTemplate.slots.internal) {
|
||||||
for (let i in shipTemplate.slots.internal) {
|
const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name = 'Military' : false
|
||||||
const isMilitary = isNaN(shipTemplate.slots.internal[i]) ? shipTemplate.slots.internal[i].name = 'Military' : false
|
|
||||||
|
|
||||||
// The internal slot might be a standard or a military slot. Military slots have a different naming system
|
// The internal slot might be a standard or a military slot. Military slots have a different naming system
|
||||||
let internalSlot = null
|
let internalSlot = null
|
||||||
if (isMilitary) {
|
if (isMilitary) {
|
||||||
const internalName = 'Military0' + militarySlotNum
|
const internalName = 'Military0' + militarySlotNum
|
||||||
internalSlot = json.Modules.find(elem => elem.Slot === internalName)
|
internalSlot = json.Modules.find(elem => elem.Slot === internalName)
|
||||||
militarySlotNum++
|
militarySlotNum++
|
||||||
} else {
|
} else {
|
||||||
// Slot numbers are not contiguous so handle skips.
|
// Slot numbers are not contiguous so handle skips.
|
||||||
while (internalSlot === null && internalSlotNum < 99) {
|
while (internalSlot === null && internalSlotNum < 99) {
|
||||||
// Slot sizes have no relationship to the actual size, either, so check all possibilities
|
// Slot sizes have no relationship to the actual size, either, so check all possibilities
|
||||||
for (let slotsize = 0; slotsize < 9; slotsize++) {
|
for (let slotsize = 0; slotsize < 9; slotsize++) {
|
||||||
const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '') + internalSlotNum + '_Size' + slotsize
|
const internalName = 'Slot' + (internalSlotNum <= 9 ? '0' : '') + internalSlotNum + '_Size' + slotsize
|
||||||
if (json.Modules.find(elem => elem.Slot === internalName)) {
|
if (json.Modules.find(elem => elem.Slot === internalName)) {
|
||||||
internalSlot = json.Modules.find(elem => elem.Slot === internalName)
|
internalSlot = json.Modules.find(elem => elem.Slot === internalName);
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
internalSlotNum++
|
||||||
}
|
}
|
||||||
internalSlotNum++
|
}
|
||||||
|
|
||||||
|
if (!internalSlot) {
|
||||||
|
// This can happen with old imports that don't contain new slots
|
||||||
|
} else if (!internalSlot) {
|
||||||
|
// No module
|
||||||
|
} else {
|
||||||
|
const internalJson = internalSlot
|
||||||
|
const internal = _moduleFromFdName(internalJson.Item)
|
||||||
|
ship.use(ship.internal[i], internal, true)
|
||||||
|
ship.internal[i].enabled = internalJson.On === true
|
||||||
|
ship.internal[i].priority = internalJson.Priority
|
||||||
|
opts.push({coriolisMod: internal, json: internalSlot});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!internalSlot) {
|
|
||||||
// This can happen with old imports that don't contain new slots
|
|
||||||
} else if (!internalSlot) {
|
|
||||||
// No module
|
|
||||||
} else {
|
|
||||||
const internalJson = internalSlot
|
|
||||||
const internal = _moduleFromFdName(internalJson.Item)
|
|
||||||
ship.use(ship.internal[i], internal, true)
|
|
||||||
ship.internal[i].enabled = internalJson.On === true
|
|
||||||
ship.internal[i].priority = internalJson.Priority
|
|
||||||
_addModifications(internal, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const i of opts) {
|
||||||
|
if (i.json.Engineering) _addModifications(i.coriolisMod, i.json.Engineering.Modifiers, i.json.Engineering.BlueprintName, i.json.Engineering.Level, i.json.Engineering.ExperimentalEffect)
|
||||||
}
|
}
|
||||||
// We don't have any information on it so guess it's priority 5 and disabled
|
// We don't have any information on it so guess it's priority 5 and disabled
|
||||||
if (!ship.cargoHatch) {
|
if (!ship.cargoHatch) {
|
||||||
|
|||||||
Reference in New Issue
Block a user