Skip to content
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

0.49.7 Testing Branch #3401

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
7d809a4
Merge remote-tracking branch 'origin/dev_Windchild_3363' into testing…
Windchild292 Jan 24, 2022
7e29134
Merge remote-tracking branch 'origin/dev_Windchild_3363' into testing…
Windchild292 Jan 24, 2022
b71fb3f
Merge remote-tracking branch 'origin/dev_Windchild_3363' into testing…
Windchild292 Jan 24, 2022
1289b6d
Merge remote-tracking branch 'upstream/master' into testing0497
Windchild292 Jan 27, 2022
8e3e495
Merge remote-tracking branch 'origin/dev_Windchild_MHQ3072' into test…
Windchild292 Jan 27, 2022
f1fae1a
Merge remote-tracking branch 'upstream/dev_Windchild_3397' into testi…
Windchild292 Jan 27, 2022
dc19290
Merge remote-tracking branch 'upstream/master' into testing0497
Windchild292 Jan 30, 2022
7f9fbaa
Merge remote-tracking branch 'origin/dev_Windchild_3319' into testing…
Windchild292 Jan 30, 2022
ddadfc8
Merge remote-tracking branch 'upstream/master' into testing0497
Windchild292 Feb 1, 2022
f091e6f
Fixing return packet NPE and improving the invalid turn logging messa…
Windchild292 Feb 6, 2022
dbc224d
Fixing a few missing nullable notes I found while creating a testing …
Windchild292 Feb 6, 2022
9a3b1bc
Missed an add
Windchild292 Feb 6, 2022
5e2bdc7
Merge remote-tracking branch 'origin/master' into testing0497
Windchild292 Feb 6, 2022
d2405d2
Merge remote-tracking branch 'origin/dev_Windchild_FixingGameTurnNull…
Windchild292 Feb 6, 2022
ab12382
Merge remote-tracking branch 'origin/dev_Windchild_ReceiveAttackLoggi…
Windchild292 Feb 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions megamek/src/megamek/common/GameTurn.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void setPlayerNum(int playerId) {
* @return <code>true</code> if the specified entity can take this turn.
* <code>false</code> if the entity is not valid for this turn.
*/
public boolean isValidEntity(Entity entity, Game game) {
public boolean isValidEntity(final @Nullable Entity entity, final Game game) {
return isValidEntity(entity, game, true);
}

Expand Down Expand Up @@ -94,17 +94,17 @@ public boolean isValidEntity(final @Nullable Entity entity, final Game game,
&& (((entity instanceof Infantry) && game.getOptions().booleanOption(OptionsConstants.INIT_INF_MOVE_LATER))
|| ((entity instanceof Protomech) && game.getOptions().booleanOption(OptionsConstants.INIT_PROTOS_MOVE_LATER)))
&& game.checkForValidNonInfantryAndOrProtomechs(playerId));
}
}

/**
* Returns true if the player and entity are both valid.
* @return true if the player and entity are both valid.
*/
public boolean isValid(int playerId, Entity entity, Game game) {
public boolean isValid(final int playerId, final @Nullable Entity entity, final Game game) {
return (playerId == this.playerId) && isValidEntity(entity, game);
}

/**
* Returns true if the player is valid.
* @return true if the player is valid.
*/
public boolean isValid(int playerId, Game game) {
return playerId == this.playerId;
Expand Down
13 changes: 5 additions & 8 deletions megamek/src/megamek/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -13244,15 +13244,12 @@ private void receiveAttack(Packet packet, int connId) {
turn = game.getTurnForPlayer(connId);
}
if ((turn == null) || !turn.isValid(connId, entity, game)) {
String msg = "error: server got invalid attack packet from connection " + connId;
if (entity != null) {
msg += ", Entity: " + entity.getShortName();
} else {
msg += ", Entity was null!";
}
LogManager.getLogger().error(msg);
LogManager.getLogger().error(String.format(
"Server got invalid attack packet from Connection %s, Entity %s, %s Turn",
connId, ((entity == null) ? "null" : entity.getShortName()),
((turn == null) ? "null" : "invalid")));
send(connId, createTurnVectorPacket());
send(connId, createTurnIndexPacket(turn.getPlayerNum()));
send(connId, createTurnIndexPacket((turn == null) ? Player.PLAYER_NONE : turn.getPlayerNum()));
return;
}

Expand Down