mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-07-14 00:02:07 -04:00
Refactored odb system (read extended), added implementation of Dynamic World Spawns
ODB no longer uses DPL layer of Berkeley DB, persistent classes have to implement the Serializable interface, annotations are no longer used, use transient modifier for variables that should not be persistent. Entity reference errors will no longer occur, however it is better to use ids if the entity that is being referenced is stored in the db too! (or you will have two different objects). DB is cached for 5 minutes then it will write its log/cache to disk, transactions are no longer used.
This commit is contained in:
@@ -61,6 +61,7 @@ odb/resourcehistory/je.info.*
|
||||
odb/resourceroots/je.info.*
|
||||
odb/resources/je.info.*
|
||||
odb/auction/je.info.*
|
||||
odb/swgobjects/je.info.*
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
Binary file not shown.
+45
-30
@@ -48,6 +48,9 @@ import net.engio.mbassy.bus.config.BusConfiguration;
|
||||
import resources.common.RadialOptions;
|
||||
import resources.common.ThreadMonitor;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.guild.GuildObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceRoot;
|
||||
import services.AttributeService;
|
||||
import services.BuffService;
|
||||
import services.CharacterService;
|
||||
@@ -71,8 +74,11 @@ import services.SurveyService;
|
||||
import services.TerrainService;
|
||||
import services.WeatherService;
|
||||
import services.ai.AIService;
|
||||
import services.bazaar.AuctionItem;
|
||||
import services.bazaar.BazaarService;
|
||||
import services.chat.ChatRoom;
|
||||
import services.chat.ChatService;
|
||||
import services.chat.Mail;
|
||||
import services.collections.CollectionService;
|
||||
import services.combat.CombatService;
|
||||
import services.command.CombatCommand;
|
||||
@@ -83,6 +89,8 @@ import services.guild.GuildService;
|
||||
import services.LoginService;
|
||||
import services.map.MapService;
|
||||
import services.mission.MissionService;
|
||||
import services.object.DuplicateId;
|
||||
import services.object.ObjectId;
|
||||
import services.object.ObjectService;
|
||||
import services.object.UpdateService;
|
||||
import services.pet.MountService;
|
||||
@@ -110,6 +118,7 @@ import engine.resources.config.Config;
|
||||
import engine.resources.config.DefaultConfig;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.database.DatabaseConnection;
|
||||
import engine.resources.database.ODBCursor;
|
||||
import engine.resources.database.ObjectDatabase;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -199,7 +208,6 @@ public class NGECore {
|
||||
public InteractiveJythonAcceptor jythonAcceptor;
|
||||
private InteractiveJythonServer jythonServer;
|
||||
|
||||
private ObjectDatabase creatureODB;
|
||||
private ObjectDatabase mailODB;
|
||||
private ObjectDatabase guildODB;
|
||||
private ObjectDatabase objectIdODB;
|
||||
@@ -208,11 +216,11 @@ public class NGECore {
|
||||
|
||||
private BusConfiguration eventBusConfig = BusConfiguration.Default(1, new ThreadPoolExecutor(1, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>()));
|
||||
|
||||
private ObjectDatabase buildingODB;
|
||||
private ObjectDatabase auctionODB;
|
||||
private ObjectDatabase resourcesODB;
|
||||
private ObjectDatabase resourceRootsODB;
|
||||
private ObjectDatabase resourceHistoryODB;
|
||||
private ObjectDatabase swgObjectODB;
|
||||
|
||||
public static boolean PACKET_DEBUG = false;
|
||||
|
||||
@@ -263,17 +271,17 @@ public class NGECore {
|
||||
}
|
||||
|
||||
setGalaxyStatus(1);
|
||||
creatureODB = new ObjectDatabase("creature", true, false, true);
|
||||
buildingODB = new ObjectDatabase("building", true, false, true);
|
||||
mailODB = new ObjectDatabase("mails", true, false, true);
|
||||
guildODB = new ObjectDatabase("guild", true, false, true);
|
||||
objectIdODB = new ObjectDatabase("oids", true, false, false);
|
||||
duplicateIdODB = new ObjectDatabase("doids", true, false, true);
|
||||
chatRoomODB = new ObjectDatabase("chatRooms", true, false, true);
|
||||
resourcesODB = new ObjectDatabase("resources", true, false, true);
|
||||
resourceRootsODB = new ObjectDatabase("resourceroots", true, false, true);
|
||||
resourceHistoryODB = new ObjectDatabase("resourcehistory", true, false, true);
|
||||
auctionODB = new ObjectDatabase("auction", true, false, true);
|
||||
swgObjectODB = new ObjectDatabase("swgobjects", true, true, true, SWGObject.class);
|
||||
|
||||
mailODB = new ObjectDatabase("mails", true, true, true, Mail.class);
|
||||
guildODB = new ObjectDatabase("guild", true, true, true, GuildObject.class);
|
||||
objectIdODB = new ObjectDatabase("oids", true, true, false, ObjectId.class);
|
||||
duplicateIdODB = new ObjectDatabase("doids", true, true, true, DuplicateId.class);
|
||||
chatRoomODB = new ObjectDatabase("chatRooms", true, true, true, ChatRoom.class);
|
||||
resourcesODB = new ObjectDatabase("resources", true, true, true, GalacticResource.class);
|
||||
resourceRootsODB = new ObjectDatabase("resourceroots", true, true, true, ResourceRoot.class);
|
||||
resourceHistoryODB = new ObjectDatabase("resourcehistory", true, true, true, GalacticResource.class);
|
||||
auctionODB = new ObjectDatabase("auction", true, true, true, AuctionItem.class);
|
||||
|
||||
// Services
|
||||
loginService = new LoginService(this);
|
||||
@@ -480,6 +488,7 @@ public class NGECore {
|
||||
spawnService.loadMobileTemplates();
|
||||
spawnService.loadLairTemplates();
|
||||
spawnService.loadLairGroups();
|
||||
spawnService.loadDynamicGroups();;
|
||||
spawnService.loadSpawnAreas();
|
||||
|
||||
housingService.loadHousingTemplates();
|
||||
@@ -495,24 +504,21 @@ public class NGECore {
|
||||
}
|
||||
|
||||
private void cleanupCreatureODB() {
|
||||
EntityCursor<CreatureObject> cursor = creatureODB.getCursor(Long.class, CreatureObject.class);
|
||||
ODBCursor cursor = swgObjectODB.getCursor();
|
||||
|
||||
Iterator<CreatureObject> it = cursor.iterator();
|
||||
List<CreatureObject> deletedObjects = new ArrayList<CreatureObject>();
|
||||
|
||||
while(it.hasNext()) {
|
||||
CreatureObject creature = it.next();
|
||||
if(!characterService.playerExists(creature.getObjectID()))
|
||||
deletedObjects.add(creature);
|
||||
while(cursor.hasNext()) {
|
||||
SWGObject creature = (SWGObject) cursor.next();
|
||||
if(!characterService.playerExists(creature.getObjectID()) && creature instanceof CreatureObject)
|
||||
deletedObjects.add((CreatureObject) creature);
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
|
||||
Transaction txn = creatureODB.getEnvironment().beginTransaction(null, null);
|
||||
for(CreatureObject creature : deletedObjects) {
|
||||
creatureODB.delete(creature.getObjectID(), Long.class, CreatureObject.class, txn);
|
||||
swgObjectODB.remove(creature.getObjectID());
|
||||
}
|
||||
txn.commitSync();
|
||||
|
||||
System.out.println("Deleted " + deletedObjects.size() + " creatures.");
|
||||
}
|
||||
|
||||
@@ -598,8 +604,8 @@ public class NGECore {
|
||||
return databaseConnection2;
|
||||
}
|
||||
|
||||
public ObjectDatabase getCreatureODB() {
|
||||
return creatureODB;
|
||||
public ObjectDatabase getSWGObjectODB() {
|
||||
return swgObjectODB;
|
||||
}
|
||||
|
||||
public ObjectDatabase getMailODB() {
|
||||
@@ -609,11 +615,7 @@ public class NGECore {
|
||||
public ObjectDatabase getGuildODB() {
|
||||
return guildODB;
|
||||
}
|
||||
|
||||
public ObjectDatabase getBuildingODB() {
|
||||
return buildingODB;
|
||||
}
|
||||
|
||||
|
||||
public ObjectDatabase getObjectIdODB() {
|
||||
return objectIdODB;
|
||||
}
|
||||
@@ -738,6 +740,19 @@ public class NGECore {
|
||||
return System.currentTimeMillis() - galacticTime;
|
||||
}
|
||||
|
||||
public void closeODBs() {
|
||||
swgObjectODB.close();
|
||||
mailODB.close();
|
||||
guildODB.close();
|
||||
chatRoomODB.close();
|
||||
resourcesODB.close();
|
||||
resourceRootsODB.close();
|
||||
resourceHistoryODB.close();
|
||||
objectIdODB.close();
|
||||
duplicateIdODB.close();
|
||||
auctionODB.close();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
@@ -30,8 +31,9 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent
|
||||
public final class AString extends Delta {
|
||||
public final class AString extends Delta implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String string;
|
||||
|
||||
public AString() {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -28,8 +29,9 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent
|
||||
public final class UString extends Delta {
|
||||
public final class UString extends Delta implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String string;
|
||||
|
||||
public UString() {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.gcw;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -28,8 +30,9 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class CurrentServerGCWZoneHistory extends Delta implements Cloneable {
|
||||
public class CurrentServerGCWZoneHistory extends Delta implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int lastUpdateTime;
|
||||
private int percent;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.gcw;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
|
||||
@@ -29,12 +30,12 @@ import org.apache.mina.core.buffer.IoBuffer;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.resources.scene.Point2D;
|
||||
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class CurrentServerGCWZonePercent extends Delta implements Cloneable {
|
||||
public class CurrentServerGCWZonePercent extends Delta implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Point2D position;
|
||||
private float radius = 0;
|
||||
private BigDecimal weight;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.gcw;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -28,8 +30,9 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class OtherServerGCWZonePercent extends Delta implements Cloneable {
|
||||
public class OtherServerGCWZonePercent extends Delta implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String zone = "";
|
||||
private int percent = 50;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.guild;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
@@ -28,12 +29,12 @@ import org.apache.mina.core.buffer.IoBuffer;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.Delta;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class Guild extends Delta {
|
||||
public class Guild extends Delta implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private String abbreviation;
|
||||
private String name;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -39,10 +40,11 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import engine.resources.common.CRC;
|
||||
|
||||
@Persistent(version=10)
|
||||
public class Buff implements IDelta {
|
||||
public class Buff implements IDelta, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@NotPersistent
|
||||
private SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
private transient SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
private String group1, group2;
|
||||
private int priority;
|
||||
private float duration;
|
||||
@@ -64,7 +66,7 @@ public class Buff implements IDelta {
|
||||
private int totalPlayTime;
|
||||
private byte decayCounter = 0;
|
||||
@NotPersistent
|
||||
private ScheduledFuture<?> removalTask;
|
||||
private transient ScheduledFuture<?> removalTask;
|
||||
private int stacks = 1;
|
||||
private long groupBufferId;
|
||||
private int buffCRC;
|
||||
|
||||
@@ -21,10 +21,14 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent
|
||||
public class BuffItem {
|
||||
public class BuffItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int affectAmount;
|
||||
private int entertainerBonus;
|
||||
private int invested;
|
||||
|
||||
@@ -21,20 +21,22 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent(version=1)
|
||||
public class DamageOverTime {
|
||||
public class DamageOverTime implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Buff buff;
|
||||
private String type;
|
||||
private int duration;
|
||||
private int intensity;
|
||||
@NotPersistent
|
||||
private ScheduledFuture<?> task;
|
||||
private transient ScheduledFuture<?> task;
|
||||
private long startTime;
|
||||
private String commandName;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@@ -33,12 +34,13 @@ import com.sleepycat.persist.model.Persistent;
|
||||
import resources.common.StringUtilities;
|
||||
|
||||
@Persistent
|
||||
public abstract class Delta implements IDelta {
|
||||
public abstract class Delta implements IDelta, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@NotPersistent
|
||||
protected final Object objectMutex = new Object();
|
||||
protected transient final Object objectMutex = new Object();
|
||||
@NotPersistent
|
||||
private static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
private transient static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
|
||||
public Delta() {
|
||||
|
||||
|
||||
@@ -21,10 +21,12 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent
|
||||
public interface IDelta {
|
||||
public interface IDelta {
|
||||
|
||||
public byte[] getBytes();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -43,16 +44,17 @@ import com.sleepycat.persist.model.Persistent;
|
||||
/* A SWGList element MUST implement IDelta, or it will refuse to work with it */
|
||||
|
||||
@Persistent
|
||||
public class SWGList<E> implements List<E> {
|
||||
public class SWGList<E> implements List<E>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private List<E> list = new ArrayList<E>();
|
||||
@NotPersistent
|
||||
private int updateCounter = 1;
|
||||
private transient int updateCounter = 1;
|
||||
private ObjectMessageBuilder messageBuilder;
|
||||
private byte viewType;
|
||||
private short updateType;
|
||||
@NotPersistent
|
||||
protected final Object objectMutex = new Object();
|
||||
protected transient final Object objectMutex = new Object();
|
||||
|
||||
public SWGList() { }
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -43,16 +44,17 @@ import com.sleepycat.persist.model.Persistent;
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@Persistent
|
||||
public class SWGMap<K, V> implements Map<K, V> {
|
||||
public class SWGMap<K, V> implements Map<K, V>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Map<K, V> map = new TreeMap<K, V>();
|
||||
@NotPersistent
|
||||
private int updateCounter = 0;
|
||||
private transient int updateCounter = 0;
|
||||
private ObjectMessageBuilder messageBuilder;
|
||||
private byte viewType;
|
||||
private short updateType;
|
||||
@NotPersistent
|
||||
protected final Object objectMutex = new Object();
|
||||
protected transient final Object objectMutex = new Object();
|
||||
|
||||
public SWGMap() { }
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -46,16 +47,17 @@ import com.sleepycat.persist.model.Persistent;
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@Persistent
|
||||
public class SWGMultiMap<K, V> implements Multimap<K, V> {
|
||||
public class SWGMultiMap<K, V> implements Multimap<K, V>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Multimap<K, V> map = ArrayListMultimap.create();
|
||||
@NotPersistent
|
||||
private int updateCounter = 0;
|
||||
private transient int updateCounter = 0;
|
||||
private ObjectMessageBuilder messageBuilder;
|
||||
private byte viewType;
|
||||
private short updateType;
|
||||
@NotPersistent
|
||||
protected final Object objectMutex = new Object();
|
||||
protected transient final Object objectMutex = new Object();
|
||||
|
||||
public SWGMultiMap() { }
|
||||
|
||||
|
||||
@@ -21,13 +21,17 @@
|
||||
******************************************************************************/
|
||||
package resources.objects;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class SkillMod extends Delta {
|
||||
public class SkillMod extends Delta implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int base;
|
||||
private int modifier;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.building;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -44,12 +45,13 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Entity(version=6)
|
||||
public class BuildingObject extends TangibleObject implements IPersistent {
|
||||
public class BuildingObject extends TangibleObject implements IPersistent, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@NotPersistent
|
||||
private BuildingMessageBuilder messageBuilder;
|
||||
private transient BuildingMessageBuilder messageBuilder;
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
private transient Transaction txn;
|
||||
|
||||
private float maintenanceAmount = 0;
|
||||
private int BMR = 0;
|
||||
|
||||
@@ -21,10 +21,13 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.cell;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import protocol.swg.UpdateCellPermissionMessage;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
@@ -32,11 +35,12 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class CellObject extends SWGObject {
|
||||
public class CellObject extends SWGObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int cellNumber = 0;
|
||||
@NotPersistent
|
||||
private CellMessageBuilder messageBuilder;
|
||||
private transient CellMessageBuilder messageBuilder;
|
||||
|
||||
public CellObject() {
|
||||
super();
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.craft;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
@@ -29,9 +32,10 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent
|
||||
public class DraftSchematic extends SWGObject {
|
||||
|
||||
public class DraftSchematic extends SWGObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DraftSchematic(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, position, orientation, template);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.creature;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.System;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -68,17 +69,16 @@ import resources.objects.tangible.TangibleObject;
|
||||
import services.command.BaseSWGCommand;
|
||||
|
||||
@Entity(version=9)
|
||||
public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
public class CreatureObject extends TangibleObject implements Serializable {
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// CREO 1
|
||||
private int bankCredits = 0;
|
||||
private int cashCredits = 0;
|
||||
private List<String> skills;
|
||||
@NotPersistent
|
||||
private int skillsUpdateCounter = 0;
|
||||
private transient int skillsUpdateCounter = 0;
|
||||
|
||||
// CREO 3
|
||||
private byte posture = 0;
|
||||
@@ -105,7 +105,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
private SWGList<MissionCriticalObject> missionCriticalObjects;
|
||||
@NotPersistent
|
||||
private int missionCriticalObjectsUpdateCounter = 0;
|
||||
private transient int missionCriticalObjectsUpdateCounter = 0;
|
||||
|
||||
|
||||
// CREO6
|
||||
@@ -130,30 +130,30 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
private boolean acceptBandflourishes = true;
|
||||
private boolean groupDance = true;
|
||||
@NotPersistent
|
||||
private CreatureObject performanceWatchee;
|
||||
private transient CreatureObject performanceWatchee;
|
||||
@NotPersistent
|
||||
private CreatureObject performanceListenee;
|
||||
private transient CreatureObject performanceListenee;
|
||||
@NotPersistent
|
||||
private Vector<CreatureObject> performanceAudience = new Vector<CreatureObject>();
|
||||
private transient Vector<CreatureObject> performanceAudience = new Vector<CreatureObject>();
|
||||
private int health = 1000;
|
||||
private int action = 300;
|
||||
@NotPersistent
|
||||
private int HAMListCounter = 0;
|
||||
private transient int HAMListCounter = 0;
|
||||
private int maxHealth = 1000;
|
||||
private int maxAction = 300;
|
||||
@NotPersistent
|
||||
private int maxHAMListCounter = 0;
|
||||
private transient int maxHAMListCounter = 0;
|
||||
|
||||
private SWGList<SWGObject> equipmentList;
|
||||
@NotPersistent
|
||||
private int equipmentListUpdateCounter = 0;
|
||||
private transient int equipmentListUpdateCounter = 0;
|
||||
private SWGList<Buff> buffList = new SWGList<Buff>();
|
||||
@NotPersistent
|
||||
private int buffListUpdateCounter = 0;
|
||||
private transient int buffListUpdateCounter = 0;
|
||||
private byte difficulty = 0;
|
||||
private SWGList<SWGObject> appearanceEquipmentList;
|
||||
@NotPersistent
|
||||
private int appearanceEquipmentListUpdateCounter = 0;
|
||||
private transient int appearanceEquipmentListUpdateCounter = 0;
|
||||
|
||||
private boolean inStealth = false;
|
||||
private boolean radarVisible = true; // radar
|
||||
@@ -161,34 +161,34 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
// non-baseline vars
|
||||
@NotPersistent
|
||||
private List<CreatureObject> duelList = Collections.synchronizedList(new ArrayList<CreatureObject>());
|
||||
private transient List<CreatureObject> duelList = Collections.synchronizedList(new ArrayList<CreatureObject>());
|
||||
@NotPersistent
|
||||
private CreatureMessageBuilder messageBuilder;
|
||||
private transient CreatureMessageBuilder messageBuilder;
|
||||
private SWGList<DamageOverTime> dotList = new SWGList<DamageOverTime>();
|
||||
@NotPersistent
|
||||
private ScheduledFuture<?> incapTask;
|
||||
private transient ScheduledFuture<?> incapTask;
|
||||
@NotPersistent
|
||||
private ScheduledFuture<?> entertainerExperience;
|
||||
private transient ScheduledFuture<?> entertainerExperience;
|
||||
@NotPersistent
|
||||
private ScheduledFuture<?> inspirationTick;
|
||||
private transient ScheduledFuture<?> inspirationTick;
|
||||
|
||||
@NotPersistent
|
||||
private ScheduledFuture<?> spectatorTask;
|
||||
private transient ScheduledFuture<?> spectatorTask;
|
||||
|
||||
private boolean staticNPC = false; // temp
|
||||
@NotPersistent
|
||||
private int flourishCount = 0;
|
||||
private transient int flourishCount = 0;
|
||||
@NotPersistent
|
||||
private boolean performingEffect;
|
||||
private transient boolean performingEffect;
|
||||
@NotPersistent
|
||||
private boolean performingFlourish;
|
||||
private transient boolean performingFlourish;
|
||||
private int coverCharge;
|
||||
@NotPersistent
|
||||
private TangibleObject conversingNpc;
|
||||
private transient TangibleObject conversingNpc;
|
||||
@NotPersistent
|
||||
private ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
|
||||
private transient ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
|
||||
@NotPersistent
|
||||
private long tefTime = System.currentTimeMillis();
|
||||
private transient long tefTime = System.currentTimeMillis();
|
||||
|
||||
public CreatureObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
|
||||
super(objectID, planet, Template, position, orientation);
|
||||
@@ -226,10 +226,6 @@ public class CreatureObject extends TangibleObject implements IPersistent {
|
||||
|
||||
notifyObservers(messageBuilder.buildCustomNameDelta(customName), true);
|
||||
}
|
||||
|
||||
public Transaction getTransaction() { return txn; }
|
||||
|
||||
public void createTransaction(Environment env) { txn = env.beginTransaction(null, null); }
|
||||
|
||||
public int getBankCredits() {
|
||||
synchronized(objectMutex) {
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.factorycrate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import protocol.swg.SceneCreateObjectByCrc;
|
||||
import protocol.swg.SceneDestroyObject;
|
||||
import protocol.swg.SceneEndBaselines;
|
||||
@@ -41,7 +41,6 @@ import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
@@ -50,8 +49,10 @@ import resources.objects.tangible.TangibleObject;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class FactoryCrateObject extends TangibleObject {
|
||||
public class FactoryCrateObject extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Vector<TangibleObject> contents;
|
||||
private byte capacity;
|
||||
private byte contentObjectQuantity;
|
||||
@@ -59,7 +60,7 @@ public class FactoryCrateObject extends TangibleObject {
|
||||
private TangibleObject contentObjectType;
|
||||
|
||||
@NotPersistent
|
||||
private FactoryCrateMessageBuilder messageBuilder;
|
||||
private transient FactoryCrateMessageBuilder messageBuilder;
|
||||
|
||||
public FactoryCrateObject() {
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.group;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.objects.universe.UniverseObject;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.guild;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -28,7 +29,6 @@ import java.util.TreeMap;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import resources.gcw.CurrentServerGCWZoneHistory;
|
||||
import resources.gcw.CurrentServerGCWZonePercent;
|
||||
import resources.gcw.OtherServerGCWZonePercent;
|
||||
@@ -51,16 +51,15 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Entity(version=1)
|
||||
public class GuildObject extends UniverseObject implements IPersistent {
|
||||
public class GuildObject extends UniverseObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected NGECore core;
|
||||
@NotPersistent
|
||||
private GuildMessageBuilder messageBuilder = new GuildMessageBuilder(this);
|
||||
private transient GuildMessageBuilder messageBuilder = new GuildMessageBuilder(this);
|
||||
|
||||
private Map<String, ServerFirst> serverFirst = new HashMap<String, ServerFirst>();
|
||||
private Map<String, Map<String, CurrentServerGCWZonePercent>> zoneMap = new TreeMap<String, Map<String, CurrentServerGCWZonePercent>>();
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
private long nextInstanceId = 0;
|
||||
|
||||
@@ -302,12 +301,5 @@ public class GuildObject extends UniverseObject implements IPersistent {
|
||||
}
|
||||
}
|
||||
|
||||
public Transaction getTransaction() {
|
||||
return txn;
|
||||
}
|
||||
|
||||
public void createTransaction(Environment env) {
|
||||
txn = env.beginTransaction(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.harvester;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
@@ -42,8 +43,10 @@ import resources.objects.resource.ResourceContainerObject;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class HarvesterObject extends InstallationObject {
|
||||
public class HarvesterObject extends InstallationObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private HarvesterMessageBuilder messageBuilder;
|
||||
private InstallationMessageBuilder installationMessageBuilder;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.installation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
|
||||
import engine.clients.Client;
|
||||
@@ -30,8 +32,10 @@ import engine.resources.scene.Quaternion;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
@Entity(version=0)
|
||||
public class InstallationObject extends TangibleObject {
|
||||
public class InstallationObject extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InstallationObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){
|
||||
super(objectID, planet, template, position, orientation);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.intangible;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
@@ -30,8 +32,10 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class IntangibleObject extends SWGObject {
|
||||
public class IntangibleObject extends SWGObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int genericInt;
|
||||
|
||||
public IntangibleObject() {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.loot;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
/**
|
||||
@@ -28,8 +30,10 @@ import com.sleepycat.persist.model.Persistent;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class LootGroup {
|
||||
public class LootGroup implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String[] lootPoolNames;
|
||||
private double[] lootPoolChances;
|
||||
private double lootGroupChance;
|
||||
|
||||
@@ -22,8 +22,12 @@
|
||||
package resources.objects.manufacture;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
@@ -34,8 +38,9 @@ import engine.resources.scene.Quaternion;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ManufactureSchematicObject extends IntangibleObject{
|
||||
public class ManufactureSchematicObject extends IntangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
//@NotPersistent
|
||||
//private ManufactureSchematicMessageBuilder messageBuilder;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.mission;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
@@ -36,8 +38,9 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=1)
|
||||
public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
|
||||
public class MissionObject extends IntangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Point3D destination;
|
||||
private Point3D startLocation;
|
||||
private String startPlanet = "";
|
||||
@@ -56,11 +59,8 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
private MissionObjective objective;
|
||||
|
||||
@NotPersistent
|
||||
MissionMessageBuilder messageBuilder = new MissionMessageBuilder(this);
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
private transient MissionMessageBuilder messageBuilder = new MissionMessageBuilder(this);
|
||||
|
||||
public MissionObject() {
|
||||
super();
|
||||
}
|
||||
@@ -286,14 +286,6 @@ public class MissionObject extends IntangibleObject implements IPersistent {
|
||||
this.missionId = missionId;
|
||||
}
|
||||
|
||||
public Transaction getTransaction() {
|
||||
return txn;
|
||||
}
|
||||
|
||||
public void createTransaction(Environment env) {
|
||||
txn = env.beginTransaction(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client destination) {
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.player;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
@@ -45,8 +46,9 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=13)
|
||||
public class PlayerObject extends IntangibleObject {
|
||||
public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// PLAY 3
|
||||
|
||||
private String title;
|
||||
@@ -71,11 +73,11 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
private Map<String, Integer> xpList = new HashMap<String, Integer>();
|
||||
@NotPersistent
|
||||
private int xpListUpdateCounter = 0;
|
||||
private transient int xpListUpdateCounter = 0;
|
||||
|
||||
private List<WaypointObject> waypoints = new ArrayList<WaypointObject>();
|
||||
@NotPersistent
|
||||
private int waypointListUpdateCounter = 0;
|
||||
private transient int waypointListUpdateCounter = 0;
|
||||
|
||||
private int currentForcePower = 0; // unused in NGE
|
||||
private int maxForcePower = 0; // unused in NGE
|
||||
@@ -85,7 +87,7 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
private List<Quest> questJournal = new ArrayList<Quest>();
|
||||
@NotPersistent
|
||||
private int questJournalUpdateCounter = 0;
|
||||
private transient int questJournalUpdateCounter = 0;
|
||||
|
||||
private String professionWheelPosition;
|
||||
|
||||
@@ -97,17 +99,17 @@ public class PlayerObject extends IntangibleObject {
|
||||
|
||||
private List<DraftSchematic> draftSchematicList = new ArrayList<DraftSchematic>();
|
||||
@NotPersistent
|
||||
private int draftSchematicListUpdateCounter = 0;
|
||||
private transient int draftSchematicListUpdateCounter = 0;
|
||||
|
||||
private int experimentationPoints = 0;
|
||||
private int accomplishmentCounter = 0;
|
||||
|
||||
private List<String> friendList = new ArrayList<String>();
|
||||
@NotPersistent
|
||||
private int friendListUpdateCounter = 0;
|
||||
private transient int friendListUpdateCounter = 0;
|
||||
private List<String> ignoreList = new ArrayList<String>();
|
||||
@NotPersistent
|
||||
private int ignoreListUpdateCounter = 0;
|
||||
private transient int ignoreListUpdateCounter = 0;
|
||||
|
||||
private int languageId = 0; // unused in NGE
|
||||
private int currentStomach = 0; // unused in NGE
|
||||
@@ -129,10 +131,10 @@ public class PlayerObject extends IntangibleObject {
|
||||
private int lotsRemaining = 10;
|
||||
|
||||
@NotPersistent
|
||||
private PlayerMessageBuilder messageBuilder;
|
||||
private transient PlayerMessageBuilder messageBuilder;
|
||||
|
||||
@NotPersistent
|
||||
private long lastPlayTimeUpdate = System.currentTimeMillis();
|
||||
private transient long lastPlayTimeUpdate = System.currentTimeMillis();
|
||||
|
||||
private Map<String, Integer> factionStandingMap = new TreeMap<String, Integer>();
|
||||
|
||||
@@ -145,7 +147,7 @@ public class PlayerObject extends IntangibleObject {
|
||||
private List<Integer> chatChannels = new ArrayList<Integer>();
|
||||
|
||||
@NotPersistent
|
||||
private boolean callingCompanion = false;
|
||||
private transient boolean callingCompanion = false;
|
||||
|
||||
public PlayerObject() {
|
||||
super();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.resource;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
@@ -48,10 +49,9 @@ import engine.resources.scene.Quaternion;
|
||||
*/
|
||||
|
||||
@Entity(version=0)
|
||||
public class GalacticResource extends SWGObject implements IPersistent {
|
||||
public class GalacticResource extends SWGObject implements Serializable {
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private String fileName;
|
||||
@@ -63,30 +63,30 @@ public class GalacticResource extends SWGObject implements IPersistent {
|
||||
|
||||
|
||||
@NotPersistent
|
||||
public static final int INT_COLDRESISTANCE = 0;
|
||||
public transient static final int INT_COLDRESISTANCE = 0;
|
||||
@NotPersistent
|
||||
public static final int INT_CONDUCTIVITY = 1;
|
||||
public transient static final int INT_CONDUCTIVITY = 1;
|
||||
@NotPersistent
|
||||
public static final int INT_DECAYRESISTANCE = 2;
|
||||
public transient static final int INT_DECAYRESISTANCE = 2;
|
||||
@NotPersistent
|
||||
public static final int INT_HEATRESISTANCE = 3;
|
||||
public transient static final int INT_HEATRESISTANCE = 3;
|
||||
@NotPersistent
|
||||
public static final int INT_MALLEABILITY = 4;
|
||||
public transient static final int INT_MALLEABILITY = 4;
|
||||
@NotPersistent
|
||||
public static final int INT_SHOCKRESISTANCE = 5;
|
||||
public transient static final int INT_SHOCKRESISTANCE = 5;
|
||||
@NotPersistent
|
||||
public static final int INT_UNITTOUGHNESS = 6;
|
||||
public transient static final int INT_UNITTOUGHNESS = 6;
|
||||
@NotPersistent
|
||||
public static final int INT_ENTANGLERESISTANCE = 7;
|
||||
public transient static final int INT_ENTANGLERESISTANCE = 7;
|
||||
@NotPersistent
|
||||
public static final int INT_POTENTIALENERGY = 8;
|
||||
public transient static final int INT_POTENTIALENERGY = 8;
|
||||
@NotPersistent
|
||||
public static final int INT_OVERALLQUALITY = 9;
|
||||
public transient static final int INT_OVERALLQUALITY = 9;
|
||||
@NotPersistent
|
||||
public static final int INT_FLAVOR = 10;
|
||||
public transient static final int INT_FLAVOR = 10;
|
||||
|
||||
@NotPersistent
|
||||
public static final String[] statNamesLookup = {"Cold Resistance",
|
||||
public transient static final String[] statNamesLookup = {"Cold Resistance",
|
||||
"Conductivity",
|
||||
"Decay Resistance",
|
||||
"Heat Resistance",
|
||||
@@ -117,16 +117,16 @@ public class GalacticResource extends SWGObject implements IPersistent {
|
||||
short[] resourceStats = new short[11];
|
||||
|
||||
@NotPersistent
|
||||
private static int RES_CAT_HI = 1; // Up to 99%, easy to find spots over 90%
|
||||
private transient static int RES_CAT_HI = 1; // Up to 99%, easy to find spots over 90%
|
||||
@NotPersistent
|
||||
private static int RES_CAT_MID = 2; // Up to 90%, often have to settle at around 80%
|
||||
private transient static int RES_CAT_MID = 2; // Up to 90%, often have to settle at around 80%
|
||||
@NotPersistent
|
||||
private static int RES_CAT_LO = 3; // Up to 70%, often have to settle around 60%
|
||||
private transient static int RES_CAT_LO = 3; // Up to 70%, often have to settle around 60%
|
||||
@NotPersistent
|
||||
private static int RES_CAT_CRE = 4; // Creature resource
|
||||
private transient static int RES_CAT_CRE = 4; // Creature resource
|
||||
|
||||
@NotPersistent // Direct Persistence Layer entity reference restriction
|
||||
private ResourceRoot resourceRoot;
|
||||
private transient ResourceRoot resourceRoot;
|
||||
|
||||
private int resourceRootID; // This is for re-referencing the resourceRoot in the reloaded resourceRoot collection
|
||||
// due to the DPL entity reference restriction
|
||||
@@ -633,13 +633,6 @@ public class GalacticResource extends SWGObject implements IPersistent {
|
||||
"zau"};
|
||||
|
||||
|
||||
@Override
|
||||
public void createTransaction(Environment env) { txn = env.beginTransaction(null, null);}
|
||||
|
||||
|
||||
@Override
|
||||
public Transaction getTransaction() { return txn; }
|
||||
|
||||
@Override
|
||||
public void sendBaselines(Client arg0) {
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package resources.objects.resource;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class PlanetDeposits {
|
||||
public class PlanetDeposits implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int planetId;
|
||||
private List<ResourceDeposit> depositList;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
package resources.objects.resource;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
@@ -40,8 +42,9 @@ import resources.objects.tangible.TangibleObject;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ResourceContainerObject extends TangibleObject {
|
||||
public class ResourceContainerObject extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Unique ID
|
||||
private long containerID;
|
||||
|
||||
@@ -131,10 +134,10 @@ public class ResourceContainerObject extends TangibleObject {
|
||||
*/
|
||||
|
||||
@NotPersistent
|
||||
public static int maximalStackCapacity = 100000;
|
||||
public transient static int maximalStackCapacity = 100000;
|
||||
|
||||
@NotPersistent
|
||||
private ResourceContainerMessageBuilder messageBuilder;
|
||||
private transient ResourceContainerMessageBuilder messageBuilder;
|
||||
|
||||
public ResourceContainerObject(){
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package resources.objects.resource;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
/**
|
||||
@@ -7,7 +9,9 @@ import com.sleepycat.persist.model.Persistent;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ResourceDeposit {
|
||||
public class ResourceDeposit implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private float spawnCoordsX;
|
||||
private float spawnCoordsZ;
|
||||
private float spawnRadius;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.resource;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
@@ -32,8 +34,9 @@ import com.sleepycat.persist.model.PrimaryKey;
|
||||
*/
|
||||
|
||||
@Entity(version=0)
|
||||
public class ResourceRoot {
|
||||
public class ResourceRoot implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Publish 15:
|
||||
|
||||
// - Total: 61, Minimum pool: 15, Random pool: 24 (3 was removed), Fixed pool: 22.
|
||||
@@ -84,7 +87,7 @@ public class ResourceRoot {
|
||||
// All 38 Organic types for each planet
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
private transient Transaction txn;
|
||||
|
||||
private static int highestID = 0;
|
||||
|
||||
|
||||
@@ -21,11 +21,14 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.ship;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class ShipObject extends TangibleObject {
|
||||
|
||||
public class ShipObject extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.staticobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@@ -31,10 +33,11 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class StaticObject extends SWGObject {
|
||||
public class StaticObject extends SWGObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@NotPersistent
|
||||
private StaticMessageBuilder messageBuilder;
|
||||
private transient StaticMessageBuilder messageBuilder;
|
||||
|
||||
public StaticObject() {
|
||||
super();
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package resources.objects.tangible;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -55,8 +56,9 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=12)
|
||||
public class TangibleObject extends SWGObject {
|
||||
public class TangibleObject extends SWGObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// TODO: Thread safety
|
||||
|
||||
protected int incapTimer = 10;
|
||||
@@ -72,9 +74,9 @@ public class TangibleObject extends SWGObject {
|
||||
protected String faction = ""; // Says you're "Imperial Special Forces" if it's 0 for some reason
|
||||
protected int factionStatus = 0;
|
||||
@NotPersistent
|
||||
private Vector<TangibleObject> defendersList = new Vector<TangibleObject>(); // unused in packets but useful for the server
|
||||
private transient Vector<TangibleObject> defendersList = new Vector<TangibleObject>(); // unused in packets but useful for the server
|
||||
@NotPersistent
|
||||
private TangibleMessageBuilder messageBuilder;
|
||||
private transient TangibleMessageBuilder messageBuilder;
|
||||
|
||||
private int respawnTime = 0;
|
||||
private Point3D spawnCoordinates = new Point3D(0, 0, 0);
|
||||
@@ -83,13 +85,13 @@ public class TangibleObject extends SWGObject {
|
||||
private List<LootGroup> lootGroups = new ArrayList<LootGroup>();
|
||||
|
||||
@NotPersistent
|
||||
private boolean looted = false; // These 4 should not need to be persisted, since a looted corpse will get wiped with server restart
|
||||
private transient boolean looted = false; // These 4 should not need to be persisted, since a looted corpse will get wiped with server restart
|
||||
@NotPersistent
|
||||
private boolean lootLock = false;
|
||||
private transient boolean lootLock = false;
|
||||
@NotPersistent
|
||||
private boolean creditRelieved = false;
|
||||
private transient boolean creditRelieved = false;
|
||||
@NotPersistent
|
||||
private boolean lootItem = false;
|
||||
private transient boolean lootItem = false;
|
||||
|
||||
private boolean stackable = false;
|
||||
private int stackCount = 1;
|
||||
@@ -101,7 +103,7 @@ public class TangibleObject extends SWGObject {
|
||||
private String serialNumber;
|
||||
|
||||
@NotPersistent
|
||||
private TangibleObject killer = null;
|
||||
private transient TangibleObject killer = null;
|
||||
|
||||
public TangibleObject(long objectID, Planet planet, String template) {
|
||||
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0), template);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.tool;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
@@ -41,8 +42,9 @@ import resources.objects.tangible.TangibleObject;
|
||||
*/
|
||||
|
||||
@Persistent(version=0)
|
||||
public class SurveyTool extends TangibleObject{
|
||||
public class SurveyTool extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private byte toolType=0;
|
||||
private long surveyResourceID;
|
||||
private long userID=0;
|
||||
@@ -50,25 +52,25 @@ public class SurveyTool extends TangibleObject{
|
||||
private byte SurveyRangeSetting=0;
|
||||
|
||||
@NotPersistent
|
||||
private String surveyEffectString="";
|
||||
private transient String surveyEffectString="";
|
||||
@NotPersistent
|
||||
private String sampleEffectString="";
|
||||
private transient String sampleEffectString="";
|
||||
@NotPersistent
|
||||
private boolean currentlySurveying=false;
|
||||
private transient boolean currentlySurveying=false;
|
||||
@NotPersistent
|
||||
private boolean currentlySampling=false;
|
||||
private transient boolean currentlySampling=false;
|
||||
@NotPersistent
|
||||
private boolean currentlyCoolingDown=false;
|
||||
private transient boolean currentlyCoolingDown=false;
|
||||
@NotPersistent
|
||||
private boolean exceptionalState=false;
|
||||
private transient boolean exceptionalState=false;
|
||||
@NotPersistent
|
||||
private boolean recoveryMode=false;
|
||||
private transient boolean recoveryMode=false;
|
||||
@NotPersistent
|
||||
private Long lastSurveyTime=0L;
|
||||
private transient Long lastSurveyTime=0L;
|
||||
@NotPersistent
|
||||
private Long lastSampleTime=0L;
|
||||
private transient Long lastSampleTime=0L;
|
||||
@NotPersistent
|
||||
private Long recoveryTime=10L;
|
||||
private transient Long recoveryTime=10L;
|
||||
|
||||
public static byte MineralSurveyDevice = 1;
|
||||
public static byte ChemicalSurveyDevice = 2;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.universe;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import engine.clients.Client;
|
||||
@@ -30,8 +32,10 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class UniverseObject extends SWGObject {
|
||||
public class UniverseObject extends SWGObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UniverseObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
|
||||
super(objectID, planet, position, orientation, Template);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.waypoint;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -31,8 +33,10 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class WaypointObject extends IntangibleObject {
|
||||
public class WaypointObject extends IntangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int cellId; // ???
|
||||
private long locationNetworkId;
|
||||
private int planetCRC;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.weapon;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import resources.datatables.WeaponType;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
|
||||
@@ -33,12 +35,14 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Persistent(version=1)
|
||||
public class WeaponObject extends TangibleObject {
|
||||
public class WeaponObject extends TangibleObject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// TODO: Thread safety
|
||||
|
||||
@NotPersistent
|
||||
private WeaponMessageBuilder messageBuilder;
|
||||
private transient WeaponMessageBuilder messageBuilder;
|
||||
|
||||
public WeaponObject(long objectID, Planet planet, String template) {
|
||||
super(objectID, planet, template, new Point3D(0, 0, 0), new Quaternion(1, 0, 1, 0));
|
||||
|
||||
@@ -269,10 +269,7 @@ public class CharacterService implements INetworkDispatch {
|
||||
core.skillModService.addSkillMod(object, "language_basic_speak", 100);
|
||||
core.skillModService.addSkillMod(object, "creature_harvesting", 25);
|
||||
core.skillModService.addSkillMod(object, "language_wookiee_comprehend", 100);
|
||||
|
||||
|
||||
object.createTransaction(core.getCreatureODB().getEnvironment());
|
||||
|
||||
|
||||
PlayerObject player = (PlayerObject) core.objectService.createObject("object/player/shared_player.iff", object.getPlanet());
|
||||
object._add(player);
|
||||
core.skillService.addSkill(object, "species_" + object.getStfName());
|
||||
@@ -337,9 +334,7 @@ public class CharacterService implements INetworkDispatch {
|
||||
createStarterClothing(object, sharedRaceTemplate, clientCreateCharacter.getStarterProfession());
|
||||
//core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", core, object);
|
||||
|
||||
core.getCreatureODB().put(object, Long.class, CreatureObject.class, object.getTransaction());
|
||||
// might not need to commit transaction but better safe than sorry
|
||||
object.getTransaction().commitSync();
|
||||
core.getSWGObjectODB().put(object.getObjectID(), object);
|
||||
|
||||
PreparedStatement ps = databaseConnection.preparedStatement("INSERT INTO characters (id, \"firstName\", \"lastName\", \"accountId\", \"galaxyId\", \"statusId\", appearance, gmflag) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
ps.setLong(1, object.getObjectID());
|
||||
|
||||
@@ -281,9 +281,7 @@ public class ConnectionService implements INetworkDispatch {
|
||||
schedulers.clear();
|
||||
core.playerService.getSchedulers().remove(object.getObjectID());
|
||||
|
||||
object.createTransaction(core.getCreatureODB().getEnvironment());
|
||||
core.getCreatureODB().put(object, Long.class, CreatureObject.class, object.getTransaction());
|
||||
object.getTransaction().commitSync();
|
||||
core.getSWGObjectODB().put(object.getObjectID(), object);
|
||||
core.objectService.destroyObject(object);
|
||||
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class LoginService implements INetworkDispatch{
|
||||
core.objectService.destroyObject(object);
|
||||
}
|
||||
|
||||
core.getCreatureODB().delete(new Long(packet.getcharId()), Long.class, CreatureObject.class);
|
||||
core.getSWGObjectODB().remove(object.getObjectID());
|
||||
DeleteCharacterReplyMessage reply = new DeleteCharacterReplyMessage(0);
|
||||
session.write(reply.serialize());
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import engine.resources.common.Event;
|
||||
import engine.resources.common.Mesh3DTriangle;
|
||||
import engine.resources.common.Ray;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.database.ODBCursor;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -186,13 +187,11 @@ public class SimulationService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public void insertPersistentBuildings() {
|
||||
EntityCursor<BuildingObject> cursor = core.getBuildingODB().getCursor(Long.class, BuildingObject.class);
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
Iterator<BuildingObject> it = cursor.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
final BuildingObject building = (BuildingObject) core.objectService.getObject(it.next().getObjectID());
|
||||
if(building == null)
|
||||
while(cursor.hasNext()) {
|
||||
SWGObject building = core.objectService.getObject(((SWGObject) cursor.next()).getObjectID());
|
||||
if(building == null || !(building instanceof BuildingObject))
|
||||
continue;
|
||||
if(building.getAttachment("hasLoadedServerTemplate") == null)
|
||||
core.objectService.loadServerTemplate(building);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package services.bazaar;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
@@ -31,8 +33,10 @@ import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.SWGObject;
|
||||
|
||||
@Entity(version=1)
|
||||
public class AuctionItem implements IPersistent, Comparable<AuctionItem> {
|
||||
public class AuctionItem implements Comparable<AuctionItem>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@PrimaryKey
|
||||
private long objectId;
|
||||
private SWGObject item;
|
||||
@@ -62,10 +66,7 @@ public class AuctionItem implements IPersistent, Comparable<AuctionItem> {
|
||||
public final static int EXPIRED = 4;
|
||||
public final static int OFFERED = 5;
|
||||
public final static int RETRIEVED = 6;
|
||||
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
|
||||
public AuctionItem() {
|
||||
|
||||
}
|
||||
@@ -256,16 +257,6 @@ public class AuctionItem implements IPersistent, Comparable<AuctionItem> {
|
||||
this.auctionOptions = auctionOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTransaction(Environment env) {
|
||||
txn = env.beginTransaction(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction getTransaction() {
|
||||
return txn;
|
||||
}
|
||||
|
||||
public SWGObject getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.sleepycat.persist.EntityCursor;
|
||||
|
||||
import main.NGECore;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.database.ODBCursor;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -81,16 +82,18 @@ public class BazaarService implements INetworkDispatch {
|
||||
public BazaarService(NGECore core) {
|
||||
this.core = core;
|
||||
loadAuctionItems();
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
System.out.println("Saving auction items...");
|
||||
auctionItems.forEach(item -> core.objectService.persistObject(item, Long.class, AuctionItem.class, core.getAuctionODB()));
|
||||
}));
|
||||
}
|
||||
|
||||
public void saveAllItems() {
|
||||
System.out.println("Saving auction items...");
|
||||
auctionItems.forEach(item -> core.objectService.persistObject(item.getObjectId(), item, core.getAuctionODB()));
|
||||
}
|
||||
|
||||
private void loadAuctionItems() {
|
||||
EntityCursor<AuctionItem> cursor = core.getAuctionODB().getCursor(Long.class, AuctionItem.class);
|
||||
Iterator<AuctionItem> it = cursor.iterator();
|
||||
it.forEachRemaining(this::addAuctionItem);
|
||||
ODBCursor cursor = core.getAuctionODB().getCursor();
|
||||
while(cursor.hasNext()) {
|
||||
addAuctionItem((AuctionItem) cursor.next());
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
@@ -412,7 +415,7 @@ public class BazaarService implements INetworkDispatch {
|
||||
if(seller == null) {
|
||||
seller = core.objectService.getCreatureFromDB(item.getOwnerId());
|
||||
seller.setBankCredits(seller.getBankCredits() + item.getPrice());
|
||||
core.objectService.persistObject(seller, Long.class, CreatureObject.class, core.getAuctionODB());
|
||||
core.objectService.persistObject(seller.getObjectID(), seller, core.getSWGObjectODB());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -752,8 +755,8 @@ public class BazaarService implements INetworkDispatch {
|
||||
if(commodityLimit.get(auctionItem.getOwnerId()) != null)
|
||||
commodityNumber = commodityLimit.get(auctionItem.getOwnerId());
|
||||
commodityLimit.put(auctionItem.getOwnerId(), commodityNumber + 1);
|
||||
if(!core.getAuctionODB().contains(auctionItem.getObjectId(), Long.class, AuctionItem.class)) {
|
||||
core.objectService.persistObject(auctionItem, Long.class, AuctionItem.class, core.getAuctionODB());
|
||||
if(!core.getAuctionODB().contains(auctionItem.getObjectId())) {
|
||||
core.objectService.persistObject(auctionItem.getObjectId(), auctionItem, core.getAuctionODB());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,7 +766,7 @@ public class BazaarService implements INetworkDispatch {
|
||||
if(commodityLimit.get(auctionItem.getOwnerId()) != null)
|
||||
commodityNumber = commodityLimit.get(auctionItem.getOwnerId());
|
||||
commodityLimit.put(auctionItem.getOwnerId(), commodityNumber - 1);
|
||||
core.objectService.deletePersistentObject(auctionItem, Long.class, AuctionItem.class, core.getAuctionODB(), auctionItem.getObjectId());
|
||||
core.objectService.deletePersistentObject(auctionItem.getObjectId(), core.getAuctionODB());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,15 +21,19 @@
|
||||
******************************************************************************/
|
||||
package services.chat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
@Entity(version=1)
|
||||
public class ChatRoom {
|
||||
public class ChatRoom implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String creator; // creator of the room (first name only, lowercase)
|
||||
private String description; // title
|
||||
@PrimaryKey
|
||||
@@ -39,7 +43,7 @@ public class ChatRoom {
|
||||
private Vector<String> moderatorList = new Vector<String>();
|
||||
private Vector<String> banList = new Vector<String>();
|
||||
@NotPersistent
|
||||
private Vector<String> userList = new Vector<String>(); // current users
|
||||
private transient Vector<String> userList = new Vector<String>(); // current users
|
||||
|
||||
private boolean moderatorsOnly;
|
||||
private boolean privateRoom;
|
||||
|
||||
@@ -42,6 +42,7 @@ import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.config.Config;
|
||||
import engine.resources.config.DefaultConfig;
|
||||
import engine.resources.database.ODBCursor;
|
||||
import engine.resources.database.ObjectDatabase;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
@@ -317,7 +318,7 @@ public class ChatService implements INetworkDispatch {
|
||||
return;
|
||||
|
||||
SWGObject obj = client.getParent();
|
||||
Mail mail = mailODB.get(new Integer(packet.getMailId()), Integer.class, Mail.class);
|
||||
Mail mail = (Mail) mailODB.get((long) packet.getMailId());
|
||||
|
||||
if(obj == null || mail == null)
|
||||
return;
|
||||
@@ -352,7 +353,7 @@ public class ChatService implements INetworkDispatch {
|
||||
return;
|
||||
|
||||
SWGObject obj = client.getParent();
|
||||
Mail mail = mailODB.get(new Integer(packet.getMailId()), Integer.class, Mail.class);
|
||||
Mail mail = (Mail) mailODB.get((long) packet.getMailId());
|
||||
|
||||
if(obj == null || mail == null)
|
||||
return;
|
||||
@@ -689,15 +690,11 @@ public class ChatService implements INetworkDispatch {
|
||||
|
||||
|
||||
public void storePersistentMessage(Mail mail) {
|
||||
Transaction txn = mailODB.getEnvironment().beginTransaction(null, null);
|
||||
mailODB.put(mail, Integer.class, Mail.class, txn);
|
||||
txn.commitSync();
|
||||
mailODB.put((long) mail.getMailId(), mail);
|
||||
}
|
||||
|
||||
public void deletePersistentMessage(Mail mail) {
|
||||
Transaction txn = mailODB.getEnvironment().beginTransaction(null, null);
|
||||
mailODB.delete(new Integer(mail.getMailId()), Integer.class, Mail.class, txn);
|
||||
txn.commitSync();
|
||||
mailODB.remove((long) mail.getMailId());
|
||||
}
|
||||
|
||||
public void loadMailHeaders(Client client) {
|
||||
@@ -707,14 +704,16 @@ public class ChatService implements INetworkDispatch {
|
||||
if(obj == null || client.getSession() == null)
|
||||
return;
|
||||
|
||||
EntityCursor<Mail> cursor = mailODB.getCursor(Integer.class, Mail.class);
|
||||
ODBCursor cursor = mailODB.getCursor();
|
||||
|
||||
for(Mail mail : cursor) {
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
Mail mail = (Mail) cursor.next();
|
||||
if(mail.getRecieverId() == obj.getObjectID()) {
|
||||
sendPersistentMessageHeader(client, mail);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
@@ -747,7 +746,7 @@ public class ChatService implements INetworkDispatch {
|
||||
|
||||
int id = rand.nextInt();
|
||||
|
||||
if(mailODB.contains(new Integer(id), Integer.class, Mail.class))
|
||||
if(mailODB.contains((long) id))
|
||||
return generateMailId();
|
||||
else
|
||||
return id;
|
||||
@@ -755,7 +754,7 @@ public class ChatService implements INetworkDispatch {
|
||||
|
||||
public Mail getMailById(int mailId) {
|
||||
|
||||
Mail mail = mailODB.get(new Integer(mailId), Integer.class, Mail.class);
|
||||
Mail mail = (Mail) mailODB.get((long) mailId);
|
||||
return mail;
|
||||
|
||||
}
|
||||
@@ -776,7 +775,7 @@ public class ChatService implements INetworkDispatch {
|
||||
Random rand = new Random();
|
||||
int id = rand.nextInt();
|
||||
|
||||
if (chatRoomsODB.contains(new Integer(id), Integer.class, ChatRoom.class))
|
||||
if (chatRoomsODB.contains((long) id))
|
||||
return generateChatRoomId();
|
||||
else
|
||||
return id;
|
||||
@@ -819,11 +818,13 @@ public class ChatService implements INetworkDispatch {
|
||||
createChatRoom("Politician chat for this galaxy", "Politician", "system", true);
|
||||
//createChatRoom("Pilot chat for this galaxy", "Pilot", "system", true);
|
||||
|
||||
EntityCursor<ChatRoom> cursor = chatRoomsODB.getCursor(Integer.class, ChatRoom.class);
|
||||
cursor.forEach(room -> {
|
||||
ODBCursor cursor = chatRoomsODB.getCursor();
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
ChatRoom room = (ChatRoom) cursor.next();
|
||||
if (!chatRooms.containsValue(room))
|
||||
chatRooms.put(room.getRoomId(), room);
|
||||
});
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
List<Planet> planets = core.terrainService.getPlanetList();
|
||||
@@ -891,9 +892,7 @@ public class ChatService implements INetworkDispatch {
|
||||
chatRooms.put(room.getRoomId(), room);
|
||||
|
||||
if(store){
|
||||
Transaction txn = chatRoomsODB.getEnvironment().beginTransaction(null, null);
|
||||
chatRoomsODB.put(room, Integer.class, ChatRoom.class, txn);
|
||||
txn.commitSync();
|
||||
chatRoomsODB.put((long) room.getRoomId(), room);
|
||||
}
|
||||
|
||||
//Console.println("Created room " + address + " with ID " + room.getRoomId());
|
||||
|
||||
@@ -21,13 +21,17 @@
|
||||
******************************************************************************/
|
||||
package services.chat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
@Entity(version=1)
|
||||
public class Mail {
|
||||
public class Mail implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@PrimaryKey
|
||||
private int mailId;
|
||||
private String senderName;
|
||||
|
||||
@@ -21,11 +21,15 @@
|
||||
******************************************************************************/
|
||||
package services.chat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent
|
||||
public class WaypointAttachment {
|
||||
public class WaypointAttachment implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public WaypointAttachment() { }
|
||||
|
||||
public long cellID;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package services.collections;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.objects.Delta;
|
||||
@@ -28,8 +30,10 @@ import resources.objects.Delta;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@Persistent
|
||||
public class ServerFirst extends Delta {
|
||||
public class ServerFirst extends Delta implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private String collection;
|
||||
private long time;
|
||||
|
||||
@@ -49,7 +49,6 @@ public class GuildService implements INetworkDispatch {
|
||||
object = (GuildObject) this.core.objectService.createObject("object/guild/shared_guild_object.iff", core.terrainService.getPlanetList().get(0));
|
||||
}
|
||||
|
||||
object.createTransaction(core.getGuildODB().getEnvironment());
|
||||
}
|
||||
|
||||
public Guild createGuild(String abbreviation, String name, SWGObject leader) {
|
||||
|
||||
@@ -21,13 +21,17 @@
|
||||
******************************************************************************/
|
||||
package services.mission;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.mission.MissionObject;
|
||||
|
||||
@Persistent(version=0)
|
||||
public abstract class MissionObjective {
|
||||
public abstract class MissionObjective implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected long startTime;
|
||||
protected boolean activated;
|
||||
protected MissionObject parent;
|
||||
|
||||
@@ -21,12 +21,16 @@
|
||||
******************************************************************************/
|
||||
package services.object;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
public class DuplicateId {
|
||||
public class DuplicateId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@PrimaryKey
|
||||
private String key;
|
||||
private long objectId;
|
||||
|
||||
@@ -21,12 +21,16 @@
|
||||
******************************************************************************/
|
||||
package services.object;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
public class ObjectId {
|
||||
public class ObjectId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@PrimaryKey
|
||||
public long objectId;
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ import engine.resources.container.Traverser;
|
||||
import engine.resources.container.WorldCellPermissions;
|
||||
import engine.resources.container.WorldPermissions;
|
||||
import engine.resources.database.DatabaseConnection;
|
||||
import engine.resources.database.ODBCursor;
|
||||
import engine.resources.database.ObjectDatabase;
|
||||
import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.SWGObject;
|
||||
@@ -147,7 +148,6 @@ public class ObjectService implements INetworkDispatch {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
core.getObjectIdODB().getEnvironment().flushLog(true);
|
||||
synchronized(objectList) {
|
||||
for(SWGObject obj : objectList.values()) {
|
||||
|
||||
@@ -157,6 +157,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
}
|
||||
core.bazaarService.saveAllItems();
|
||||
core.closeODBs();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -175,25 +177,20 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public void loadBuildings() {
|
||||
EntityCursor<BuildingObject> cursor = core.getBuildingODB().getCursor(Long.class, BuildingObject.class);
|
||||
|
||||
Iterator<BuildingObject> it = cursor.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
final BuildingObject building = it.next();
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
final SWGObject building = (SWGObject) cursor.next();
|
||||
if(!(building instanceof BuildingObject))
|
||||
continue;
|
||||
objectList.put(building.getObjectID(), building);
|
||||
Planet planet = core.terrainService.getPlanetByID(building.getPlanetId());
|
||||
building.setPlanet(planet);
|
||||
building.viewChildren(building, true, true, new Traverser() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject object) {
|
||||
objectList.put(object.getObjectID(), object);
|
||||
if(object.getParentId() != 0 && object.getContainer() == null)
|
||||
object.setParent(building);
|
||||
object.getContainerInfo(object.getTemplate());
|
||||
}
|
||||
|
||||
building.viewChildren(building, true, true, (object) -> {
|
||||
objectList.put(object.getObjectID(), object);
|
||||
if(object.getParentId() != 0 && object.getContainer() == null)
|
||||
object.setParent(building);
|
||||
object.getContainerInfo(object.getTemplate());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -346,8 +343,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
object.setAttachment("customServerTemplate", customServerTemplate);
|
||||
|
||||
object.setisInSnapshot(isSnapshot);
|
||||
if(!core.getObjectIdODB().contains(objectID, Long.class, ObjectId.class)) {
|
||||
core.getObjectIdODB().put(new ObjectId(objectID), Long.class, ObjectId.class);
|
||||
if(!core.getObjectIdODB().contains(objectID)) {
|
||||
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
|
||||
}
|
||||
if(loadServerTemplate)
|
||||
loadServerTemplate(object);
|
||||
@@ -546,13 +543,11 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
EntityCursor<CreatureObject> cursor = core.getCreatureODB().getCursor(Long.class, CreatureObject.class);
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
Iterator<CreatureObject> it = cursor.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
if(it.next().getCustomName().equals(customName))
|
||||
return it.next();
|
||||
while(cursor.hasNext()) {
|
||||
if(((SWGObject) cursor.next()).getCustomName().equals(customName))
|
||||
return (SWGObject) cursor.next();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -572,13 +567,11 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
EntityCursor<CreatureObject> cursor = core.getCreatureODB().getCursor(Long.class, CreatureObject.class);
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
Iterator<CreatureObject> it = cursor.iterator();
|
||||
|
||||
while(it.hasNext()) {
|
||||
if(it.next().getCustomName().startsWith(customName))
|
||||
return it.next();
|
||||
while(cursor.hasNext()) {
|
||||
if(((SWGObject) cursor.next()).getCustomName().startsWith(customName))
|
||||
return (SWGObject) cursor.next();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -586,21 +579,15 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public CreatureObject getCreatureFromDB(long objectId) {
|
||||
CreatureObject object = core.getCreatureODB().get(new Long(objectId), Long.class, CreatureObject.class);
|
||||
|
||||
SWGObject object = (SWGObject) core.getSWGObjectODB().get(objectId);
|
||||
if(!(object instanceof CreatureObject))
|
||||
return null;
|
||||
if (object != null && getObject(object.getObjectID()) == null) {
|
||||
loadServerTemplate(object);
|
||||
|
||||
object.viewChildren(object, true, true, new Traverser() {
|
||||
|
||||
public void process(SWGObject child) {
|
||||
loadServerTemplate(child);
|
||||
}
|
||||
|
||||
});
|
||||
object.viewChildren(object, true, true, (child) -> loadServerTemplate(child));
|
||||
}
|
||||
|
||||
return object;
|
||||
return (CreatureObject) object;
|
||||
}
|
||||
|
||||
public long generateObjectID() {
|
||||
@@ -633,7 +620,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(getObject(newId) != null || core.getObjectIdODB().contains(newId, Long.class, ObjectId.class))
|
||||
if(getObject(newId) != null || core.getObjectIdODB().contains(newId))
|
||||
found = false;
|
||||
else
|
||||
found = true;
|
||||
@@ -1089,13 +1076,11 @@ public class ObjectService implements INetworkDispatch {
|
||||
String key = "" + CRC.StringtoCRC(planet.getName()) + CRC.StringtoCRC(template) + type + containerId + cellIndex + x + py + z;
|
||||
long newObjectId = 0;
|
||||
|
||||
if (core.getDuplicateIdODB().contains(key, String.class, DuplicateId.class)) {
|
||||
newObjectId = core.getDuplicateIdODB().get(key, String.class, DuplicateId.class).getObjectId();
|
||||
if (core.getDuplicateIdODB().contains(key)) {
|
||||
newObjectId = ((DuplicateId) core.getDuplicateIdODB().get(key)).getObjectId();
|
||||
} else {
|
||||
newObjectId = generateObjectID();
|
||||
Transaction txn = core.getDuplicateIdODB().getEnvironment().beginTransaction(null, null);
|
||||
core.getDuplicateIdODB().put(new DuplicateId(key, newObjectId), String.class, DuplicateId.class, txn);
|
||||
txn.commitSync();
|
||||
core.getDuplicateIdODB().put(key, new DuplicateId(key, newObjectId));
|
||||
}
|
||||
|
||||
duplicate.put(objectId, newObjectId);
|
||||
@@ -1106,7 +1091,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
SWGObject object;
|
||||
if(objectId != 0 && containerId == 0) {
|
||||
if(portalCRC != 0) {
|
||||
if (core.getBuildingODB().contains(objectId, Long.class, BuildingObject.class) && !duplicate.containsValue(objectId))
|
||||
if (core.getSWGObjectODB().contains(objectId) && !duplicate.containsValue(objectId))
|
||||
continue;
|
||||
containers.add(objectId);
|
||||
object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz), null, true, false);
|
||||
@@ -1158,9 +1143,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
for(BuildingObject building : persistentBuildings) {
|
||||
building.createTransaction(core.getBuildingODB().getEnvironment());
|
||||
core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction());
|
||||
building.getTransaction().commitSync();
|
||||
core.getSWGObjectODB().put(building.getObjectID(), building);
|
||||
destroyObject(building);
|
||||
}
|
||||
|
||||
@@ -1187,16 +1170,12 @@ public class ObjectService implements INetworkDispatch {
|
||||
return count.get();
|
||||
}
|
||||
|
||||
public void persistObject(IPersistent object, Class<?> keyClass, Class<?> valueClass, ObjectDatabase odb) {
|
||||
object.createTransaction(odb.getEnvironment());
|
||||
core.getAuctionODB().put(object, keyClass, valueClass, object.getTransaction());
|
||||
object.getTransaction().commitSync();
|
||||
public void persistObject(long key, Object value, ObjectDatabase odb) {
|
||||
odb.put(key, value);
|
||||
}
|
||||
|
||||
public void deletePersistentObject(IPersistent object, Class<?> keyClass, Class<?> valueClass, ObjectDatabase odb, Object key) {
|
||||
object.createTransaction(odb.getEnvironment());
|
||||
core.getAuctionODB().delete(key, keyClass, valueClass, object.getTransaction());
|
||||
object.getTransaction().commitSync();
|
||||
public void deletePersistentObject(long key, ObjectDatabase odb) {
|
||||
odb.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
******************************************************************************/
|
||||
package services.playercities;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -40,8 +41,10 @@ import engine.resources.scene.Point3D;
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
public class PlayerCity {
|
||||
public class PlayerCity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int DESERTED = 0;
|
||||
public static final int OUTPOST = 1;
|
||||
public static final int VILLAGE = 2;
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.sleepycat.persist.EntityCursor;
|
||||
|
||||
import main.NGECore;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.database.ODBCursor;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -114,9 +115,8 @@ public class ResourceService implements INetworkDispatch {
|
||||
// createCollections2();
|
||||
// createCollections3();
|
||||
// } else {
|
||||
EntityCursor<ResourceRoot> cursor = core.getResourceRootsODB().getCursor(Integer.class, ResourceRoot.class);
|
||||
Iterator<ResourceRoot> it = cursor.iterator();
|
||||
if(!it.hasNext()) {
|
||||
ODBCursor cursor = core.getResourceRootsODB().getCursor();
|
||||
if(!cursor.hasNext()) {
|
||||
createCollections();
|
||||
createCollections2();
|
||||
createCollections3();
|
||||
@@ -133,12 +133,11 @@ public class ResourceService implements INetworkDispatch {
|
||||
|
||||
// loads the resource roots at server start
|
||||
public void loadResourceRoots() {
|
||||
EntityCursor<ResourceRoot> cursor = core.getResourceRootsODB().getCursor(Integer.class, ResourceRoot.class);
|
||||
Iterator<ResourceRoot> it = cursor.iterator();
|
||||
ODBCursor cursor = core.getResourceRootsODB().getCursor();
|
||||
int loadedResourceRootsCounter = 0;
|
||||
System.out.println("Loading resource roots...");
|
||||
while(it.hasNext()) {
|
||||
final ResourceRoot resourceRoot = it.next();
|
||||
while(cursor.hasNext()) {
|
||||
final ResourceRoot resourceRoot = (ResourceRoot) cursor.next();
|
||||
System.err.println("resourceRoot loaded ID: " + resourceRoot.getResourceRootID() + " " + resourceRoot.getResourceFileName());
|
||||
core.resourceService.add_resourceRoot(resourceRoot);
|
||||
loadedResourceRootsCounter++;
|
||||
@@ -154,12 +153,11 @@ public class ResourceService implements INetworkDispatch {
|
||||
|
||||
// loads the currently spawned resources at server start
|
||||
public void loadResources() {
|
||||
EntityCursor<GalacticResource> cursor = core.getResourcesODB().getCursor(Long.class, GalacticResource.class);
|
||||
Iterator<GalacticResource> it = cursor.iterator();
|
||||
ODBCursor cursor = core.getResourcesODB().getCursor();
|
||||
int loadedResourceCounter = 0;
|
||||
System.out.println("Loading resources...");
|
||||
while(it.hasNext()) {
|
||||
final GalacticResource resource = it.next();
|
||||
while(cursor.hasNext()) {
|
||||
final GalacticResource resource = (GalacticResource) cursor.next();
|
||||
System.err.println("resource " + resource.getName() + " rootID " + resource.getResourceRootID());
|
||||
core.objectService.getObjectList().put(resource.getId(), resource);
|
||||
|
||||
@@ -10800,9 +10798,7 @@ public class ResourceService implements INetworkDispatch {
|
||||
for (int i=0;i<indices;i++){
|
||||
ResourceRoot persistRoot = resourceRootTable.get(new Integer(i));
|
||||
System.err.println("Persisting Root with ID " + persistRoot.getResourceRootID() +" " + persistRoot.getResourceFileName());
|
||||
persistRoot.createTransaction(core.getResourceRootsODB().getEnvironment());
|
||||
core.getResourceRootsODB().put(persistRoot, Integer.class, ResourceRoot.class, persistRoot.getTransaction());
|
||||
persistRoot.getTransaction().commitSync();
|
||||
core.getResourceRootsODB().put((long) persistRoot.getResourceRootID(), persistRoot);
|
||||
}
|
||||
|
||||
|
||||
@@ -11183,15 +11179,11 @@ public class ResourceService implements INetworkDispatch {
|
||||
resource.setPoolNumber((byte)1);
|
||||
resource.initializeNewGalaxyResource(completeResourceNameHistory);
|
||||
|
||||
resource.createTransaction(core.getResourcesODB().getEnvironment());
|
||||
core.getResourcesODB().put(resource, Long.class, GalacticResource.class, resource.getTransaction());
|
||||
resource.getTransaction().commitSync();
|
||||
core.getResourcesODB().put(resource.getObjectID(), resource);
|
||||
|
||||
if (enableResourceHistory){
|
||||
GalacticResource historicResource = resource.convertToHistoricResource();
|
||||
historicResource.createTransaction(core.getResourceHistoryODB().getEnvironment());
|
||||
core.getResourceHistoryODB().put(historicResource, Long.class, GalacticResource.class, historicResource.getTransaction());
|
||||
historicResource.getTransaction().commitSync();
|
||||
core.getResourceHistoryODB().put(historicResource.getObjectID(), historicResource);
|
||||
}
|
||||
|
||||
completeResourceNameHistory.add(resource.getName());
|
||||
@@ -11212,15 +11204,11 @@ public class ResourceService implements INetworkDispatch {
|
||||
resource.setPoolNumber((byte)2);
|
||||
resource.initializeNewGalaxyResource(completeResourceNameHistory);
|
||||
|
||||
resource.createTransaction(core.getResourcesODB().getEnvironment());
|
||||
core.getResourcesODB().put(resource, Long.class, GalacticResource.class, resource.getTransaction());
|
||||
resource.getTransaction().commitSync();
|
||||
core.getResourcesODB().put(resource.getObjectID(), resource);
|
||||
|
||||
if (enableResourceHistory){
|
||||
GalacticResource historicResource = resource.convertToHistoricResource();
|
||||
historicResource.createTransaction(core.getResourceHistoryODB().getEnvironment());
|
||||
core.getResourceHistoryODB().put(historicResource, Long.class, GalacticResource.class, historicResource.getTransaction());
|
||||
historicResource.getTransaction().commitSync();
|
||||
core.getResourceHistoryODB().put(historicResource.getObjectID(), historicResource);
|
||||
}
|
||||
|
||||
completeResourceNameHistory.add(resource.getName());
|
||||
@@ -11241,15 +11229,11 @@ public class ResourceService implements INetworkDispatch {
|
||||
resource.setPoolNumber((byte)3);
|
||||
resource.initializeNewGalaxyResource(completeResourceNameHistory);
|
||||
|
||||
resource.createTransaction(core.getResourcesODB().getEnvironment());
|
||||
core.getResourcesODB().put(resource, Long.class, GalacticResource.class, resource.getTransaction());
|
||||
resource.getTransaction().commitSync();
|
||||
core.getResourcesODB().put(resource.getObjectID(), resource);
|
||||
|
||||
if (enableResourceHistory){
|
||||
GalacticResource historicResource = resource.convertToHistoricResource();
|
||||
historicResource.createTransaction(core.getResourceHistoryODB().getEnvironment());
|
||||
core.getResourceHistoryODB().put(historicResource, Long.class, GalacticResource.class, historicResource.getTransaction());
|
||||
historicResource.getTransaction().commitSync();
|
||||
core.getResourceHistoryODB().put(historicResource.getObjectID(), historicResource);
|
||||
}
|
||||
|
||||
completeResourceNameHistory.add(resource.getName());
|
||||
@@ -11271,15 +11255,11 @@ public class ResourceService implements INetworkDispatch {
|
||||
resource.setPlanetID(planetID);
|
||||
resource.initializeNewGalaxyResource(completeResourceNameHistory);
|
||||
|
||||
resource.createTransaction(core.getResourcesODB().getEnvironment());
|
||||
core.getResourcesODB().put(resource, Long.class, GalacticResource.class, resource.getTransaction());
|
||||
resource.getTransaction().commitSync();
|
||||
core.getResourcesODB().put(resource.getObjectID(), resource);
|
||||
|
||||
if (enableResourceHistory){
|
||||
GalacticResource historicResource = resource.convertToHistoricResource();
|
||||
historicResource.createTransaction(core.getResourceHistoryODB().getEnvironment());
|
||||
core.getResourceHistoryODB().put(historicResource, Long.class, GalacticResource.class, historicResource.getTransaction());
|
||||
historicResource.getTransaction().commitSync();
|
||||
core.getResourceHistoryODB().put(historicResource.getObjectID(), historicResource);
|
||||
}
|
||||
|
||||
completeResourceNameHistory.add(resource.getName());
|
||||
|
||||
@@ -21,28 +21,141 @@
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.datatables.Posture;
|
||||
import main.NGECore;
|
||||
import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import services.TerrainService;
|
||||
import services.SimulationService.MoveEvent;
|
||||
import services.ai.LairActor;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
|
||||
public class DynamicSpawnArea extends SpawnArea {
|
||||
|
||||
public DynamicSpawnArea(Planet planet, AbstractCollidable area) {
|
||||
private DynamicSpawnGroup spawnGroup;
|
||||
private Vector<CreatureObject> mobiles = new Vector<CreatureObject>();
|
||||
|
||||
public DynamicSpawnArea(Planet planet, AbstractCollidable area, DynamicSpawnGroup spawnGroup) {
|
||||
super(planet, area);
|
||||
this.spawnGroup = spawnGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onEnter(EnterEvent event) {
|
||||
|
||||
SWGObject object = event.object;
|
||||
|
||||
if(object == null || !(object instanceof CreatureObject))
|
||||
return;
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
if(creature.getSlottedObject("ghost") == null)
|
||||
return;
|
||||
|
||||
creature.getEventBus().subscribe(this);
|
||||
// spawn some creatures
|
||||
for(int i = 0; i < 5; i++)
|
||||
spawnCreature(creature);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onExit(ExitEvent event) {
|
||||
|
||||
SWGObject object = event.object;
|
||||
|
||||
if(object == null || !(object instanceof CreatureObject))
|
||||
return;
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
if(creature.getSlottedObject("ghost") == null)
|
||||
return;
|
||||
|
||||
creature.getEventBus().unsubscribe(this);
|
||||
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void onMove(MoveEvent event) {
|
||||
|
||||
SWGObject object = event.object;
|
||||
|
||||
if(object == null || !(object instanceof CreatureObject) || object.getContainer() != null)
|
||||
return;
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
if(creature.getSlottedObject("ghost") == null)
|
||||
return;
|
||||
|
||||
if(new Random().nextFloat() <= 0.25)
|
||||
spawnCreature(creature);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void spawnCreature(CreatureObject creature) {
|
||||
|
||||
NGECore core = NGECore.getInstance();
|
||||
|
||||
Iterator<CreatureObject> it = mobiles.iterator();
|
||||
it.forEachRemaining(mobile -> {
|
||||
if(mobile.getPosture() == Posture.Dead)
|
||||
it.remove();
|
||||
});
|
||||
|
||||
if(mobiles.size() >= spawnGroup.getMaxSpawns())
|
||||
return;
|
||||
|
||||
boolean foundPos = false;
|
||||
int tries = 0;
|
||||
Point3D randomPosition = null;
|
||||
|
||||
while(!foundPos && ++tries < 10) {
|
||||
|
||||
randomPosition = getRandomPosition(creature.getWorldPosition(), 32.f, 200.f);
|
||||
|
||||
if(randomPosition == null)
|
||||
return;
|
||||
|
||||
TerrainService terrainSvc = core.terrainService;
|
||||
|
||||
float height = terrainSvc.getHeight(getPlanet().getID(), randomPosition.x, randomPosition.z);
|
||||
randomPosition.y = height;
|
||||
|
||||
for(CreatureObject mobile : mobiles) {
|
||||
if(mobile.getWorldPosition().getDistance(randomPosition) > spawnGroup.getMinSpawnDistance())
|
||||
foundPos = true;
|
||||
}
|
||||
|
||||
if(!terrainSvc.canBuildAtPosition(creature, randomPosition.x, randomPosition.z))
|
||||
foundPos = false;
|
||||
|
||||
}
|
||||
|
||||
if(!foundPos)
|
||||
return;
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
String mobileTemplate = spawnGroup.getMobiles().get(random.nextInt(spawnGroup.getMobiles().size()));
|
||||
CreatureObject spawnedCreature = core.spawnService.spawnCreature(mobileTemplate, getPlanet().getName(), 0, randomPosition.x, randomPosition.y, randomPosition.z);
|
||||
if(spawnedCreature != null)
|
||||
mobiles.add(spawnedCreature);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class DynamicSpawnGroup {
|
||||
|
||||
private Vector<String> mobiles;
|
||||
private String name;
|
||||
private int maxSpawns;
|
||||
private int minSpawnDistance;
|
||||
|
||||
public Vector<String> getMobiles() {
|
||||
return mobiles;
|
||||
}
|
||||
|
||||
public void setMobiles(Vector<String> mobiles) {
|
||||
this.mobiles = mobiles;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getMaxSpawns() {
|
||||
return maxSpawns;
|
||||
}
|
||||
|
||||
public void setMaxSpawns(int maxSpawns) {
|
||||
this.maxSpawns = maxSpawns;
|
||||
}
|
||||
|
||||
public int getMinSpawnDistance() {
|
||||
return minSpawnDistance;
|
||||
}
|
||||
|
||||
public void setMinSpawnDistance(int minSpawnDistance) {
|
||||
this.minSpawnDistance = minSpawnDistance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class LairSpawnArea extends SpawnArea {
|
||||
randomPosition.y = height;
|
||||
|
||||
for(LairActor otherLair : lairs) {
|
||||
if(otherLair.getLairObject().getWorldPosition().getDistance(randomPosition) < 10)
|
||||
if(otherLair.getLairObject().getWorldPosition().getDistance(randomPosition) < 30)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class SpawnService {
|
||||
private Map<String, LairGroupTemplate> lairGroupTemplates = new ConcurrentHashMap<String, LairGroupTemplate>();
|
||||
private Map<String, LairTemplate> lairTemplates = new ConcurrentHashMap<String, LairTemplate>();
|
||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(4);
|
||||
private Map<String, DynamicSpawnGroup> dynamicGroupTemplates = new ConcurrentHashMap<String, DynamicSpawnGroup>();
|
||||
|
||||
public SpawnService(NGECore core) {
|
||||
this.core = core;
|
||||
@@ -304,6 +305,26 @@ public class SpawnService {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDynamicGroups() {
|
||||
Path p = Paths.get("scripts/mobiles/dynamicgroups");
|
||||
FileVisitor<Path> fv = new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
core.scriptService.callScript("scripts/mobiles/dynamicgroups/", file.getFileName().toString().replace(".py", ""), "addDynamicGroup", core);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
try {
|
||||
Files.walkFileTree(p, fv);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addDynamicGroup(String name, DynamicSpawnGroup dynamicSpawnGroup) {
|
||||
dynamicGroupTemplates.put(name, dynamicSpawnGroup);
|
||||
}
|
||||
|
||||
public void addLairGroup(String name, Vector<LairSpawnTemplate> lairSpawnTemplates) {
|
||||
lairGroupTemplates.put(name, new LairGroupTemplate(name, lairSpawnTemplates));
|
||||
}
|
||||
@@ -334,6 +355,18 @@ public class SpawnService {
|
||||
spawnAreas.get(planet).add(lairSpawnArea);
|
||||
core.simulationService.addCollidable(collidableCircle, x, z);
|
||||
}
|
||||
|
||||
public void addDynamicSpawnArea(String dynamicGroup, float x, float z, float radius, String planetName) {
|
||||
DynamicSpawnGroup dynamicGroupTemplate = dynamicGroupTemplates .get(dynamicGroup);
|
||||
Planet planet = core.terrainService.getPlanetByName(planetName);
|
||||
if(dynamicGroupTemplate == null || planet == null)
|
||||
return;
|
||||
CollidableCircle collidableCircle = new CollidableCircle(new Point3D(x, 0, z), radius, planet);
|
||||
DynamicSpawnArea dynamicSpawnArea = new DynamicSpawnArea(planet, collidableCircle, dynamicGroupTemplate);
|
||||
spawnAreas.get(planet).add(dynamicSpawnArea);
|
||||
core.simulationService.addCollidable(collidableCircle, x, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user