Browse Source

Cleanup of cityChoice handler

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

92
src/engine/objects/City.java

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

4
src/engine/objects/Guild.java

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

Loading…
Cancel
Save