Fixing a few bugs, and adding in some debug output for unsolved ones.
This commit is contained in:
@ -98,7 +98,8 @@ public class Board extends Entity<Board> implements BoardInterface
|
||||
public Faction getFactionAt(PS ps)
|
||||
{
|
||||
if (ps == null) return null;
|
||||
return FactionColls.get().get(this).get(this.getTerritoryAccessAt(ps).getHostFactionId());
|
||||
String factionId = this.getTerritoryAccessAt(ps).getHostFactionId();
|
||||
return FactionColls.get().get(this).get(factionId);
|
||||
}
|
||||
|
||||
// SET
|
||||
@ -158,16 +159,18 @@ public class Board extends Entity<Board> implements BoardInterface
|
||||
@Override
|
||||
public void clean()
|
||||
{
|
||||
FactionColl factionColl = FactionColls.get().get(this);
|
||||
|
||||
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
|
||||
{
|
||||
TerritoryAccess territoryAccess = entry.getValue();
|
||||
|
||||
if (FactionColls.get().get(this).containsId(territoryAccess.getHostFactionId())) continue;
|
||||
String factionId = territoryAccess.getHostFactionId();
|
||||
if (factionColl.containsId(factionId)) continue;
|
||||
|
||||
PS ps = entry.getKey();
|
||||
this.removeAt(ps);
|
||||
|
||||
Factions.get().log("Board cleaner removed "+territoryAccess.getHostFactionId()+" from "+entry.getKey());
|
||||
Factions.get().log("Board cleaner removed "+factionId+" from "+ps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,14 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Entry<FPerm, Set<Rel>> entry = iter.next();
|
||||
if (entry.getKey().getDefault(this).equals(entry.getValue()))
|
||||
FPerm key = entry.getKey();
|
||||
Set<Rel> keyDefault = key.getDefault(this);
|
||||
Set<Rel> value = entry.getValue();
|
||||
|
||||
if (keyDefault == null) System.out.println("keyDefault was null");
|
||||
if (value == null) System.out.println("value was null");
|
||||
|
||||
if (keyDefault.equals(value))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
|
@ -40,29 +40,6 @@ public class FactionColl extends Coll<Faction>
|
||||
this.createSpecialFactions();
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
protected synchronized String attach(Faction faction, Object oid, boolean noteChange)
|
||||
{
|
||||
String ret = super.attach(faction, oid, noteChange);
|
||||
|
||||
// Factions start with 0 money.
|
||||
// TODO: Can this be done here?
|
||||
// TODO: Or will it be a to heavy operation to do this often?
|
||||
|
||||
//System.out.println("faction "+faction);
|
||||
//System.out.println("faction.getId() "+faction.getId());
|
||||
// TODO: Why does this happen for Wilderness?
|
||||
if (faction.getId() == null) return ret;
|
||||
|
||||
if (!Money.exists(faction))
|
||||
{
|
||||
Money.set(faction, 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
// TODO: I hope this one is not crucial anymore.
|
||||
// If it turns out to be I will just have to recreate the feature in the proper place.
|
||||
/*
|
||||
@ -80,6 +57,23 @@ public class FactionColl extends Coll<Faction>
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Faction get(Object oid)
|
||||
{
|
||||
Faction ret = super.get(oid);
|
||||
|
||||
if (ret == null)
|
||||
{
|
||||
String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid));
|
||||
Factions.get().log(message);
|
||||
|
||||
BoardColls.get().clean();
|
||||
UPlayerColls.get().clean();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Faction detachId(Object oid)
|
||||
{
|
||||
|
@ -80,4 +80,16 @@ public class UPlayerColls extends XColls<UPlayerColl, UPlayer>
|
||||
oldFile.renameTo(newFile);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void clean()
|
||||
{
|
||||
for (UPlayerColl coll : this.getColls())
|
||||
{
|
||||
coll.clean();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user