mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-26 11:13:16 -04:00
Fixed loading issue for SWGObject ODB, and removed the Creature ODB
This commit is contained in:
@@ -233,7 +233,6 @@ public class NGECore {
|
||||
private ObjectDatabase auctionODB;
|
||||
private ObjectDatabase resourceHistoryODB;
|
||||
private ObjectDatabase swgObjectODB;
|
||||
private ObjectDatabase creatureODB;
|
||||
private ObjectDatabase bountiesODB;
|
||||
private ObjectDatabase cityODB;
|
||||
|
||||
@@ -304,7 +303,6 @@ public class NGECore {
|
||||
}
|
||||
|
||||
setGalaxyStatus(GalaxyStatus.Loading);
|
||||
creatureODB = new ObjectDatabase("players", true, true, true, CreatureObject.class);
|
||||
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);
|
||||
@@ -672,10 +670,6 @@ public class NGECore {
|
||||
return databaseConnection2;
|
||||
}
|
||||
|
||||
public ObjectDatabase getCreatureODB() {
|
||||
return creatureODB;
|
||||
}
|
||||
|
||||
public ObjectDatabase getSWGObjectODB() {
|
||||
return swgObjectODB;
|
||||
}
|
||||
@@ -813,7 +807,6 @@ public class NGECore {
|
||||
}
|
||||
|
||||
public void closeODBs() {
|
||||
creatureODB.close();
|
||||
swgObjectODB.close();
|
||||
mailODB.close();
|
||||
guildODB.close();
|
||||
|
||||
@@ -204,6 +204,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
|
||||
|
||||
@@ -355,7 +355,7 @@ public class CharacterService implements INetworkDispatch {
|
||||
//core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", core, object);
|
||||
|
||||
System.out.println("Saving character with name: " + object.getCustomName());
|
||||
core.getCreatureODB().put(object.getObjectID(), object);
|
||||
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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -194,52 +195,10 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
while (cursor.hasNext()) {
|
||||
SWGObject object = (SWGObject) cursor.next();
|
||||
if (object != null && !(object instanceof BuildingObject))
|
||||
if (object != null && !(object instanceof BuildingObject) && !objectList.containsKey(object.getObjectID()))
|
||||
objectList.put(object.getObjectID(), object);
|
||||
}
|
||||
|
||||
cursor = core.getCreatureODB().getCursor();
|
||||
|
||||
while (cursor.hasNext()) {
|
||||
CreatureObject object = (CreatureObject) cursor.next();
|
||||
if (object != null) {
|
||||
System.out.println("Loaded character with name: " + object.getCustomName());
|
||||
objectList.put(object.getObjectID(), object);
|
||||
|
||||
loadServerTemplate(object);
|
||||
object.viewChildren(object, true, true, (child) -> loadServerTemplate(child));
|
||||
} else {
|
||||
System.err.println("Character was null!");
|
||||
}
|
||||
}
|
||||
|
||||
// Loading characters by using a lookup
|
||||
try {
|
||||
PreparedStatement ps = core.getDatabase1().preparedStatement("SELECT * FROM characters");
|
||||
ResultSet resultSet = ps.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
long objectId = resultSet.getLong("id");
|
||||
CreatureObject object = (CreatureObject) core.getCreatureODB().get(objectId);
|
||||
if (object != null) {
|
||||
if (object.getCustomName() == null || object.getCustomName().isEmpty()) {
|
||||
String first = resultSet.getString("firstName");
|
||||
String last = resultSet.getString("lastName");
|
||||
if (last.isEmpty())
|
||||
object.setCustomName(first);
|
||||
else
|
||||
object.setCustomName(first + " " + last);
|
||||
}
|
||||
System.out.println("Loaded character manually with name: " + object.getCustomName());
|
||||
objectList.put(objectId, object);
|
||||
} else {
|
||||
System.err.println("Attempt failed to recover character.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
loadBuildings();
|
||||
System.out.println("Finished loading objects.");
|
||||
}
|
||||
@@ -729,7 +688,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public CreatureObject getCreatureFromDB(long objectId) {
|
||||
CreatureObject object = (CreatureObject) core.getCreatureODB().get(objectId);
|
||||
CreatureObject object = (CreatureObject) core.getSWGObjectODB().get(objectId);
|
||||
if (object != null) {
|
||||
loadServerTemplate(object);
|
||||
object.viewChildren(object, true, true, (child) -> loadServerTemplate(child));
|
||||
|
||||
Reference in New Issue
Block a user