mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-21 11:03:00 -04:00
Fixed spawning in the buildout buildings, fixed gm permissions, added command to lock and unlock server for gms
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
import sys
|
||||
from engine.resources.scene import Point3D
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
playerObject = actor.getSlottedObject('ghost')
|
||||
|
||||
if not playerObject:
|
||||
return
|
||||
|
||||
commandArgs = commandString.split(' ')
|
||||
command = commandArgs[0]
|
||||
if len(commandArgs) > 1:
|
||||
arg1 = commandArgs[1]
|
||||
if len(commandArgs) > 2:
|
||||
arg2 = commandArgs[2]
|
||||
if len(commandArgs) > 3:
|
||||
arg3 = commandArgs[3]
|
||||
if len(commandArgs) > 4:
|
||||
arg4 = commandArgs[4]
|
||||
|
||||
if not command:
|
||||
return
|
||||
|
||||
if command == 'lockServer':
|
||||
core.setGalaxyStatus(3)
|
||||
if command == 'unlockServer':
|
||||
core.setGalaxyStatus(2)
|
||||
|
||||
return
|
||||
@@ -168,6 +168,8 @@ public class NGECore {
|
||||
|
||||
private BusConfiguration eventBusConfig = BusConfiguration.Default(1, new ThreadPoolExecutor(1, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>()));
|
||||
|
||||
private ObjectDatabase buildingODB;
|
||||
|
||||
|
||||
public NGECore() {
|
||||
|
||||
@@ -209,6 +211,7 @@ 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);
|
||||
// Services
|
||||
@@ -305,6 +308,7 @@ public class NGECore {
|
||||
travelService.loadTravelPoints();
|
||||
simulationService = new SimulationService(this);
|
||||
|
||||
objectService.loadBuildings();
|
||||
terrainService.loadSnapShotObjects();
|
||||
simulationService.insertSnapShotObjects();
|
||||
|
||||
@@ -438,6 +442,10 @@ public class NGECore {
|
||||
return guildODB;
|
||||
}
|
||||
|
||||
public ObjectDatabase getBuildingODB() {
|
||||
return buildingODB;
|
||||
}
|
||||
|
||||
public int getActiveClients() {
|
||||
int connections = 0;
|
||||
for (Map.Entry<Integer, Client> c : clients.entrySet()) {
|
||||
|
||||
@@ -21,22 +21,29 @@
|
||||
******************************************************************************/
|
||||
package resources.objects.building;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import resources.objects.cell.CellObject;
|
||||
|
||||
import com.sleepycat.je.Environment;
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.IPersistent;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
@Entity
|
||||
public class BuildingObject extends SWGObject {
|
||||
public class BuildingObject extends SWGObject implements IPersistent {
|
||||
|
||||
@NotPersistent
|
||||
private BuildingMessageBuilder messageBuilder;
|
||||
@NotPersistent
|
||||
private Transaction txn;
|
||||
|
||||
public BuildingObject() {
|
||||
super();
|
||||
@@ -52,17 +59,21 @@ public class BuildingObject extends SWGObject {
|
||||
|
||||
final AtomicReference<CellObject> ref = new AtomicReference<CellObject>();
|
||||
|
||||
this.viewChildren(this, true, false, new Traverser() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject obj) {
|
||||
synchronized(objectMutex) {
|
||||
|
||||
this.viewChildren(this, true, false, new Traverser() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject obj) {
|
||||
|
||||
if(obj instanceof CellObject && ((CellObject) obj).getCellNumber() == cellNumber)
|
||||
ref.set((CellObject) obj);
|
||||
|
||||
}
|
||||
|
||||
if(obj instanceof CellObject && ((CellObject) obj).getCellNumber() == cellNumber)
|
||||
ref.set((CellObject) obj);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return ref.get();
|
||||
|
||||
@@ -83,4 +94,11 @@ public class BuildingObject extends SWGObject {
|
||||
|
||||
}
|
||||
|
||||
public Transaction getTransaction() { return txn; }
|
||||
|
||||
public void createTransaction(Environment env) {
|
||||
txn = env.beginTransaction(null, null);
|
||||
txn.setLockTimeout(500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -209,9 +209,10 @@ public class LoginService implements INetworkDispatch{
|
||||
public boolean checkForGmPermission(int id) {
|
||||
PreparedStatement preparedStatement;
|
||||
try {
|
||||
preparedStatement = databaseConnection1.preparedStatement("SELECT * FROM characters WHERE \"accountId\"=" + id + "");
|
||||
preparedStatement = databaseConnection1.preparedStatement("SELECT * FROM accounts WHERE id=" + id + "");
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
return resultSet.getBoolean("gmflag");
|
||||
if(resultSet.next())
|
||||
return resultSet.getBoolean("gmflag");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ public class SimulationService implements INetworkDispatch {
|
||||
core.commandService.registerGmCommand("setgodmode");
|
||||
core.commandService.registerCommand("requestwaypointatposition");
|
||||
core.commandService.registerCommand("meditate");
|
||||
core.commandService.registerGmCommand("server");
|
||||
|
||||
}
|
||||
|
||||
@@ -622,7 +623,7 @@ public class SimulationService implements INetworkDispatch {
|
||||
SWGObject obj = it.next();
|
||||
if(obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance(pos) > 200)
|
||||
continue;
|
||||
System.out.println(obj.getTemplate());
|
||||
//System.out.println(obj.getTemplate());
|
||||
object.makeAware(obj);
|
||||
if(obj.getClient() != null)
|
||||
obj.makeAware(object);
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import resources.common.FileUtilities;
|
||||
import resources.common.collidables.CollidableCircle;
|
||||
import resources.objects.building.BuildingObject;
|
||||
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
@@ -226,6 +227,26 @@ public class TerrainService {
|
||||
}
|
||||
}
|
||||
|
||||
synchronized(core.objectService.getObjectList()) {
|
||||
|
||||
for(SWGObject object : core.objectService.getObjectList().values()) {
|
||||
|
||||
if(!(object instanceof BuildingObject))
|
||||
continue;
|
||||
|
||||
BuildingObject building = (BuildingObject) object;
|
||||
|
||||
if(building.getTransaction() == null)
|
||||
continue;
|
||||
|
||||
building.createTransaction(core.getBuildingODB().getEnvironment());
|
||||
core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction());
|
||||
building.getTransaction().commitSync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canBuildAtPosition(SWGObject object, float x, float z) {
|
||||
|
||||
@@ -139,6 +139,32 @@ 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();
|
||||
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());
|
||||
}
|
||||
|
||||
});
|
||||
core.simulationService.add(building, building.getPosition().x, building.getPosition().z);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation, String customServerTemplate) {
|
||||
return createObject(Template, objectID, planet, position, orientation, customServerTemplate, false);
|
||||
}
|
||||
@@ -537,6 +563,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
if(creature.getParentId() != 0) {
|
||||
SWGObject parent = getObject(creature.getParentId());
|
||||
System.out.println("Building: " + parent.getContainer().getTemplate());
|
||||
parent._add(creature);
|
||||
}
|
||||
|
||||
@@ -558,9 +585,10 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
creature.makeAware(core.guildService.getGuildObject());
|
||||
core.chatService.loadMailHeaders(client);
|
||||
|
||||
core.simulationService.handleZoneIn(client);
|
||||
|
||||
creature.makeAware(creature);
|
||||
|
||||
|
||||
PlayerObject ghost = (PlayerObject) creature.getSlottedObject("ghost");
|
||||
|
||||
@@ -631,7 +659,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
if(obj.getParentId() != 0 && getObject(obj.getParentId()) != null) {
|
||||
SWGObject parent = getObject(obj.getParentId());
|
||||
parent.add(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,7 +779,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
portalCRC = (Integer) buildoutTable.getObject(i, 13);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(!template.equals("object/cell/shared_cell.iff") && objectId != 0 && getObject(objectId) != null) {
|
||||
//System.out.println("Duplicate buildout object: " + template);
|
||||
continue;
|
||||
@@ -762,7 +790,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
if(objectId != 0 && containerId == 0) {
|
||||
if(portalCRC != 0) {
|
||||
containers.add(objectId);
|
||||
object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz), null, true);
|
||||
object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz), null, true);
|
||||
((BuildingObject) object).createTransaction(core.getBuildingODB().getEnvironment());
|
||||
} else {
|
||||
object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz));
|
||||
}
|
||||
@@ -772,7 +801,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
object.setAttachment("bigSpawnRange", new Boolean(true));
|
||||
core.simulationService.add(object, object.getPosition().x, object.getPosition().z);
|
||||
} else if(containerId != 0) {
|
||||
object = createObject(template, objectId, planet, new Point3D(px, py, pz), new Quaternion(qw, qx, qy, qz));
|
||||
object = createObject(template, 0, planet, new Point3D(px, py, pz), new Quaternion(qw, qx, qy, qz));
|
||||
if(containers.contains(containerId)) {
|
||||
object.setisInSnapshot(false);
|
||||
containers.add(objectId);
|
||||
@@ -781,8 +810,16 @@ public class ObjectService implements INetworkDispatch {
|
||||
((CellObject) object).setCellNumber(cellIndex);
|
||||
SWGObject parent = getObject(containerId);
|
||||
|
||||
if(parent != null && object != null)
|
||||
if(parent != null && object != null) {
|
||||
if(parent instanceof BuildingObject && ((BuildingObject) parent).getCellByCellNumber(cellIndex) != null)
|
||||
continue;
|
||||
parent.add(object);
|
||||
/*if(parent instanceof BuildingObject) {
|
||||
((BuildingObject) parent).createTransaction(core.getBuildingODB().getEnvironment());
|
||||
core.getBuildingODB().put((BuildingObject) parent, Long.class, BuildingObject.class, ((BuildingObject) parent).getTransaction());
|
||||
((BuildingObject) parent).getTransaction().commitSync();
|
||||
}*/
|
||||
}
|
||||
} else {
|
||||
object = createObject(template, 0, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz));
|
||||
core.simulationService.add(object, object.getPosition().x, object.getPosition().z);
|
||||
|
||||
Reference in New Issue
Block a user