Skip to content

Commit

Permalink
Merge branch 'master' into GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez authored Apr 22, 2021
2 parents 090f5b0 + 23ccda2 commit 3442850
Show file tree
Hide file tree
Showing 28 changed files with 954 additions and 161 deletions.
8 changes: 8 additions & 0 deletions megamek/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ VERSION HISTORY:
+ Data: New maps, unit fixes including fix for #2707
+ Issue #2597: Add thread safety to duplicate name hash
+ Issue #2722: Do not send IP addresses in chat by default
+ PR #2691: Base Components: Creating Base Components based on the previous MekHQ Preference setup
+ PR #2724: "File>Unit List>Refresh Unit Cache" loads any changes in the unit files without having to restart
+ PR #2730: Tooltips for target number calculations on the round report
+ Issue #146: Disengage/Remove Unit Button for Offboard Artillery
Expand All @@ -30,6 +31,13 @@ VERSION HISTORY:
+ Issue #2758, 2759: Infantry no longer able to leap up to flying VTOLs for swarm attacks;
target movement modifier now applies to legal leg/swarm attacks.
+ Issue #2767: Incorrect Citation for "(Unofficial) Specify the number of pre-designated artillery autohit hexes per map area
+ Issue #547: Implement air-launched Arrow IV (homing and non-homing)
+ PR #2773: Launch Fighters (bot version)
+ Issue #1219: Adding Defensive Code for RATGenerator Era
+ Issues #1785/#2138: Fixing and Improving Round Report Player Stats
+ Issues #2787: Protomech AC gun and ammo are different tech levels
+ PR #2786: Units set for a delayed assault drop no longer disappear on the first turn of the game.
+ Issue #2438: Adding More Detail to Fire Damage Reporting

0.48.0 (Stable) - (2021-03-05 1530 UTC)
+ PR #2638, #2640: Turret data fixes
Expand Down
17 changes: 15 additions & 2 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ Cancel.text=Cancel
Cancel.toolTipText=Cancel out of the dialog. No changes made will be saved.
Ok.text=Ok
Ok.toolTipText=Confirm the changes and close the dialog.
Validate.text=Validate
Validate.toolTipText=Validate the data contained within this dialog.



##### client/ui Resources
#### client/ui/dialogs Resources
# AbstractHelpDialog Class
#### Dialogs
### AbstractHelpDialog Class
AbstractHelpDialog.errorReading=Error reading help file:\u0020
AbstractHelpDialog.helpFile=Help File:\u0020
AbstractHelpDialog.noHelp.title=No Help Available



#### Panes
### EntityViewPane Class
Summary.title=Summary
TRO.title=TRO



##### Unsorted Resources
# Generic Resources
No=No
Expand Down
1 change: 0 additions & 1 deletion megamek/i18n/megamek/common/options/messages_en.properties

This file was deleted.

