Compare commits
55 Commits
9d5e16aa5c
...
6559f232a3
| Author | SHA1 | Date | |
|---|---|---|---|
| 6559f232a3 | |||
| db8b33a621 | |||
| 781a4ee16d | |||
| 7ce94a5166 | |||
| a487a7bd2f | |||
| f0fedcc049 | |||
| 3a63f98ac3 | |||
| 4c994e6e55 | |||
| 1c93846ed3 | |||
| 3ef444c128 | |||
| eaaba8ab0c | |||
| 1daa45d604 | |||
| cf7e19bfde | |||
| 6a76cc7a29 | |||
| fff16d2211 | |||
| a2df7cda22 | |||
| 5858fa4de4 | |||
| fb6ec0caf4 | |||
| 944bcb7e84 | |||
| 4274e6a148 | |||
| 5e629e7890 | |||
| e991a01b50 | |||
| 7a1700cec3 | |||
| 79eb5b9cdf | |||
| 7886aa6041 | |||
| b928bedeb6 | |||
| beb2b47162 | |||
| 2cc37481ca | |||
| 5ac62d60be | |||
| 6fb1e2e5f1 | |||
| 385695a610 | |||
| 838776c471 | |||
| 44743b772b | |||
| 88f67efd51 | |||
| a04bdc147f | |||
| 145d9bafa0 | |||
| d2c00cce70 | |||
| 602f8bc843 | |||
| 89cb808481 | |||
| 4d290c9064 | |||
| 9ee60c9361 | |||
| 77cc91319a | |||
| ee4009bf8d | |||
| ff1c0bd347 | |||
| e1add3c7e6 | |||
| bf06734a9b | |||
| 5ed21f9b76 | |||
| e689cb541a | |||
| da32765902 | |||
| 9392ceda61 | |||
| 694b10d3b2 | |||
| 6b3c64faea | |||
| ab17dd08cd | |||
| f889bcf927 | |||
| 34024c9fb4 |
@@ -13,6 +13,7 @@ import engine.Enum;
|
||||
import engine.Enum.DbObjectType;
|
||||
import engine.Enum.ProtectionState;
|
||||
import engine.Enum.TaxType;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
@@ -27,6 +28,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class dbBuildingHandler extends dbHandlerBase {
|
||||
|
||||
@@ -88,14 +90,12 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return removeFromBuildings(b);
|
||||
}
|
||||
|
||||
public ArrayList<Building> GET_ALL_BUILDINGS_FOR_ZONE(Zone zone) {
|
||||
public ArrayList<Building> GET_ALL_BUILDINGS() {
|
||||
|
||||
ArrayList<Building> buildings = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, zone.getObjectUUID());
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
buildings = getObjectsFromRs(rs, 1000);
|
||||
@@ -425,26 +425,28 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void LOAD_ALL_FRIENDS_FOR_BUILDING(Building building) {
|
||||
|
||||
if (building == null)
|
||||
return;
|
||||
public void LOAD_BUILDING_FRIENDS() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends` WHERE `buildingUID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends`")) {
|
||||
|
||||
preparedStatement.setInt(1, building.getObjectUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
BuildingFriends friend = new BuildingFriends(rs);
|
||||
switch (friend.getFriendType()) {
|
||||
|
||||
// Create map if it does not yet exist
|
||||
|
||||
if (!BuildingManager._buildingFriends.containsKey(friend.buildingUID))
|
||||
BuildingManager._buildingFriends.put(friend.buildingUID, new ConcurrentHashMap<>());
|
||||
|
||||
switch (friend.friendType) {
|
||||
case 7:
|
||||
building.getFriends().put(friend.getPlayerUID(), friend);
|
||||
BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.playerUID, friend);
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
building.getFriends().put(friend.getGuildUID(), friend);
|
||||
BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.guildUID, friend);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -455,26 +457,29 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) {
|
||||
|
||||
if (building == null)
|
||||
return;
|
||||
public void LOAD_BUILDING_CONDEMNED() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned` WHERE `buildingUID` = ?")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned`")) {
|
||||
|
||||
preparedStatement.setInt(1, building.getObjectUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
|
||||
Condemned condemned = new Condemned(rs);
|
||||
switch (condemned.getFriendType()) {
|
||||
|
||||
// Create map if it does not yet exist
|
||||
|
||||
if (!BuildingManager._buildingCondemned.containsKey(condemned.buildingUUID))
|
||||
BuildingManager._buildingCondemned.put(condemned.buildingUUID, new ConcurrentHashMap<>());
|
||||
|
||||
switch (condemned.friendType) {
|
||||
case 2:
|
||||
building.getCondemned().put(condemned.getPlayerUID(), condemned);
|
||||
BuildingManager._buildingCondemned.get(condemned.buildingUUID).put(condemned.playerUID, condemned);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
building.getCondemned().put(condemned.getGuildUID(), condemned);
|
||||
BuildingManager._buildingCondemned.get(condemned.buildingUUID).put(condemned.guildUID, condemned);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -484,35 +489,27 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Vector3fImmutable> LOAD_PATROL_POINTS(Building building) {
|
||||
|
||||
if (building == null)
|
||||
return null;
|
||||
|
||||
ArrayList<Vector3fImmutable> patrolPoints = new ArrayList<>();
|
||||
public void LOAD_BARRACKS_PATROL_POINTS() {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points` WHERE `buildingUID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, building.getObjectUUID());
|
||||
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points`")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
float x1 = rs.getFloat("patrolX");
|
||||
float y1 = rs.getFloat("patrolY");
|
||||
float z1 = rs.getFloat("patrolZ");
|
||||
Vector3fImmutable patrolPoint = new Vector3fImmutable(x1, y1, z1);
|
||||
patrolPoints.add(patrolPoint);
|
||||
|
||||
int buildingUUID = rs.getInt("buildingUID");
|
||||
|
||||
if (!BuildingManager._buildingPatrolPoints.containsKey(buildingUUID))
|
||||
BuildingManager._buildingPatrolPoints.put(buildingUUID, new ArrayList<>());
|
||||
|
||||
Vector3fImmutable patrolPoint = new Vector3fImmutable(rs.getFloat("patrolX"), rs.getFloat("patrolY"), rs.getFloat("patrolZ"));
|
||||
BuildingManager._buildingPatrolPoints.get(buildingUUID).add(patrolPoint);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return patrolPoints;
|
||||
|
||||
}
|
||||
|
||||
public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) {
|
||||
@@ -722,10 +719,10 @@ public class dbBuildingHandler extends dbHandlerBase {
|
||||
+ "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?")) {
|
||||
|
||||
preparedStatement.setBoolean(1, active);
|
||||
preparedStatement.setInt(2, condemn.getParent());
|
||||
preparedStatement.setInt(3, condemn.getPlayerUID());
|
||||
preparedStatement.setInt(4, condemn.getGuildUID());
|
||||
preparedStatement.setInt(5, condemn.getFriendType());
|
||||
preparedStatement.setInt(2, condemn.buildingUUID);
|
||||
preparedStatement.setInt(3, condemn.playerUID);
|
||||
preparedStatement.setInt(4, condemn.guildUID);
|
||||
preparedStatement.setInt(5, condemn.friendType);
|
||||
|
||||
return (preparedStatement.executeUpdate() > 0);
|
||||
|
||||
|
||||
@@ -96,14 +96,12 @@ public class dbCityHandler extends dbHandlerBase {
|
||||
return objectList;
|
||||
}
|
||||
|
||||
public ArrayList<City> GET_CITIES_BY_ZONE(final int objectUUID) {
|
||||
public ArrayList<City> GET_ALL_CITIES() {
|
||||
|
||||
ArrayList<City> cityList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;")) {
|
||||
|
||||
preparedStatement.setLong(1, objectUUID);
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
cityList = getObjectsFromRs(rs, 100);
|
||||
|
||||
@@ -11,7 +11,6 @@ package engine.db.handlers;
|
||||
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.Zone;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -65,6 +64,23 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public ArrayList<Mob> GET_ALL_MOBS() {
|
||||
|
||||
ArrayList<Mob> mobileList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
mobileList = getObjectsFromRs(rs, 1000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return mobileList;
|
||||
}
|
||||
|
||||
public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
@@ -174,25 +190,6 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Mob> GET_ALL_MOBS_FOR_ZONE(Zone zone) {
|
||||
|
||||
ArrayList<Mob> mobileList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, zone.getObjectUUID());
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
mobileList = getObjectsFromRs(rs, 1000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return mobileList;
|
||||
}
|
||||
|
||||
public Mob GET_MOB(final int objectUUID) {
|
||||
|
||||
Mob mobile = null;
|
||||
|
||||
@@ -15,7 +15,6 @@ import engine.math.Vector3fImmutable;
|
||||
import engine.objects.NPC;
|
||||
import engine.objects.NPCProfits;
|
||||
import engine.objects.ProducedItem;
|
||||
import engine.objects.Zone;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
@@ -94,14 +93,12 @@ public class dbNPCHandler extends dbHandlerBase {
|
||||
return row_count;
|
||||
}
|
||||
|
||||
public ArrayList<NPC> GET_ALL_NPCS_FOR_ZONE(Zone zone) {
|
||||
public ArrayList<NPC> GET_ALL_NPCS() {
|
||||
|
||||
ArrayList<NPC> npcList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, zone.getObjectUUID());
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
npcList = getObjectsFromRs(rs, 1000);
|
||||
|
||||
@@ -27,25 +27,21 @@ public class dbZoneHandler extends dbHandlerBase {
|
||||
this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||
}
|
||||
|
||||
public ArrayList<Zone> GET_ALL_NODES(Zone zone) {
|
||||
ArrayList<Zone> wsmList = new ArrayList<>();
|
||||
wsmList.addAll(zone.getNodes());
|
||||
if (zone.absX == 0.0f) {
|
||||
zone.absX = zone.xOffset;
|
||||
public ArrayList<Zone> GET_ALL_ZONES() {
|
||||
|
||||
ArrayList<Zone> zoneList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
zoneList = getObjectsFromRs(rs, 2000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
if (zone.absY == 0.0f) {
|
||||
zone.absY = zone.yOffset;
|
||||
}
|
||||
if (zone.absZ == 0.0f) {
|
||||
zone.absZ = zone.zOffset;
|
||||
}
|
||||
for (Zone child : zone.getNodes()) {
|
||||
child.absX = child.xOffset + zone.absX;
|
||||
child.absY = child.yOffset + zone.absY;
|
||||
child.absZ = child.zOffset + zone.absZ;
|
||||
wsmList.addAll(this.GET_ALL_NODES(child));
|
||||
}
|
||||
return wsmList;
|
||||
|
||||
return zoneList;
|
||||
}
|
||||
|
||||
public Zone GET_BY_UID(long ID) {
|
||||
@@ -70,25 +66,6 @@ public class dbZoneHandler extends dbHandlerBase {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public ArrayList<Zone> GET_MAP_NODES(final int objectUUID) {
|
||||
|
||||
ArrayList<Zone> zoneList = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||
|
||||
preparedStatement.setLong(1, objectUUID);
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
zoneList = getObjectsFromRs(rs, 2000);
|
||||
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
return zoneList;
|
||||
}
|
||||
|
||||
public boolean DELETE_ZONE(final Zone zone) {
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
|
||||
@@ -60,13 +60,13 @@ public class GetHeightCmd extends AbstractDevCmd {
|
||||
this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
|
||||
this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
|
||||
|
||||
this.throwbackInfo(playerCharacter, "------------");
|
||||
|
||||
this.throwbackInfo(playerCharacter, "Child Height: " + Math.ceil(childHeight));
|
||||
this.throwbackInfo(playerCharacter, "Parent Height : " + Math.ceil(parentHeight));
|
||||
this.throwbackInfo(playerCharacter, "Blended Height : " + Math.ceil(blendedHeight));
|
||||
this.throwbackInfo(playerCharacter, "Child Height at loc: " + Math.ceil(childHeight));
|
||||
this.throwbackInfo(playerCharacter, "Parent Height at loc: " + Math.ceil(parentHeight));
|
||||
this.throwbackInfo(playerCharacter, "Blended Height (Ceil): " + blendedHeight + " (" + Math.ceil(blendedHeight) + ")");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ public class MakeBaneCmd extends AbstractDevCmd {
|
||||
return;
|
||||
}
|
||||
stone.addEffectBit((1 << 19));
|
||||
stone.setRank((byte) rank);
|
||||
BuildingManager.setRank(stone, (byte) rank);
|
||||
stone.setMaxHitPoints(blueprint.getMaxHealth(stone.getRank()));
|
||||
stone.setCurrentHitPoints(stone.getMaxHitPoints());
|
||||
BuildingManager.setUpgradeDateTime(stone, null, 0);
|
||||
|
||||
@@ -11,6 +11,7 @@ package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -25,6 +26,14 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output;
|
||||
output = "Target Region Information:" + newline;
|
||||
|
||||
Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc);
|
||||
if(building == null){
|
||||
this.throwbackInfo(pc, "No Building At This Location.") ;
|
||||
}
|
||||
Regions region = ((AbstractCharacter)target).region;
|
||||
if (region == null) {
|
||||
this.throwbackInfo(pc, "No Region Found.");
|
||||
@@ -32,9 +41,12 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
if(region != null) {
|
||||
this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName());
|
||||
this.throwbackInfo(pc, "Region Name: " + region);
|
||||
this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target));
|
||||
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
||||
output += "Region Building: " + building.getName() + newline;
|
||||
output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline;
|
||||
output += "is Stairs: " + region.isStairs() + newline;
|
||||
output += "is Outside: " + region.isOutside();
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SetRankCmd extends AbstractDevCmd {
|
||||
Blueprint blueprint = targetBuilding.getBlueprint();
|
||||
|
||||
if (blueprint == null) {
|
||||
targetBuilding.setRank(targetRank);
|
||||
BuildingManager.setRank(targetBuilding, targetRank);
|
||||
ChatManager.chatSayInfo(player, "Building ranked without blueprint" + targetBuilding.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
@@ -68,9 +68,8 @@ public class SetRankCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
// Set the current targetRank
|
||||
int lastMeshID = targetBuilding.getMeshUUID();
|
||||
targetBuilding.setRank(targetRank);
|
||||
|
||||
BuildingManager.setRank(targetBuilding, targetRank);
|
||||
ChatManager.chatSayInfo(player, "Rank set for building with ID " + targetBuilding.getObjectUUID() + " to rank " + targetRank);
|
||||
break;
|
||||
case NPC:
|
||||
@@ -114,7 +113,7 @@ public class SetRankCmd extends AbstractDevCmd {
|
||||
|
||||
// Set the current targetRank
|
||||
int lastMeshID = targetBuilding.getMeshUUID();
|
||||
targetBuilding.setRank(targetRank);
|
||||
BuildingManager.setRank(targetBuilding, targetRank);
|
||||
|
||||
if (lastMeshID != targetBuilding.getMeshUUID())
|
||||
targetBuilding.refresh(true);
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ZoneInfoCmd extends AbstractDevCmd {
|
||||
} else {
|
||||
output = "children:";
|
||||
|
||||
ArrayList<Zone> nodes = zone.getNodes();
|
||||
ArrayList<Zone> nodes = zone.nodes;
|
||||
|
||||
if (nodes.isEmpty())
|
||||
output += " none";
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public enum BuildingManager {
|
||||
@@ -40,6 +41,9 @@ public enum BuildingManager {
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _stuckLocations = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<BuildingLocation>> _slotLocations = new HashMap<>();
|
||||
|
||||
public static HashMap<Integer, ConcurrentHashMap<Integer, BuildingFriends>> _buildingFriends = new HashMap<>();
|
||||
public static HashMap<Integer, ConcurrentHashMap<Integer, Condemned>> _buildingCondemned = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<Vector3fImmutable>> _buildingPatrolPoints = new HashMap<>();
|
||||
public static int getAvailableSlot(Building building) {
|
||||
|
||||
ArrayList<BuildingLocation> slotLocations = _slotLocations.get(building.meshUUID);
|
||||
@@ -104,7 +108,6 @@ public enum BuildingManager {
|
||||
if (building == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
@@ -112,26 +115,25 @@ public enum BuildingManager {
|
||||
return true;
|
||||
|
||||
//individual friend.
|
||||
if (building.getFriends().get(player.getObjectUUID()) != null)
|
||||
if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null)
|
||||
return true;
|
||||
|
||||
//Admin's can access stuff
|
||||
//Admins can access stuff
|
||||
|
||||
if (player.isCSR())
|
||||
return true;
|
||||
|
||||
//Guild stuff
|
||||
|
||||
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
if (building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).getFriendType() == 8)
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8)
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).getFriendType() == 9
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9
|
||||
&& GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
|
||||
@@ -494,18 +496,18 @@ public enum BuildingManager {
|
||||
|
||||
Condemned condemn = building.getCondemned().get(player.getObjectUUID());
|
||||
|
||||
if (condemn != null && condemn.isActive())
|
||||
if (condemn != null && condemn.active)
|
||||
return true;
|
||||
|
||||
if (player.getGuild() != null) {
|
||||
|
||||
Condemned guildCondemn = building.getCondemned().get(player.getGuild().getObjectUUID());
|
||||
|
||||
if (guildCondemn != null && guildCondemn.isActive())
|
||||
if (guildCondemn != null && guildCondemn.active)
|
||||
return true;
|
||||
|
||||
Condemned nationCondemn = building.getCondemned().get(player.getGuild().getNation().getObjectUUID());
|
||||
return nationCondemn != null && nationCondemn.isActive() && nationCondemn.getFriendType() == Condemned.NATION;
|
||||
return nationCondemn != null && nationCondemn.active && nationCondemn.friendType == Condemned.NATION;
|
||||
} else {
|
||||
//TODO ADD ERRANT KOS CHECK
|
||||
}
|
||||
@@ -513,18 +515,18 @@ public enum BuildingManager {
|
||||
|
||||
Condemned condemn = building.getCondemned().get(player.getObjectUUID());
|
||||
|
||||
if (condemn != null && condemn.isActive())
|
||||
if (condemn != null && condemn.active)
|
||||
return false;
|
||||
|
||||
if (player.getGuild() != null) {
|
||||
|
||||
Condemned guildCondemn = building.getCondemned().get(player.getGuild().getObjectUUID());
|
||||
|
||||
if (guildCondemn != null && guildCondemn.isActive())
|
||||
if (guildCondemn != null && guildCondemn.active)
|
||||
return false;
|
||||
|
||||
Condemned nationCondemn = building.getCondemned().get(player.getGuild().getNation().getObjectUUID());
|
||||
return nationCondemn == null || !nationCondemn.isActive() || nationCondemn.getFriendType() != Condemned.NATION;
|
||||
return nationCondemn == null || !nationCondemn.active || nationCondemn.friendType != Condemned.NATION;
|
||||
} else {
|
||||
//TODO ADD ERRANT KOS CHECK
|
||||
}
|
||||
@@ -851,4 +853,111 @@ public enum BuildingManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void rebuildMine(Building mineBuilding) {
|
||||
setRank(mineBuilding, 1);
|
||||
mineBuilding.meshUUID = mineBuilding.getBlueprint().getMeshForRank(mineBuilding.rank);
|
||||
|
||||
// New rank mean new max hit points.
|
||||
|
||||
mineBuilding.healthMax = mineBuilding.getBlueprint().getMaxHealth(mineBuilding.rank);
|
||||
mineBuilding.setCurrentHitPoints(mineBuilding.healthMax);
|
||||
mineBuilding.getBounds().setBounds(mineBuilding);
|
||||
}
|
||||
|
||||
public static void setRank(Building building, int rank) {
|
||||
|
||||
int newMeshUUID;
|
||||
boolean success;
|
||||
|
||||
|
||||
// If this building has no blueprint then set rank and exit immediatly.
|
||||
|
||||
if (building.blueprintUUID == 0 || building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)) {
|
||||
building.rank = rank;
|
||||
DbManager.BuildingQueries.CHANGE_RANK(building.getObjectUUID(), rank);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete any upgrade jobs before doing anything else. It won't quite work
|
||||
// if in a few lines we happen to delete this building.
|
||||
|
||||
JobContainer jc = building.getTimers().get("UPGRADE");
|
||||
|
||||
if (jc != null) {
|
||||
if (!JobScheduler.getInstance().cancelScheduledJob(jc))
|
||||
Logger.error("failed to cancel existing upgrade job.");
|
||||
}
|
||||
|
||||
// Attempt write to database, or delete the building
|
||||
// if we are destroying it.
|
||||
|
||||
if (rank == -1)
|
||||
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
||||
else
|
||||
success = DbManager.BuildingQueries.updateBuildingRank(building, rank);
|
||||
|
||||
if (success == false) {
|
||||
Logger.error("Error writing to database UUID: " + building.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
building.isDeranking.compareAndSet(false, true);
|
||||
|
||||
// Change the building's rank
|
||||
|
||||
building.rank = rank;
|
||||
|
||||
// New rank means new mesh
|
||||
|
||||
newMeshUUID = building.getBlueprint().getMeshForRank(building.rank);
|
||||
building.meshUUID = newMeshUUID;
|
||||
|
||||
// New rank mean new max hitpoints.
|
||||
|
||||
building.healthMax = building.getBlueprint().getMaxHealth(building.rank);
|
||||
building.setCurrentHitPoints(building.healthMax);
|
||||
|
||||
if (building.getUpgradeDateTime() != null)
|
||||
setUpgradeDateTime(building, null, 0);
|
||||
|
||||
// If we destroyed this building make sure to turn off
|
||||
// protection
|
||||
|
||||
if (building.rank == -1)
|
||||
building.protectionState = Enum.ProtectionState.NONE;
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
&& (building.rank == 8))
|
||||
building.meshUUID = Realm.getRealmMesh(building.getCity());
|
||||
|
||||
// update object to clients
|
||||
|
||||
building.refresh(true);
|
||||
|
||||
if (building.getBounds() != null)
|
||||
building.getBounds().setBounds(building);
|
||||
|
||||
// Cleanup hirelings resulting from rank change
|
||||
|
||||
cleanupHirelings(building);
|
||||
|
||||
building.isDeranking.compareAndSet(true, false);
|
||||
}
|
||||
|
||||
public static Building getBuildingAtLocation(Vector3fImmutable loc) {
|
||||
|
||||
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc, 64, MBServerStatics.MASK_BUILDING)) {
|
||||
Building building = (Building) awo;
|
||||
|
||||
if (building == null)
|
||||
continue;
|
||||
|
||||
if (Bounds.collide(loc, building.getBounds()))
|
||||
return building;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ package engine.gameManager;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.db.archive.CityRecord;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
@@ -87,7 +85,7 @@ public enum ZoneManager {
|
||||
|
||||
childFound = false;
|
||||
|
||||
ArrayList<Zone> nodes = zone.getNodes();
|
||||
ArrayList<Zone> nodes = zone.nodes;
|
||||
|
||||
// Logger.info("soze", "" + nodes.size());
|
||||
if (nodes != null)
|
||||
@@ -103,16 +101,6 @@ public enum ZoneManager {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public static void addZone(final int zoneID, final Zone zone) {
|
||||
|
||||
ZoneManager.zonesByID.put(zoneID, zone);
|
||||
|
||||
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
|
||||
|
||||
ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone);
|
||||
|
||||
}
|
||||
|
||||
// Returns the number of available hotZones
|
||||
// remaining in this cycle (1am)
|
||||
|
||||
@@ -175,26 +163,25 @@ public enum ZoneManager {
|
||||
return (Bounds.collide(loc, ZoneManager.hotZone.bounds));
|
||||
}
|
||||
|
||||
public static void setSeaFloor(final Zone value) {
|
||||
ZoneManager.seaFloor = value;
|
||||
}
|
||||
|
||||
public static void populateWorldZones(final Zone zone) {
|
||||
|
||||
int loadNum = zone.template;
|
||||
public static void populateZoneCollections(final Zone zone) {
|
||||
|
||||
// Zones are added to separate
|
||||
// collections for quick access
|
||||
// based upon their type.
|
||||
|
||||
ZoneManager.zonesByID.put(zone.template, zone);
|
||||
|
||||
ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone);
|
||||
|
||||
ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone);
|
||||
|
||||
if (zone.isMacroZone()) {
|
||||
addMacroZone(zone);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (zone.guild_zone) {
|
||||
addPlayerCityZone(zone);
|
||||
ZoneManager.playerCityZones.add(zone);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -212,11 +199,6 @@ public enum ZoneManager {
|
||||
ZoneManager.npcCityZones.add(zone);
|
||||
}
|
||||
|
||||
public static final void addPlayerCityZone(final Zone zone) {
|
||||
zone.guild_zone = true;
|
||||
ZoneManager.playerCityZones.add(zone);
|
||||
}
|
||||
|
||||
public static final void generateAndSetRandomHotzone() {
|
||||
|
||||
Zone hotZone;
|
||||
@@ -252,10 +234,10 @@ public enum ZoneManager {
|
||||
if (zone.peace_zone == (byte) 1)
|
||||
return false; // no safe zone hotzones// if (this.hotzone == null)
|
||||
|
||||
if (zone.getNodes().isEmpty())
|
||||
if (zone.equals(ZoneManager.seaFloor))
|
||||
return false;
|
||||
|
||||
if (zone.equals(ZoneManager.seaFloor))
|
||||
if (zone.nodes.isEmpty())
|
||||
return false;
|
||||
|
||||
//no duplicate hotZones
|
||||
@@ -316,8 +298,6 @@ public enum ZoneManager {
|
||||
localCoords = new Vector2f(worldLoc.x, worldLoc.z);
|
||||
localCoords = localCoords.subtract(zoneOrigin);
|
||||
|
||||
// TODO : Make sure this value does not go outside the zone's bounds.
|
||||
|
||||
return localCoords;
|
||||
}
|
||||
|
||||
@@ -338,9 +318,10 @@ public enum ZoneManager {
|
||||
if (building.getBounds().getQuaternion() == null)
|
||||
return building.getLoc();
|
||||
|
||||
// handle building rotation
|
||||
|
||||
Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion());
|
||||
|
||||
// handle building rotation
|
||||
// handle building translation
|
||||
|
||||
return building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z);
|
||||
@@ -350,12 +331,10 @@ public enum ZoneManager {
|
||||
//used for regions, Building bounds not set yet.
|
||||
public static Vector3f convertLocalToWorld(Building building, Vector3f localPos, Bounds bounds) {
|
||||
|
||||
// convert from SB rotation value to radians
|
||||
|
||||
// handle building rotation
|
||||
|
||||
Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion());
|
||||
|
||||
// handle building rotation
|
||||
// handle building translation
|
||||
|
||||
return new Vector3f(building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z));
|
||||
@@ -378,8 +357,6 @@ public enum ZoneManager {
|
||||
public static City getCityAtLocation(Vector3fImmutable worldLoc) {
|
||||
|
||||
Zone currentZone;
|
||||
ArrayList<Zone> zoneList;
|
||||
City city;
|
||||
|
||||
currentZone = ZoneManager.findSmallestZone(worldLoc);
|
||||
|
||||
@@ -409,7 +386,7 @@ public enum ZoneManager {
|
||||
treeBounds = Bounds.borrow();
|
||||
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.halfExtents, Enum.CityBoundsType.PLACEMENT.halfExtents), 0.0f);
|
||||
|
||||
zoneList = currentZone.getNodes();
|
||||
zoneList = currentZone.nodes;
|
||||
|
||||
for (Zone zone : zoneList) {
|
||||
|
||||
@@ -424,56 +401,29 @@ public enum ZoneManager {
|
||||
return validLocation;
|
||||
}
|
||||
|
||||
public static void loadCities(Zone zone) {
|
||||
|
||||
ArrayList<City> cities = DbManager.CityQueries.GET_CITIES_BY_ZONE(zone.getObjectUUID());
|
||||
|
||||
for (City city : cities) {
|
||||
|
||||
city.setParent(zone);
|
||||
city.setObjectTypeMask(MBServerStatics.MASK_CITY);
|
||||
city.setLoc(city.getLoc()); // huh?
|
||||
|
||||
//not player city, must be npc city..
|
||||
|
||||
if (!zone.guild_zone)
|
||||
zone.isNPCCity = true;
|
||||
|
||||
if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) {
|
||||
|
||||
city.setHash();
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, city.getObjectUUID()) == false) {
|
||||
CityRecord cityRecord = CityRecord.borrow(city, Enum.RecordEventType.CREATE);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static float calculateGlobalZoneHeight(Zone zone) {
|
||||
|
||||
float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
float worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
|
||||
// Seafloor
|
||||
|
||||
if (ZoneManager.seaFloor.equals(zone))
|
||||
return worldAlttitude;
|
||||
return worldAltitude;
|
||||
|
||||
// Children of seafloor
|
||||
|
||||
if (ZoneManager.seaFloor.equals(zone.parent))
|
||||
return worldAlttitude + zone.yOffset;
|
||||
return worldAltitude + zone.yOffset;
|
||||
|
||||
// return height from heightmap engine at zone location
|
||||
|
||||
worldAlttitude = Terrain.getWorldHeight(zone.parent, zone.getLoc());
|
||||
worldAltitude = Terrain.getWorldHeight(zone.parent, zone.getLoc());
|
||||
|
||||
// Add zone offset to value
|
||||
|
||||
worldAlttitude += zone.yOffset;
|
||||
worldAltitude += zone.yOffset;
|
||||
|
||||
return worldAlttitude;
|
||||
return worldAltitude;
|
||||
}
|
||||
|
||||
public static boolean isLocUnderwater(Vector3fImmutable currentLoc) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package engine.jobs;
|
||||
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.job.AbstractScheduleJob;
|
||||
import engine.objects.Building;
|
||||
import org.pmw.tinylog.Logger;
|
||||
@@ -39,7 +40,7 @@ public class UpgradeBuildingJob extends AbstractScheduleJob {
|
||||
// SetCurrentRank also changes the mesh and maxhp
|
||||
// accordingly for buildings with blueprints
|
||||
|
||||
rankingBuilding.setRank(rankingBuilding.getRank() + 1);
|
||||
BuildingManager.setRank(rankingBuilding, rankingBuilding.getRank() + 1);
|
||||
|
||||
// Reload the object
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ public class Bounds {
|
||||
this.origin.set(building.getLoc().x, building.getLoc().z);
|
||||
|
||||
|
||||
// Magicbane uses half halfExtents
|
||||
// Magicbane uses halfExtents
|
||||
|
||||
if (meshBounds == null) {
|
||||
halfExtentX = 1;
|
||||
@@ -438,8 +438,10 @@ public class Bounds {
|
||||
// The rotation is reset after the new aabb is calculated.
|
||||
|
||||
this.rotation = building.getRot().y;
|
||||
|
||||
// Caclculate and set the new half halfExtents for the rotated bounding box
|
||||
// and reset the rotation to 0 for this bounds.
|
||||
|
||||
this.halfExtents.set(halfExtentX, (halfExtentY));
|
||||
this.rotation = 0;
|
||||
|
||||
@@ -453,7 +455,6 @@ public class Bounds {
|
||||
this.halfExtents.set(blueprint.getExtents());
|
||||
this.flipExtents = Bounds.calculateFlipExtents(this);
|
||||
|
||||
|
||||
this.setRegions(building);
|
||||
this.setColliders(building);
|
||||
|
||||
|
||||
@@ -657,7 +657,7 @@ public class MobAI {
|
||||
for (Entry playerEntry : loadedPlayers.entrySet()) {
|
||||
|
||||
int playerID = (int) playerEntry.getKey();
|
||||
PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID);
|
||||
PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID);
|
||||
|
||||
//Player is null, let's remove them from the list.
|
||||
|
||||
@@ -1105,7 +1105,7 @@ public class MobAI {
|
||||
for (Entry playerEntry : loadedPlayers.entrySet()) {
|
||||
|
||||
int playerID = (int) playerEntry.getKey();
|
||||
PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID);
|
||||
PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID);
|
||||
|
||||
//Player is null, let's remove them from the list.
|
||||
|
||||
@@ -1175,17 +1175,17 @@ public class MobAI {
|
||||
|
||||
//target is listed individually
|
||||
|
||||
if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive())
|
||||
if (entry.getValue().playerUID == target.getObjectUUID() && entry.getValue().active)
|
||||
return false;
|
||||
|
||||
//target's guild is listed
|
||||
|
||||
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild())
|
||||
if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild())
|
||||
return false;
|
||||
|
||||
//target's nation is listed
|
||||
|
||||
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation())
|
||||
if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild().getNation())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1197,17 +1197,17 @@ public class MobAI {
|
||||
|
||||
//target is listed individually
|
||||
|
||||
if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive())
|
||||
if (entry.getValue().playerUID == target.getObjectUUID() && entry.getValue().active)
|
||||
return true;
|
||||
|
||||
//target's guild is listed
|
||||
|
||||
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild())
|
||||
if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild())
|
||||
return true;
|
||||
|
||||
//target's nation is listed
|
||||
|
||||
if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation())
|
||||
if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild().getNation())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1263,7 +1263,7 @@ public class MobAI {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e.getMessage());
|
||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1280,7 +1280,7 @@ public class MobAI {
|
||||
|
||||
for (Entry playerEntry : mob.playerAgroMap.entrySet()) {
|
||||
|
||||
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey());
|
||||
PlayerCharacter potentialTarget = PlayerCharacter.getPlayerCharacter((int) playerEntry.getKey());
|
||||
|
||||
if (potentialTarget.equals(mob.getCombatTarget()))
|
||||
continue;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler {
|
||||
city.setWarehouseBuildingID(0);
|
||||
}
|
||||
|
||||
building.setRank(-1);
|
||||
BuildingManager.setRank(building, -1);
|
||||
WorldGrid.RemoveWorldObject(building);
|
||||
WorldGrid.removeObject(building);
|
||||
building.getParentZone().zoneBuildingSet.remove(building);
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
realm.claimRealmForCity(city, charterUUID);
|
||||
|
||||
tol.setRank(8);
|
||||
BuildingManager.setRank(tol, 8);
|
||||
WorldGrid.updateObject(tol);
|
||||
|
||||
for (Building building : city.getParent().zoneBuildingSet) {
|
||||
|
||||
@@ -151,7 +151,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
if (removeCondemn == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.getParent(), removeCondemn.getPlayerUID(), removeCondemn.getGuildUID(), removeCondemn.getFriendType()))
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.buildingUUID, removeCondemn.playerUID, removeCondemn.guildUID, removeCondemn.friendType))
|
||||
return true;
|
||||
|
||||
sourceBuilding.getCondemned().remove(msg.getRemoveFriendID());
|
||||
@@ -175,7 +175,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
|
||||
condemn.setActive(msg.isReverseKOS());
|
||||
openFriendsCondemnListMsg.setReverseKOS(condemn.isActive());
|
||||
openFriendsCondemnListMsg.setReverseKOS(condemn.active);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
@@ -354,7 +354,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
if (friend == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.getPlayerUID(), friend.getGuildUID(), friend.getFriendType())) {
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.playerUID, friend.guildUID, friend.friendType)) {
|
||||
Logger.debug("Failed to remove Friend: " + msg.getRemoveFriendID() + " from Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -780,37 +780,19 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
playerNation = playerCharacter.getGuild();
|
||||
playerNation.setGuildState(GuildState.Sovereign);
|
||||
|
||||
// Link the zone with the city and then add
|
||||
// to the appropriate hash tables and cache
|
||||
|
||||
zoneObject.guild_zone = true;
|
||||
|
||||
if (zoneObject.parent != null)
|
||||
zoneObject.parent.addNode(zoneObject); //add as child to parent
|
||||
|
||||
ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject);
|
||||
ZoneManager.addPlayerCityZone(zoneObject);
|
||||
serverZone.addNode(zoneObject);
|
||||
|
||||
zoneObject.global_height = ZoneManager.calculateGlobalZoneHeight(zoneObject);
|
||||
|
||||
cityObject.setParent(zoneObject);
|
||||
cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already
|
||||
|
||||
//Link the tree of life with the new zone
|
||||
|
||||
treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||
treeObject.setParentZone(zoneObject);
|
||||
MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7));
|
||||
|
||||
// Update guild binds and tags
|
||||
|
||||
GuildManager.updateAllGuildBinds(playerNation, cityObject);
|
||||
GuildManager.updateAllGuildTags(playerNation);
|
||||
|
||||
//load the new city on the clients
|
||||
|
||||
CityZoneMsg czm = new CityZoneMsg(1, treeObject.getLoc().x, treeObject.getLoc().y, treeObject.getLoc().z, cityObject.getCityName(), zoneObject, Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents);
|
||||
DispatchMessage.dispatchMsgToAll(czm);
|
||||
|
||||
GuildManager.updateAllGuildBinds(playerNation, cityObject);
|
||||
GuildManager.updateAllGuildTags(playerNation);
|
||||
// Set maintenance date
|
||||
|
||||
MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7));
|
||||
|
||||
// Send all the cities to the clients?
|
||||
// *** Refactor : figure out how to send like, one?
|
||||
|
||||
@@ -513,17 +513,17 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
|
||||
writer.put((byte) 1);
|
||||
|
||||
switch (condemned.getFriendType()) {
|
||||
switch (condemned.friendType) {
|
||||
case 2:
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getObject(engine.Enum.GameObjectType.PlayerCharacter, condemned.getPlayerUID());
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getObject(engine.Enum.GameObjectType.PlayerCharacter, condemned.playerUID);
|
||||
|
||||
|
||||
guild = playerCharacter.getGuild();
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(condemned.getPlayerUID());
|
||||
writer.putInt(condemned.getFriendType());
|
||||
writer.putInt(condemned.playerUID);
|
||||
writer.putInt(condemned.friendType);
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(condemned.getPlayerUID());
|
||||
writer.putInt(condemned.playerUID);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
@@ -531,9 +531,9 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
writer.putInt(guild.getObjectUUID());
|
||||
else
|
||||
writer.putInt(0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
writer.put((byte) 0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
|
||||
if (playerCharacter != null)
|
||||
writer.putString(playerCharacter.getFirstName());
|
||||
@@ -547,16 +547,16 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
guild = Guild.getGuild(condemned.getGuildUID());
|
||||
guild = Guild.getGuild(condemned.guildUID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.getFriendType());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.putInt(condemned.friendType);
|
||||
writer.putLong(0);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.putLong(0);
|
||||
writer.put((byte) 0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
writer.put((byte) 0);
|
||||
if (guild != null)
|
||||
writer.putString(guild.getName());
|
||||
@@ -570,17 +570,17 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
GuildTag._serializeForDisplay(GuildTag.ERRANT, writer);
|
||||
break;
|
||||
case 5:
|
||||
guild = Guild.getGuild(condemned.getGuildUID());
|
||||
guild = Guild.getGuild(condemned.guildUID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.getFriendType());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.putInt(condemned.friendType);
|
||||
writer.putLong(0);
|
||||
writer.putLong(0);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(condemned.getGuildUID());
|
||||
writer.putInt(condemned.guildUID);
|
||||
writer.put((byte) 0);
|
||||
writer.put((byte) 0);
|
||||
writer.put(condemned.isActive() ? (byte) 1 : (byte) 0);
|
||||
writer.put(condemned.active ? (byte) 1 : (byte) 0);
|
||||
if (guild != null)
|
||||
writer.putString(guild.getName());
|
||||
else
|
||||
@@ -619,22 +619,22 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg {
|
||||
writer.putInt(listSize);
|
||||
|
||||
for (BuildingFriends friend : this.friends.values()) {
|
||||
pc = PlayerCharacter.getFromCache(friend.getPlayerUID());
|
||||
guild = Guild.getGuild(friend.getGuildUID());
|
||||
if (friend.getFriendType() == 7) {
|
||||
pc = PlayerCharacter.getFromCache(friend.playerUID);
|
||||
guild = Guild.getGuild(friend.guildUID);
|
||||
if (friend.friendType == 7) {
|
||||
if (pc != null)
|
||||
name = pc.getCombinedName();
|
||||
} else if (guild != null)
|
||||
name = guild.getName();
|
||||
writer.put((byte) 1);
|
||||
if (friend.getFriendType() == 7) {
|
||||
if (friend.friendType == 7) {
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(friend.getPlayerUID());
|
||||
writer.putInt(friend.playerUID);
|
||||
} else {
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(friend.getGuildUID());
|
||||
writer.putInt(friend.guildUID);
|
||||
}
|
||||
writer.putInt(friend.getFriendType());
|
||||
writer.putInt(friend.friendType);
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.ByteBufferReader;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.client.Protocol;
|
||||
import engine.objects.Building;
|
||||
import engine.objects.Zone;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SyncMessage extends ClientNetMsg {
|
||||
|
||||
private int type;
|
||||
private int size;
|
||||
private int pad = 0;
|
||||
private int objectType;
|
||||
private int objectUUID;
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public SyncMessage(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.CITYASSET, origin, reader);
|
||||
}
|
||||
|
||||
public SyncMessage() {
|
||||
super(Protocol.CITYASSET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
//none yet
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
//lets do returns before writing so we don't send improper structures to the client
|
||||
|
||||
Building tol = BuildingManager.getBuilding(this.objectUUID);
|
||||
|
||||
if (tol == null) {
|
||||
Logger.debug("TOL is null");
|
||||
return;
|
||||
}
|
||||
Zone zone = ZoneManager.findSmallestZone(tol.getLoc());
|
||||
if (zone == null) {
|
||||
Logger.debug("Zone is null");
|
||||
return;
|
||||
}
|
||||
ArrayList<Building> allCityAssets = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
|
||||
|
||||
// *** Refactor: collection created but never used?
|
||||
|
||||
ArrayList<Building> canProtectAssets = new ArrayList<>();
|
||||
|
||||
for (Building b : allCityAssets) {
|
||||
if (b.getBlueprintUUID() != 0)
|
||||
canProtectAssets.add(b);
|
||||
}
|
||||
|
||||
// *** Refactor : Not sure what this synch message does
|
||||
// Get the feeling it should be looping over upgradable
|
||||
// assets.
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
writer.putInt(this.objectType);
|
||||
writer.putInt(this.objectUUID);
|
||||
writer.putInt(allCityAssets.size());
|
||||
for (Building b : allCityAssets) {
|
||||
String name = b.getName();
|
||||
// if (name.equals(""))
|
||||
// name = b.getBuildingSet().getName();
|
||||
writer.putInt(b.getObjectType().ordinal());
|
||||
writer.putInt(b.getObjectUUID());
|
||||
|
||||
writer.putString(b.getName()); // Blueprint name?
|
||||
writer.putString(b.getGuild().getName());
|
||||
writer.putInt(20);// \/ Temp \/
|
||||
writer.putInt(b.getRank());
|
||||
writer.putInt(1); // symbol
|
||||
writer.putInt(7); //TODO identify these Guild tags??
|
||||
writer.putInt(17);
|
||||
writer.putInt(14);
|
||||
writer.putInt(14);
|
||||
writer.putInt(98);// /\ Temp /\
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
public void setObjectType(int value) {
|
||||
this.objectType = value;
|
||||
}
|
||||
|
||||
public int getUUID() {
|
||||
return objectUUID;
|
||||
|
||||
}
|
||||
|
||||
public int getPad() {
|
||||
return pad;
|
||||
}
|
||||
|
||||
public void setPad(int value) {
|
||||
this.pad = value;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,10 @@
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
import engine.Enum;
|
||||
import engine.exception.SerializationException;
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.net.AbstractConnection;
|
||||
import engine.net.AbstractNetMsg;
|
||||
@@ -44,14 +46,9 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
super(Protocol.NEWWORLD, origin, reader);
|
||||
}
|
||||
|
||||
private static int getTotalMapSize(Zone root) {
|
||||
if (root.getNodes().isEmpty())
|
||||
return 0;
|
||||
private static int getTotalMapSize() {
|
||||
|
||||
int size = root.getNodes().size();
|
||||
for (Zone child : root.getNodes())
|
||||
size += getTotalMapSize(child);
|
||||
return size;
|
||||
return DbManager.getList(Enum.GameObjectType.Zone).size();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,11 +83,10 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
writer.putInt(WorldServer.worldMapID);
|
||||
writer.putInt(0x00000000);
|
||||
|
||||
writer.putInt(getTotalMapSize(root) + 1);
|
||||
writer.putInt(getTotalMapSize());
|
||||
Zone.serializeForClientMsg(root, writer);
|
||||
|
||||
Zone hotzone = ZoneManager.hotZone;
|
||||
;
|
||||
|
||||
if (hotzone == null)
|
||||
writer.putLong(0L);
|
||||
@@ -99,7 +95,6 @@ public class WorldDataMsg extends ClientNetMsg {
|
||||
writer.putInt(hotzone.getObjectUUID());
|
||||
}
|
||||
|
||||
|
||||
writer.putFloat(0);
|
||||
writer.putFloat(1);
|
||||
writer.putFloat(0);
|
||||
|
||||
@@ -27,6 +27,7 @@ import engine.math.Bounds;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.UpdateStateMsg;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -985,7 +986,19 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
|
||||
@Override
|
||||
public final void setLoc(final Vector3fImmutable value) {
|
||||
Regions region = Regions.GetRegionForTeleport(value);
|
||||
|
||||
Building building = BuildingManager.getBuildingAtLocation(this.loc);
|
||||
Regions region = null;
|
||||
if(building != null) {
|
||||
//look for region in the building we are in
|
||||
for (Regions regionCycle : building.getBounds().getRegions()) {
|
||||
float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y;
|
||||
if(regionHeight < 10)
|
||||
regionHeight = 10;
|
||||
if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight)
|
||||
region = regionCycle;
|
||||
}
|
||||
}
|
||||
float regionHeightOffset = 0;
|
||||
if(region != null){
|
||||
this.region = region;
|
||||
@@ -999,6 +1012,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.inBuildingID = 0;
|
||||
this.inFloorID = -1;
|
||||
}
|
||||
|
||||
float terrainHeight = Terrain.getWorldHeight(value);
|
||||
Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z);
|
||||
super.setLoc(finalLocation); // set the location in the world
|
||||
|
||||
+130
-324
@@ -55,6 +55,7 @@ public class Building extends AbstractWorldObject {
|
||||
private final HashMap<Integer, DoorCloseJob> doorJobs = new HashMap<>();
|
||||
public int meshUUID;
|
||||
public Zone parentZone;
|
||||
public int parentZoneUUID;
|
||||
public boolean reverseKOS;
|
||||
public int reserve = 0;
|
||||
public float statLat;
|
||||
@@ -62,7 +63,6 @@ public class Building extends AbstractWorldObject {
|
||||
public float statAlt;
|
||||
public LocalDateTime upgradeDateTime = null;
|
||||
public LocalDateTime taxDateTime = null;
|
||||
public ArrayList<Vector3fImmutable> patrolPoints = new ArrayList<>();
|
||||
public ArrayList<Vector3fImmutable> sentryPoints = new ArrayList<>();
|
||||
public TaxType taxType = TaxType.NONE;
|
||||
public int taxAmount;
|
||||
@@ -75,11 +75,14 @@ public class Building extends AbstractWorldObject {
|
||||
public int level;
|
||||
public AtomicBoolean isDeranking = new AtomicBoolean(false);
|
||||
public LocalDateTime maintDateTime;
|
||||
protected Resists resists;
|
||||
/* The Blueprint class has methods able to derive
|
||||
* all defining characteristics of this building,
|
||||
*/
|
||||
private int blueprintUUID = 0;
|
||||
public int blueprintUUID = 0;
|
||||
public int rank;
|
||||
public ArrayList<Vector3fImmutable> patrolPoints;
|
||||
public ProtectionState protectionState = ProtectionState.NONE;
|
||||
protected Resists resists;
|
||||
private float w = 1.0f;
|
||||
private Vector3f meshScale = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
private int doorState = 0;
|
||||
@@ -88,14 +91,12 @@ public class Building extends AbstractWorldObject {
|
||||
private int maxGold;
|
||||
private int effectFlags = 0;
|
||||
private String name = "";
|
||||
private int rank;
|
||||
private boolean ownerIsNPC = true;
|
||||
private boolean spireIsActive = false;
|
||||
private ConcurrentHashMap<String, JobContainer> timers = null;
|
||||
private ConcurrentHashMap<String, Long> timestamps = null;
|
||||
private ConcurrentHashMap<Integer, BuildingFriends> friends = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<Integer, Condemned> condemned = new ConcurrentHashMap<>();
|
||||
private ProtectionState protectionState = ProtectionState.NONE;
|
||||
private ConcurrentHashMap<Integer, BuildingFriends> friends;
|
||||
private ConcurrentHashMap<Integer, Condemned> condemned;
|
||||
private ArrayList<Building> children = null;
|
||||
|
||||
/**
|
||||
@@ -106,27 +107,23 @@ public class Building extends AbstractWorldObject {
|
||||
super(rs);
|
||||
|
||||
float scale;
|
||||
Blueprint blueprint = null;
|
||||
|
||||
try {
|
||||
this.meshUUID = rs.getInt("meshUUID");
|
||||
this.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||
this.blueprintUUID = rs.getInt("blueprintUUID");
|
||||
this.gridObjectType = GridObjectType.STATIC;
|
||||
this.parentZone = DbManager.ZoneQueries.GET_BY_UID(rs.getLong("parent"));
|
||||
this.parentZoneUUID = rs.getInt("parent");
|
||||
this.name = rs.getString("name");
|
||||
this.ownerUUID = rs.getInt("ownerUUID");
|
||||
|
||||
// Orphaned Object Sanity Check
|
||||
//This was causing ABANDONED Tols.
|
||||
// if (objectType == DbObjectType.INVALID)
|
||||
// this.ownerUUID = 0;
|
||||
|
||||
this.doorState = rs.getInt("doorState");
|
||||
this.setHealth(rs.getInt("currentHP"));
|
||||
this.w = rs.getFloat("w");
|
||||
this.setRot(new Vector3f(0f, rs.getFloat("rotY"), 0f));
|
||||
this.reverseKOS = rs.getByte("reverseKOS") == 1 ? true : false;
|
||||
this.reverseKOS = rs.getByte("reverseKOS") == 1;
|
||||
this.statLat = rs.getFloat("locationX");
|
||||
this.statAlt = rs.getFloat("locationY");
|
||||
this.statLon = rs.getFloat("locationZ");
|
||||
|
||||
scale = rs.getFloat("scale");
|
||||
this.meshScale = new Vector3f(scale, scale, scale);
|
||||
@@ -143,79 +140,10 @@ public class Building extends AbstractWorldObject {
|
||||
this.level = rs.getInt("level");
|
||||
this.isFurniture = (rs.getBoolean("isFurniture"));
|
||||
|
||||
// Lookup building blueprint
|
||||
|
||||
if (this.blueprintUUID == 0)
|
||||
blueprint = Blueprint._meshLookup.get(meshUUID);
|
||||
else
|
||||
blueprint = this.getBlueprint();
|
||||
|
||||
// Log error if something went horrible wrong
|
||||
|
||||
if ((this.blueprintUUID != 0) && (blueprint == null))
|
||||
Logger.error("Invalid blueprint for object: " + this.getObjectUUID());
|
||||
|
||||
// Note: We handle R8 tree edge case for mesh and health
|
||||
// after city is loaded to avoid recursive result set call
|
||||
// in City resulting in a stack ovreflow.
|
||||
|
||||
if (blueprint != null) {
|
||||
|
||||
// Only switch mesh for player dropped structures
|
||||
|
||||
if (this.blueprintUUID != 0)
|
||||
this.meshUUID = blueprint.getMeshForRank(rank);
|
||||
|
||||
this.healthMax = blueprint.getMaxHealth(this.rank);
|
||||
|
||||
// If this object has no blueprint but is a blueprint
|
||||
// mesh then set it's current health to max health
|
||||
|
||||
if (this.blueprintUUID == 0)
|
||||
this.setHealth(healthMax);
|
||||
|
||||
if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK))
|
||||
this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this);
|
||||
|
||||
} else {
|
||||
this.healthMax = 100000; // Structures with no blueprint mesh
|
||||
this.setHealth(healthMax);
|
||||
}
|
||||
|
||||
// Null out blueprint if not needed (npc building)
|
||||
|
||||
if (blueprintUUID == 0)
|
||||
blueprint = null;
|
||||
|
||||
resists = new Resists("Building");
|
||||
this.statLat = rs.getFloat("locationX");
|
||||
this.statAlt = rs.getFloat("locationY");
|
||||
this.statLon = rs.getFloat("locationZ");
|
||||
|
||||
if (this.parentZone != null) {
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID);
|
||||
if (parentBuilding != null) {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon));
|
||||
} else {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ));
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
// Altitude of this building is derived from the heightmap engine.
|
||||
|
||||
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ);
|
||||
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z);
|
||||
this.setLoc(tempLoc);
|
||||
}
|
||||
}
|
||||
|
||||
this._strongboxValue = rs.getInt("currentGold");
|
||||
this.maxGold = 15000000; // *** Refactor to blueprint method
|
||||
this.reserve = rs.getInt("reserve");
|
||||
|
||||
// Does building have a protection contract?
|
||||
this.taxType = TaxType.valueOf(rs.getString("taxType"));
|
||||
this.taxAmount = rs.getInt("taxAmount");
|
||||
this.protectionState = ProtectionState.valueOf(rs.getString("protectionState"));
|
||||
@@ -236,8 +164,7 @@ public class Building extends AbstractWorldObject {
|
||||
this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault());
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e.toString());
|
||||
Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,86 +277,6 @@ public class Building extends AbstractWorldObject {
|
||||
return rank;
|
||||
}
|
||||
|
||||
public final void setRank(int newRank) {
|
||||
|
||||
int newMeshUUID;
|
||||
boolean success;
|
||||
|
||||
|
||||
// If this building has no blueprint then set rank and exit immediatly.
|
||||
|
||||
if (this.blueprintUUID == 0 || this.getBlueprint() != null && this.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)) {
|
||||
this.rank = newRank;
|
||||
DbManager.BuildingQueries.CHANGE_RANK(this.getObjectUUID(), newRank);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete any upgrade jobs before doing anything else. It won't quite work
|
||||
// if in a few lines we happen to delete this building.
|
||||
|
||||
JobContainer jc = this.getTimers().get("UPGRADE");
|
||||
|
||||
if (jc != null) {
|
||||
if (!JobScheduler.getInstance().cancelScheduledJob(jc))
|
||||
Logger.error("failed to cancel existing upgrade job.");
|
||||
}
|
||||
|
||||
// Attempt write to database, or delete the building
|
||||
// if we are destroying it.
|
||||
|
||||
if (newRank == -1)
|
||||
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(this);
|
||||
else
|
||||
success = DbManager.BuildingQueries.updateBuildingRank(this, newRank);
|
||||
|
||||
if (success == false) {
|
||||
Logger.error("Error writing to database UUID: " + this.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
this.isDeranking.compareAndSet(false, true);
|
||||
|
||||
// Change the building's rank
|
||||
|
||||
this.rank = newRank;
|
||||
|
||||
// New rank means new mesh
|
||||
|
||||
newMeshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||
this.meshUUID = newMeshUUID;
|
||||
|
||||
// New rank mean new max hitpoints.
|
||||
|
||||
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
|
||||
this.setCurrentHitPoints(this.healthMax);
|
||||
|
||||
if (this.getUpgradeDateTime() != null)
|
||||
BuildingManager.setUpgradeDateTime(this, null, 0);
|
||||
|
||||
// If we destroyed this building make sure to turn off
|
||||
// protection
|
||||
|
||||
if (this.rank == -1)
|
||||
this.protectionState = ProtectionState.NONE;
|
||||
|
||||
if ((this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
&& (this.rank == 8))
|
||||
this.meshUUID = Realm.getRealmMesh(this.getCity());
|
||||
;
|
||||
|
||||
// update object to clients
|
||||
|
||||
this.refresh(true);
|
||||
if (this.getBounds() != null)
|
||||
this.getBounds().setBounds(this);
|
||||
|
||||
// Cleanup hirelings resulting from rank change
|
||||
|
||||
BuildingManager.cleanupHirelings(this);
|
||||
|
||||
this.isDeranking.compareAndSet(true, false);
|
||||
}
|
||||
|
||||
public final int getOwnerUUID() {
|
||||
return ownerUUID;
|
||||
}
|
||||
@@ -538,14 +385,14 @@ public class Building extends AbstractWorldObject {
|
||||
Mine.SendMineAttackMessage(this);
|
||||
|
||||
City playerCity = ZoneManager.getCityAtLocation(this.loc);
|
||||
if(playerCity != null){
|
||||
if(this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())){
|
||||
if (playerCity != null) {
|
||||
if (this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())) {
|
||||
//friendly building has been attacked, add attacker to city outlaw list
|
||||
if(!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
if (!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
playerCity.cityOutlaws.add(attacker.getObjectUUID());
|
||||
for(Mob guard : playerCity.getParent().zoneMobSet)
|
||||
if(guard.combatTarget == null)
|
||||
guard.setCombatTarget(attacker);
|
||||
for (Mob guard : playerCity.getParent().zoneMobSet)
|
||||
if (guard.combatTarget == null)
|
||||
guard.setCombatTarget(attacker);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,7 +448,7 @@ public class Building extends AbstractWorldObject {
|
||||
MineRecord mineRecord = MineRecord.borrow(mine, attacker, RecordEventType.DESTROY);
|
||||
DataWarehouse.pushToWarehouse(mineRecord);
|
||||
|
||||
this.setRank(-1);
|
||||
BuildingManager.setRank(this, -1);
|
||||
this.setCurrentHitPoints((float) 1);
|
||||
this.healthMax = (float) 1;
|
||||
this.meshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||
@@ -624,9 +471,9 @@ public class Building extends AbstractWorldObject {
|
||||
// Time to either derank or destroy the building.
|
||||
|
||||
if ((this.rank - 1) < 1)
|
||||
this.setRank(-1);
|
||||
BuildingManager.setRank(this, -1);
|
||||
else
|
||||
this.setRank(this.rank - 1);
|
||||
BuildingManager.setRank(this, this.rank - 1);
|
||||
|
||||
}
|
||||
|
||||
@@ -684,7 +531,7 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
if (spireBuilding != null) {
|
||||
spireBuilding.disableSpire(true);
|
||||
spireBuilding.setRank(-1);
|
||||
BuildingManager.setRank(spireBuilding, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,7 +542,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Delete a random shrine
|
||||
|
||||
if (shrineBuilding != null)
|
||||
shrineBuilding.setRank(-1);
|
||||
BuildingManager.setRank(shrineBuilding, -1);
|
||||
}
|
||||
|
||||
if (barracksBuildings.size() > this.rank - 1) {
|
||||
@@ -705,7 +552,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Delete a random barrack
|
||||
|
||||
if (barracksBuilding != null)
|
||||
barracksBuilding.setRank(-1);
|
||||
BuildingManager.setRank(barracksBuilding, -1);
|
||||
}
|
||||
|
||||
// If the tree is R8 and deranking, we need to update it's
|
||||
@@ -734,7 +581,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Let's do so and early exit
|
||||
|
||||
if (this.rank > 1) {
|
||||
this.setRank(rank - 1);
|
||||
BuildingManager.setRank(this, rank - 1);
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
return;
|
||||
}
|
||||
@@ -852,10 +699,6 @@ public class Building extends AbstractWorldObject {
|
||||
return this.meshUUID;
|
||||
}
|
||||
|
||||
public final void setMeshUUID(int value) {
|
||||
this.meshUUID = value;
|
||||
}
|
||||
|
||||
public final Resists getResists() {
|
||||
return this.resists;
|
||||
}
|
||||
@@ -942,13 +785,8 @@ public class Building extends AbstractWorldObject {
|
||||
DispatchMessage.sendToAllInRange(this, applyBuildingEffectMsg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utils
|
||||
*/
|
||||
|
||||
public void removeEffectBit(int bit) {
|
||||
this.effectFlags &= (~bit);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -965,26 +803,18 @@ public class Building extends AbstractWorldObject {
|
||||
this.updateName();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Serializing
|
||||
*/
|
||||
|
||||
public final AbstractCharacter getOwner() {
|
||||
|
||||
if (this.ownerUUID == 0)
|
||||
return null;
|
||||
if (this.ownerIsNPC)
|
||||
return NPC.getFromCache(this.ownerUUID);
|
||||
|
||||
return PlayerCharacter.getFromCache(this.ownerUUID);
|
||||
if (this.ownerIsNPC)
|
||||
return NPC.getNPC(this.ownerUUID);
|
||||
|
||||
return PlayerCharacter.getPlayerCharacter(this.ownerUUID);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Database
|
||||
*/
|
||||
|
||||
public final String getOwnerName() {
|
||||
AbstractCharacter owner = this.getOwner();
|
||||
if (owner != null)
|
||||
@@ -1045,19 +875,6 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
}
|
||||
|
||||
// *** Refactor: Can't we just use setRank() for this?
|
||||
|
||||
public final void rebuildMine() {
|
||||
this.setRank(1);
|
||||
this.meshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||
|
||||
// New rank mean new max hitpoints.
|
||||
|
||||
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
|
||||
this.setCurrentHitPoints(this.healthMax);
|
||||
this.getBounds().setBounds(this);
|
||||
}
|
||||
|
||||
public final void refreshGuild() {
|
||||
|
||||
UpdateObjectMsg uom = new UpdateObjectMsg(this, 5);
|
||||
@@ -1069,105 +886,123 @@ public class Building extends AbstractWorldObject {
|
||||
return maxGold;
|
||||
}
|
||||
|
||||
//This returns if a player is allowed access to control the building
|
||||
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
try {
|
||||
// Set Parent Zone
|
||||
|
||||
this.parentZone.zoneBuildingSet.add(this);
|
||||
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID);
|
||||
this.parentZone.zoneBuildingSet.add(this);
|
||||
|
||||
// Submit upgrade job if building is currently set to rank.
|
||||
// Lookup building blueprint
|
||||
|
||||
try {
|
||||
DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID);
|
||||
this.ownerIsNPC = (objectType == DbObjectType.NPC);
|
||||
} catch (Exception e) {
|
||||
this.ownerIsNPC = false;
|
||||
Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
}
|
||||
Blueprint blueprint;
|
||||
|
||||
try {
|
||||
DbManager.BuildingQueries.LOAD_ALL_FRIENDS_FOR_BUILDING(this);
|
||||
DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this);
|
||||
} catch (Exception e) {
|
||||
Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage());
|
||||
}
|
||||
if (this.blueprintUUID == 0)
|
||||
blueprint = Blueprint._meshLookup.get(meshUUID);
|
||||
else
|
||||
blueprint = this.getBlueprint();
|
||||
|
||||
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
||||
// Log error if something went horrible wrong
|
||||
|
||||
if (this.ownerIsNPC) {
|
||||
if (NPC.getNPC(this.ownerUUID) == null)
|
||||
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
if ((this.blueprintUUID != 0) && (blueprint == null))
|
||||
Logger.error("Invalid blueprint for object: " + this.getObjectUUID());
|
||||
|
||||
} else if (this.ownerUUID != 0) {
|
||||
if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) {
|
||||
Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
}
|
||||
}
|
||||
// Note: We handle R8 tree edge case for mesh and health
|
||||
// after city is loaded to avoid recursive result set call
|
||||
// in City resulting in a stack ovreflow.
|
||||
|
||||
// Apply health bonus and special mesh for realm if applicable
|
||||
if ((this.getCity() != null) && this.getCity().getTOL() != null && (this.getCity().getTOL().rank == 8)) {
|
||||
if (blueprint != null) {
|
||||
|
||||
// Update mesh accordingly
|
||||
if (this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)
|
||||
this.meshUUID = Realm.getRealmMesh(this.getCity());
|
||||
// Only switch mesh for player dropped structures
|
||||
|
||||
// Apply realm capital health bonus.
|
||||
// Do not apply bonus to banestones or TOL's. *** Refactor:
|
||||
// Possibly only protected buildings? Needs some thought.
|
||||
if (this.blueprintUUID != 0)
|
||||
this.meshUUID = blueprint.getMeshForRank(rank);
|
||||
|
||||
float missingHealth = 0;
|
||||
this.healthMax = blueprint.getMaxHealth(this.rank);
|
||||
|
||||
if (this.health.get() != 0)
|
||||
missingHealth = this.healthMax - this.health.get();
|
||||
// If this object has no blueprint but is a blueprint
|
||||
// mesh then set it's current health to max health
|
||||
|
||||
if ((this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() != BuildingGroup.TOL)
|
||||
&& (this.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)) {
|
||||
this.healthMax += (this.healthMax * Realm.getRealmHealthMod(this.getCity()));
|
||||
if (this.blueprintUUID == 0)
|
||||
this.setHealth(healthMax);
|
||||
|
||||
if (this.health.get() != 0)
|
||||
this.health.set(this.healthMax - missingHealth);
|
||||
this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>());
|
||||
|
||||
if (this.health.get() > this.healthMax)
|
||||
this.health.set(this.healthMax);
|
||||
}
|
||||
}
|
||||
if (this.patrolPoints == null)
|
||||
Logger.error("Null patrol points");
|
||||
|
||||
// Set bounds for this building
|
||||
|
||||
Bounds buildingBounds = Bounds.borrow();
|
||||
buildingBounds.setBounds(this);
|
||||
this.setBounds(buildingBounds);
|
||||
|
||||
//create a new list for children if the building is not a child. children list default is null.
|
||||
//TODO Remove Furniture/Child buildings from building class and move them into a seperate class.
|
||||
|
||||
if (this.parentBuildingID == 0)
|
||||
this.children = new ArrayList<>();
|
||||
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parent = BuildingManager.getBuildingFromCache(this.parentBuildingID);
|
||||
|
||||
if (parent != null) {
|
||||
parent.children.add(this);
|
||||
|
||||
//add furniture to region cache. floor and level are reversed in database, //TODO Fix
|
||||
|
||||
Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z);
|
||||
if (region != null)
|
||||
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.upgradeDateTime != null)
|
||||
BuildingManager.submitUpgradeJob(this);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
this.healthMax = 100000; // Structures with no blueprint mesh
|
||||
this.setHealth(healthMax);
|
||||
}
|
||||
|
||||
resists = new Resists("Building");
|
||||
|
||||
if (this.parentZone != null) {
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID);
|
||||
if (parentBuilding != null) {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon));
|
||||
} else {
|
||||
this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ));
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
// Altitude of this building is derived from the heightmap engine.
|
||||
|
||||
Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ);
|
||||
tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z);
|
||||
this.setLoc(tempLoc);
|
||||
}
|
||||
}
|
||||
|
||||
// Submit upgrade job if building is currently set to rank.
|
||||
|
||||
try {
|
||||
DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID);
|
||||
this.ownerIsNPC = (objectType == DbObjectType.NPC);
|
||||
} catch (Exception e) {
|
||||
this.ownerIsNPC = false;
|
||||
Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString());
|
||||
}
|
||||
|
||||
// Reference friend and condemn lists from BuildingManager
|
||||
|
||||
this.friends = BuildingManager._buildingFriends.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>());
|
||||
this.condemned = BuildingManager._buildingCondemned.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>());
|
||||
|
||||
// Set bounds for this building
|
||||
|
||||
Bounds buildingBounds = Bounds.borrow();
|
||||
buildingBounds.setBounds(this);
|
||||
this.setBounds(buildingBounds);
|
||||
|
||||
//create a new list for children if the building is not a child. children list default is null.
|
||||
//TODO Remove Furniture/Child buildings from building class and move them into a seperate class.
|
||||
|
||||
if (this.parentBuildingID == 0)
|
||||
this.children = new ArrayList<>();
|
||||
|
||||
if (this.parentBuildingID != 0) {
|
||||
Building parent = BuildingManager.getBuilding(this.parentBuildingID);
|
||||
|
||||
if (parent != null) {
|
||||
parent.children.add(this);
|
||||
|
||||
//add furniture to region cache. floor and level are reversed in database, //TODO Fix
|
||||
|
||||
Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z);
|
||||
|
||||
if (region != null)
|
||||
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.upgradeDateTime != null)
|
||||
BuildingManager.submitUpgradeJob(this);
|
||||
}
|
||||
|
||||
public synchronized boolean setOwner(AbstractCharacter newOwner) {
|
||||
@@ -1193,7 +1028,6 @@ public class Building extends AbstractWorldObject {
|
||||
this.ownerIsNPC = (newOwner.getObjectType() == GameObjectType.NPC);
|
||||
}
|
||||
|
||||
|
||||
// Set new guild for hirelings and refresh all clients
|
||||
|
||||
this.refreshGuild();
|
||||
@@ -1313,7 +1147,7 @@ public class Building extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
// Save to database ?
|
||||
if (updateRecord == true)
|
||||
if (updateRecord)
|
||||
return DbManager.BuildingQueries.UPDATE_DOOR_LOCK(this.getObjectUUID(), this.doorState);
|
||||
else
|
||||
return true;
|
||||
@@ -1349,7 +1183,6 @@ public class Building extends AbstractWorldObject {
|
||||
this.spireIsActive = true;
|
||||
this.updateEffects();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public final void disableSpire(boolean refreshEffect) {
|
||||
@@ -1558,10 +1391,7 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
public boolean assetIsProtected() {
|
||||
|
||||
boolean outValue = false;
|
||||
|
||||
if (protectionState.equals(ProtectionState.PROTECTED))
|
||||
outValue = true;
|
||||
boolean outValue = protectionState.equals(ProtectionState.PROTECTED);
|
||||
|
||||
if (protectionState.equals(ProtectionState.CONTRACT))
|
||||
outValue = true;
|
||||
@@ -1638,18 +1468,10 @@ public class Building extends AbstractWorldObject {
|
||||
return patrolPoints;
|
||||
}
|
||||
|
||||
public void setPatrolPoints(ArrayList<Vector3fImmutable> patrolPoints) {
|
||||
this.patrolPoints = patrolPoints;
|
||||
}
|
||||
|
||||
public ArrayList<Vector3fImmutable> getSentryPoints() {
|
||||
return sentryPoints;
|
||||
}
|
||||
|
||||
public void setSentryPoints(ArrayList<Vector3fImmutable> sentryPoints) {
|
||||
this.sentryPoints = sentryPoints;
|
||||
}
|
||||
|
||||
public synchronized boolean addProtectionTax(Building building, PlayerCharacter pc, final TaxType taxType, int amount, boolean enforceKOS) {
|
||||
if (building == null)
|
||||
return false;
|
||||
@@ -1674,14 +1496,6 @@ public class Building extends AbstractWorldObject {
|
||||
|
||||
}
|
||||
|
||||
public synchronized boolean declineTaxOffer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean acceptTaxOffer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean acceptTaxes() {
|
||||
|
||||
if (!DbManager.BuildingQueries.acceptTaxes(this))
|
||||
@@ -1706,14 +1520,6 @@ public class Building extends AbstractWorldObject {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isTaxed() {
|
||||
if (this.taxType == TaxType.NONE)
|
||||
return false;
|
||||
if (this.taxAmount == 0)
|
||||
return false;
|
||||
return this.taxDateTime != null;
|
||||
}
|
||||
|
||||
public void AddToBarracksList() {
|
||||
City playerCity = ZoneManager.getCityAtLocation(this.loc);
|
||||
if (playerCity != null) {
|
||||
|
||||
@@ -14,10 +14,10 @@ import java.sql.SQLException;
|
||||
|
||||
public class BuildingFriends {
|
||||
|
||||
private int playerUID;
|
||||
private int buildingUID;
|
||||
private int guildUID;
|
||||
private int friendType;
|
||||
public int playerUID;
|
||||
public int buildingUID;
|
||||
public int guildUID;
|
||||
public int friendType;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
@@ -38,16 +38,4 @@ public class BuildingFriends {
|
||||
this.friendType = friendType;
|
||||
}
|
||||
|
||||
public int getPlayerUID() {
|
||||
return playerUID;
|
||||
}
|
||||
|
||||
public int getGuildUID() {
|
||||
return guildUID;
|
||||
}
|
||||
|
||||
public int getFriendType() {
|
||||
return friendType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
public static long lastCityUpdate = 0;
|
||||
public final HashSet<Integer> _playerMemory = new HashSet<>();
|
||||
private final boolean isOpen = false;
|
||||
private final boolean reverseKOS = false;
|
||||
public java.time.LocalDateTime established;
|
||||
public boolean hasBeenTransfered = false;
|
||||
public LocalDateTime realmTaxDate;
|
||||
@@ -55,7 +57,8 @@ public class City extends AbstractWorldObject {
|
||||
public volatile boolean protectionEnforced = true;
|
||||
public ArrayList<Building> cityBarracks;
|
||||
public ArrayList<Integer> cityOutlaws = new ArrayList<>();
|
||||
protected Zone parentZone;
|
||||
public Zone parentZone;
|
||||
public int parentZoneUUID;
|
||||
private String cityName;
|
||||
private String motto;
|
||||
private String description;
|
||||
@@ -73,15 +76,12 @@ public class City extends AbstractWorldObject {
|
||||
private boolean forceRename = false;
|
||||
private boolean noTeleport = false; //used by npc cities
|
||||
private boolean noRepledge = false; //used by npc cities
|
||||
private final boolean isOpen = false;
|
||||
private int treeOfLifeID;
|
||||
private Vector3fImmutable location = Vector3fImmutable.ZERO;
|
||||
|
||||
// Players who have entered the city (used for adding and removing affects)
|
||||
private Vector3fImmutable bindLoc;
|
||||
private int warehouseBuildingID = 0;
|
||||
private boolean open = false;
|
||||
private boolean reverseKOS = false;
|
||||
private String hash;
|
||||
|
||||
/**
|
||||
@@ -91,6 +91,7 @@ public class City extends AbstractWorldObject {
|
||||
public City(ResultSet rs) throws SQLException {
|
||||
super(rs);
|
||||
try {
|
||||
this.parentZoneUUID = rs.getInt("parent");
|
||||
this.cityName = rs.getString("name");
|
||||
this.motto = rs.getString("motto");
|
||||
this.isNpc = rs.getByte("isNpc");
|
||||
@@ -126,7 +127,9 @@ public class City extends AbstractWorldObject {
|
||||
this.location.getY(),
|
||||
this.location.getZ() + this.bindZ);
|
||||
this.radiusType = rs.getInt("radiusType");
|
||||
|
||||
float bindradiustemp = rs.getFloat("bindRadius");
|
||||
|
||||
if (bindradiustemp > 2)
|
||||
bindradiustemp -= 2;
|
||||
|
||||
@@ -135,30 +138,8 @@ public class City extends AbstractWorldObject {
|
||||
this.forceRename = rs.getInt("forceRename") == 1;
|
||||
this.open = rs.getInt("open") == 1;
|
||||
|
||||
if (this.cityName.equals("Perdition") || this.cityName.equals("Bastion")) {
|
||||
this.noTeleport = true;
|
||||
this.noRepledge = true;
|
||||
} else {
|
||||
this.noTeleport = false;
|
||||
this.noRepledge = false;
|
||||
}
|
||||
|
||||
this.hash = rs.getString("hash");
|
||||
|
||||
if (this.motto.isEmpty()) {
|
||||
Guild guild = this.getGuild();
|
||||
|
||||
if (guild != null && guild.isEmptyGuild() == false)
|
||||
this.motto = guild.getMotto();
|
||||
}
|
||||
|
||||
Zone zone = ZoneManager.getZoneByUUID(rs.getInt("parent"));
|
||||
|
||||
if (zone != null)
|
||||
setParent(zone);
|
||||
|
||||
//npc cities without heightmaps except swampstone are specials.
|
||||
|
||||
this.realmID = rs.getInt("realmID");
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -567,30 +548,6 @@ public class City extends AbstractWorldObject {
|
||||
return this.parentZone;
|
||||
}
|
||||
|
||||
public void setParent(Zone zone) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
this.parentZone = zone;
|
||||
this.location = new Vector3fImmutable(zone.absX, zone.absY, zone.absZ);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
||||
this.location.y,
|
||||
this.location.z + this.bindZ);
|
||||
|
||||
// set city bounds
|
||||
|
||||
Bounds cityBounds = Bounds.borrow();
|
||||
cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city.
|
||||
new Vector2f(Enum.CityBoundsType.GRID.halfExtents, Enum.CityBoundsType.GRID.halfExtents),
|
||||
0.0f);
|
||||
this.setBounds(cityBounds);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractCharacter getOwner() {
|
||||
|
||||
if (this.getTOL() == null)
|
||||
@@ -720,11 +677,33 @@ public class City extends AbstractWorldObject {
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
// Set city bounds
|
||||
// *** Note: Moved to SetParent()
|
||||
// for some undocumented reason
|
||||
this.setObjectTypeMask(MBServerStatics.MASK_CITY);
|
||||
|
||||
// Set city motto to current guild motto
|
||||
// Set parent
|
||||
|
||||
this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID);
|
||||
|
||||
// If it's not a player city then must be an NPC city
|
||||
|
||||
if (!parentZone.guild_zone)
|
||||
parentZone.isNPCCity = true;
|
||||
|
||||
// Set location for this city
|
||||
|
||||
this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ);
|
||||
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX,
|
||||
this.location.y,
|
||||
this.location.z + this.bindZ);
|
||||
|
||||
// set city bounds
|
||||
|
||||
Bounds cityBounds = Bounds.borrow();
|
||||
cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city.
|
||||
new Vector2f(Enum.CityBoundsType.GRID.halfExtents, Enum.CityBoundsType.GRID.halfExtents),
|
||||
0.0f);
|
||||
this.setBounds(cityBounds);
|
||||
|
||||
// Sanity check; no tol
|
||||
|
||||
if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
|
||||
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
|
||||
@@ -740,6 +719,8 @@ public class City extends AbstractWorldObject {
|
||||
Logger.error("Unable to find realm of ID " + realmID + " for city " + this.getObjectUUID());
|
||||
}
|
||||
|
||||
// Set city motto to current guild motto
|
||||
|
||||
if (this.getGuild() != null) {
|
||||
this.motto = this.getGuild().getMotto();
|
||||
|
||||
@@ -749,8 +730,10 @@ public class City extends AbstractWorldObject {
|
||||
for (Guild sub : this.getGuild().getSubGuildList()) {
|
||||
|
||||
if ((sub.getGuildState() == GuildState.Protectorate) ||
|
||||
(sub.getGuildState() == GuildState.Province))
|
||||
(sub.getGuildState() == GuildState.Province)) {
|
||||
this.isCapital = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> guildList = Guild.GuildRoster(this.getGuild());
|
||||
@@ -758,6 +741,61 @@ public class City extends AbstractWorldObject {
|
||||
this.population = guildList.size();
|
||||
}
|
||||
|
||||
if (this.cityName.equals("Perdition") || this.cityName.equals("Bastion")) {
|
||||
this.noTeleport = true;
|
||||
this.noRepledge = true;
|
||||
} else {
|
||||
this.noTeleport = false;
|
||||
this.noRepledge = false;
|
||||
}
|
||||
|
||||
// Add city entry to data warehouse if newly created
|
||||
|
||||
if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (this.getHash() == null)) {
|
||||
|
||||
this.setHash();
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, this.getObjectUUID()) == false) {
|
||||
CityRecord cityRecord = CityRecord.borrow(this, Enum.RecordEventType.CREATE);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply health bonus and special mesh for realm if applicable
|
||||
|
||||
if (this.getTOL().rank == 8) {
|
||||
|
||||
// Update mesh accordingly
|
||||
|
||||
this.getTOL().meshUUID = Realm.getRealmMesh(this);
|
||||
|
||||
// Apply realm capital health bonus.
|
||||
// Do not apply bonus to banestones or TOL's. *** Refactor:
|
||||
// Possibly only protected buildings? Needs some thought.
|
||||
|
||||
float missingHealth = 0;
|
||||
|
||||
if (this.health.get() != 0)
|
||||
missingHealth = this.healthMax - this.health.get();
|
||||
|
||||
for (Building building : this.parentZone.zoneBuildingSet) {
|
||||
|
||||
if (building.getBlueprint() != null &&
|
||||
building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE &&
|
||||
building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
|
||||
|
||||
building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this));
|
||||
|
||||
if (this.health.get() != 0)
|
||||
this.health.set(this.healthMax - missingHealth);
|
||||
|
||||
if (this.health.get() > this.healthMax)
|
||||
this.health.set(this.healthMax);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Banes are loaded for this city from the database at this point
|
||||
|
||||
if (this.getBane() == null)
|
||||
@@ -765,12 +803,12 @@ public class City extends AbstractWorldObject {
|
||||
|
||||
// if this city is baned, add the siege effect
|
||||
|
||||
try {
|
||||
this.getTOL().addEffectBit((1 << 16));
|
||||
this.getBane().getStone().addEffectBit((1 << 19));
|
||||
} catch (Exception e) {
|
||||
Logger.info("Failed ao add bane effects on city." + e.getMessage());
|
||||
}
|
||||
this.getTOL().addEffectBit((1 << 16));
|
||||
this.getBane().getStone().addEffectBit((1 << 19));
|
||||
|
||||
// Spawn city
|
||||
|
||||
this.setLoc(this.getLoc());
|
||||
}
|
||||
|
||||
public void addCityEffect(EffectsBase effectBase, int rank) {
|
||||
@@ -830,7 +868,6 @@ public class City extends AbstractWorldObject {
|
||||
player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Warehouse getWarehouse() {
|
||||
@@ -856,12 +893,6 @@ public class City extends AbstractWorldObject {
|
||||
return collided;
|
||||
}
|
||||
|
||||
public boolean isLocationOnCityGrid(Bounds newBounds) {
|
||||
|
||||
boolean collided = Bounds.collide(this.getBounds(), newBounds, 0);
|
||||
return collided;
|
||||
}
|
||||
|
||||
public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) {
|
||||
|
||||
return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.halfExtents);
|
||||
|
||||
@@ -14,72 +14,45 @@ import engine.gameManager.DbManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
public class Condemned {
|
||||
|
||||
public static final int INDIVIDUAL = 2;
|
||||
public static final int GUILD = 4;
|
||||
public static final int NATION = 5;
|
||||
private int ID;
|
||||
private int playerUID;
|
||||
private int parent;
|
||||
private int guildUID;
|
||||
private int friendType;
|
||||
private boolean active;
|
||||
|
||||
public int playerUID;
|
||||
public int buildingUUID;
|
||||
public int guildUID;
|
||||
public int friendType;
|
||||
public boolean active;
|
||||
|
||||
/**
|
||||
* ResultSet Constructor
|
||||
*/
|
||||
public Condemned(ResultSet rs) throws SQLException {
|
||||
this.playerUID = rs.getInt("playerUID");
|
||||
this.parent = rs.getInt("buildingUID");
|
||||
this.buildingUUID = rs.getInt("buildingUID");
|
||||
this.guildUID = rs.getInt("guildUID");
|
||||
this.friendType = rs.getInt("friendType");
|
||||
this.active = rs.getBoolean("active");
|
||||
}
|
||||
|
||||
|
||||
public Condemned(int playerUID, int parent, int guildUID, int friendType) {
|
||||
public Condemned(int playerUID, int buildingUUID, int guildUID, int friendType) {
|
||||
super();
|
||||
this.playerUID = playerUID;
|
||||
this.parent = parent;
|
||||
this.buildingUUID = buildingUUID;
|
||||
this.guildUID = guildUID;
|
||||
this.friendType = friendType;
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
|
||||
public int getPlayerUID() {
|
||||
return playerUID;
|
||||
}
|
||||
|
||||
|
||||
public int getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
|
||||
public int getGuildUID() {
|
||||
return guildUID;
|
||||
}
|
||||
|
||||
|
||||
public int getFriendType() {
|
||||
return friendType;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
|
||||
public boolean setActive(boolean active) {
|
||||
|
||||
if (!DbManager.BuildingQueries.updateActiveCondemn(this, active))
|
||||
return false;
|
||||
|
||||
this.active = active;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ public class Guild extends AbstractWorldObject {
|
||||
private int cityUUID = 0;
|
||||
private int mineTime;
|
||||
private ArrayList<PlayerCharacter> banishList;
|
||||
private ArrayList<PlayerCharacter> characterKOSList;
|
||||
private ArrayList<Guild> guildKOSList;
|
||||
private ArrayList<Guild> allyList = new ArrayList<>();
|
||||
private ArrayList<Guild> enemyList = new ArrayList<>();
|
||||
private ArrayList<Guild> recommendList = new ArrayList<>();
|
||||
@@ -83,8 +81,6 @@ public class Guild extends AbstractWorldObject {
|
||||
this.leadershipType = leadershipType;
|
||||
|
||||
this.banishList = new ArrayList<>();
|
||||
this.characterKOSList = new ArrayList<>();
|
||||
this.guildKOSList = new ArrayList<>();
|
||||
this.allyList = new ArrayList<>();
|
||||
this.enemyList = new ArrayList<>();
|
||||
this.subGuildList = new ArrayList<>();
|
||||
@@ -115,8 +111,6 @@ public class Guild extends AbstractWorldObject {
|
||||
this.leadershipType = leadershipType;
|
||||
|
||||
this.banishList = new ArrayList<>();
|
||||
this.characterKOSList = new ArrayList<>();
|
||||
this.guildKOSList = new ArrayList<>();
|
||||
this.allyList = new ArrayList<>();
|
||||
this.enemyList = new ArrayList<>();
|
||||
this.subGuildList = new ArrayList<>();
|
||||
@@ -189,22 +183,6 @@ public class Guild extends AbstractWorldObject {
|
||||
return a.getObjectUUID() == b.getObjectUUID();
|
||||
}
|
||||
|
||||
public static boolean sameGuildExcludeErrant(Guild a, Guild b) {
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
if (a.isEmptyGuild() || b.isEmptyGuild())
|
||||
return false;
|
||||
return a.getObjectUUID() == b.getObjectUUID();
|
||||
}
|
||||
|
||||
public static boolean sameGuildIncludeErrant(Guild a, Guild b) {
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
if (a.isEmptyGuild() || b.isEmptyGuild())
|
||||
return true;
|
||||
return a.getObjectUUID() == b.getObjectUUID();
|
||||
}
|
||||
|
||||
public static boolean sameNation(Guild a, Guild b) {
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
@@ -225,11 +203,6 @@ public class Guild extends AbstractWorldObject {
|
||||
return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild();
|
||||
}
|
||||
|
||||
public static boolean isTaxCollector(int uuid) {
|
||||
//TODO add the handling for this later
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canSwearIn(Guild toSub) {
|
||||
|
||||
boolean canSwear = false;
|
||||
@@ -393,7 +366,9 @@ public class Guild extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public static ArrayList<PlayerCharacter> GuildRoster(Guild guild) {
|
||||
|
||||
ArrayList<PlayerCharacter> roster = new ArrayList<>();
|
||||
|
||||
if (guild == null)
|
||||
return roster;
|
||||
|
||||
@@ -402,6 +377,7 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
if (DbManager.getList(GameObjectType.PlayerCharacter) == null)
|
||||
return roster;
|
||||
|
||||
for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)) {
|
||||
PlayerCharacter toAdd = (PlayerCharacter) ago;
|
||||
|
||||
@@ -462,14 +438,6 @@ public class Guild extends AbstractWorldObject {
|
||||
return banishList;
|
||||
}
|
||||
|
||||
public ArrayList<PlayerCharacter> getCharacterKOSList() {
|
||||
return characterKOSList;
|
||||
}
|
||||
|
||||
public ArrayList<Guild> getGuildKOSList() {
|
||||
return guildKOSList;
|
||||
}
|
||||
|
||||
public ArrayList<Guild> getAllyList() {
|
||||
return allyList;
|
||||
}
|
||||
@@ -560,9 +528,12 @@ public class Guild extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public boolean setGuildLeader(AbstractCharacter ac) {
|
||||
|
||||
if (ac == null)
|
||||
return false;
|
||||
|
||||
// errant guilds cant be guild leader.
|
||||
|
||||
if (this.isEmptyGuild())
|
||||
return false;
|
||||
|
||||
@@ -575,6 +546,7 @@ public class Guild extends AbstractWorldObject {
|
||||
PlayerCharacter oldGuildLeader = PlayerCharacter.getFromCache(this.guildLeaderUUID);
|
||||
|
||||
//old guildLeader no longer has guildLeadership stauts.
|
||||
|
||||
if (oldGuildLeader != null)
|
||||
oldGuildLeader.setGuildLeader(false);
|
||||
|
||||
@@ -586,9 +558,12 @@ public class Guild extends AbstractWorldObject {
|
||||
}
|
||||
|
||||
public boolean setGuildLeaderForCreate(AbstractCharacter ac) {
|
||||
|
||||
if (ac == null)
|
||||
return false;
|
||||
|
||||
// errant guilds cant be guild leader.
|
||||
|
||||
if (this.isEmptyGuild())
|
||||
return false;
|
||||
|
||||
@@ -824,17 +799,6 @@ public class Guild extends AbstractWorldObject {
|
||||
Logger.error("Failed to find Object Type for owner " + this.guildLeaderUUID);
|
||||
}
|
||||
|
||||
|
||||
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
||||
if (this.ownerIsNPC) {
|
||||
if (NPC.getNPC(this.guildLeaderUUID) == null)
|
||||
Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.guildLeaderUUID);
|
||||
|
||||
} else if (this.guildLeaderUUID != 0) {
|
||||
if (PlayerCharacter.getPlayerCharacter(this.guildLeaderUUID) == null)
|
||||
Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.guildLeaderUUID);
|
||||
}
|
||||
|
||||
// If loading this guild for the first time write it's character record to disk
|
||||
|
||||
if (ConfigManager.serverType.equals(ServerType.WORLDSERVER)
|
||||
@@ -859,7 +823,9 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
if (this.nation == null)
|
||||
this.nation = Guild.getErrantGuild();
|
||||
|
||||
//Get guild states.
|
||||
|
||||
try {
|
||||
this.subGuildList = DbManager.GuildQueries.GET_SUB_GUILDS(this.getObjectUUID());
|
||||
} catch (Exception e) {
|
||||
@@ -882,7 +848,6 @@ public class Guild extends AbstractWorldObject {
|
||||
if (this.cityUUID == 0)
|
||||
return;
|
||||
|
||||
|
||||
// Calculate number of realms this guild controls
|
||||
// Only do this on the game server to avoid loading a TOL/City/Zone needlessly
|
||||
|
||||
@@ -898,9 +863,8 @@ public class Guild extends AbstractWorldObject {
|
||||
|
||||
//add alliance list, clear all lists as there seems to be a bug where alliances are doubled, need to find where.
|
||||
//possible runAfterLoad being called twice?!?!
|
||||
|
||||
this.banishList = dbGuildHandler.GET_GUILD_BANISHED(this.getObjectUUID());
|
||||
this.characterKOSList = DbManager.GuildQueries.GET_GUILD_KOS_CHARACTER(this.getObjectUUID());
|
||||
this.guildKOSList = DbManager.GuildQueries.GET_GUILD_KOS_GUILD(this.getObjectUUID());
|
||||
|
||||
this.allyList.clear();
|
||||
this.enemyList.clear();
|
||||
|
||||
@@ -1677,10 +1677,13 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (this.getMobBase().enemy.size() > 0)
|
||||
this.enemy.addAll(this.getMobBase().enemy);
|
||||
}
|
||||
|
||||
// Load skills, powers and effects
|
||||
|
||||
NPCManager.applyMobbaseEffects(this);
|
||||
NPCManager.applyEquipmentResists(this);
|
||||
NPCManager.applyMobbaseSkill(this);
|
||||
NPCManager.applyRuneSkills(this,this.getMobBaseID());
|
||||
NPCManager.applyRuneSkills(this, this.getMobBaseID());
|
||||
this.recalculateStats();
|
||||
this.setHealth(this.healthMax);
|
||||
|
||||
@@ -1695,6 +1698,11 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (this.agentType.equals(AIAgentType.MOBILE))
|
||||
NPCManager.AssignPatrolPoints(this);
|
||||
|
||||
// Load minions for guard captain.
|
||||
|
||||
if (this.agentType.equals(AIAgentType.GUARDCAPTAIN))
|
||||
DbManager.MobQueries.LOAD_GUARD_MINIONS(this);
|
||||
|
||||
this.deathTime = 0;
|
||||
}
|
||||
|
||||
@@ -1732,9 +1740,9 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (!ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
return;
|
||||
|
||||
if (this.getCombatTarget() == null) {
|
||||
if (this.getCombatTarget() == null)
|
||||
this.setCombatTarget(ac);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setRank(int newRank) {
|
||||
|
||||
@@ -170,10 +170,10 @@ public class Regions {
|
||||
return true;
|
||||
|
||||
//next region is stairs, if they are on the same level as stairs or 1 up, world object can enter.
|
||||
if (toEnter.stairs)
|
||||
if (toEnter.isStairs())
|
||||
if (worldObject.region.level == toEnter.level || toEnter.level - 1 == worldObject.region.level)
|
||||
return true;
|
||||
if (worldObject.region.stairs) {
|
||||
if (worldObject.region.isStairs()) {
|
||||
|
||||
boolean movingUp = false;
|
||||
|
||||
@@ -239,7 +239,7 @@ public class Regions {
|
||||
return true;
|
||||
|
||||
//cant move up a level without stairs.
|
||||
if (!fromRegion.stairs)
|
||||
if (!fromRegion.isStairs())
|
||||
return false;
|
||||
|
||||
boolean movingUp = false;
|
||||
@@ -367,7 +367,8 @@ public class Regions {
|
||||
}
|
||||
|
||||
public boolean isStairs() {
|
||||
return stairs;
|
||||
|
||||
return this.highLerp.y - this.lowLerp.y > 0.25f;
|
||||
}
|
||||
|
||||
public boolean isExit() {
|
||||
|
||||
@@ -12,7 +12,6 @@ package engine.objects;
|
||||
import engine.Enum;
|
||||
import engine.InterestManagement.Terrain;
|
||||
import engine.db.archive.DataWarehouse;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
@@ -28,8 +27,10 @@ import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Zone extends AbstractGameObject {
|
||||
public class Zone extends AbstractWorldObject {
|
||||
|
||||
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public static long lastRespawn = 0;
|
||||
public final Set<Building> zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
@@ -49,7 +50,7 @@ public class Zone extends AbstractGameObject {
|
||||
public int min_level;
|
||||
public int max_level;
|
||||
public boolean hasBeenHotzone = false;
|
||||
public ArrayList<Zone> nodes = null;
|
||||
public ArrayList<Zone> nodes = new ArrayList<>();
|
||||
public int parentZoneID;
|
||||
public Zone parent = null;
|
||||
public Bounds bounds;
|
||||
@@ -59,8 +60,6 @@ public class Zone extends AbstractGameObject {
|
||||
public float global_height = 0;
|
||||
public float seaLevel = 0f;
|
||||
public float sea_level_offset = 0;
|
||||
public static final Set<Mob> respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
public static long lastRespawn = 0;
|
||||
public float major_radius;
|
||||
public float minor_radius;
|
||||
public float min_blend;
|
||||
@@ -80,56 +79,40 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
super(rs);
|
||||
|
||||
this.parentZoneID = rs.getInt("parent");
|
||||
this.playerCityUUID = rs.getInt("playerCityUUID");
|
||||
this.guild_zone = this.playerCityUUID != 0;
|
||||
this.zoneName = rs.getString("zone_name");
|
||||
this.xOffset = rs.getFloat("xOffset");
|
||||
this.zOffset = rs.getFloat("zOffset");
|
||||
this.yOffset = rs.getFloat("yOffset");
|
||||
this.template = rs.getInt("template");
|
||||
this.peace_zone = rs.getByte("peace_zone");
|
||||
this.icon1 = rs.getString("icon1");
|
||||
this.icon2 = rs.getString("icon2");
|
||||
this.icon3 = rs.getString("icon3");
|
||||
this.min_level = rs.getInt("min_level");
|
||||
this.max_level = rs.getInt("max_level");
|
||||
this.major_radius = rs.getFloat("major_radius");
|
||||
this.minor_radius = rs.getFloat("minor_radius");
|
||||
this.min_blend = rs.getFloat("min_blend");
|
||||
this.max_blend = rs.getFloat("max_blend");
|
||||
this.sea_level_type = rs.getString("sea_level_type");
|
||||
this.sea_level_offset = rs.getFloat("sea_level");
|
||||
this.terrain_type = rs.getString("terrain_type");
|
||||
this.terrain_max_y = rs.getFloat("terrain_max_y");
|
||||
this.terrain_image = rs.getInt("terrain_image");
|
||||
this.parentZoneID = rs.getInt("parent");
|
||||
this.playerCityUUID = rs.getInt("playerCityUUID");
|
||||
this.guild_zone = this.playerCityUUID != 0;
|
||||
this.zoneName = rs.getString("zone_name");
|
||||
this.xOffset = rs.getFloat("xOffset");
|
||||
this.zOffset = rs.getFloat("zOffset");
|
||||
this.yOffset = rs.getFloat("yOffset");
|
||||
this.template = rs.getInt("template");
|
||||
this.peace_zone = rs.getByte("peace_zone");
|
||||
this.icon1 = rs.getString("icon1");
|
||||
this.icon2 = rs.getString("icon2");
|
||||
this.icon3 = rs.getString("icon3");
|
||||
this.min_level = rs.getInt("min_level");
|
||||
this.max_level = rs.getInt("max_level");
|
||||
this.major_radius = rs.getFloat("major_radius");
|
||||
this.minor_radius = rs.getFloat("minor_radius");
|
||||
this.min_blend = rs.getFloat("min_blend");
|
||||
this.max_blend = rs.getFloat("max_blend");
|
||||
this.sea_level_type = rs.getString("sea_level_type");
|
||||
this.sea_level_offset = rs.getFloat("sea_level");
|
||||
this.terrain_type = rs.getString("terrain_type");
|
||||
this.terrain_max_y = rs.getFloat("terrain_max_y");
|
||||
this.terrain_image = rs.getInt("terrain_image");
|
||||
|
||||
if (this.guild_zone) {
|
||||
this.max_blend = 128;
|
||||
this.min_blend = 128;
|
||||
this.terrain_max_y = 5;
|
||||
this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||
this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||
this.terrain_type = "PLANAR";
|
||||
}
|
||||
// Configuration for player cities
|
||||
|
||||
if (this.terrain_type.equals("NONE"))
|
||||
this.terrain = null;
|
||||
else
|
||||
this.terrain = new Terrain(this);
|
||||
|
||||
//this needs to be here specifically for new zones created after server boot (e.g. player city zones)
|
||||
|
||||
Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID);
|
||||
this.setParent(parentZone);
|
||||
|
||||
if (this.min_level == 0 && parentZone != null) {
|
||||
this.min_level = parentZone.min_level;
|
||||
this.max_level = parentZone.max_level;
|
||||
}
|
||||
|
||||
if (parentZone != null)
|
||||
parentZone.addNode(this);
|
||||
if (this.guild_zone) {
|
||||
this.max_blend = 128;
|
||||
this.min_blend = 128;
|
||||
this.terrain_max_y = 5;
|
||||
this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||
this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents;
|
||||
this.terrain_type = "PLANAR";
|
||||
}
|
||||
|
||||
// If zone doesn't yet hava a hash then write it back to the zone table
|
||||
|
||||
@@ -191,6 +174,30 @@ public class Zone extends AbstractGameObject {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
// First zone is always the seafloor
|
||||
|
||||
if (ZoneManager.seaFloor == null)
|
||||
ZoneManager.seaFloor = this;
|
||||
|
||||
if (this.terrain_type.equals("NONE"))
|
||||
this.terrain = null;
|
||||
else
|
||||
this.terrain = new Terrain(this);
|
||||
|
||||
this.setParent();
|
||||
|
||||
if (this.min_level == 0 && this.parent != null) {
|
||||
this.min_level = this.parent.min_level;
|
||||
this.max_level = this.parent.max_level;
|
||||
}
|
||||
|
||||
ZoneManager.populateZoneCollections(this);
|
||||
|
||||
}
|
||||
|
||||
/* Method sets a default value for player cities
|
||||
* otherwise using values derived from the loadnum
|
||||
* field in the obj_zone database table.
|
||||
@@ -204,14 +211,16 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
}
|
||||
|
||||
public void setParent(final Zone value) {
|
||||
public void setParent() {
|
||||
|
||||
this.parent = value;
|
||||
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
||||
this.parent = ZoneManager.getZoneByUUID(parentZoneID);
|
||||
|
||||
if (parent != null)
|
||||
parent.addNode(this);
|
||||
|
||||
// Seafloor
|
||||
|
||||
if (this.parent == null) {
|
||||
if (ZoneManager.seaFloor.equals(this)) {
|
||||
this.absX = this.xOffset;
|
||||
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
this.global_height = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||
@@ -261,7 +270,7 @@ public class Zone extends AbstractGameObject {
|
||||
|
||||
// Macro zones have icons.
|
||||
|
||||
if (this.guild_zone == true)
|
||||
if (this.guild_zone)
|
||||
return false;
|
||||
|
||||
if (this.parent == null)
|
||||
@@ -278,19 +287,6 @@ public class Zone extends AbstractGameObject {
|
||||
return this.parentZoneID;
|
||||
}
|
||||
|
||||
public ArrayList<Zone> getNodes() {
|
||||
|
||||
if (this.nodes == null) {
|
||||
this.nodes = DbManager.ZoneQueries.GET_MAP_NODES(super.getObjectUUID());
|
||||
|
||||
//Add reverse lookup for child->parent
|
||||
if (this.nodes != null)
|
||||
for (Zone zone : this.nodes)
|
||||
zone.setParent(this);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Serializing
|
||||
*/
|
||||
@@ -309,15 +305,16 @@ public class Zone extends AbstractGameObject {
|
||||
if (this.equals(ZoneManager.seaFloor))
|
||||
return false;
|
||||
|
||||
if (this.getNodes().isEmpty())
|
||||
if (this.nodes.isEmpty())
|
||||
return false;
|
||||
|
||||
if (this.getNodes().get(0).isMacroZone())
|
||||
if (this.nodes.get(0).isMacroZone())
|
||||
return true;
|
||||
|
||||
return this.parent.equals(ZoneManager.seaFloor);
|
||||
|
||||
}
|
||||
|
||||
public void setHash() {
|
||||
|
||||
this.hash = DataWarehouse.hasher.encrypt(this.getObjectUUID());
|
||||
|
||||
@@ -312,12 +312,21 @@ public class WorldServer {
|
||||
Logger.info("Initializing PowersManager.");
|
||||
PowersManager.initPowersManager(true);
|
||||
|
||||
Logger.info("Initializing granted Skills for Runes");
|
||||
Logger.info("Loading granted Skills for Runes");
|
||||
DbManager.SkillsBaseQueries.LOAD_ALL_RUNE_SKILLS();
|
||||
|
||||
Logger.info("Initializing Player Friends");
|
||||
Logger.info("Loading Player Friends");
|
||||
DbManager.PlayerCharacterQueries.LOAD_PLAYER_FRIENDS();
|
||||
|
||||
Logger.info("Loading Building Friends");
|
||||
DbManager.BuildingQueries.LOAD_BUILDING_FRIENDS();
|
||||
|
||||
Logger.info("Loading Building Condemned");
|
||||
DbManager.BuildingQueries.LOAD_BUILDING_CONDEMNED();
|
||||
|
||||
Logger.info("Loading Barracks Patrol Points");
|
||||
DbManager.BuildingQueries.LOAD_BARRACKS_PATROL_POINTS();
|
||||
|
||||
Logger.info("Initializing NPC Profits");
|
||||
DbManager.NPCQueries.LOAD_NPC_PROFITS();
|
||||
|
||||
@@ -409,7 +418,17 @@ public class WorldServer {
|
||||
|
||||
//Load Buildings, Mobs and NPCs for server
|
||||
|
||||
getWorldBuildingsMobsNPCs();
|
||||
Logger.info("Populating world with objects");
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
DbManager.ZoneQueries.GET_ALL_ZONES();
|
||||
DbManager.BuildingQueries.GET_ALL_BUILDINGS();
|
||||
DbManager.CityQueries.GET_ALL_CITIES();
|
||||
DbManager.NPCQueries.GET_ALL_NPCS();
|
||||
DbManager.MobQueries.GET_ALL_MOBS();
|
||||
|
||||
Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms");
|
||||
|
||||
// Configure realms for serialization
|
||||
// Doing this after the world is loaded
|
||||
@@ -438,19 +457,6 @@ public class WorldServer {
|
||||
//pick a startup Hotzone
|
||||
ZoneManager.generateAndSetRandomHotzone();
|
||||
|
||||
Logger.info("Loading All Players from database to Server Cache");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
DbManager.PlayerCharacterQueries.GET_ALL_CHARACTERS();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
|
||||
Logger.info("Loading All Players took " + (end - start) + " ms.");
|
||||
|
||||
ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize();
|
||||
|
||||
Logger.info("Loading Player Heraldries");
|
||||
@@ -531,98 +537,6 @@ public class WorldServer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void getWorldBuildingsMobsNPCs() {
|
||||
|
||||
ArrayList<Zone> rootParent;
|
||||
|
||||
rootParent = DbManager.ZoneQueries.GET_MAP_NODES(worldUUID);
|
||||
|
||||
if (rootParent.isEmpty()) {
|
||||
Logger.error("populateWorldBuildings: No entries found in worldMap for parent " + worldUUID);
|
||||
return;
|
||||
}
|
||||
|
||||
//Set sea floor object for server
|
||||
|
||||
Zone seaFloor = rootParent.get(0);
|
||||
seaFloor.setParent(null);
|
||||
ZoneManager.setSeaFloor(seaFloor);
|
||||
|
||||
rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor));
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
for (Zone zone : rootParent) {
|
||||
|
||||
ZoneManager.addZone(zone.template, zone);
|
||||
|
||||
//Handle Buildings
|
||||
|
||||
try {
|
||||
ArrayList<Building> bList;
|
||||
bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
|
||||
|
||||
for (Building b : bList) {
|
||||
|
||||
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
|
||||
b.setLoc(b.getLoc());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Handle Mobs
|
||||
|
||||
try {
|
||||
ArrayList<Mob> mobs;
|
||||
mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone);
|
||||
|
||||
for (Mob m : mobs) {
|
||||
m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks());
|
||||
m.setLoc(m.getLoc());
|
||||
|
||||
// Load Minions for Guard Captains here.
|
||||
|
||||
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK)
|
||||
DbManager.MobQueries.LOAD_GUARD_MINIONS(m);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Handle NPCs
|
||||
|
||||
try {
|
||||
ArrayList<NPC> npcs;
|
||||
|
||||
// Ignore NPCs on the seafloor (npc guild leaders, etc)
|
||||
|
||||
if (zone.equals(seaFloor))
|
||||
continue;
|
||||
|
||||
npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone);
|
||||
|
||||
for (NPC n : npcs) {
|
||||
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
|
||||
n.setLoc(n.getLoc());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//Handle cities
|
||||
|
||||
ZoneManager.loadCities(zone);
|
||||
ZoneManager.populateWorldZones(zone);
|
||||
|
||||
}
|
||||
|
||||
Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to remove a client on "leave world", "quit game", killed client
|
||||
* process, etc.
|
||||
|
||||
@@ -19,6 +19,7 @@ package engine.workthreads;
|
||||
*/
|
||||
|
||||
import engine.Enum;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.GuildManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
@@ -127,7 +128,7 @@ public class DestroyCityThread implements Runnable {
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.WAREHOUSE)) {
|
||||
|
||||
if (cityBuilding.getRank() != -1)
|
||||
cityBuilding.setRank(-1);
|
||||
BuildingManager.setRank(cityBuilding, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class HourlyJobThread implements Runnable {
|
||||
mine.nationName = nation.getName();
|
||||
mine.nationTag = nation.getGuildTag();
|
||||
|
||||
mineBuilding.rebuildMine();
|
||||
BuildingManager.rebuildMine(mineBuilding);
|
||||
WorldGrid.updateObject(mineBuilding);
|
||||
|
||||
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.lastClaimer.getName() + " has claimed the mine in " + mine.getParentZone().parent.zoneName + " for " + mine.getOwningGuild().getName() + ". The mine is no longer active.");
|
||||
@@ -176,7 +176,7 @@ public class HourlyJobThread implements Runnable {
|
||||
MineRecord mineRecord = MineRecord.borrow(mine, mine.lastClaimer, Enum.RecordEventType.CAPTURE);
|
||||
DataWarehouse.pushToWarehouse(mineRecord);
|
||||
|
||||
mineBuilding.setRank(mineBuilding.getRank());
|
||||
BuildingManager.setRank(mineBuilding, mineBuilding.getRank());
|
||||
mine.lastClaimer = null;
|
||||
mine.setActive(false);
|
||||
mine.wasClaimed = true;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class TransferCityThread implements Runnable {
|
||||
|
||||
//Reset TOL to rank 1
|
||||
|
||||
city.getTOL().setRank(1);
|
||||
BuildingManager.setRank(city.getTOL(), 1);
|
||||
|
||||
// Transfer all assets to new owner
|
||||
|
||||
|
||||
Reference in New Issue
Block a user