Skip to content

Commit

Permalink
Merge pull request #4709 from Sleet01/fix_1182_mixed_tech_DS_do_not_s…
Browse files Browse the repository at this point in the history
…ave_BA_tech_type

Fix 1182 mixed tech ds do not save ba tech type
  • Loading branch information
HammerGS authored Aug 23, 2023
2 parents 1aacd32 + e248132 commit 956b7c1
Show file tree
Hide file tree
Showing 29 changed files with 1,012 additions and 346 deletions.
10 changes: 8 additions & 2 deletions megamek/src/megamek/common/ASFBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ public int getPersonnel(boolean clan) {

@Override
public String toString() {
return (hasARTS() ? "artsasfbay:" : "asfbay:") + totalSpace + ":" + doors + ":" + bayNumber;
String bayType = (hasARTS() ? "artsasfbay" : "asfbay");
return this.bayString(
bayType,
totalSpace,
doors,
bayNumber
);
}

public static TechAdvancement techAdvancement() {
Expand All @@ -117,4 +123,4 @@ public TechAdvancement getTechAdvancement() {
public long getCost() {
return 20000L * (long) totalSpace + (hasARTS() ? 1000000L : 0);
}
}
}
87 changes: 44 additions & 43 deletions megamek/src/megamek/common/Aero.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class Aero extends Entity implements IAero, IBomber {
public static final int COCKPIT_SMALL = 1;
public static final int COCKPIT_COMMAND_CONSOLE = 2;
public static final int COCKPIT_PRIMITIVE = 3;
public static final String[] COCKPIT_STRING = { "Standard Cockpit", "Small Cockpit", "Command Console",
"Primitive Cockpit" };
public static final String[] COCKPIT_SHORT_STRING = { "Standard", "Small", "Command Console", "Primitive" };
public static final String[] COCKPIT_STRING = {"Standard Cockpit", "Small Cockpit", "Command Console",
"Primitive Cockpit"};
public static final String[] COCKPIT_SHORT_STRING = {"Standard", "Small", "Command Console", "Primitive"};

// critical hits
public static final int CRIT_NONE = -1;
Expand Down Expand Up @@ -86,10 +86,10 @@ public class Aero extends Entity implements IAero, IBomber {
// this needs to be larger, it is too easy to go over when you get to
// warships
// and bombs and such
private static final int[] NUM_OF_SLOTS = { 100, 100, 100, 100, 100, 100, 100 };
private static final int[] NUM_OF_SLOTS = {100, 100, 100, 100, 100, 100, 100};

private static String[] LOCATION_ABBRS = { "NOS", "LWG", "RWG", "AFT", "WNG", "FSLG" };
private static String[] LOCATION_NAMES = { "Nose", "Left Wing", "Right Wing", "Aft", "Wings", "Fuselage" };
private static String[] LOCATION_ABBRS = {"NOS", "LWG", "RWG", "AFT", "WNG", "FSLG"};
private static String[] LOCATION_NAMES = {"Nose", "Left Wing", "Right Wing", "Aft", "Wings", "Fuselage"};

@Override
public String[] getLocationAbbrs() {
Expand All @@ -111,7 +111,7 @@ public String[] getLocationNames() {
private int structIntegrity;
private int orig_structIntegrity;
// set up damage threshold
protected int[] damThresh = { 0, 0, 0, 0, 0, 0 };
protected int[] damThresh = {0, 0, 0, 0, 0, 0};
// set up an int for what the critical effect would be
private int potCrit = CRIT_NONE;

Expand Down Expand Up @@ -212,7 +212,7 @@ public String[] getLocationNames() {
private Set<String> escapeCraftList = new HashSet<>();

//Maps unique id of each assigned marine to marine point value
private Map<UUID,Integer> marines;
private Map<UUID, Integer> marines;

public Aero() {
super();
Expand All @@ -230,7 +230,7 @@ public int getUnitType() {
.setTechRating(RATING_D).setAvailability(RATING_C, RATING_E, RATING_D, RATING_C)
.setStaticTechLevel(SimpleTechLevel.STANDARD);
protected static final TechAdvancement TA_ASF_PRIMITIVE = new TechAdvancement(TECH_BASE_IS)
//Per MUL team and per availability codes should exist to around 2781
//Per MUL team and per availability codes should exist to around 2781
.setISAdvancement(DATE_ES, 2200, DATE_NONE, 2781, DATE_NONE)
.setISApproximate(false, true, false, true, false).setProductionFactions(F_TA)
.setTechRating(RATING_D).setAvailability(RATING_D, RATING_X, RATING_F, RATING_F)
Expand All @@ -247,28 +247,28 @@ public TechAdvancement getConstructionTechAdvancement() {

protected static final TechAdvancement[] COCKPIT_TA = {
new TechAdvancement(TECH_BASE_ALL).setAdvancement(2460, 2470, 2491)
.setApproximate(true, false, false).setPrototypeFactions(F_TH)
.setPrototypeFactions(F_TH).setTechRating(RATING_C)
.setAvailability(RATING_C, RATING_C, RATING_C, RATING_C)
.setStaticTechLevel(SimpleTechLevel.STANDARD), //Standard
.setApproximate(true, false, false).setPrototypeFactions(F_TH)
.setPrototypeFactions(F_TH).setTechRating(RATING_C)
.setAvailability(RATING_C, RATING_C, RATING_C, RATING_C)
.setStaticTechLevel(SimpleTechLevel.STANDARD), //Standard
new TechAdvancement(TECH_BASE_IS).setISAdvancement(3065, 3070, 3080)
.setClanAdvancement(DATE_NONE, DATE_NONE, 3080)
.setISApproximate(true, false, false).setPrototypeFactions(F_WB)
.setPrototypeFactions(F_WB, F_CSR).setTechRating(RATING_E)
.setAvailability(RATING_X, RATING_X, RATING_E, RATING_D)
.setStaticTechLevel(SimpleTechLevel.STANDARD), //Small
.setClanAdvancement(DATE_NONE, DATE_NONE, 3080)
.setISApproximate(true, false, false).setPrototypeFactions(F_WB)
.setPrototypeFactions(F_WB, F_CSR).setTechRating(RATING_E)
.setAvailability(RATING_X, RATING_X, RATING_E, RATING_D)
.setStaticTechLevel(SimpleTechLevel.STANDARD), //Small
new TechAdvancement(TECH_BASE_ALL).setISAdvancement(2625, 2631, DATE_NONE, 2850, 3030)
.setISApproximate(true, false, false, true, true)
.setClanAdvancement(2625, 2631).setClanApproximate(true, false)
.setClanApproximate(true, false).setPrototypeFactions(F_TH)
.setPrototypeFactions(F_TH).setReintroductionFactions(F_FS).setTechRating(RATING_D)
.setAvailability(RATING_C, RATING_F, RATING_E, RATING_D)
.setStaticTechLevel(SimpleTechLevel.ADVANCED), //Cockpit command console
.setISApproximate(true, false, false, true, true)
.setClanAdvancement(2625, 2631).setClanApproximate(true, false)
.setClanApproximate(true, false).setPrototypeFactions(F_TH)
.setPrototypeFactions(F_TH).setReintroductionFactions(F_FS).setTechRating(RATING_D)
.setAvailability(RATING_C, RATING_F, RATING_E, RATING_D)
.setStaticTechLevel(SimpleTechLevel.ADVANCED), //Cockpit command console
new TechAdvancement(TECH_BASE_ALL).setAdvancement(DATE_ES, 2300, DATE_NONE, 2520)
.setISApproximate(false, true, false, false)
.setPrototypeFactions(F_TA).setTechRating(RATING_C)
.setAvailability(RATING_D, RATING_X, RATING_X, RATING_F)
.setStaticTechLevel(SimpleTechLevel.STANDARD), //Primitive
.setISApproximate(false, true, false, false)
.setPrototypeFactions(F_TA).setTechRating(RATING_C)
.setAvailability(RATING_D, RATING_X, RATING_X, RATING_F)
.setStaticTechLevel(SimpleTechLevel.STANDARD), //Primitive
};

public static TechAdvancement getCockpitTechAdvancement(int cockpitType) {
Expand Down Expand Up @@ -747,9 +747,9 @@ public int getLandingGearPartialRepairs() {
@Override
public int getAvionicsMisreplaced() {
if (getPartialRepairs().booleanOption("aero_avionics_replace")) {
return 1;
return 1;
} else {
return 0;
return 0;
}
}

Expand Down Expand Up @@ -2496,15 +2496,15 @@ public String getCritDamageString() {
if (!first) {
toReturn.append(", ");
}
toReturn.append(String.format(Messages.getString("Aero.bayDamageString"), next.getType(), next.getBayNumber()));
first = false;
toReturn.append(String.format(Messages.getString("Aero.bayDamageString"), next.getType(), next.getBayNumber()));
first = false;
}
if (next.getCurrentDoors() < next.getDoors()) {
if (!first) {
toReturn.append(", ");
}
toReturn.append(String.format(Messages.getString("Aero.bayDoorDamageString"), next.getType(), next.getBayNumber(), (next.getDoors() - next.getCurrentDoors())));
first = false;
toReturn.append(String.format(Messages.getString("Aero.bayDoorDamageString"), next.getType(), next.getBayNumber(), (next.getDoors() - next.getCurrentDoors())));
first = false;
}
}
return toReturn.toString();
Expand Down Expand Up @@ -2662,8 +2662,8 @@ public boolean canSpot() {
if (!isAirborne() || hasWorkingMisc(MiscType.F_RECON_CAMERA) || hasWorkingMisc(MiscType.F_INFRARED_IMAGER)
|| hasWorkingMisc(MiscType.F_HYPERSPECTRAL_IMAGER)
|| (hasWorkingMisc(MiscType.F_HIRES_IMAGER)
&& ((game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DAY)
|| (game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DUSK)))) {
&& ((game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DAY)
|| (game.getPlanetaryConditions().getLight() == PlanetaryConditions.L_DUSK)))) {
return true;
} else {
return false;
Expand Down Expand Up @@ -2842,7 +2842,7 @@ public void setNMarines(int marines) {
* Returns our list of unique individuals being transported as marines
* @return
*/
public Map<UUID,Integer> getMarines() {
public Map<UUID, Integer> getMarines() {
return marines;
}

Expand Down Expand Up @@ -3000,7 +3000,7 @@ public boolean isBomber() {

@Override
/**
* Returns true if this is an aerospace or conventional fighter
* Returns true if this is an aerospace or conventional fighter
* but not a larger craft (i.e. "SmallCraft" or "Dropship" and bigger
*/
public boolean isFighter() {
Expand Down Expand Up @@ -3044,7 +3044,7 @@ public List<Mounted> getActiveAMS() {
// Skip anything that's not an AMS, AMS Bay or Point Defense Bay
if (!weapon.getType().hasFlag(WeaponType.F_AMS)
&& !weapon.getType().hasFlag(WeaponType.F_AMSBAY)
&& !weapon.getType().hasFlag(WeaponType.F_PDBAY)) {
&& !weapon.getType().hasFlag(WeaponType.F_PDBAY)) {
continue;
}

Expand All @@ -3067,15 +3067,15 @@ public List<Mounted> getActiveAMS() {
Mounted bayWAmmo = bayW.getLinked();
if (!(weapon.getType().hasFlag(WeaponType.F_ENERGY))
&& ((bayWAmmo == null) || (bayWAmmo.getUsableShotsLeft() == 0)
|| bayWAmmo.isDumping())) {
|| bayWAmmo.isDumping())) {
loadWeapon(weapon);
bayWAmmo = weapon.getLinked();
}

// try again
if (!(weapon.getType().hasFlag(WeaponType.F_ENERGY))
&& ((bayWAmmo == null) || (bayWAmmo.getUsableShotsLeft() == 0)
|| bayWAmmo.isDumping())) {
|| bayWAmmo.isDumping())) {
// No ammo for this AMS.
continue;
}
Expand Down Expand Up @@ -3132,7 +3132,7 @@ public void updateSensorOptions() {
}
getSensors().removeAll(sensorsToRemove);
if (sensorsToRemove.size() >= 1) {
setNextSensor(getSensors().firstElement());
setNextSensor(getSensors().firstElement());
}
}
//If we are in space, add them back...
Expand All @@ -3154,7 +3154,7 @@ public void updateSensorOptions() {
}
}
} else if (hasETypeFlag(Entity.ETYPE_AERO)
|| hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) {
|| hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) {
//ASFs and small craft get thermal/optical sensors
if (!hasAeroThermal) {
getSensors().add(new Sensor(Sensor.TYPE_AERO_THERMAL));
Expand All @@ -3165,6 +3165,7 @@ public void updateSensorOptions() {
}

// autoejection methods

/**
* @return unit has an ejection seat
*/
Expand Down
19 changes: 18 additions & 1 deletion megamek/src/megamek/common/BattleArmorBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,20 @@ public int getPersonnel(boolean clan) {

@Override
public String toString() {
return "battlearmorbay:" + totalSpace + ":" + doors + ":"+bayNumber+(isComStar?":C*":"");
// See BLKFile.java:BLKFile constants
int bitmap = 0;
bitmap |= (isComStar? 1 : 0);
bitmap |= (isClan? 1 << 1 : 0);
String bayType = "battlearmorbay";
return this.bayString(
bayType,
totalSpace,
doors,
bayNumber,
"",
Entity.LOC_NONE,
bitmap
);
}

public static TechAdvancement techAdvancement() {
Expand All @@ -136,6 +149,10 @@ public boolean isClan() {
return isClan;
}

public boolean isComStar() {
return isComStar;
}

@Override
public long getCost() {
// Based on the weight of the equipment (not capacity), rounded up to the whole ton
Expand Down
22 changes: 20 additions & 2 deletions megamek/src/megamek/common/Bay.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,27 @@ public int getPersonnel(boolean clan) {
return 0;
}

/**
* Updated toString() and helpers to normalize bay string output
* To match new 6-field format:
* type:space(current or total):doors:bayNumber:infantryType:facing:status bitmap
* See BLKFile.java:BLKFile constants
*/
@Override
public String toString() {
return "bay:" + totalSpace + ":" + doors + ":"+ bayNumber;
return this.bayString("bay", totalSpace, doors, bayNumber, "", Entity.LOC_NONE, 0);
}

public String bayString(String bayType, double space, int doors, int bayNumber, String infType, int facing, int bitmap){
return String.format("%s:%s:%s:%s:%s:%s:%s", bayType, space, doors, bayNumber, infType, facing, bitmap);
}

public String bayString(String bayType, double space, int doors, int bayNumber){
return String.format("%s:%s:%s:%s:%s:%s:%s", bayType, space, doors, bayNumber, "", Entity.LOC_NONE, 0);
}

public String bayString(String bayType, double space, int doors){
return String.format("%s:%s:%s:%s:%s:%s:%s", bayType, space, doors, -1, "", Entity.LOC_NONE, 0);
}

/**
Expand Down Expand Up @@ -535,4 +553,4 @@ public long getCost() {
public int getSafeLaunchRate() {
return getCurrentDoors() * 2;
}
}
}
10 changes: 8 additions & 2 deletions megamek/src/megamek/common/CargoBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ public String getType() {

@Override
public String toString() {
return "cargobay:" + totalSpace + ":" + doors + ":" + bayNumber;
String bayType = "cargobay";
return this.bayString(
bayType,
totalSpace,
doors,
bayNumber
);
}

@Override
public boolean isCargo() {
return true;
Expand Down
7 changes: 6 additions & 1 deletion megamek/src/megamek/common/CrewQuartersCargoBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ public double getWeight() {

@Override
public String toString() {
return "crewquarters:" + weight + ":" + doors;
String bayType = "crewquarters";
return this.bayString(
bayType,
weight,
doors
);
}

@Override
Expand Down
14 changes: 10 additions & 4 deletions megamek/src/megamek/common/DropshuttleBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ public void setFacing(int facing) {

@Override
public String toString() {
return "dropshuttlebay:" + totalSpace + FIELD_SEPARATOR
+ doors + FIELD_SEPARATOR
+ bayNumber + FIELD_SEPARATOR
+ FACING_PREFIX + facing;
String bayType = "dropshuttlebay";
return this.bayString(
bayType,
totalSpace,
doors,
bayNumber,
"",
facing,
0
);
}

@Override
Expand Down
7 changes: 6 additions & 1 deletion megamek/src/megamek/common/EjectionSeatCargoBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ public String getType() {

@Override
public String toString() {
return "ejectionseats:" + currentSpace + ":" + doors;
String bayType = "ejectionseats";
return this.bayString(
bayType,
currentSpace,
doors
);
}

@Override
Expand Down
7 changes: 6 additions & 1 deletion megamek/src/megamek/common/FirstClassQuartersCargoBay.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ public boolean isQuarters() {

@Override
public String toString() {
return "1stclassquarters:" + weight + ":" + doors;
String bayType = "1stclassquarters";
return this.bayString(
bayType,
weight,
doors
);
}

@Override
Expand Down
Loading

0 comments on commit 956b7c1

Please sign in to comment.