Skip to content

Commit

Permalink
Merge pull request #5545 from SJuliez/missing-round-increase
Browse files Browse the repository at this point in the history
Fix seemingly incorrect round counter handling
  • Loading branch information
SJuliez authored Jun 6, 2024
2 parents 5c2689d + 383ed35 commit cdba4d8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 4 additions & 1 deletion megamek/src/megamek/common/AbstractGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public abstract class AbstractGame implements IGame {
*/
private final Map<Integer, List<Deployable>> deploymentTable = new HashMap<>();

protected int currentRound = 0;
/**
* The round counter. It gets incremented before initiative; round 0 is initial deployment only.
*/
protected int currentRound = -1;

@Override
public Forces getForces() {
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ public void removeEntities(List<Integer> ids, int condition) {
public synchronized void reset() {
uuid = UUID.randomUUID();

currentRound = 0;
currentRound = -1;

inGameObjects.clear();
entityPosLookup.clear();
Expand Down
6 changes: 2 additions & 4 deletions megamek/src/megamek/server/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1865,10 +1865,8 @@ private void prepareForPhase(GamePhase phase) {
// commander initiative bonus. Now that initiative is rolled, clear the flag.
game.getEntities().forEachRemaining(e -> e.getCrew().resetActedFlag());

if (!game.shouldDeployThisRound()) {
incrementAndSendGameRound();
asService.performRollingAutosave(this);
}
incrementAndSendGameRound();
asService.performRollingAutosave(this);

// setIneligible(phase);
determineTurnOrder(phase);
Expand Down
2 changes: 0 additions & 2 deletions megamek/src/megamek/server/SBFGameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,8 @@ private void prepareForCurrentPhase() {
// commander initiative bonus. Now that initiative is rolled, clear the flag.
// game.getEntities().forEachRemaining(e -> e.getCrew().resetActedFlag());

if (!game.shouldDeployThisRound()) {
// incrementAndSendGameRound();
// asService.performRollingAutosave(this);
}

// setIneligible(phase);
// determineTurnOrder(phase);
Expand Down

0 comments on commit cdba4d8

Please sign in to comment.