diff --git a/ngengine_public.jar b/ngengine_public.jar index beacd257..901385d6 100644 Binary files a/ngengine_public.jar and b/ngengine_public.jar differ diff --git a/src/resources/buffs/Buff.java b/src/resources/buffs/Buff.java index 24d4937f..72728526 100644 --- a/src/resources/buffs/Buff.java +++ b/src/resources/buffs/Buff.java @@ -45,7 +45,7 @@ public class Buff implements IDelta, Serializable { private static final long serialVersionUID = 1L; @NotPersistent - private transient SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); + private transient static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); private String group1, group2; private int priority; private float duration; diff --git a/src/resources/objects/Delta.java b/src/resources/objects/Delta.java index 6e57706e..19033f03 100644 --- a/src/resources/objects/Delta.java +++ b/src/resources/objects/Delta.java @@ -38,7 +38,7 @@ public abstract class Delta implements IDelta, Serializable { private static final long serialVersionUID = 1L; @NotPersistent - protected transient final Object objectMutex = new Object(); + protected transient Object objectMutex = new Object(); @NotPersistent private transient static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); @@ -46,6 +46,10 @@ public abstract class Delta implements IDelta, Serializable { } + public void init() { + objectMutex = new Object(); + } + protected String getAsciiString(ByteBuffer buffer) { return StringUtilities.getAsciiString(buffer); } diff --git a/src/resources/objects/SWGList.java b/src/resources/objects/SWGList.java index 13e1854d..9316760e 100644 --- a/src/resources/objects/SWGList.java +++ b/src/resources/objects/SWGList.java @@ -59,7 +59,7 @@ public class SWGList implements List, Serializable { private byte viewType; private short updateType; @NotPersistent - protected transient final Object objectMutex = new Object(); + protected transient Object objectMutex = new Object(); public SWGList() { } @@ -69,6 +69,11 @@ public class SWGList implements List, Serializable { this.updateType = (short) updateType; } + public void init() { + objectMutex = new Object(); + updateCounter = 1; + } + @Override public boolean add(E e) { synchronized(objectMutex) { @@ -420,7 +425,7 @@ public class SWGList implements List, Serializable { messageBuilder.sendListDelta(viewType, updateType, buffer); } - + @Override public boolean removeIf(Predicate filter) { return false; @@ -433,20 +438,17 @@ public class SWGList implements List, Serializable { @Override public Stream stream() { - // TODO Auto-generated method stub - return null; + return list.stream(); } @Override public Stream parallelStream() { - // TODO Auto-generated method stub - return null; + return list.parallelStream(); } @Override public void forEach(Consumer action) { - // TODO Auto-generated method stub - + list.forEach(action); } @Override diff --git a/src/resources/objects/SWGMap.java b/src/resources/objects/SWGMap.java index ffd380af..8d873024 100644 --- a/src/resources/objects/SWGMap.java +++ b/src/resources/objects/SWGMap.java @@ -60,7 +60,7 @@ public class SWGMap implements Map, Serializable { private byte viewType; private short updateType; @NotPersistent - protected transient final Object objectMutex = new Object(); + protected transient Object objectMutex = new Object(); public SWGMap() { } @@ -80,6 +80,10 @@ public class SWGMap implements Map, Serializable { } } + public void init() { + objectMutex = new Object(); + } + public void clear() { throw new UnsupportedOperationException(); } @@ -305,8 +309,7 @@ public class SWGMap implements Map, Serializable { @Override public void forEach(BiConsumer action) { - // TODO Auto-generated method stub - + map.forEach(action); } @Override diff --git a/src/resources/objects/SWGMultiMap.java b/src/resources/objects/SWGMultiMap.java index 22659c1b..a2126a3b 100644 --- a/src/resources/objects/SWGMultiMap.java +++ b/src/resources/objects/SWGMultiMap.java @@ -63,7 +63,7 @@ public class SWGMultiMap implements Multimap, Serializable { private byte viewType; private short updateType; @NotPersistent - protected transient final Object objectMutex = new Object(); + protected transient Object objectMutex = new Object(); public SWGMultiMap() { } @@ -83,6 +83,10 @@ public class SWGMultiMap implements Multimap, Serializable { } } + public void init() { + objectMutex = new Object(); + } + public Map> asMap() { synchronized(objectMutex) { return map.asMap(); diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index bd8afc56..431f3d61 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -260,6 +260,7 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria public void initAfterDBLoad() { super.init(); messageBuilder = new BuildingMessageBuilder(this); + defendersList = new Vector(); } public ObjectMessageBuilder getMessageBuilder() { diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index b1191fea..9784a56e 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -210,11 +210,19 @@ public class CreatureObject extends TangibleObject implements Serializable { @Override public void initAfterDBLoad() { super.init(); + defendersList = new Vector(); duelList = Collections.synchronizedList(new ArrayList()); cooldowns = new ConcurrentHashMap(); performanceAudience = new Vector(); messageBuilder = new CreatureMessageBuilder(this); - + dotList.init(); + buffList.init(); + equipmentList.init(); + appearanceEquipmentList.init(); + missionCriticalObjects.init(); + abilities.init(); + skillMods.init(); + skillMods.forEach((name, skillMod) -> skillMod.init()); } private void loadTemplateData() { @@ -1073,9 +1081,7 @@ public class CreatureObject extends TangibleObject implements Serializable { } public SWGList getEquipmentList() { - synchronized(objectMutex) { return equipmentList; - } } public SWGList getBuffList() { diff --git a/src/resources/objects/guild/GuildObject.java b/src/resources/objects/guild/GuildObject.java index fe01d97a..e614df21 100644 --- a/src/resources/objects/guild/GuildObject.java +++ b/src/resources/objects/guild/GuildObject.java @@ -92,6 +92,13 @@ public class GuildObject extends UniverseObject implements Serializable { public void initAfterDBLoad() { super.init(); messageBuilder = new GuildMessageBuilder(this); + guildList.init(); + currentServerGCWZonePercentMap.init(); + currentServerGCWTotalPercentMap.init(); + currentServerGCWZoneHistoryMap.init(); + currentServerGCWTotalHistoryMap.init(); + otherServerGCWZonePercentMap.init(); + otherServerGCWTotalPercentMap.init(); } diff --git a/src/resources/objects/harvester/HarvesterObject.java b/src/resources/objects/harvester/HarvesterObject.java index 87cc8ea1..42300a49 100644 --- a/src/resources/objects/harvester/HarvesterObject.java +++ b/src/resources/objects/harvester/HarvesterObject.java @@ -38,6 +38,7 @@ import resources.objects.installation.InstallationMessageBuilder; import resources.objects.installation.InstallationObject; import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; +import resources.objects.tangible.TangibleObject; /** * @author Charon @@ -138,6 +139,10 @@ public class HarvesterObject extends InstallationObject implements Serializable super.init(); messageBuilder = new HarvesterMessageBuilder(this); installationMessageBuilder = new InstallationMessageBuilder((InstallationObject)this); + outputHopperContent.forEach(ResourceContainerObject::initAfterDBLoad); + if(selectedHarvestResource != null) + selectedHarvestResource.initAfterDBLoad(); + defendersList = new Vector(); } diff --git a/src/resources/objects/installation/InstallationObject.java b/src/resources/objects/installation/InstallationObject.java index a31fc02e..c6269dc3 100644 --- a/src/resources/objects/installation/InstallationObject.java +++ b/src/resources/objects/installation/InstallationObject.java @@ -22,6 +22,7 @@ package resources.objects.installation; import java.io.Serializable; +import java.util.Vector; import com.sleepycat.persist.model.Entity; @@ -52,6 +53,7 @@ public class InstallationObject extends TangibleObject implements Serializable { public void initAfterDBLoad() { super.init(); messageBuilder = new InstallationMessageBuilder(this); + defendersList = new Vector(); } public ObjectMessageBuilder getMessageBuilder() { diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index a5e4d195..47a8f07b 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -80,6 +80,8 @@ public class MissionObject extends IntangibleObject implements Serializable { public void initAfterDBLoad() { super.init(); messageBuilder = new MissionMessageBuilder(this); + if(attachedWaypoint != null) + attachedWaypoint.initAfterDBLoad(); } public int getMissionLevel() { diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 5b2e9ad9..d727f58a 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -76,7 +76,7 @@ public class TangibleObject extends SWGObject implements Serializable { protected String faction = ""; // Says you're "Imperial Special Forces" if it's 0 for some reason protected int factionStatus = 0; @NotPersistent - private transient Vector defendersList = new Vector(); // unused in packets but useful for the server + protected transient Vector defendersList = new Vector(); // unused in packets but useful for the server @NotPersistent private transient TangibleMessageBuilder messageBuilder; diff --git a/src/resources/objects/tool/SurveyTool.java b/src/resources/objects/tool/SurveyTool.java index 0badcabd..e9337445 100644 --- a/src/resources/objects/tool/SurveyTool.java +++ b/src/resources/objects/tool/SurveyTool.java @@ -92,6 +92,7 @@ public class SurveyTool extends TangibleObject implements Serializable { this.exceptionalState = false; surveyEffectString = ""; sampleEffectString = ""; + defendersList = new Vector(); } public SurveyTool(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ diff --git a/src/resources/objects/weapon/WeaponObject.java b/src/resources/objects/weapon/WeaponObject.java index 65d15a72..46526b1b 100644 --- a/src/resources/objects/weapon/WeaponObject.java +++ b/src/resources/objects/weapon/WeaponObject.java @@ -22,6 +22,7 @@ package resources.objects.weapon; import java.io.Serializable; +import java.util.Vector; import resources.datatables.WeaponType; import resources.objects.tangible.TangibleObject; @@ -67,6 +68,7 @@ public class WeaponObject extends TangibleObject implements Serializable { public void initAfterDBLoad() { super.init(); messageBuilder = new WeaponMessageBuilder(this); + defendersList = new Vector(); } public int getIncapTimer() { diff --git a/src/services/bazaar/BazaarService.java b/src/services/bazaar/BazaarService.java index b6e542b1..c94feb02 100644 --- a/src/services/bazaar/BazaarService.java +++ b/src/services/bazaar/BazaarService.java @@ -94,6 +94,10 @@ public class BazaarService implements INetworkDispatch { while(cursor.hasNext()) { addAuctionItem((AuctionItem) cursor.next()); } + auctionItems.stream().map(AuctionItem::getItem).forEach(obj -> { + obj.initAfterDBLoad(); + obj.viewChildren(obj, true, true, obj2 -> obj2.initAfterDBLoad()); + }); cursor.close(); } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index c3ec991e..36be488b 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -806,26 +806,18 @@ public class ObjectService implements INetworkDispatch { objectList.put(creature.getObjectID(), creature); - creature.viewChildren(creature, true, true, new Traverser() { - - @Override - public void process(SWGObject object) { - objectList.put(object.getObjectID(), object); - } - + creature.viewChildren(creature, true, true, (object) -> { + objectList.put(object.getObjectID(), object); }); - creature.viewChildren(creature, true, true, new Traverser() { - - @Override - public void process(SWGObject object) { - if(object.getParentId() != 0 && object.getContainer() == null) - object.setParent(getObject(object.getParentId())); - object.getContainerInfo(object.getTemplate()); - if(getObject(object.getObjectID()) == null) - objectList.put(object.getObjectID(), object); - } - + creature.viewChildren(creature, true, true, (object) -> { + if(object.getMutex() == null) + object.init(); + if(object.getParentId() != 0 && object.getContainer() == null) + object.setParent(getObject(object.getParentId())); + object.getContainerInfo(object.getTemplate()); + if(getObject(object.getObjectID()) == null) + objectList.put(object.getObjectID(), object); }); if(creature.getParentId() != 0) {