City realm id lookup not db load

This commit is contained in:
2024-04-27 11:32:05 -04:00
parent 3a8521683b
commit 916a12a434
8 changed files with 32 additions and 31 deletions
+7 -14
View File
@@ -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;
}
}