mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-11 21:45:43 -04:00
begin work on vendors, fixed highestid sql query(might fix crash bug)
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
|
||||
if actor.getCombatFlag() > 0:
|
||||
return
|
||||
|
||||
cell = actor.getContainer()
|
||||
building = actor.getGrandparent()
|
||||
ghost = actor.getSlottedObject('ghost')
|
||||
|
||||
if not ghost or not cell or not building or not core.housingService.getPermissions(player, cell)
|
||||
return
|
||||
|
||||
if ghost.getAmountOfVendors() >= actor.getSkillModBase('manage_vendor'):
|
||||
actor.sendSystemMessage('@player_structure:full_vendors', 0)
|
||||
return
|
||||
|
||||
|
||||
|
||||
return
|
||||
|
||||
@@ -24,6 +24,8 @@ def createRadial(core, owner, target, radials):
|
||||
radials.add(RadialOptions(2, 172, 0, 'Pack Up This Building'))
|
||||
radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_enter'))
|
||||
radials.add(RadialOptions(3, 123, 0, '@player_structure:permission_banned'))
|
||||
if owner.getSkillModBase('manage_vendor') >= 1:
|
||||
radials.add(RadialOptions(2, 130, 0, '@player_structure:create_vendor'))
|
||||
|
||||
return
|
||||
|
||||
@@ -73,5 +75,7 @@ def handleSelection(core, owner, target, option):
|
||||
if owner is not None:
|
||||
core.housingService.handlePermissionBan(owner,target)
|
||||
return
|
||||
|
||||
|
||||
if option == 130:
|
||||
if owner is not None and owner.getSkillModBase('manage_vendor') >= 1:
|
||||
core.commandService.callCommand(owner, 'createvendor', None, '')
|
||||
return
|
||||
|
||||
@@ -450,6 +450,7 @@ public class NGECore {
|
||||
simulationService = new SimulationService(this);
|
||||
|
||||
objectService.loadBuildings();
|
||||
harvesterService.loadHarvesters();
|
||||
|
||||
if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") > 0) {
|
||||
resourceService.loadResourceRoots();
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.objects.ObjectMessageBuilder;
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
@@ -151,6 +152,7 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
private transient boolean callingCompanion = false;
|
||||
|
||||
private long bountyMissionId;
|
||||
private Vector<Long> ownedVendors = new Vector<Long>();
|
||||
|
||||
public PlayerObject() {
|
||||
super();
|
||||
@@ -921,5 +923,21 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
public ObjectMessageBuilder getMessageBuilder() {
|
||||
return messageBuilder;
|
||||
}
|
||||
|
||||
public Vector<Long> getOwnedVendors() {
|
||||
return ownedVendors;
|
||||
}
|
||||
|
||||
public void addVendor(long vendorId) {
|
||||
ownedVendors.add(vendorId);
|
||||
}
|
||||
|
||||
public void removeVendor(long vendorId) {
|
||||
ownedVendors.remove(vendorId);
|
||||
}
|
||||
|
||||
public int getAmountOfVendors() {
|
||||
return ownedVendors.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ import resources.objects.building.BuildingObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.common.*;
|
||||
@@ -192,7 +193,7 @@ public class SimulationService implements INetworkDispatch {
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
SWGObject building = core.objectService.getObject(((SWGObject) cursor.next()).getObjectID());
|
||||
if(building == null || !(building instanceof BuildingObject))
|
||||
if(building == null || (!(building instanceof BuildingObject) && !(building instanceof HarvesterObject)))
|
||||
continue;
|
||||
if(building.getAttachment("hasLoadedServerTemplate") == null)
|
||||
core.objectService.loadServerTemplate(building);
|
||||
|
||||
@@ -81,6 +81,7 @@ public class BazaarService implements INetworkDispatch {
|
||||
|
||||
public BazaarService(NGECore core) {
|
||||
this.core = core;
|
||||
core.commandService.registerCommand("createvendor");
|
||||
loadAuctionItems();
|
||||
}
|
||||
|
||||
|
||||
@@ -708,6 +708,8 @@ public class ChatService implements INetworkDispatch {
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
Mail mail = (Mail) cursor.next();
|
||||
if(mail == null)
|
||||
continue;
|
||||
if(mail.getRecieverId() == obj.getObjectID()) {
|
||||
sendPersistentMessageHeader(client, mail);
|
||||
}
|
||||
|
||||
@@ -168,10 +168,15 @@ public class HousingService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
// Save structure to DB
|
||||
/*building.createTransaction(core.getBuildingODB().getEnvironment());
|
||||
core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction());
|
||||
building.getTransaction().commitSync();*/
|
||||
//core.objectService.persistObject(building.getObjectID(), building, core.getSWGObjectODB());
|
||||
|
||||
}
|
||||
|
||||
public void saveBuildings() {
|
||||
core.objectService.getObjectList()
|
||||
.values().stream()
|
||||
.filter(obj -> obj instanceof BuildingObject && obj.getAttachment("structureOwner") != null)
|
||||
.forEach(building -> core.objectService.persistObject(building.getObjectID(), building, core.getSWGObjectODB()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -157,6 +157,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
core.bazaarService.saveAllItems();
|
||||
core.housingService.saveBuildings();
|
||||
core.harvesterService.saveHarvesters();
|
||||
core.closeODBs();
|
||||
}
|
||||
});
|
||||
@@ -239,13 +241,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
object = new SurveyTool(objectID, planet, Template, position, orientation);
|
||||
|
||||
}
|
||||
// else if(Template.startsWith("object/tangible/container/drum/shared_treasure_drum.iff")) {
|
||||
//
|
||||
// object = new CreatureObject(objectID, planet, position, orientation, Template);
|
||||
//
|
||||
// }
|
||||
else if(Template.startsWith("object/tangible")) {
|
||||
} else if(Template.startsWith("object/tangible")) {
|
||||
|
||||
object = new TangibleObject(objectID, planet, Template, position, orientation);
|
||||
|
||||
@@ -253,7 +249,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
object = new IntangibleObject(objectID, planet, position, orientation,Template);
|
||||
|
||||
}else if(Template.startsWith("object/weapon")) {
|
||||
} else if(Template.startsWith("object/weapon")) {
|
||||
|
||||
object = new WeaponObject(objectID, planet, Template, position, orientation);
|
||||
|
||||
@@ -336,9 +332,10 @@ public class ObjectService implements INetworkDispatch {
|
||||
object.setAttachment("customServerTemplate", customServerTemplate);
|
||||
|
||||
object.setisInSnapshot(isSnapshot);
|
||||
if(!core.getObjectIdODB().contains(objectID))
|
||||
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
|
||||
|
||||
synchronized(objectMutex) {
|
||||
if(!core.getObjectIdODB().contains(objectID))
|
||||
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
|
||||
}
|
||||
// Set Options - easier to set them across the board here
|
||||
// because we'll be spawning them despite most of them being unscripted.
|
||||
// Any such settings can be completely reset with setOptionsBitmask
|
||||
@@ -618,24 +615,22 @@ public class ObjectService implements INetworkDispatch {
|
||||
long newId = 0;
|
||||
boolean found = false;
|
||||
// stack overflow when using recursion
|
||||
while(!found) {
|
||||
synchronized(objectMutex) {
|
||||
synchronized(objectMutex) {
|
||||
while(!found) {
|
||||
newId = highestId.incrementAndGet();
|
||||
PreparedStatement ps2;
|
||||
try {
|
||||
ps2 = databaseConnection.preparedStatement("UPDATE highestid SET id=" + newId + " WHERE id=(SELECT MAX(id) FROM highestid)");
|
||||
ps2.executeUpdate();
|
||||
ps2.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(objectList.containsKey(newId) || core.getObjectIdODB().contains(newId))
|
||||
found = false;
|
||||
else
|
||||
found = true;
|
||||
}
|
||||
|
||||
PreparedStatement ps2;
|
||||
|
||||
try {
|
||||
ps2 = databaseConnection.preparedStatement("UPDATE highestid SET id=" + newId + " WHERE id=" + (newId-1));
|
||||
ps2.executeUpdate();
|
||||
ps2.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(getObject(newId) != null || core.getObjectIdODB().contains(newId))
|
||||
found = false;
|
||||
else
|
||||
found = true;
|
||||
}
|
||||
|
||||
return newId;
|
||||
|
||||
@@ -47,12 +47,15 @@ import main.NGECore;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.common.CRC;
|
||||
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;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.harvester.HarvesterMessageBuilder;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
@@ -95,6 +98,35 @@ public class HarvesterService implements INetworkDispatch {
|
||||
scheduleHarvesterService();
|
||||
}
|
||||
|
||||
public void loadHarvesters() {
|
||||
ODBCursor cursor = core.getSWGObjectODB().getCursor();
|
||||
|
||||
while(cursor.hasNext()) {
|
||||
final SWGObject harvester = (SWGObject) cursor.next();
|
||||
if(!(harvester instanceof HarvesterObject) || harvester == null)
|
||||
continue;
|
||||
core.objectService.getObjectList().put(harvester.getObjectID(), harvester);
|
||||
Planet planet = core.terrainService.getPlanetByID(harvester.getPlanetId());
|
||||
harvester.setPlanet(planet);
|
||||
harvester.viewChildren(harvester, true, true, (object) -> {
|
||||
core.objectService.getObjectList().put(object.getObjectID(), object);
|
||||
if(object.getParentId() != 0 && object.getContainer() == null)
|
||||
object.setParent(harvester);
|
||||
object.getContainerInfo(object.getTemplate());
|
||||
});
|
||||
allHarvesters.add((HarvesterObject) harvester);
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
public void saveHarvesters() {
|
||||
for(HarvesterObject harvester : allHarvesters) {
|
||||
core.objectService.persistObject(harvester.getObjectID(), harvester, core.getSWGObjectODB());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> swgOpcodes, Map<Integer, INetworkRemoteEvent> objControllerOpcodes) {
|
||||
|
||||
@@ -1055,6 +1087,7 @@ public class HarvesterService implements INetworkDispatch {
|
||||
//NGECore.getInstance().chatService.sendPersistentMessage(actor.getClient(), constructionNotificationMail);
|
||||
NGECore.getInstance().chatService.storePersistentMessage(constructionNotificationMail);
|
||||
NGECore.getInstance().chatService.sendPersistentMessageHeader(actor.getClient(), constructionNotificationMail);
|
||||
//core.objectService.persistObject(harvester.getObjectID(), harvester, core.getSWGObjectODB());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user