mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-19 09:03:02 -04:00
Created the RelationalServerFactory, which is the SDB equivalent to ServerFactory
This commit is contained in:
@@ -13,10 +13,10 @@ import resources.objects.SWGObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.server_info.Log;
|
||||
import resources.server_info.RelationalServerData;
|
||||
import resources.server_info.RelationalServerFactory;
|
||||
|
||||
public class ClientObjectLoader {
|
||||
|
||||
private static final String FILE_PREFIX = "serverdata/buildout/";
|
||||
private static final String GET_CLIENT_OBJECTS_SQL = "SELECT objects.*, areas.adjust_coordinates, areas.terrain "
|
||||
+ "FROM objects, areas "
|
||||
+ "WHERE areas.event == '' AND objects.area_id = areas.id "
|
||||
@@ -27,15 +27,15 @@ public class ClientObjectLoader {
|
||||
|
||||
public ClientObjectLoader() {
|
||||
strings = (CrcStringTableData) ClientFactory.getInfoFromFile("misc/object_template_crc_string_table.iff");
|
||||
clientSdb = new RelationalServerData(FILE_PREFIX+"buildouts.db");
|
||||
clientSdb = RelationalServerFactory.getServerData("buildout/buildouts.db", "areas", "objects");
|
||||
if (clientSdb == null)
|
||||
throw new main.ProjectSWG.CoreException("Unable to load sdb files for ClientObjectLoader");
|
||||
}
|
||||
|
||||
public Map<Long, SWGObject> loadClientObjects(Terrain terrain) {
|
||||
System.out.println("ClientObjectLoader: Loading client objects...");
|
||||
Log.i("ClientObjectLoader", "Loading client objects...");
|
||||
Map<Long, SWGObject> objects = new Hashtable<>(4*1024);
|
||||
if (!loadTables())
|
||||
return objects;
|
||||
try (ResultSet set = clientSdb.prepareStatement(GET_CLIENT_OBJECTS_SQL).executeQuery()) {
|
||||
set.setFetchSize(1500);
|
||||
ColumnIndexes ind = new ColumnIndexes(set);
|
||||
@@ -68,15 +68,6 @@ public class ClientObjectLoader {
|
||||
return obj;
|
||||
}
|
||||
|
||||
private boolean loadTables() {
|
||||
if (!clientSdb.linkTableWithSdb("areas", FILE_PREFIX+"areas.sdb") || !clientSdb.linkTableWithSdb("objects", FILE_PREFIX+"objects.sdb")) {
|
||||
System.err.println("ObjectManager: Failed to load client objects! Cannot link SDB");
|
||||
Log.e("ObjectManager", "Failed to load client object SDB files!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class ColumnIndexes {
|
||||
|
||||
public final int idInd;
|
||||
|
||||
Reference in New Issue
Block a user