Skip to content

Commit

Permalink
allow gm to see and edit all units on any team hidden or not in lobby
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Nov 25, 2023
1 parent 262b730 commit b3150d6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
8 changes: 5 additions & 3 deletions megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,8 @@ private void refreshMekTable() {
boolean localUnit = entity.getOwner().equals(localPlayer());
boolean teamUnit = !entity.getOwner().isEnemyOf(localPlayer());
boolean realBlindDrop = opts.booleanOption(OptionsConstants.BASE_REAL_BLIND_DROP);
if (localUnit || teamUnit || !realBlindDrop) {
boolean localGM = localPlayer().isGameMaster();
if (localUnit || teamUnit || !realBlindDrop || localGM) {
mekModel.addUnit(entity);
}
}
Expand Down Expand Up @@ -1504,8 +1505,9 @@ void disembarkAll(Collection<Entity> entities) {
* own units (and bots) though.
*/
boolean isEditable(Entity entity) {
return clientgui.getLocalBots().containsKey(entity.getOwner().getName())
|| (entity.getOwnerId() == localPlayer().getId());
boolean localGM = clientgui.getClient().getLocalPlayer().isGameMaster();
return !localGM && (clientgui.getLocalBots().containsKey(entity.getOwner().getName())
|| (entity.getOwnerId() == localPlayer().getId()));
}

/**
Expand Down
7 changes: 5 additions & 2 deletions megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,9 @@ private Client correctSender(Force force) {
* player is allowed to change everything.
*/
boolean isEditable(Entity entity) {
return client().localBots.containsKey(entity.getOwner().getName())
boolean localGM = client().getLocalPlayer().isGameMaster();
return localGM
|| client().localBots.containsKey(entity.getOwner().getName())
|| (entity.getOwnerId() == localPlayer().getId())
|| (entity.partOfForce() && isSelfOrLocalBot(game().getForces().getOwner(entity.getForceId())))
|| (entity.partOfForce() && isEditable(game().getForces().getForce(entity)));
Expand Down Expand Up @@ -1222,7 +1224,8 @@ boolean isEditable(Collection<Entity> entities) {
* of the entities are not on his team.
*/
boolean canSeeAll(Collection<Entity> entities) {
if (!isBlindDrop(game()) && !isRealBlindDrop(game())) {
boolean localGM = client().getLocalPlayer().isGameMaster();
if (localGM || (!isBlindDrop(game()) && !isRealBlindDrop(game()))) {
return true;
}
return entities.stream().noneMatch(this::isLocalEnemy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ static String formatUnitFull(Entity entity, ChatLounge lobby, boolean forceView)
GameOptions options = game.getOptions();
Player localPlayer = client.getLocalPlayer();
Player owner = entity.getOwner();
boolean hideEntity = owner.isEnemyOf(localPlayer)
boolean localGM = localPlayer.isGameMaster();
boolean hideEntity = !localGM && owner.isEnemyOf(localPlayer)
&& options.booleanOption(OptionsConstants.BASE_BLIND_DROP);
if (hideEntity) {
result.append(DOT_SPACER);
Expand Down Expand Up @@ -493,7 +494,8 @@ static String formatUnitCompact(Entity entity, ChatLounge lobby, boolean forceVi
GameOptions options = game.getOptions();
Player localPlayer = client.getLocalPlayer();
Player owner = entity.getOwner();
boolean hideEntity = owner.isEnemyOf(localPlayer)
boolean localGM = localPlayer.isGameMaster();
boolean hideEntity = !localGM && owner.isEnemyOf(localPlayer)
&& options.booleanOption(OptionsConstants.BASE_BLIND_DROP);
if (hideEntity) {
String value = "<HTML><NOBR>&nbsp;&nbsp;";
Expand Down
10 changes: 7 additions & 3 deletions megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public Object getValueAt(int row, int col) {
if (col == COLS.BV.ordinal()) {
boolean isEnemy = clientGui.getClient().getLocalPlayer().isEnemyOf(ownerOf(entity));
boolean isBlindDrop = clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP);
boolean hideEntity = isEnemy && isBlindDrop;
boolean localGM = clientGui.getClient().getLocalPlayer().isGameMaster();
boolean hideEntity = !localGM && isEnemy && isBlindDrop;
float size = chatLounge.isCompact() ? 0 : 0.2f;
return hideEntity ? "" : guiScaledFontHTML(size) + NumberFormat.getIntegerInstance().format(bv.get(row));

Expand Down Expand Up @@ -176,8 +177,10 @@ private void addCellData(InGameObject entity) {
// Note that units of a player's bots are obscured because they could be added from
// a MekHQ AtB campaign. Thus, the player can still configure them and so can identify
// the obscured units but has to actively decide to do it.
boolean hideEntity = clientGui.getClient().getLocalPlayer().isEnemyOf(owner)
boolean localGM = clientGui.getClient().getLocalPlayer().isGameMaster();
boolean hideEntity = !localGM && clientGui.getClient().getLocalPlayer().isEnemyOf(owner)
&& clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP);

if (hideEntity) {
unitTooltips.add(null);
pilotTooltips.add(null);
Expand Down Expand Up @@ -295,7 +298,8 @@ public Component getTableCellRendererComponent(final JTable table,
}

Player owner = ownerOf(entity);
boolean showAsUnknown = clientGui.getClient().getLocalPlayer().isEnemyOf(owner)
boolean localGM = clientGui.getClient().getLocalPlayer().isGameMaster();
boolean showAsUnknown = !localGM && clientGui.getClient().getLocalPlayer().isEnemyOf(owner)
&& clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.BASE_BLIND_DROP);
int size = UIUtil.scaleForGUI(MEKTABLE_IMGHEIGHT);

Expand Down

0 comments on commit b3150d6

Please sign in to comment.