Browse Source

City realm id lookup not db load

combat-2
MagicBot 7 months ago
parent
commit
916a12a434
  1. 2
      src/engine/InterestManagement/RealmMap.java
  2. 5
      src/engine/net/client/handlers/TaxCityMsgHandler.java
  3. 2
      src/engine/objects/Building.java
  4. 21
      src/engine/objects/City.java
  5. 7
      src/engine/objects/Guild.java
  6. 18
      src/engine/objects/PlayerCharacter.java
  7. 2
      src/engine/objects/Realm.java
  8. 6
      src/engine/workthreads/DestroyCityThread.java

2
src/engine/InterestManagement/RealmMap.java

@ -68,7 +68,7 @@ public enum RealmMap { @@ -68,7 +68,7 @@ public enum RealmMap {
public static Realm getRealmForCity(City city) {
Realm outRealm = null;
outRealm = city.getRealm();
outRealm = city.realm;
return outRealm;
}

5
src/engine/net/client/handlers/TaxCityMsgHandler.java

@ -1,9 +1,9 @@ @@ -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 { @@ -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;
}

2
src/engine/objects/Building.java

@ -561,7 +561,7 @@ public class Building extends AbstractWorldObject { @@ -561,7 +561,7 @@ public class Building extends AbstractWorldObject {
if (this.rank == 8) {
cityRealm = city.getRealm();
cityRealm = city.realm;
if (cityRealm != null)
cityRealm.abandonRealm();

21
src/engine/objects/City.java

@ -63,7 +63,6 @@ public class City extends AbstractWorldObject { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -1388,4 +1380,5 @@ public class City extends AbstractWorldObject {
DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
return true;
}
}

7
src/engine/objects/Guild.java

@ -9,12 +9,12 @@ @@ -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 { @@ -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());

18
src/engine/objects/PlayerCharacter.java

@ -1434,12 +1434,15 @@ public class PlayerCharacter extends AbstractCharacter { @@ -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 { @@ -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++;
}

2
src/engine/objects/Realm.java

@ -160,7 +160,7 @@ public class Realm { @@ -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();

6
src/engine/workthreads/DestroyCityThread.java

@ -18,12 +18,12 @@ package engine.workthreads; @@ -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 { @@ -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

Loading…
Cancel
Save