Skip to content

Commit

Permalink
Merge pull request #1017 from SJuliez/Issues
Browse files Browse the repository at this point in the history
Fixes for 1016, 1012, 1008
  • Loading branch information
Windchild292 authored Jan 26, 2022
2 parents 0615104 + f38554f commit 6f955f9
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/megameklab/com/printing/PrintMech.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,10 @@ private void writeLocationCriticals(int loc, SVGRectElement svgRect) {
double x = viewX + viewWidth * 0.075;
x += addTextElement(canvas, x, viewY - 1, mech.getLocationName(loc),
fontSize * 1.25f, SVGConstants.SVG_START_VALUE, SVGConstants.SVG_BOLD_VALUE);
if (mech.isClan() && UnitUtil.hasAmmo(mech, loc) && !mech.hasCASEII(loc)) {
addTextElement(canvas, x + fontSize / 2, viewY - 1, "(CASE)", fontSize,
if ((mech.isClan() && UnitUtil.hasAmmo(mech, loc))
|| (!mech.isClan() && (mech.hasCASEII(loc) || mech.locationHasCase(loc)))) {
String text = "(CASE" + (mech.hasCASEII(loc) ? " II)" : ")");
addTextElement(canvas, x + fontSize / 2, viewY - 1, text, fontSize,
SVGConstants.SVG_START_VALUE, SVGConstants.SVG_NORMAL_VALUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected void addEquipment(EquipmentType equip, int count) {
} else {
try {
mount = new Mounted(getTank(), equip);
UnitUtil.setVariableSizeMiscTypeMinimumSize(mount);
int loc = Entity.LOC_NONE;
if (isMisc && equip.hasFlag(MiscType.F_MAST_MOUNT)) {
loc = VTOL.LOC_ROTOR;
Expand Down
16 changes: 11 additions & 5 deletions src/megameklab/com/ui/fighterAero/ASChassisView.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,24 +294,30 @@ public List<Engine> getAvailableEngines() {
flags |= Engine.LARGE_ENGINE;
}
int altFlags = flags ^ Engine.CLAN_ENGINE;
// Non-superheavies can use non-fusion engines under experimental rules
for (int i : ENGINE_TYPES) {
Engine e = new Engine(getEngineRating(), i, flags);
if (e.engineValid && (e.isFusion() || conventional)
&& techManager.isLegal(e)) {
if (e.engineValid && techManager.isLegal(e) && (validCFEngine(e) || validASFEngine(e))) {
retVal.add(e);
}
// Only add the opposite tech base if the engine is different.
if (isMixed && e.getSideTorsoCriticalSlots().length > 0) {
e = new Engine(getEngineRating(), i, altFlags);
if (e.engineValid && (e.isFusion() || conventional)
&& techManager.isLegal(e)) {
if (e.engineValid && techManager.isLegal(e) && (validCFEngine(e) || validASFEngine(e))) {
retVal.add(e);
}
}
}
return retVal;
}

private boolean validCFEngine(Engine engine) {
return conventional && ((engine.getEngineType() == Engine.NORMAL_ENGINE)
|| (engine.getEngineType() == Engine.COMBUSTION_ENGINE));
}

private boolean validASFEngine(Engine engine) {
return !conventional && engine.isFusion();
}

private void refreshCockpit() {
cbCockpit.removeActionListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected void addEquipment(EquipmentType equip, int count) {
} else {
try {
Mounted mount = new Mounted(getAero(), equip);
UnitUtil.setVariableSizeMiscTypeMinimumSize(mount);
int location = (equip instanceof AmmoType) ? Aero.LOC_FUSELAGE : Aero.LOC_NONE;
getAero().addEquipment(mount, location, false);
if ((equip instanceof WeaponType) && equip.hasFlag(WeaponType.F_ONESHOT)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected void addEquipment(EquipmentType equip, int count) {
try {
for (int i = 0; i < count; i++) {
mount = new Mounted(getAero(), equip);
UnitUtil.setVariableSizeMiscTypeMinimumSize(mount);
getAero().addEquipment(mount, Entity.LOC_NONE, false);
if ((equip instanceof WeaponType) && equip.hasFlag(WeaponType.F_ONESHOT)) {
UnitUtil.removeOneShotAmmo(eSource.getEntity());
Expand Down
1 change: 1 addition & 0 deletions src/megameklab/com/ui/mek/BMEquipmentDatabaseView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected void addEquipment(EquipmentType equip, int count) {
} else {
try {
mount = new Mounted(getMech(), equip);
UnitUtil.setVariableSizeMiscTypeMinimumSize(mount);
getMech().addEquipment(mount, Entity.LOC_NONE, false);
if ((equip instanceof WeaponType) && equip.hasFlag(WeaponType.F_ONESHOT)) {
UnitUtil.removeOneShotAmmo(eSource.getEntity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected void addEquipment(EquipmentType equip, int count) {
}
for (int i = 0; i < count; i++) {
mount = new Mounted(eSource.getEntity(), equip);
UnitUtil.setVariableSizeMiscTypeMinimumSize(mount);
if ((eSource.getEntity().isFighter()
&& (equip instanceof MiscType)) && equip.hasFlag(MiscType.F_BLUE_SHIELD)) {
getAero().addEquipment(mount, Aero.LOC_FUSELAGE, false);
Expand Down
10 changes: 10 additions & 0 deletions src/megameklab/com/util/UnitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4464,5 +4464,15 @@ public static void setManualBV(int manualBV, Entity entity) {
entity.setUseManualBV(manualBV > 0);
}

/**
* For MiscTypes of variable size such as Ladders this sets the size to the minimum
* size which is equal to the step size (20m for Ladders, 0.5t for Cargo space and the like).
*/
public static void setVariableSizeMiscTypeMinimumSize(Mounted mounted) {
if ((mounted.getType() instanceof MiscType) && mounted.getType().isVariableSize()) {
mounted.setSize(mounted.getType().variableStepSize());
}
}


}

0 comments on commit 6f955f9

Please sign in to comment.