Skip to content

Commit

Permalink
Merge pull request #5806 from SJuliez/lobby-coppy-paste-revisit
Browse files Browse the repository at this point in the history
Fix lobby copy paste for empty model units
  • Loading branch information
SJuliez authored Jul 28, 2024
2 parents 63226af + 25f0675 commit fde43fd
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java
Original file line number Diff line number Diff line change
Expand Up @@ -2569,23 +2569,17 @@ public void importClipboard() {
StringTokenizer lines = new StringTokenizer(result, "\n");
while (lines.hasMoreTokens()) {
String line = lines.nextToken();
StringTokenizer tabs = new StringTokenizer(line, "\t");
String unit = "";
if (tabs.hasMoreTokens()) {
unit = tabs.nextToken();
}
if (tabs.hasMoreTokens()) {
unit += " " + tabs.nextToken();
}
MechSummary ms = MechSummaryCache.getInstance().getMech(unit);
if (ms == null) {
continue;
}
Entity newEntity = new MechFileParser(ms.getSourceFile(),
ms.getEntryName()).getEntity();
if (newEntity != null) {
newEntity.setOwner(localPlayer());
newEntities.add(newEntity);
String[] tokens = line.split("\t");
if (tokens.length >= 2) {
String unitName = (tokens[0] + " " + tokens[1]).trim();
MechSummary ms = MechSummaryCache.getInstance().getMech(unitName);
if (ms != null) {
Entity newEntity = ms.loadEntity();
if (newEntity != null) {
newEntity.setOwner(localPlayer());
newEntities.add(newEntity);
}
}
}
}
} catch (Exception ex) {
Expand Down

0 comments on commit fde43fd

Please sign in to comment.