mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-07-14 00:02:07 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
This commit is contained in:
Binary file not shown.
@@ -242,7 +242,8 @@ public class NGECore {
|
||||
public static boolean PACKET_DEBUG = false;
|
||||
|
||||
public NGECore() {
|
||||
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
@@ -513,7 +514,7 @@ public class NGECore {
|
||||
|
||||
terrainService.loadSnapShotObjects();
|
||||
objectService.loadServerTemplates();
|
||||
objectService.loadBuildings();
|
||||
objectService.loadObjects();
|
||||
harvesterService.loadHarvesters();
|
||||
|
||||
simulationService.insertSnapShotObjects();
|
||||
@@ -828,7 +829,7 @@ public class NGECore {
|
||||
public long getGalacticTime() {
|
||||
return System.currentTimeMillis() - galacticTime;
|
||||
}
|
||||
|
||||
|
||||
public void closeODBs() {
|
||||
swgObjectODB.close();
|
||||
mailODB.close();
|
||||
|
||||
@@ -83,159 +83,130 @@ public class SWGSet<E> implements Set<E>, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean add(E e) {
|
||||
synchronized(objectMutex) {
|
||||
if (valid(e)) {
|
||||
if (set.add(e)) {
|
||||
queue(item(1, e, null, true, false));
|
||||
return true;
|
||||
}
|
||||
public synchronized boolean add(E e) {
|
||||
if (valid(e)) {
|
||||
if (set.add(e)) {
|
||||
queue(item(1, e, null, true, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized boolean addAll(Collection<? extends E> c) {
|
||||
List<byte[]> buffer = new ArrayList<byte[]>();
|
||||
|
||||
for (E e : c) {
|
||||
if (valid(e) && set.add(e)) {
|
||||
buffer.add(item(1, e, null, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer.size() > 0) {
|
||||
queue(buffer);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
synchronized(objectMutex) {
|
||||
List<byte[]> buffer = new ArrayList<byte[]>();
|
||||
|
||||
for (E e : c) {
|
||||
if (valid(e) && set.add(e)) {
|
||||
buffer.add(item(1, e, null, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer.size() > 0) {
|
||||
queue(buffer);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
public synchronized void clear() {
|
||||
set.clear();
|
||||
queue(item(2, null, null, false, false));
|
||||
}
|
||||
|
||||
public synchronized boolean contains(Object o) {
|
||||
return set.contains(o);
|
||||
}
|
||||
|
||||
public synchronized boolean containsAll(Collection<?> c) {
|
||||
return set.containsAll(c);
|
||||
}
|
||||
|
||||
public synchronized boolean isEmpty() {
|
||||
return set.isEmpty();
|
||||
}
|
||||
|
||||
public synchronized Iterator<E> iterator() {
|
||||
return set.iterator();
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Object e) {
|
||||
if (valid(e) && set.remove(e)) {
|
||||
queue(item(0, e, null, true, false));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized boolean removeAll(Collection<?> c) {
|
||||
List<byte[]> buffer = new ArrayList<byte[]>();
|
||||
|
||||
for (Object o : c) {
|
||||
if (valid(o) && set.remove(o)) {
|
||||
buffer.add(item(0, o, null, true, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
synchronized(objectMutex) {
|
||||
set.clear();
|
||||
queue(item(2, null, null, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(Object o) {
|
||||
synchronized(objectMutex) {
|
||||
return set.contains(o);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
synchronized(objectMutex) {
|
||||
return set.containsAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
synchronized(objectMutex) {
|
||||
return set.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<E> iterator() {
|
||||
synchronized(objectMutex) {
|
||||
return set.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove(Object e) {
|
||||
synchronized(objectMutex) {
|
||||
if (valid(e) && set.remove(e)) {
|
||||
queue(item(0, e, null, true, false));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (buffer.size() > 0) {
|
||||
queue(buffer);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
synchronized(objectMutex) {
|
||||
List<byte[]> buffer = new ArrayList<byte[]>();
|
||||
|
||||
for (Object o : c) {
|
||||
if (valid(o) && set.remove(o)) {
|
||||
buffer.add(item(0, o, null, true, false));
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer.size() > 0) {
|
||||
queue(buffer);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
public synchronized boolean retainAll(Collection<?> c) {
|
||||
synchronized(objectMutex) {
|
||||
return set.retainAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
synchronized(objectMutex) {
|
||||
return set.size();
|
||||
}
|
||||
public synchronized int size() {
|
||||
return set.size();
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
synchronized(objectMutex) {
|
||||
return set.toArray();
|
||||
}
|
||||
public synchronized Object[] toArray() {
|
||||
return set.toArray();
|
||||
}
|
||||
|
||||
public <T> T[] toArray(T[] a) {
|
||||
synchronized(objectMutex) {
|
||||
return set.toArray(a);
|
||||
}
|
||||
public synchronized <T> T[] toArray(T[] a) {
|
||||
return set.toArray(a);
|
||||
}
|
||||
|
||||
public int getUpdateCounter() {
|
||||
synchronized(objectMutex) {
|
||||
return updateCounter;
|
||||
}
|
||||
public synchronized int getUpdateCounter() {
|
||||
return updateCounter;
|
||||
}
|
||||
|
||||
public Object getMutex() {
|
||||
return objectMutex;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
synchronized(objectMutex) {
|
||||
byte[] objects = { };
|
||||
int size = 0;
|
||||
public synchronized byte[] getBytes() {
|
||||
byte[] objects = { };
|
||||
int size = 0;
|
||||
|
||||
for (Object o : set) {
|
||||
byte[] object = Baseline.toBytes(o);
|
||||
size += object.length;
|
||||
|
||||
for (Object o : set) {
|
||||
byte[] object = Baseline.toBytes(o);
|
||||
size += object.length;
|
||||
|
||||
IoBuffer buffer = Delta.createBuffer(size);
|
||||
buffer.put(objects);
|
||||
if (addByte) buffer.put((byte) 0);
|
||||
buffer.put(object);
|
||||
buffer.flip();
|
||||
|
||||
objects = buffer.array();
|
||||
}
|
||||
|
||||
IoBuffer buffer = Delta.createBuffer(8 + size);
|
||||
buffer.putInt(set.size());
|
||||
buffer.putInt(updateCounter);
|
||||
IoBuffer buffer = Delta.createBuffer(size);
|
||||
buffer.put(objects);
|
||||
if (addByte) buffer.put((byte) 0);
|
||||
buffer.put(object);
|
||||
buffer.flip();
|
||||
|
||||
return buffer.array();
|
||||
objects = buffer.array();
|
||||
}
|
||||
|
||||
IoBuffer buffer = Delta.createBuffer(8 + size);
|
||||
buffer.putInt(set.size());
|
||||
buffer.putInt(updateCounter);
|
||||
buffer.put(objects);
|
||||
buffer.flip();
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
private boolean valid(Object o) {
|
||||
|
||||
@@ -205,6 +205,9 @@ public class CreatureObject extends TangibleObject implements Serializable {
|
||||
public CreatureObject() {
|
||||
super();
|
||||
messageBuilder = new CreatureMessageBuilder(this);
|
||||
System.out.println("Name: " + getCustomName());
|
||||
System.out.println(" Cash Credits: " + cashCredits);
|
||||
System.out.println(" Bank Credits: " + bankCredits);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,87 +67,63 @@ public class WaypointObject extends IntangibleObject implements Serializable, ID
|
||||
super.init();
|
||||
}
|
||||
|
||||
public int getCellId() {
|
||||
synchronized(objectMutex) {
|
||||
return cellId;
|
||||
}
|
||||
public synchronized int getCellId() {
|
||||
return cellId;
|
||||
}
|
||||
|
||||
|
||||
public void setCellId(int cellId) {
|
||||
synchronized(objectMutex) {
|
||||
this.cellId = cellId;
|
||||
}
|
||||
public synchronized void setCellId(int cellId) {
|
||||
this.cellId = cellId;
|
||||
}
|
||||
|
||||
|
||||
public long getLocationNetworkId() {
|
||||
synchronized(objectMutex) {
|
||||
return locationNetworkId;
|
||||
}
|
||||
public synchronized long getLocationNetworkId() {
|
||||
return locationNetworkId;
|
||||
}
|
||||
|
||||
|
||||
public void setLocationNetworkId(long locationNetworkId) {
|
||||
synchronized(objectMutex) {
|
||||
this.locationNetworkId = locationNetworkId;
|
||||
}
|
||||
public synchronized void setLocationNetworkId(long locationNetworkId) {
|
||||
this.locationNetworkId = locationNetworkId;
|
||||
}
|
||||
|
||||
|
||||
public int getPlanetCRC() {
|
||||
synchronized(objectMutex) {
|
||||
return planetCRC;
|
||||
}
|
||||
public synchronized int getPlanetCRC() {
|
||||
return planetCRC;
|
||||
}
|
||||
|
||||
|
||||
public void setPlanetCRC(int planetCRC) {
|
||||
synchronized(objectMutex) {
|
||||
this.planetCRC = planetCRC;
|
||||
}
|
||||
public synchronized void setPlanetCRC(int planetCRC) {
|
||||
this.planetCRC = planetCRC;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
synchronized(objectMutex) {
|
||||
return name;
|
||||
}
|
||||
public synchronized String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
synchronized(objectMutex) {
|
||||
this.name = name;
|
||||
}
|
||||
public synchronized void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public byte getColor() {
|
||||
synchronized(objectMutex) {
|
||||
return color;
|
||||
}
|
||||
public synchronized byte getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
public void setColor(byte color) {
|
||||
synchronized(objectMutex) {
|
||||
this.color = color;
|
||||
}
|
||||
public synchronized void setColor(byte color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
public boolean isActive() {
|
||||
synchronized(objectMutex) {
|
||||
return isActive;
|
||||
}
|
||||
public synchronized boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
|
||||
public void setActive(boolean isActive) {
|
||||
synchronized(objectMutex) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -354,6 +354,7 @@ public class CharacterService implements INetworkDispatch {
|
||||
createStarterClothing(object, sharedRaceTemplate, clientCreateCharacter.getStarterProfession());
|
||||
//core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", core, object);
|
||||
|
||||
System.out.println("Saving character with name: " + object.getCustomName());
|
||||
core.getSWGObjectODB().put(object.getObjectID(), object);
|
||||
|
||||
PreparedStatement ps = databaseConnection.preparedStatement("INSERT INTO characters (id, \"firstName\", \"lastName\", \"accountId\", \"galaxyId\", \"statusId\", appearance, gmflag) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
|
||||
@@ -55,6 +55,7 @@ import resources.harvest.SurveyTool;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.python.antlr.PythonParser.list_for_return;
|
||||
import org.python.core.Py;
|
||||
import org.python.core.PyObject;
|
||||
|
||||
@@ -170,6 +171,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
core.harvesterService.saveHarvesters();
|
||||
core.playerCityService.saveAllCities();
|
||||
core.closeODBs();
|
||||
System.out.println("Databases closed.");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -187,7 +189,21 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadBuildings() {
|
||||
public void loadObjects() {
|
||||
System.out.println("Loading objects...");
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
while (cursor.hasNext()) {
|
||||
SWGObject object = (SWGObject) cursor.next();
|
||||
if (object != null && !(object instanceof BuildingObject) && !objectList.containsKey(object.getObjectID()))
|
||||
objectList.put(object.getObjectID(), object);
|
||||
}
|
||||
|
||||
loadBuildings();
|
||||
System.out.println("Finished loading objects.");
|
||||
}
|
||||
|
||||
private void loadBuildings() {
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
@@ -251,15 +267,17 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
synchronized(objectMutex) {
|
||||
if(objectID == 0)
|
||||
objectID = generateObjectID();
|
||||
else
|
||||
isSnapshot = !overrideSnapshot;
|
||||
|
||||
if(!core.getObjectIdODB().contains(objectID))
|
||||
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
|
||||
}
|
||||
if (objectID == 0) {
|
||||
synchronized(objectMutex) {
|
||||
if(objectID == 0)
|
||||
objectID = generateObjectID();
|
||||
|
||||
if(!core.getObjectIdODB().contains(objectID))
|
||||
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
|
||||
}
|
||||
} else
|
||||
isSnapshot = !overrideSnapshot;
|
||||
|
||||
|
||||
if (planet == null) {
|
||||
System.err.println("Planet is null in createObject for some reason.");
|
||||
@@ -433,10 +451,10 @@ public class ObjectService implements INetworkDispatch {
|
||||
SWGObject ret = objectList.put(objectID, object);
|
||||
|
||||
//if (ret != null && !ret.getTemplate().equals(object.getTemplate())) {
|
||||
if (ret == null) {
|
||||
//System.err.println("ObjectService: Detected duplicate Id. Assigning new one.")
|
||||
object = createObject(Template, objectID, planet, position, orientation, customServerTemplate, overrideSnapshot, loadServerTemplate);
|
||||
}
|
||||
// if (ret == null) {
|
||||
// //System.err.println("ObjectService: Detected duplicate Id. Assigning new one.")
|
||||
// object = createObject(Template, objectID, planet, position, orientation, customServerTemplate, overrideSnapshot, loadServerTemplate);
|
||||
// }
|
||||
|
||||
return object;
|
||||
}
|
||||
@@ -498,7 +516,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
if (objectList.containsKey(objectID)) {
|
||||
System.err.println("getObject(): object is null but objectList contains objectID key");
|
||||
} else {
|
||||
//System.err.println("getObject(): object is null");
|
||||
// System.err.println("getObject(): object is null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,10 +688,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public CreatureObject getCreatureFromDB(long objectId) {
|
||||
SWGObject object = (SWGObject) core.getSWGObjectODB().get(objectId);
|
||||
if(!(object instanceof CreatureObject))
|
||||
return null;
|
||||
if (object != null && getObject(object.getObjectID()) == null) {
|
||||
CreatureObject object = (CreatureObject) core.getSWGObjectODB().get(objectId);
|
||||
if (object != null) {
|
||||
loadServerTemplate(object);
|
||||
object.viewChildren(object, true, true, (child) -> loadServerTemplate(child));
|
||||
}
|
||||
@@ -986,7 +1002,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
if(creature == null) {
|
||||
System.out.println("Cant get creature from db");
|
||||
} else {
|
||||
if (creature.getCustomName() == null || creature.getCustomName() == "") {
|
||||
if (creature.getCustomName() == null || creature.getCustomName().isEmpty()) {
|
||||
System.err.println("Name: " + creature.getCustomName());
|
||||
System.out.println("Player with ObjID of " + creature.getObjectID() + " tried logging in but has a null/empty name!");
|
||||
return;
|
||||
}
|
||||
@@ -998,6 +1015,9 @@ public class ObjectService implements INetworkDispatch {
|
||||
return;
|
||||
|
||||
creature = (CreatureObject) getObject(objectId);
|
||||
if (creature.getCustomName() == null || creature.getCustomName().isEmpty()) {
|
||||
System.err.println("Creature's custom name was null/empty! Name: " + creature.getCustomName());
|
||||
}
|
||||
if(creature.getAttachment("disconnectTask") != null && creature.getClient() != null && !creature.getClient().getSession().isClosing())
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user