Browse Source

Cleanup of cityChoice handler

postwipe-guilds
MagicBot 5 months ago
parent
commit
8a3e39e97d
  1. 74
      src/engine/objects/City.java
  2. 4
      src/engine/objects/Guild.java

74
src/engine/objects/City.java

@ -120,9 +120,7 @@ public class City extends AbstractWorldObject {
this.treeOfLifeID = rs.getInt("treeOfLifeUUID"); this.treeOfLifeID = rs.getInt("treeOfLifeUUID");
this.bindX = rs.getFloat("bindX"); this.bindX = rs.getFloat("bindX");
this.bindZ = rs.getFloat("bindZ"); this.bindZ = rs.getFloat("bindZ");
this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX, this.bindLoc = new Vector3fImmutable(this.location.getX() + this.bindX, this.location.getY(), this.location.getZ() + this.bindZ);
this.location.getY(),
this.location.getZ() + this.bindZ);
this.radiusType = rs.getInt("radiusType"); this.radiusType = rs.getInt("radiusType");
float bindradiustemp = rs.getFloat("bindRadius"); float bindradiustemp = rs.getFloat("bindRadius");
@ -298,7 +296,9 @@ public class City extends AbstractWorldObject {
ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(mbEnums.GameObjectType.City); ConcurrentHashMap<Integer, AbstractGameObject> worldCities = DbManager.getMap(mbEnums.GameObjectType.City);
if (ConfigManager.MB_RULESET.getValue().equals("LORE")) { if (ConfigManager.MB_RULESET.getValue().equals("LORE")) {
//handle compiling of cities able to be teleported to for lore rule-set //handle compiling of cities able to be teleported to for lore rule-set
for (AbstractGameObject ago : worldCities.values()) { for (AbstractGameObject ago : worldCities.values()) {
City city = (City) ago; City city = (City) ago;
@ -321,36 +321,38 @@ public class City extends AbstractWorldObject {
continue; continue;
} }
if (playerCharacter.guild.isEmptyGuild() && city.isNpc == 1) { if (playerCharacter.guild.isEmptyGuild() && city.isNpc == 1 && city.isNoobIsle == 0 && playerCharacter.level >= 20) {
cities.add(city); // Erranrs can travel everywhere. cities.add(city); // Errants can travel everywhere off noob isle.
continue; continue;
} }
if (city.isOpen() && city.getTOL().rank > 4 && city.getGuild().charter.equals(playerCharacter.guild.charter)) if (city.isOpen() && city.getTOL().rank > 4 && city.getGuild().charter.equals(playerCharacter.guild.charter)) {
if (!city.getTOL().reverseKOS) { if (!city.getTOL().reverseKOS) {
cities.add(city);//can teleport to any open ToL that shares charter cities.add(city);//can teleport to any open ToL that shares charter
continue; continue;
} else { }
if (city.getTOL().getCondemned().containsKey(playerCharacter.objectUUID) && city.getTOL().getCondemned().get(playerCharacter.objectUUID).active) { if (city.getTOL().getCondemned().containsKey(playerCharacter.objectUUID) && city.getTOL().getCondemned().get(playerCharacter.objectUUID).active) {
cities.add(city);//this player is allowed for the reverse KOS cities.add(city);//this player is allowed for the reverse KOS
continue; continue;
} }
if (city.getTOL().getCondemned().containsKey(playerCharacter.guildUUID) && city.getTOL().getCondemned().get(playerCharacter.guildUUID).active) { if (city.getTOL().getCondemned().containsKey(playerCharacter.guildUUID) && city.getTOL().getCondemned().get(playerCharacter.guildUUID).active) {
cities.add(city);//this guild is allowed for the reverse KOS cities.add(city);//this guild is allowed for the reverse KOS
continue; continue;
} }
if (city.getTOL().getCondemned().containsKey(playerCharacter.guild.getNation().getObjectUUID()) && city.getTOL().getCondemned().get(playerCharacter.guild.getNation().getObjectUUID()).active) {
if (city.getTOL().getCondemned().containsKey(playerCharacter.guild.getNation().getObjectUUID()) && city.getTOL().getCondemned().get(playerCharacter.guild.getNation().getObjectUUID()).active)
cities.add(city);//this nation is allowed for the reverse KOS cities.add(city);//this nation is allowed for the reverse KOS
continue;
}
} }
if (city.getGuild().getNation().equals(playerCharacter.guild.getNation())) {
cities.add(city);//can always teleport inside your own nation
} }
return cities;
} }
} else {
Guild pcG = playerCharacter.getGuild(); Guild guild = playerCharacter.getGuild();
//add npc cities //add npc cities
for (AbstractGameObject ago : worldCities.values()) { for (AbstractGameObject ago : worldCities.values()) {
@ -381,7 +383,7 @@ public class City extends AbstractWorldObject {
cities.add(city); //verify nation or guild is same cities.add(city); //verify nation or guild is same
} }
} }
} else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG)) } else if (Guild.sameNationExcludeErrant(city.getGuild(), guild))
cities.add(city); cities.add(city);
@ -404,7 +406,6 @@ public class City extends AbstractWorldObject {
} }
} }
}
return cities; return cities;
} }
@ -601,7 +602,7 @@ public class City extends AbstractWorldObject {
if (this.siegesWithstood == siegesWithstood) if (this.siegesWithstood == siegesWithstood)
return; return;
if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood) == true) if (DbManager.CityQueries.updateSiegesWithstood(this, siegesWithstood))
this.siegesWithstood = siegesWithstood; this.siegesWithstood = siegesWithstood;
else else
Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID()); Logger.error("Error when writing to database for cityUUID: " + this.getObjectUUID());
@ -739,7 +740,7 @@ public class City extends AbstractWorldObject {
for (AbstractCharacter npc : getTOL().getHirelings().keySet()) { for (AbstractCharacter npc : getTOL().getHirelings().keySet()) {
if (npc.getObjectType() == GameObjectType.NPC) if (npc.getObjectType() == GameObjectType.NPC)
if (((NPC) npc).getContract().isRuneMaster() == true) if (((NPC) npc).getContract().isRuneMaster())
outNPC = (NPC) npc; outNPC = (NPC) npc;
} }
@ -772,16 +773,13 @@ public class City extends AbstractWorldObject {
// Set location for this city // Set location for this city
this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ); this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ);
this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, this.location.y, this.location.z + this.bindZ);
this.location.y,
this.location.z + this.bindZ);
// set city bounds // set city bounds
Bounds cityBounds = Bounds.borrow(); 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. 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(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents), new Vector2f(mbEnums.CityBoundsType.GRID.halfExtents, mbEnums.CityBoundsType.GRID.halfExtents), 0.0f);
0.0f);
this.setBounds(cityBounds); this.setBounds(cityBounds);
// Sanity check; no tol // Sanity check; no tol
@ -789,8 +787,7 @@ public class City extends AbstractWorldObject {
if (BuildingManager.getBuilding(this.treeOfLifeID) == null) if (BuildingManager.getBuilding(this.treeOfLifeID) == null)
Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID); Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID);
if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) if ((ConfigManager.serverType.equals(ServerType.WORLDSERVER)) && (this.isNpc == (byte) 0)) {
&& (this.isNpc == (byte) 0)) {
this.realm = RealmMap.getRealmAtLocation(this.getLoc()); this.realm = RealmMap.getRealmAtLocation(this.getLoc());
@ -810,8 +807,7 @@ public class City extends AbstractWorldObject {
if (this.getGuild().getGuildState() == GuildState.Nation) if (this.getGuild().getGuildState() == GuildState.Nation)
for (Guild sub : this.getGuild().getSubGuildList()) { for (Guild sub : this.getGuild().getSubGuildList()) {
if ((sub.getGuildState() == GuildState.Protectorate) || if ((sub.getGuildState() == GuildState.Protectorate) || (sub.getGuildState() == GuildState.Province)) {
(sub.getGuildState() == GuildState.Province)) {
this.isCapital = 1; this.isCapital = 1;
break; break;
} }
@ -836,7 +832,7 @@ public class City extends AbstractWorldObject {
this.setHash(); this.setHash();
if (DataWarehouse.recordExists(mbEnums.DataRecordType.CITY, this.getObjectUUID()) == false) { if (!DataWarehouse.recordExists(DataRecordType.CITY, this.getObjectUUID())) {
CityRecord cityRecord = CityRecord.borrow(this, mbEnums.RecordEventType.CREATE); CityRecord cityRecord = CityRecord.borrow(this, mbEnums.RecordEventType.CREATE);
DataWarehouse.pushToWarehouse(cityRecord); DataWarehouse.pushToWarehouse(cityRecord);
} }
@ -861,9 +857,7 @@ public class City extends AbstractWorldObject {
for (Building building : this.parentZone.zoneBuildingSet) { for (Building building : this.parentZone.zoneBuildingSet) {
if (building.getBlueprint() != null && if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE && building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE &&
building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) {
building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this)); building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this));
@ -945,7 +939,7 @@ public class City extends AbstractWorldObject {
// Reapply effect with timeout? // Reapply effect with timeout?
if (refreshEffect == true) if (refreshEffect)
player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this); player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this);
} }
@ -1201,18 +1195,13 @@ public class City extends AbstractWorldObject {
// All protection contracts are void upon transfer of a city // All protection contracts are void upon transfer of a city
//Dont forget to not Flip protection on Banestones and siege Equipment... Noob. //Dont forget to not Flip protection on Banestones and siege Equipment... Noob.
if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() if (cityBuilding.getBlueprint() != null && !cityBuilding.getBlueprint().isSiegeEquip() && cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
&& cityBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)
cityBuilding.setProtectionState(ProtectionState.NONE); cityBuilding.setProtectionState(ProtectionState.NONE);
// Transfer ownership of valid city assets // Transfer ownership of valid city assets
// these assets are autoprotected. // these assets are autoprotected.
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
cityBuilding.claim(sourcePlayer); cityBuilding.claim(sourcePlayer);
cityBuilding.setProtectionState(ProtectionState.PROTECTED); cityBuilding.setProtectionState(ProtectionState.PROTECTED);
@ -1253,12 +1242,7 @@ public class City extends AbstractWorldObject {
// Transfer ownership of valid city assets // Transfer ownership of valid city assets
// these assets are autoprotected. // these assets are autoprotected.
if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) if ((cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)
) {
cityBuilding.claim(sourcePlayer); cityBuilding.claim(sourcePlayer);
cityBuilding.setProtectionState(ProtectionState.PROTECTED); cityBuilding.setProtectionState(ProtectionState.PROTECTED);

4
src/engine/objects/Guild.java

@ -193,12 +193,16 @@ public class Guild extends AbstractWorldObject {
} }
public static boolean sameNationExcludeErrant(Guild a, Guild b) { public static boolean sameNationExcludeErrant(Guild a, Guild b) {
if (a == null || b == null) if (a == null || b == null)
return false; return false;
if (a.getObjectUUID() == b.getObjectUUID()) if (a.getObjectUUID() == b.getObjectUUID())
return true; return true;
if (a.nation == null || b.nation == null) if (a.nation == null || b.nation == null)
return false; return false;
return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild(); return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild();
} }

Loading…
Cancel
Save