diff --git a/megamek/i18n/megamek/common/options/messages.properties b/megamek/i18n/megamek/common/options/messages.properties index 25156978141..a782497f76b 100644 --- a/megamek/i18n/megamek/common/options/messages.properties +++ b/megamek/i18n/megamek/common/options/messages.properties @@ -63,6 +63,8 @@ GameOptionsInfo.option.full_rotor_hits.displayableName=(Unofficial) No reduced d GameOptionsInfo.option.full_rotor_hits.description=If checked, VTOLs will take full damage from a rotor hit instead of Total Warfare-style reduced damage. \nUnchecked by default. GameOptionsInfo.option.suppress_unit_tooltip_in_report_log.displayableName=Hide Unit Tooltip in report log GameOptionsInfo.option.suppress_unit_tooltip_in_report_log.description=If checked, Unit Tooltip will not show in the end phase on the report log +GameOptionsInfo.option.gm_controls_done_report_phase.displayableName=GM controls done button in the report phases +GameOptionsInfo.option.gm_controls_done_report_phase.description=If checked, other player are automatically set to done in report phases. GM has control even if they have no units. GameOptionsInfo.option.hide_unofficial.displayableName=Don't show unofficial game options GameOptionsInfo.option.hide_unofficial.description=If checked, unofficial game options will be deactivated and hidden GameOptionsInfo.option.hide_legacy.displayableName=Don't show legacy game options diff --git a/megamek/src/megamek/client/ui/swing/ReportDisplay.java b/megamek/src/megamek/client/ui/swing/ReportDisplay.java index c68a026205a..d2dda549a69 100644 --- a/megamek/src/megamek/client/ui/swing/ReportDisplay.java +++ b/megamek/src/megamek/client/ui/swing/ReportDisplay.java @@ -211,7 +211,7 @@ public void actionPerformed(ActionEvent ev) { } private void resetButtons() { - butDone.setEnabled(true); + butDone.setEnabled(!clientgui.getClient().getLocalPlayer().isDone()); setReportEnabled(true); setPlayerListEnabled(true); diff --git a/megamek/src/megamek/common/options/GameOptions.java b/megamek/src/megamek/common/options/GameOptions.java index e385635afe4..de4a71012fb 100755 --- a/megamek/src/megamek/common/options/GameOptions.java +++ b/megamek/src/megamek/common/options/GameOptions.java @@ -75,6 +75,7 @@ public synchronized void initialize() { addOption(base, OptionsConstants.BASE_AUTO_AMS, true); addOption(base, OptionsConstants.BASE_TURN_TIMER, 0); addOption(base, OptionsConstants.BASE_SUPPRESS_UNIT_TOOLTIP_IN_REPORT_LOG, false); + addOption(base, OptionsConstants.BASE_GM_CONTROLS_DONE_REPORT_PHASE, false); addOption(base, OptionsConstants.BASE_HIDE_UNOFFICIAL, false); addOption(base, OptionsConstants.BASE_HIDE_LEGACY, false); diff --git a/megamek/src/megamek/common/options/OptionsConstants.java b/megamek/src/megamek/common/options/OptionsConstants.java index 034f11d1e0e..387e6196fe7 100644 --- a/megamek/src/megamek/common/options/OptionsConstants.java +++ b/megamek/src/megamek/common/options/OptionsConstants.java @@ -292,6 +292,7 @@ public class OptionsConstants { public static final String BASE_RANDOM_BASEMENTS = "random_basements"; public static final String BASE_AUTO_AMS = "auto_ams"; public static final String BASE_SUPPRESS_UNIT_TOOLTIP_IN_REPORT_LOG = "suppress_unit_tooltip_in_report_log"; + public static final String BASE_GM_CONTROLS_DONE_REPORT_PHASE = "gm_controls_done_report_phase"; public static final String BASE_HIDE_UNOFFICIAL = "hide_unofficial"; public static final String BASE_HIDE_LEGACY = "hide_legacy"; diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index 5b28d2b3322..dc9266fad8b 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -295,7 +295,6 @@ public void resetGame() { // reset all players resetPlayersDone(); - transmitAllPlayerDones(); // Write end of game to stdout so controlling scripts can rotate logs. LogManager.getLogger().info(LocalDateTime.now() + " END OF GAME"); @@ -660,7 +659,8 @@ public void sendCurrentInfo(int connId) { } else { send(connId, createFullEntitiesPacket()); } - player.setDone(getGame().getEntitiesOwnedBy(player) <= 0); + + setPlayerDone(player, getGame().getEntitiesOwnedBy(player) <= 0); send(connId, new Packet(PacketCommand.PHASE_CHANGE, getGame().getPhase())); } @@ -811,7 +811,6 @@ public void handlePacket(int connId, Packet packet) { case ENTITY_LOAD: receiveEntityLoad(packet, connId); resetPlayersDone(); - transmitAllPlayerDones(); break; case ENTITY_MODECHANGE: receiveEntityModeChange(packet, connId); @@ -863,7 +862,6 @@ public void handlePacket(int connId, Packet packet) { case SENDING_GAME_SETTINGS: if (receiveGameOptions(packet, connId)) { resetPlayersDone(); - transmitAllPlayerDones(); send(createGameSettingsPacket()); receiveGameOptionsAux(packet, connId); } @@ -880,7 +878,6 @@ public void handlePacket(int connId, Packet packet) { mapSettings.setNullBoards(DEFAULT_BOARD); game.setMapSettings(mapSettings); resetPlayersDone(); - transmitAllPlayerDones(); send(createMapSettingsPacket()); } break; @@ -896,7 +893,6 @@ public void handlePacket(int connId, Packet packet) { mapSettings.setNullBoards(DEFAULT_BOARD); game.setMapSettings(mapSettings); resetPlayersDone(); - transmitAllPlayerDones(); send(createMapSettingsPacket()); } break; @@ -906,7 +902,6 @@ public void handlePacket(int connId, Packet packet) { sendServerChat(player + " changed planetary conditions"); game.setPlanetaryConditions(conditions); resetPlayersDone(); - transmitAllPlayerDones(); send(createPlanetaryConditionsPacket()); } break; @@ -919,12 +914,10 @@ public void handlePacket(int connId, Packet packet) { case CUSTOM_INITIATIVE: receiveCustomInit(packet, connId); resetPlayersDone(); - transmitAllPlayerDones(); break; case SQUADRON_ADD: receiveSquadronAdd(packet, connId); resetPlayersDone(); - transmitAllPlayerDones(); break; case RESET_ROUND_DEPLOYMENT: game.setupRoundDeployment(); @@ -1129,6 +1122,20 @@ public void decrementASEWTurns() { } } + private void setPlayerDone(Player player, boolean normalDone) { + if (getGame().getPhase().isReport() + && getGame().getOptions().booleanOption(OptionsConstants.BASE_GM_CONTROLS_DONE_REPORT_PHASE) + && getGame().getPlayersList().stream().filter(p -> p.isGameMaster()).count() > 0) { + if (player.isGameMaster()) { + player.setDone(false); + } else { + player.setDone(true); + } + } else { + player.setDone(normalDone); + } + } + /** * Called at the beginning of certain phases to make every player not ready. */ @@ -1137,10 +1144,10 @@ private void resetPlayersDone() { return; } - for (Enumeration i = game.getPlayers(); i.hasMoreElements(); ) { - final Player player = i.nextElement(); - player.setDone(false); + for (Player player : game.getPlayersList()) { + setPlayerDone(player, false); } + transmitAllPlayerDones(); } @@ -1149,10 +1156,10 @@ private void resetPlayersDone() { * ready. */ private void resetActivePlayersDone() { - for (Enumeration i = game.getPlayers(); i.hasMoreElements(); ) { - final Player player = i.nextElement(); - player.setDone(game.getEntitiesOwnedBy(player) <= 0); + for (Player player : game.getPlayersList()) { + setPlayerDone(player, getGame().getEntitiesOwnedBy(player) <= 0); } + transmitAllPlayerDones(); } @@ -1342,8 +1349,7 @@ public void forceVictory(Player victor) { */ private void checkReady() { // check if all active players are done - for (Enumeration i = game.getPlayers(); i.hasMoreElements(); ) { - final Player player = i.nextElement(); + for (Player player : game.getPlayersList()) { if (!player.isGhost() && !player.isObserver() && !player.isDone()) { return; } @@ -29935,6 +29941,7 @@ private void receiveInitiativeRerollRequest(Packet pkt, int connIndex) { if (null != player) { player.setDone(true); } + checkReady(); } @@ -30249,8 +30256,7 @@ private Packet createEndOfGamePacket() { * Sends out the player ready stats for all players to all connections */ private void transmitAllPlayerDones() { - for (Enumeration i = getGame().getPlayers(); i.hasMoreElements(); ) { - final Player player = i.nextElement(); + for (Player player : getGame().getPlayersList()) { send(createPlayerDonePacket(player.getId())); } }