diff --git a/megamek/src/megamek/common/EntityListFile.java b/megamek/src/megamek/common/EntityListFile.java index 3d6486fc75f..58250eee74a 100644 --- a/megamek/src/megamek/common/EntityListFile.java +++ b/megamek/src/megamek/common/EntityListFile.java @@ -748,10 +748,11 @@ public static void writeEntityList(Writer output, ArrayList list) throws output.write(String.valueOf(entity.getQuirkList("::"))); } if ((entity.getGame() != null) && (entity.getC3Master() != null)) { - output.write("\" " + MULParser.ATTR_C3MASTERIS + "=\""); - output.write(entity.getGame() - .getEntity(entity.getC3Master().getId()) - .getC3UUIDAsString()); + Entity entityC3MAster = entity.getGame().getEntity(entity.getC3Master().getId()); + if (entityC3MAster.getC3UUIDAsString() != null) { + output.write("\" " + MULParser.ATTR_C3MASTERIS + "=\""); + output.write(entityC3MAster.getC3UUIDAsString()); + } } if (entity.hasC3() || entity.hasC3i() || entity.hasNavalC3()) { if (entity.getC3UUIDAsString() != null) { @@ -998,7 +999,8 @@ public static void writeEntityList(Writer output, ArrayList list) throws while (c3iList.hasNext()) { final Entity C3iEntity = c3iList.next(); - if (C3iEntity.onSameC3NetworkAs(entity, true)) { + if ((C3iEntity.getC3UUIDAsString() != null) && + C3iEntity.onSameC3NetworkAs(entity, true)) { output.write(indentStr(indentLvl + 1) + "<" + MULParser.ELE_C3ILINK + " " + MULParser.ATTR_LINK + "=\""); output.write(C3iEntity.getC3UUIDAsString()); output.write("\"/>\n"); @@ -1014,7 +1016,8 @@ public static void writeEntityList(Writer output, ArrayList list) throws while (NC3List.hasNext()) { final Entity NC3Entity = NC3List.next(); - if (NC3Entity.onSameC3NetworkAs(entity, true)) { + if ((NC3Entity.getC3UUIDAsString() != null) && + NC3Entity.onSameC3NetworkAs(entity, true)) { output.write(indentStr(indentLvl + 1) + "<" + MULParser.ELE_NC3LINK + " " + MULParser.ATTR_LINK + "=\""); output.write(NC3Entity.getC3UUIDAsString()); output.write("\"/>\n");