18 changes: 9 additions & 9 deletions megamek/i18n/megamek/common/report-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@
5087=fails and takes a critical hit.
5090=<data> (<data>) is in extreme temperatures and dies.
5095=<data> (<data>) is on fire, but is protected by its gear.
5100=<data> (<data>) is on fire. Needs an 8+ to avoid damage, rolls <data> : <msg:5101,5102>
5100=<data> (<data>) is on fire in hex <data>. Needs an 8+ to avoid damage, rolls <data> : <msg:5101,5102>
5101=avoids successfully!
5102=fails to avoid damage.
5105=Luckily, there is no ammo to explode.
Expand All @@ -635,13 +635,13 @@
5130=Inferno fire at <data> is burning brightly.
5135=Fire at <data> was started this round.
5136=Fire at <data> was started due to an engine explosion!
5140=Heavy woods at <data> burns down to Light Woods!
5141=Ultra Heavy woods at <data> burns down to Heavy Woods!
5142=Heavy jungle at <data> burns down to Light jungle!
5143=Ultra heavy jungle at <data> burns down to Heavy jungle!
5145=Light woods at <data> burns down to Rough and goes out!!
5146=Light jungle at <data> burns down to Rough and goes out!!
5150=Fire spreads to <data>!
5140=Heavy Woods at <data> burns down to Light Woods!
5141=Ultra Heavy Woods at <data> burns down to Heavy Woods!
5142=Heavy Jungle at <data> burns down to Light Jungle!
5143=Ultra Heavy Jungle at <data> burns down to Heavy Jungle!
5145=Light Woods at <data> burns down to Rough and goes out!!
5146=Light Jungle at <data> burns down to Rough and goes out!!
5150=Fire spreads to <data> from <data>!
5155=Gains 30 heat and is now at <data> heat.
5160=Luckily, there is no inferno ammo to explode.
5165=<data> (<data>) is freed from its swarm attack.
Expand Down Expand Up @@ -940,7 +940,7 @@
7005=A strange game. The only winning move is not to play.<newline>
7010=Winner is: <data><newline>
7015=Winner is: TEAM #<data><newline>
7016=<data>: <data> BV remaining (<data>% of <data> initially) <data> BV fled
7016=<data>: <data> / <data> BV remaining (<data>%), <data> BV fled. <data> / <data> units remaining (<data>%).
7020=<newline>Survivors are:
7025=<data> (<data>)
7030=Pilot :
Expand Down
3 changes: 0 additions & 3 deletions megamek/i18n/megamek/common/report-messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@
5087=versagt und erh\u00e4lt einen kritischen Treffer.
5090=<data> (<data>) stirbt auf Grund extremer Temperatur.
5095=<data> (<data>) brennt, wird aber durch Ausr\u00fcstung gesch\u00fctzt.
5100=<data> (<data>) brennt. Ben\u00f6tigt 8+, um eine Zerst\u00f6rung zu vermeiden, w\u00fcrfelt <data> : <msg:5101,5102>
5101=\u00fcberlebt!
5102=verbrennt.
5105=Gl\u00fccklicherweise war keine Munition da, die explodieren konnte.
Expand All @@ -412,7 +411,6 @@
5143=Ultra Dichter Jungle <data> ist zu Dichtem Jungle heruntergebrannt!
5145=Lichter Wald in <data> ist ausgebrannt!!
5146=Lichter Jungle in <data> ist ausgebrannt!!
5150=Feuer breitet sich aus nach <data>!
5155=Erh\u00e4lt 30 zus\u00e4tzliche Hitze und ist jetzt bei <data>.
5160=Gl\u00fccklicherweise war da keine Infernomunition, die explodieren konnte.
5165=<data> (<data>) ist von eine Schwarmattacke befreit.
Expand Down Expand Up @@ -583,7 +581,6 @@
7005=Der Gewinner ist: Die Chicago Cubs!!!<newline>
7010=Der Gewinner ist: <data><newline>
7015=Der Gewinner ist: TEAM #<data><newline>
7016=<data>: <data> BV \u00fcbrig (von urspr\u00fcnglich <data>)
7020=\u00dcberlebende sind:
7025=<data> (<data>)
7030=Pilot:
Expand Down
5 changes: 2 additions & 3 deletions megamek/i18n/megamek/common/report-messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@
5087=неудачно и получает критический урон.
5090=<data> (<data>) умирает при экстремальной температуре.
5095=<data> (<data>) горит, но защищен своей броней.
5100=<data> (<data>) горит. Нужно 8+ чтобы избежать урона, выбрасывает <data> : <msg:5101,5102>
5101=избегает удачно!
5102=не удается избежать урона.
5105=К счастью, не осталось боеприпасов, которые могли бы взорваться.
Expand All @@ -544,7 +543,7 @@
5143=Ультра Густые Джунгли в <data> выгорают до Густых Джунглей!
5145=Редкий Лес в <data> выгорает до Пересеченной местности и пожар гаснет!!
5146=Редкие Джунгли в <data> выгорают до Пересеченной местности и пожар гаснет!!
5150=Огонь переходит на <data>!
5150=Огонь распространился с <data> на <data>!
5155=Набирает 30 тепла и сейчас нагрет на <data> тепла.
5160=К счастью, не осталось инферно боеприпасов, которые могли бы взорваться.
5165=<data> (<data>) освобожден от штурмующей атаки.
Expand Down Expand Up @@ -815,7 +814,7 @@
7005=Победитель: Чикаго Кабс!!!<newline>
7010=Победитель: <data><newline>
7015=Победитель: КОМАНДА #<data><newline>
7016=<data>: <data> BV осталось (из <data> изначальных) <data> BV убежало
7016=<data>: <data> / <data> BV осталось (<data> из изначальных), <data> BV убежало. <data> / <data> бойцов осталось (<data>%).
7020=<newline>Выжившие:
7025=<data> (<data>)
7030=Пилот :
Expand Down
59 changes: 58 additions & 1 deletion megamek/src/megamek/client/bot/princess/Princess.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -38,6 +39,7 @@
import megamek.client.ui.SharedUtility;
import megamek.common.AmmoType;
import megamek.common.BattleArmor;
import megamek.common.Bay;
import megamek.common.Building;
import megamek.common.BuildingTarget;
import megamek.common.BulldozerMovePath;
Expand Down Expand Up @@ -1976,6 +1978,7 @@ private MovePath performPathPostProcessing(MovePath path, double expectedDamage)
evadeIfNotFiring(retval, expectedDamage >= 0);
turnOnSearchLight(retval, expectedDamage >= 0);
unloadTransportedInfantry(retval);
launchFighters(retval);
unjamRAC(retval);

