diff --git a/src/engine/InterestManagement/RealmMap.java b/src/engine/InterestManagement/RealmMap.java index 57b3c71c..36fee92b 100644 --- a/src/engine/InterestManagement/RealmMap.java +++ b/src/engine/InterestManagement/RealmMap.java @@ -68,7 +68,7 @@ public enum RealmMap { public static Realm getRealmForCity(City city) { Realm outRealm = null; - outRealm = city.getRealm(); + outRealm = city.realm; return outRealm; } diff --git a/src/engine/net/client/handlers/TaxCityMsgHandler.java b/src/engine/net/client/handlers/TaxCityMsgHandler.java index 5cdf9241..ae13304f 100644 --- a/src/engine/net/client/handlers/TaxCityMsgHandler.java +++ b/src/engine/net/client/handlers/TaxCityMsgHandler.java @@ -1,9 +1,9 @@ package engine.net.client.handlers; -import engine.mbEnums; import engine.InterestManagement.RealmMap; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; +import engine.mbEnums; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -72,7 +72,8 @@ public class TaxCityMsgHandler extends AbstractClientMsgHandler { // return true; // } - if (playerGuild.getOwnedCity().getRealm() == null) { + City city1 = playerGuild.getOwnedCity(); + if (city1.realm == null) { ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!"); return true; } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index bb31eaf1..c70ae851 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -561,7 +561,7 @@ public class Building extends AbstractWorldObject { if (this.rank == 8) { - cityRealm = city.getRealm(); + cityRealm = city.realm; if (cityRealm != null) cityRealm.abandonRealm(); diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 74cb81dd..ce946486 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -63,7 +63,6 @@ public class City extends AbstractWorldObject { private int isNoobIsle; //1: noob, 0: not noob: -1: not noob, no teleport private int population = 0; private int siegesWithstood = 0; - private int realmID; private int radiusType; private float bindRadius; private float bindX; @@ -81,6 +80,7 @@ public class City extends AbstractWorldObject { private boolean open = false; private String hash; public Warehouse warehouse; + public Realm realm; /** * ResultSet Constructor @@ -138,8 +138,6 @@ public class City extends AbstractWorldObject { this.hash = rs.getString("hash"); - this.realmID = rs.getInt("realmID"); - } catch (Exception e) { Logger.error(e); } @@ -734,12 +732,12 @@ public class City extends AbstractWorldObject { if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (this.isNpc == (byte) 0)) { - Realm wsr = Realm.getRealm(this.realmID); + this.realm = RealmMap.getRealmAtLocation(this.getLoc()); - if (wsr != null) - wsr.addCity(this.getObjectUUID()); + if (realm != null) + realm.addCity(this.getObjectUUID()); else - Logger.error("Unable to find realm of ID " + realmID + " for city " + this.getObjectUUID()); + Logger.error("Unable to find realm for city " + this.getObjectUUID()); } // Set city motto to current guild motto @@ -893,12 +891,6 @@ public class City extends AbstractWorldObject { } } - public Realm getRealm() { - - return Realm.getRealm(this.realmID); - - } - public boolean isLocationOnCityGrid(Vector3fImmutable insideLoc) { Bounds newBounds = Bounds.borrow(); @@ -1300,7 +1292,7 @@ public class City extends AbstractWorldObject { return true; } - if (playerGuild.getOwnedCity().getRealm() == null) { + if (RealmMap.getRealmIDAtLocation(playerGuild.getOwnedCity().getLoc()) == 0) { ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!"); return true; } @@ -1388,4 +1380,5 @@ public class City extends AbstractWorldObject { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); return true; } + } diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 2384d20d..769a1f5d 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -9,12 +9,12 @@ package engine.objects; -import engine.mbEnums; -import engine.mbEnums.*; import engine.db.archive.DataWarehouse; import engine.db.archive.GuildRecord; import engine.db.handlers.dbGuildHandler; import engine.gameManager.*; +import engine.mbEnums; +import engine.mbEnums.*; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -250,7 +250,8 @@ public class Guild extends AbstractWorldObject { City ownedCity = guild.getOwnedCity(); if (ownedCity != null) { - Realm realm = guild.getOwnedCity().getRealm(); + City city = guild.getOwnedCity(); + Realm realm = city.realm; if (realm != null && realm.getRulingCity() != null) { if (realm.getRulingCity().equals(ownedCity)) { writer.putInt(realm.getCharterType()); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 0d4704b5..01e5115a 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1434,12 +1434,15 @@ public class PlayerCharacter extends AbstractCharacter { return 0; if (player.getGuild().getOwnedCity() == null) return 10; - if (player.getGuild().getOwnedCity().getRealm() == null) + City city5 = player.getGuild().getOwnedCity(); + if (city5.realm == null) return 10; - if (player.getGuild().getOwnedCity().getRealm().getRulingCity() == null) + City city4 = player.getGuild().getOwnedCity(); + if (city4.realm.getRulingCity() == null) return 10; - if (player.getGuild().getOwnedCity().getRealm().getRulingCity().getObjectUUID() != player.getGuild().getOwnedCity().getObjectUUID()) + City city3 = player.getGuild().getOwnedCity(); + if (city3.realm.getRulingCity().getObjectUUID() != player.getGuild().getOwnedCity().getObjectUUID()) return 10; int realmTitle = 1; if (player.getGuild().getSubGuildList() == null || player.getGuild().getSubGuildList().isEmpty()) @@ -1447,11 +1450,14 @@ public class PlayerCharacter extends AbstractCharacter { for (Guild subGuild : player.getGuild().getSubGuildList()) { if (subGuild.getOwnedCity() == null) continue; - if (subGuild.getOwnedCity().getRealm() == null) + City city2 = subGuild.getOwnedCity(); + if (city2.realm == null) continue; - if (subGuild.getOwnedCity().getRealm().getRulingCity() == null) + City city1 = subGuild.getOwnedCity(); + if (city1.realm.getRulingCity() == null) continue; - if (subGuild.getOwnedCity().getRealm().getRulingCity().getObjectUUID() != subGuild.getOwnedCity().getObjectUUID()) + City city = subGuild.getOwnedCity(); + if (city.realm.getRulingCity().getObjectUUID() != subGuild.getOwnedCity().getObjectUUID()) continue; realmTitle++; } diff --git a/src/engine/objects/Realm.java b/src/engine/objects/Realm.java index e27aed2d..bf18cb81 100644 --- a/src/engine/objects/Realm.java +++ b/src/engine/objects/Realm.java @@ -160,7 +160,7 @@ public class Realm { Realm serverRealm; CharterType charterType; - serverRealm = city.getRealm(); + serverRealm = city.realm; charterType = CharterType.getCharterTypeByID(serverRealm.charterType); return charterType.getMeshID(); diff --git a/src/engine/workthreads/DestroyCityThread.java b/src/engine/workthreads/DestroyCityThread.java index a2222dd5..c7783536 100644 --- a/src/engine/workthreads/DestroyCityThread.java +++ b/src/engine/workthreads/DestroyCityThread.java @@ -18,12 +18,12 @@ package engine.workthreads; * next reboot. */ -import engine.mbEnums; import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; import engine.gameManager.GuildManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; +import engine.mbEnums; import engine.objects.Building; import engine.objects.City; import engine.objects.Guild; @@ -144,8 +144,8 @@ public class DestroyCityThread implements Runnable { if (tol != null) BuildingManager.setRank(tol, -1); - if (city.getRealm() != null) - city.getRealm().removeCity(city.getObjectUUID()); + if (city.realm != null) + city.realm.removeCity(city.getObjectUUID()); // It's now safe to delete the city zone from the database // which will cause a cascade delete of everything else