Fix NPE caused by lazy cleanup
This commit is contained in:
		@@ -80,9 +80,11 @@ public class TerritoryAccess
 | 
				
			|||||||
	// FIELDS: DIRECT
 | 
						// FIELDS: DIRECT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						// This method intentionally returns null if the Faction no longer exists.
 | 
				
			||||||
 | 
						// In Board we don't even return this TerritoryAccess if that is the case.
 | 
				
			||||||
	public Faction getHostFaction()
 | 
						public Faction getHostFaction()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return FactionColl.get().get(this.getHostFactionId());
 | 
							return Faction.get(this.getHostFactionId());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Set<MPlayer> getGrantedMPlayers()
 | 
						public Set<MPlayer> getGrantedMPlayers()
 | 
				
			||||||
@@ -108,7 +110,9 @@ public class TerritoryAccess
 | 
				
			|||||||
		// Fill
 | 
							// Fill
 | 
				
			||||||
		for (String factionId : this.getFactionIds())
 | 
							for (String factionId : this.getFactionIds())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ret.add(FactionColl.get().get(factionId));
 | 
								Faction faction = Faction.get(factionId);
 | 
				
			||||||
 | 
								if (faction == null) continue;
 | 
				
			||||||
 | 
								ret.add(faction);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Return
 | 
							// Return
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,7 +92,7 @@ public class Board extends Entity<Board> implements BoardInterface
 | 
				
			|||||||
		if (ps == null) return null;
 | 
							if (ps == null) return null;
 | 
				
			||||||
		ps = ps.getChunkCoords(true);
 | 
							ps = ps.getChunkCoords(true);
 | 
				
			||||||
		TerritoryAccess ret = this.map.get(ps);
 | 
							TerritoryAccess ret = this.map.get(ps);
 | 
				
			||||||
		if (ret == null) ret = TerritoryAccess.valueOf(Factions.ID_NONE);
 | 
							if (ret == null || ret.getHostFaction() == null) ret = TerritoryAccess.valueOf(Factions.ID_NONE);
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user