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
+1 -1
View File
@@ -68,7 +68,7 @@ public enum RealmMap {
public static Realm getRealmForCity(City city) {
Realm outRealm = null;
outRealm = city.getRealm();
outRealm = city.realm;
return outRealm;
}
@@ -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;
}
+1 -1
View File
@@ -561,7 +561,7 @@ public class Building extends AbstractWorldObject {
if (this.rank == 8) {
cityRealm = city.getRealm();
cityRealm = city.realm;
if (cityRealm != null)
cityRealm.abandonRealm();
+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;
}
}
+4 -3
View File
@@ -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());
+12 -6
View File
@@ -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++;
}
+1 -1
View File
@@ -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();
@@ -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