// if we are using vector movement, there's a whole bunch of post-processing that happens to
Expand Down Expand Up @@ -2057,7 +2060,7 @@ private void unloadTransportedInfantry(MovePath path) {
Targetable closestEnemy = getPathRanker(movingEntity).findClosestEnemy(movingEntity, pathEndpoint, getGame(), false);

// if there are no enemies on the board, then we're not unloading anything.
// infantry can't clear hexes, so let's not use th
// infantry can't clear hexes, so let's not unload them for that purpose
if((null == closestEnemy) || (closestEnemy.getTargetType() == Targetable.TYPE_HEX_CLEAR)) {
return;
}
Expand All @@ -2066,6 +2069,11 @@ private void unloadTransportedInfantry(MovePath path) {

// loop through all entities carried by the current entity
for(Transporter transport : movingEntity.getTransports()) {
// this operation is intended for entities on the ground
if (transport instanceof Bay) {
continue;
}

for(Entity loadedEntity : transport.getLoadedUnits()) {
// there's really no good reason for Princess to disconnect trailers.
// Let's skip those for now. We don't want to create a bogus 'unload' step for them anyhow.
Expand Down Expand Up @@ -2098,6 +2106,55 @@ private void unloadTransportedInfantry(MovePath path) {
}
}

/**
* Helper function that adds an "launch" step for units that are transporting
* launchable units in some kind of bay.
*/
private void launchFighters(MovePath path) {
// if my objective is to cross the board, even though it's tempting, I won't be leaving the infantry
// behind. They're not that good at screening against high speed pursuit anyway.
if (getBehaviorSettings().shouldGoHome()) {
return;
}

Entity movingEntity = path.getEntity();
Coords pathEndpoint = path.getFinalCoords();
Targetable closestEnemy = getPathRanker(movingEntity).findClosestEnemy(movingEntity, pathEndpoint, getGame(), false);

// if there are no enemies on the board, then we're not launching anything.
if ((null == closestEnemy) || (closestEnemy.getTargetType() != Targetable.TYPE_ENTITY)) {
return;
}

TreeMap<Integer, Vector<Integer>> unitsToLaunch = new TreeMap<>();
boolean executeLaunch = false;

// loop through all fighter (or smallcraft) bays in the current entity
// grouping launched craft by bay to limit launches to 'safe' rate.
Vector<Bay> fighterBays = movingEntity.getFighterBays();

for (int bayIndex = 0; bayIndex < fighterBays.size(); bayIndex++) {
Bay bay = fighterBays.get(bayIndex);

for (Entity loadedEntity : bay.getLaunchableUnits()) {
unitsToLaunch.putIfAbsent(bayIndex, new Vector<>());

// for now, just launch fighters at the 'safe' rate
if (unitsToLaunch.get(bayIndex).size() < bay.getSafeLaunchRate()) {
unitsToLaunch.get(bayIndex).add(loadedEntity.getId());
executeLaunch = true;
} else {
break;
}
}
}

// only add the step if we're actually launching something
if (executeLaunch) {
path.addStep(MoveStepType.LAUNCH, unitsToLaunch);
}
}

public void sendChat(final String message,
final LogLevel logLevel) {
if (getVerbosity().willLog(logLevel)) {
Expand Down
41 changes: 27 additions & 14 deletions megamek/src/megamek/client/ratgenerator/RATGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import javax.xml.parsers.DocumentBuilder;

import megamek.common.annotations.Nullable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -339,11 +340,13 @@ public Collection<String> getFactionKeySet() {
return factions.keySet();
}

public int eraForYear(int year) {
if (year < eraSet.first()) {
return eraSet.first();
public int eraForYear(final int year) {
if (year < getEraSet().first()) {
return getEraSet().first();
} else {
final Integer floor = getEraSet().floor(year);
return (floor == null) ? year : floor;
}
return eraSet.floor(year);
}

public boolean eraIsLoaded(int era) {
Expand Down Expand Up @@ -841,18 +844,23 @@ private synchronized void initialize(File dir) {
}

/**
* If year is equal to one of the era marks, loads that era. If it is between,
* loads eras on both sides.
* If the year is equal to one of the era marks, it loads that era. If it is between two, it
* loads eras on both sides. Otherwise, just load the closest era.
*/
public void loadYear(int year) {
if (eraSet.contains(year)) {
public void loadYear(final int year) {
if (getEraSet().isEmpty()) {
return;
} else if (getEraSet().contains(year)) {
loadEra(year);
return;
}
if (year > eraSet.first()) {
loadEra(eraSet.floor(year));

if (year > getEraSet().first()) {
loadEra(getEraSet().floor(year));
}
if (year < eraSet.last()) {
loadEra(eraSet.ceiling(year));

if (year < getEraSet().last()) {
loadEra(getEraSet().ceiling(year));
}
}

Expand Down Expand Up @@ -894,8 +902,13 @@ private void loadFactions(File dir) {
}
}

private void loadEra(int era) {
loadEra(era, Configuration.forceGeneratorDir());
/**
* @param era the era to load, which may be null if there isn't anything found
*/
private void loadEra(final @Nullable Integer era) {
if (era != null) {
loadEra(era, Configuration.forceGeneratorDir());
}
}

private synchronized void loadEra(int era, File dir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ResourceBundle;

/**
Expand Down Expand Up @@ -107,33 +106,18 @@ protected void initialize() {
*/
protected JPanel createButtonPanel() {
JPanel panel = new JPanel(new GridLayout(1, 2));
panel.add(createButton("Ok.text", "Ok.toolTipText", "okButton", this::okButtonActionPerformed));
panel.add(createButton("Cancel.text", "Cancel.toolTipText", "cancelButton", this::cancelActionPerformed));
panel.add(new MMButton("okButton", resources.getString("Ok.text"),
resources.getString("Ok.toolTipText"), this::okButtonActionPerformed));
panel.add(new MMButton("cancelButton", resources.getString("Cancel.text"),
resources.getString("Cancel.toolTipText"), this::cancelActionPerformed));
return panel;
}

/**
* This creates a standard button for use in the dialog
* @param text the text resource string
* @param toolTipText the toolTipText resource string
* @param name the name of the button
* @param actionListener the {@link ActionListener} to assign to the button
* @return the created button
*/
protected JButton createButton(final String text, final String toolTipText, final String name,
final ActionListener actionListener) {
JButton button = new JButton(resources.getString(text));
button.setToolTipText(resources.getString(toolTipText));
button.setName(name);
button.addActionListener(actionListener);
return button;
}
//endregion Initialization

//region Button Actions
/**
* This is the default Action Event Listener for the Ok Button's action. This triggers the Ok Action,
* sets the result to confirmed, and then sets the dialog so that it is no longer visible.
* This is the default Action Event Listener for the Ok Button's action. This triggers the Ok
* Action, sets the result to confirmed, and then sets the dialog so that it is no longer visible.
* @param evt the event triggering this
*/
protected void okButtonActionPerformed(final ActionEvent evt) {
Expand Down
Loading

0 comments on commit 3442850

Please sign in to comment.