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

add null checks for getC3UUIDAsString() #5426

Merged
Merged
Changes from all commits
Commits
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
15 changes: 9 additions & 6 deletions megamek/src/megamek/common/EntityListFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,11 @@ public static void writeEntityList(Writer output, ArrayList<Entity> 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) {
Expand Down Expand Up @@ -998,7 +999,8 @@ public static void writeEntityList(Writer output, ArrayList<Entity> 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");
Expand All @@ -1014,7 +1016,8 @@ public static void writeEntityList(Writer output, ArrayList<Entity> 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");
Expand Down
Loading