diff --git a/options.cfg b/options.cfg index 0a08fe99..9d9cd740 100644 --- a/options.cfg +++ b/options.cfg @@ -4,11 +4,11 @@ LOAD.SNAPSHOT_OBJECTS=1 # Toggles the loading of /clientdata/buildouts. # 1 = Enabled, 0 = Disabled. -LOAD.BUILDOUT_OBJECTS=0 +LOAD.BUILDOUT_OBJECTS=1 # Toggles the loading of /clinetdata/buildouts for a paticular terrain. # Specify the terrain. This line should be commented out to be disabled. -LOAD.BUILDOUT_ONLY_FOR=tatooine +#LOAD.BUILDOUT_ONLY_FOR=tatooine # Toggles Loading Old/Creating new/Spawning New Resources. # 1 = On, 0 = Off. diff --git a/scripts/mobiles/generic/faction/imperial/eow_fbase_imperial_corporal.py b/scripts/mobiles/generic/faction/imperial/eow_fbase_imperial_corporal.py index 25b38ea1..333fc3cc 100644 --- a/scripts/mobiles/generic/faction/imperial/eow_fbase_imperial_corporal.py +++ b/scripts/mobiles/generic/faction/imperial/eow_fbase_imperial_corporal.py @@ -34,8 +34,8 @@ def addTemplate(core): mobileTemplate.setWeaponTemplateVector(weaponTemplates) attacks = Vector() - #mobileTemplate.setDefaultAttack('rangedShot') - #mobileTemplate.setAttacks(attacks) + mobileTemplate.setDefaultAttack('rangedShot') + mobileTemplate.setAttacks(attacks) core.spawnService.addMobileTemplate('eow_fbase_imperial_corporal', mobileTemplate) return \ No newline at end of file diff --git a/scripts/mobiles/generic/faction/imperial/eow_fbase_stormtrooper.py b/scripts/mobiles/generic/faction/imperial/eow_fbase_stormtrooper.py index c94f48f6..1244e263 100644 --- a/scripts/mobiles/generic/faction/imperial/eow_fbase_stormtrooper.py +++ b/scripts/mobiles/generic/faction/imperial/eow_fbase_stormtrooper.py @@ -34,8 +34,8 @@ def addTemplate(core): mobileTemplate.setWeaponTemplateVector(weaponTemplates) attacks = Vector() - #mobileTemplate.setDefaultAttack('rangedShot') - #mobileTemplate.setAttacks(attacks) + mobileTemplate.setDefaultAttack('rangedShot') + mobileTemplate.setAttacks(attacks) core.spawnService.addMobileTemplate('eow_fbase_stormtrooper', mobileTemplate) return \ No newline at end of file diff --git a/scripts/static_spawns/tatooine/jabbas_palace.py b/scripts/static_spawns/tatooine/jabbas_palace.py index acbe4b6a..c1f61b37 100644 --- a/scripts/static_spawns/tatooine/jabbas_palace.py +++ b/scripts/static_spawns/tatooine/jabbas_palace.py @@ -75,7 +75,8 @@ def addPlanetSpawns(core, planet): #outside Palace smuggler = stcSvc.spawnObject('object/mobile/shared_dressed_tatooine_jabba_henchman.iff', 'tatooine', long(0), float(-5863), float(90), float(-6198.2), float(0.71), float(0), float(0.70), float(0)) #still need to find correct template - smuggler.setCustomName('Smuggler Pilot') - smuggler.setOptionsBitmask(256) + if smuggler: + smuggler.setCustomName('Smuggler Pilot') + smuggler.setOptionsBitmask(256) return diff --git a/scripts/static_spawns/tatooine/mos_entha.py b/scripts/static_spawns/tatooine/mos_entha.py index 5b61aee2..838733e6 100644 --- a/scripts/static_spawns/tatooine/mos_entha.py +++ b/scripts/static_spawns/tatooine/mos_entha.py @@ -17,7 +17,7 @@ def addPlanetSpawns(core, planet): #Outside ankwee = stcSvc.spawnObject('object/mobile/shared_dressed_tatooine_entha_ankwee.iff', 'tatooine', long(0), float(1351), float(5.0), float(3108), float(0.42), float(0.91)) - ankwee.setCustomName2('An\'kwee') + ankwee.setCustomName('An\'kwee') ankwee.setOptionsBitmask(256) sarlin = stcSvc.spawnObject('sarlin', 'tatooine', long(0), float(1537), float(7), float(3052), float(0.6), float(0.8)) diff --git a/scripts/static_spawns/tatooine/mos_espa.py b/scripts/static_spawns/tatooine/mos_espa.py index ce0fb2c7..09829cd8 100644 --- a/scripts/static_spawns/tatooine/mos_espa.py +++ b/scripts/static_spawns/tatooine/mos_espa.py @@ -33,39 +33,39 @@ def addPlanetSpawns(core, planet): #Exterior Uninteractable NPCs commoner18 = stcSvc.spawnObject('object/mobile/shared_dressed_commoner_naboo_zabrak_female_02.iff', 'tatooine', long(0), float(-2915.3), float(5.0), float(2148.5), float(0), float(0)) - commoner18.setCustomName2('a Commoner') + commoner18.setCustomName('a Commoner') commoner18.setOptionsBitmask(256) jawa10 = stcSvc.spawnObject('object/mobile/shared_jawa.iff', 'tatooine', long(0), float(-2966.3), float(5.0), float(2196.9), float(0), float(0)) - jawa10.setCustomName2('a Jawa') + jawa10.setCustomName('a Jawa') jawa10.setOptionsBitmask(256) commoner19 = stcSvc.spawnObject('object/mobile/shared_dressed_commoner_naboo_human_male_06.iff', 'tatooine', long(0), float(-2960.4), float(5.0), float(2271.3), float(0), float(0)) - commoner19.setCustomName2('a Commoner') + commoner19.setCustomName('a Commoner') commoner19.setOptionsBitmask(256) commoner20 = stcSvc.spawnObject('object/mobile/shared_dressed_commoner_tatooine_devaronian_male_01.iff', 'tatooine', long(0), float(-2934.3), float(5.0), float(2298.9), float(0.71), float(0.71)) - commoner20.setCustomName2('a Commoner') + commoner20.setCustomName('a Commoner') commoner20.setOptionsBitmask(256) commoner21 = stcSvc.spawnObject('object/mobile/shared_dressed_noble_human_female_01.iff', 'tatooine', long(0), float(-2897.7), float(5.0), float(2345.4), float(0.71), float(0.71)) - commoner21.setCustomName2('a Commoner') + commoner21.setCustomName('a Commoner') commoner21.setOptionsBitmask(256) commoner22 = stcSvc.spawnObject('object/mobile/shared_dressed_commoner_fat_twilek_male_01.iff', 'tatooine', long(0), float(-2763.8), float(5.0), float(2305.2), float(0.71), float(0.71)) - commoner22.setCustomName2('a Commoner') + commoner22.setCustomName('a Commoner') commoner22.setOptionsBitmask(256) jawa11 = stcSvc.spawnObject('object/mobile/shared_jawa.iff', 'tatooine', long(0), float(-2936.8), float(5.0), float(2078.4), float(0.95105), float(0.3090)) - jawa11.setCustomName2('a Jawa') + jawa11.setCustomName('a Jawa') jawa11.setOptionsBitmask(256) businessman4 = stcSvc.spawnObject('object/mobile/shared_dressed_commoner_tatooine_trandoshan_male_02.iff', 'tatooine', long(0), float(-2914.2), float(5.0), float(2022.4), float(0), float(0)) - businessman4.setCustomName2('a Businessman') + businessman4.setCustomName('a Businessman') businessman4.setOptionsBitmask(256) commoner23 = stcSvc.spawnObject('object/mobile/shared_dressed_commoner_naboo_moncal_male_01.iff', 'tatooine', long(0), float(-2904.1), float(5.0), float(1965.3), float(0.71), float(0.71)) - commoner23.setCustomName2('a Commoner') + commoner23.setCustomName('a Commoner') commoner23.setOptionsBitmask(256) #Junkdealer will be added as soon as i can find coords diff --git a/src/services/StaticService.java b/src/services/StaticService.java index 0af320d3..e09c2288 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -127,11 +127,9 @@ public class StaticService implements INetworkDispatch { long buildingId = 0; int cellNumber = 0; - SWGObject cell = null; + SWGObject cell = core.objectService.getObject(cellId); - if (cellId != 0L && cellId != 0) { - cell = core.objectService.getObject(cellId); - } else { + if (cellId != 0 && cell == null) { System.err.println("CellId invalid for template " + template); return null; } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 0106b1e3..a90b620d 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -161,6 +161,8 @@ public class ObjectService implements INetworkDispatch { private int iteratedReusedIds = 0; private List reusableIds = Collections.synchronizedList(new ArrayList()); + private boolean buildoutDEBUG = false; + public ObjectService(final NGECore core) { this.core = core; databaseConnection = core.getDatabase1(); @@ -236,10 +238,12 @@ public class ObjectService implements INetworkDispatch { Planet planet = core.terrainService.getPlanetByID(building.getPlanetId()); building.setPlanet(planet); building.viewChildren(building, true, true, (object) -> { - objectList.put(object.getObjectID(), object); - if(object.getParentId() != 0 && object.getContainer() == null) - object.setParent(building); - object.getContainerInfo(object.getTemplate()); + if (!checkIfObjectAlreadyInList(object.getObjectID())) { + objectList.put(object.getObjectID(), object); + if(object.getParentId() != 0 && object.getContainer() == null) + object.setParent(building); + object.getContainerInfo(object.getTemplate()); + } }); SWGObject sign = (SWGObject) building.getAttachment("sign"); if(sign != null) { @@ -737,6 +741,8 @@ public class ObjectService implements INetworkDispatch { } } + cursor.close(); + return null; } @@ -1527,7 +1533,7 @@ public class ObjectService implements INetworkDispatch { public void readBuildoutDatatable(DatatableVisitor buildoutTable, Planet planet, float x1, float z1) throws InstantiationException, IllegalAccessException { CrcStringTableVisitor crcTable = ClientFileManager.loadFile("misc/object_template_crc_string_table.iff", CrcStringTableVisitor.class); - + String planetName = planet.getName(); Map duplicate = new HashMap(); for (int i = 0; i < buildoutTable.getRowCount(); i++) { @@ -1581,6 +1587,7 @@ public class ObjectService implements INetworkDispatch { } + // Treeku - Refactored to work around duplicate objectIds // Required for instances/heroics which are duplicated ie. 10 times //if(!template.equals("object/cell/shared_cell.iff") && objectId != 0 && getObject(objectId) != null) { @@ -1599,8 +1606,9 @@ public class ObjectService implements INetworkDispatch { if (duplicate.containsKey(containerId)) { containerId = duplicate.get(containerId); } - - String planetName = planet.getName(); + + + // TODO needs to a way to work for mustafar and kashyyyk which both have instances //if (objectId != 0 && getObject(objectId) != null && (planetName.contains("dungeon") || planetName.contains("adventure"))) { @@ -1621,36 +1629,55 @@ public class ObjectService implements INetworkDispatch { duplicate.put(objectId, newObjectId); objectId = newObjectId; } + List containers = new ArrayList(); SWGObject object; if(objectId != 0 && containerId == 0) { - if(portalCRC != 0) { - - if (core.getSWGObjectODB().contains(objectId) && !duplicate.containsValue(objectId)){ + if(portalCRC != 0) { // Is building + //if (core.getSWGObjectODB().contains(objectId) && !duplicate.containsValue(objectId)){ + if (core.getSWGObjectODB().contains(objectId)){ + if(buildoutDEBUG) System.err.println("core.getSWGObjectODB().contains(objectId)" + template + " "+ Long.toHexString(objectId)); continue; } + if (duplicate.containsValue(objectId)){ + if(buildoutDEBUG) System.err.println("duplicate.containsValue(objectId)" + template + " "+ Long.toHexString(objectId)); + continue; + } + if (checkIfObjectAlreadyInList(objectId)){ + if(buildoutDEBUG) System.err.println("checkIfObjectAlreadyInList(objectId) " + template + " "+ Long.toHexString(objectId)); + continue; + } + containers.add(objectId); object = createObject(template, objectId, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz), null, true, true); object.setAttachment("childObjects", null); - - buildingMap.put(objectId2, ((BuildingObject) object)); + // must use the objectListId to identify the building later with cellMap.get(containerId) + buildingMap.put(objectId, ((BuildingObject) object)); + //System.out.println("buildingMap put " + Long.toHexString(objectId)); /*if (!duplicate.containsValue(objectId)) { ((BuildingObject) object).createTransaction(core.getBuildingODB().getEnvironment()); core.getBuildingODB().put((BuildingObject) object, Long.class, BuildingObject.class, ((BuildingObject) object).getTransaction()); ((BuildingObject) object).getTransaction().commitSync(); }*/ - } else { + } else { // building without portal, Seems to never happen object = createObject(template, 0, planet, new Point3D(px + x1, py, pz + z1), new Quaternion(qw, qx, qy, qz), null, false, true); + } - if(object == null) + if(object == null) { + //System.err.println("Buildout table contained an entry that can't be instantiated!"); continue; + } object.setContainerPermissions(WorldPermissions.WORLD_PERMISSIONS); if(radius > 256) object.setAttachment("bigSpawnRange", new Boolean(true)); + + if (!duplicate.containsValue(objectId) && object instanceof BuildingObject && portalCRC != 0){ - persistentBuildings.add((BuildingObject) object); + synchronized(persistentBuildings) { + persistentBuildings.add((BuildingObject) object); + } } } else if(containerId != 0) { @@ -1658,19 +1685,20 @@ public class ObjectService implements INetworkDispatch { if(containers.contains(containerId)) { object.setContainerPermissions(WorldPermissions.WORLD_PERMISSIONS); object.setisInSnapshot(false); - containers.add(objectId); + //containers.add(objectId); // ?!?!?! } if(object instanceof CellObject && cellIndex != 0) { object.setContainerPermissions(WorldCellPermissions.WORLD_CELL_PERMISSIONS); ((CellObject) object).setCellNumber(cellIndex); - List cellList = cellMap.get(containerId2); + List cellList = cellMap.get(containerId); + //System.out.println("Cell containerId " + Long.toHexString(containerId)); if (cellList != null){ cellList.add(((CellObject) object)); - cellMap.put(containerId2, cellList); + cellMap.put(containerId, cellList); } else { cellList = new ArrayList(); cellList.add(((CellObject) object)); - cellMap.put(containerId2, cellList); + cellMap.put(containerId, cellList); } } // SWGObject parent = getObject(containerId); @@ -1707,8 +1735,10 @@ public class ObjectService implements INetworkDispatch { } private void addCellsToBuildings(){ - - Iterator it = buildingMap.entrySet().iterator(); + Iterator it = null; + synchronized(buildingMap){ + it = buildingMap.entrySet().iterator(); + } while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); long buildingId = (long) pairs.getKey(); @@ -1716,23 +1746,25 @@ public class ObjectService implements INetworkDispatch { //System.out.println("We have buildingId " +buildingId); List cellList = cellMap.get(buildingId); if (cellList!=null) { - System.out.println("We have " + cellList.size() + " cells"); + if(buildoutDEBUG) System.out.println("We have " + cellList.size() + " cells"); for (CellObject cell : cellList){ building.add(cell); - System.out.println("Building : " + building.getTemplate() + " cell " + cell.getCellNumber()); + if(buildoutDEBUG) System.out.println("Building : " + building.getTemplate() + " cell " + cell.getCellNumber()); } } else {/*System.out.println("Cellist null");*/} - it.remove(); + } + it.remove(); } private void finalizeBuildings(){ - - for(BuildingObject building : persistentBuildings) { - building.setAttachment("buildoutBuilding", true); - core.getSWGObjectODB().put(building.getObjectID(), building); - destroyObject(building); + synchronized(persistentBuildings) { + for(BuildingObject building : persistentBuildings) { + building.setAttachment("buildoutBuilding", true); + core.getSWGObjectODB().put(building.getObjectID(), building); + destroyObject(building); + } } }