-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ACS-Like autoresolve #6239
base: master
Are you sure you want to change the base?
ACS-Like autoresolve #6239
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6239 +/- ##
============================================
- Coverage 28.99% 28.98% -0.01%
- Complexity 13982 13986 +4
============================================
Files 2652 2656 +4
Lines 268296 268423 +127
Branches 47764 47787 +23
============================================
+ Hits 77799 77812 +13
- Misses 186615 186726 +111
- Partials 3882 3885 +3 ☔ View full report in Codecov by Sentry. |
@@ -49,5 +50,5 @@ | |||
* @param context The context to consider, see {@link VictoryCondition} (currently unused) | |||
* @return The result of the victory condition test | |||
*/ | |||
VictoryResult checkVictory(Game game, Map<String, Object> context); | |||
VictoryResult checkVictory(IGame game, Map<String, Object> context); |
Check notice
Code scanning / CodeQL
Useless parameter Note
megamek/src/megamek/common/net/marshalling/NativeSerializationMarshaller.java
Fixed
Show fixed
Hide fixed
megamek/src/megamek/common/net/marshalling/NativeSerializationMarshaller.java
Fixed
Show fixed
Hide fixed
|
||
@Override | ||
public IOption getOption(String name) { | ||
if (tableInfo == null) { |
Check warning
Code scanning / CodeQL
Useless null check Warning
tableInfo
new HashMap<String,IOption>(...)
<AppenderRef ref="Console" /> | ||
<AppenderRef ref="${env:mm.profile:-null}" /> | ||
</Logger> | ||
<Logger name="megamek" level="info" additivity="false"> | ||
<AppenderRef ref="MegaMekLog" /> | ||
<AppenderRef ref="Console" /> | ||
<AppenderRef ref="${env:mm.profile:-null}" /> | ||
</Logger> | ||
<Logger name="megameklab" level="info" additivity="false"> | ||
<AppenderRef ref="MegaMekLabLog" /> | ||
<AppenderRef ref="Console" /> | ||
<AppenderRef ref="${env:mm.profile:-null}" /> | ||
</Logger> | ||
<Logger name="mekhq" level="info" additivity="false"> | ||
<AppenderRef ref="MekHQLog" /> | ||
<AppenderRef ref="Console" /> | ||
<AppenderRef ref="${env:mm.profile:-null}" /> | ||
</Logger> | ||
|
||
<Root level="info"> | ||
<AppenderRef ref="Console" /> | ||
<AppenderRef ref="MegaMekLog" /> | ||
<AppenderRef ref="${env:mm.profile:-null}" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to document this somewhere
long start = System.currentTimeMillis(); | ||
var stopwatch = StopWatch.create(); | ||
stopwatch.start(); | ||
rug.populateUnits(); | ||
long end = System.currentTimeMillis(); | ||
logger.info("Loaded Rats in: " + (end - start) + "ms."); | ||
stopwatch.stop(); | ||
logger.info("Loaded Rats in: {}", stopwatch.toString()); | ||
rug.initialized = true; | ||
latch.countDown(); | ||
}, "Random Unit Generator unit populater"); | ||
rug.loader.setPriority(Thread.NORM_PRIORITY - 1); | ||
rug.loader.start(); | ||
} | ||
|
||
try { | ||
latch.await(); | ||
} catch (InterruptedException e) { | ||
logger.error("Initialization interrupted", e); | ||
Thread.currentThread().interrupt(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
substitutes the while sleep loop with a latch await
logger.error("Trying to resize a unit icon of height or width 0!"); | ||
logger.debug("Trying to resize a unit icon of height or width 0!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an error should be something that we need to fix, this apparently is here just to tell "hey, the image is not imaging"
@@ -9901,7 +9874,7 @@ public boolean isEligibleForFiring() { | |||
} | |||
|
|||
// check game options | |||
if (!game.getOptions().booleanOption(OptionsConstants.BASE_SKIP_INELIGABLE_FIRING)) { | |||
if (!game.getOptions().booleanOption(OptionsConstants.BASE_SKIP_INELIGIBLE_FIRING)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
@@ -322,10 +329,10 @@ public void setupTeams() { | |||
Vector<Team> initTeams = new Vector<>(); | |||
boolean useTeamInit = getOptions().getOption(OptionsConstants.BASE_TEAM_INITIATIVE) | |||
.booleanValue(); | |||
|
|||
var players = getPlayersList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return the lpayer list only once.
private static final Option.OptionValue[] baseOptions = { | ||
Option.of(OptionsConstants.BASE_FRIENDLY_FIRE, false), | ||
Option.of(OptionsConstants.BASE_SKIP_INELIGIBLE_MOVEMENT, false), | ||
Option.of(OptionsConstants.BASE_SKIP_INELIGIBLE_FIRING, false), | ||
Option.of(OptionsConstants.BASE_SKIP_INELIGIBLE_PHYSICAL, true), | ||
Option.of(OptionsConstants.BASE_TEAM_INITIATIVE, true), | ||
Option.of(OptionsConstants.BASE_AUTOSAVE_MSG, true), | ||
Option.of(OptionsConstants.BASE_PARANOID_AUTOSAVE, false), | ||
Option.of(OptionsConstants.BASE_MAX_NUMBER_ROUND_SAVES, 3), | ||
Option.of(OptionsConstants.BASE_EXCLUSIVE_DB_DEPLOYMENT, true), | ||
Option.of(OptionsConstants.BASE_BLIND_DROP, false), | ||
Option.of(OptionsConstants.BASE_REAL_BLIND_DROP, false), | ||
Option.of(OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE, false), | ||
Option.of(OptionsConstants.BASE_SET_DEFAULT_TEAM_1, false), | ||
Option.of(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0, false), | ||
Option.of(OptionsConstants.BASE_RESTRICT_GAME_COMMANDS, false), | ||
Option.of(OptionsConstants.BASE_DISABLE_LOCAL_SAVE, false), | ||
Option.of(OptionsConstants.BASE_BRIDGECF, 0), | ||
Option.of(OptionsConstants.BASE_RNG_TYPE, 1), | ||
Option.of(OptionsConstants.BASE_RNG_LOG, false), | ||
Option.of(OptionsConstants.BASE_TURN_TIMER_TARGETING, 0), | ||
Option.of(OptionsConstants.BASE_TURN_TIMER_MOVEMENT, 0), | ||
Option.of(OptionsConstants.BASE_TURN_TIMER_FIRING, 0), | ||
Option.of(OptionsConstants.BASE_TURN_TIMER_PHYSICAL, 0), | ||
Option.of(OptionsConstants.BASE_TURN_TIMER_ALLOW_EXTENSION, true), | ||
Option.of(OptionsConstants.BASE_SUPPRESS_UNIT_TOOLTIP_IN_REPORT_LOG, true), | ||
Option.of(OptionsConstants.BASE_GM_CONTROLS_DONE_REPORT_PHASE, false), | ||
Option.of(OptionsConstants.BASE_HIDE_UNOFFICIAL, false), | ||
Option.of(OptionsConstants.BASE_HIDE_LEGACY, false) | ||
}; | ||
|
||
private static final Option.OptionValue[] victoryOptions = { | ||
Option.of(OptionsConstants.VICTORY_CHECK_VICTORY, true) | ||
}; | ||
|
||
|
||
private void addOptions(IBasicOptionGroup group, Option.OptionValue[] options) { | ||
for (var entry : options) { | ||
addOption(group, entry.getName(), entry.getType(), entry.getValue()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big improvement in performance for loading options
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class StaticGameOptions implements IGameOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve performance for auto-resolve scenario simulations by not having to load the same set of options hundreds of times.
Alot of the changes for ACS-Like Autoresolve depend heavily in Megamek having a "sane" game interface which allow us detach entities from the gameboard.
However, many of the tools require the current TW Game as a basis, be it to declare a winner, be it to do checks like unit damage, limb blownoff, pilot survival, etc.
This Pull Request has multiple changes that has effect on absolutelly nothing. It just extract interfaces so we can implement and use stubs for the game object, publish end game events, etc. It also has many "weird" changes that do cause big effects, mostly improving initialization times, reducing number of function calls and reducing memory usage. Those changes are not earthshatering, they are more like "the full process takes 300ms, of those, 270ms are spent parsing a file, of that time, 70ms are spent loading the options for the hundreds of equipments, this change reduced from 70ms to 7ms the options loading, reducing the final time to 207ms
It also includes a change to log4j2 so that a developer may simply set an env var and have the logs show up in the console without the need for anything else.