@ -48,6 +48,8 @@ public class City extends AbstractWorldObject {
@@ -48,6 +48,8 @@ public class City extends AbstractWorldObject {
public static long lastCityUpdate = 0 ;
public final HashSet < Integer > _playerMemory = new HashSet < > ( ) ;
private final boolean isOpen = false ;
private final boolean reverseKOS = false ;
public java . time . LocalDateTime established ;
public boolean hasBeenTransfered = false ;
public LocalDateTime realmTaxDate ;
@ -55,7 +57,8 @@ public class City extends AbstractWorldObject {
@@ -55,7 +57,8 @@ public class City extends AbstractWorldObject {
public volatile boolean protectionEnforced = true ;
public ArrayList < Building > cityBarracks ;
public ArrayList < Integer > cityOutlaws = new ArrayList < > ( ) ;
protected Zone parentZone ;
public Zone parentZone ;
public int parentZoneUUID ;
private String cityName ;
private String motto ;
private String description ;
@ -73,15 +76,12 @@ public class City extends AbstractWorldObject {
@@ -73,15 +76,12 @@ public class City extends AbstractWorldObject {
private boolean forceRename = false ;
private boolean noTeleport = false ; //used by npc cities
private boolean noRepledge = false ; //used by npc cities
private final boolean isOpen = false ;
private int treeOfLifeID ;
private Vector3fImmutable location = Vector3fImmutable . ZERO ;
// Players who have entered the city (used for adding and removing affects)
private Vector3fImmutable bindLoc ;
private int warehouseBuildingID = 0 ;
private boolean open = false ;
private boolean reverseKOS = false ;
private String hash ;
/ * *
@ -91,6 +91,7 @@ public class City extends AbstractWorldObject {
@@ -91,6 +91,7 @@ public class City extends AbstractWorldObject {
public City ( ResultSet rs ) throws SQLException {
super ( rs ) ;
try {
this . parentZoneUUID = rs . getInt ( "parent" ) ;
this . cityName = rs . getString ( "name" ) ;
this . motto = rs . getString ( "motto" ) ;
this . isNpc = rs . getByte ( "isNpc" ) ;
@ -126,7 +127,9 @@ public class City extends AbstractWorldObject {
@@ -126,7 +127,9 @@ public class City extends AbstractWorldObject {
this . location . getY ( ) ,
this . location . getZ ( ) + this . bindZ ) ;
this . radiusType = rs . getInt ( "radiusType" ) ;
float bindradiustemp = rs . getFloat ( "bindRadius" ) ;
if ( bindradiustemp > 2 )
bindradiustemp - = 2 ;
@ -135,30 +138,8 @@ public class City extends AbstractWorldObject {
@@ -135,30 +138,8 @@ public class City extends AbstractWorldObject {
this . forceRename = rs . getInt ( "forceRename" ) = = 1 ;
this . open = rs . getInt ( "open" ) = = 1 ;
if ( this . cityName . equals ( "Perdition" ) | | this . cityName . equals ( "Bastion" ) ) {
this . noTeleport = true ;
this . noRepledge = true ;
} else {
this . noTeleport = false ;
this . noRepledge = false ;
}
this . hash = rs . getString ( "hash" ) ;
if ( this . motto . isEmpty ( ) ) {
Guild guild = this . getGuild ( ) ;
if ( guild ! = null & & guild . isEmptyGuild ( ) = = false )
this . motto = guild . getMotto ( ) ;
}
Zone zone = ZoneManager . getZoneByUUID ( rs . getInt ( "parent" ) ) ;
if ( zone ! = null )
setParent ( zone ) ;
//npc cities without heightmaps except swampstone are specials.
this . realmID = rs . getInt ( "realmID" ) ;
} catch ( Exception e ) {
@ -567,30 +548,6 @@ public class City extends AbstractWorldObject {
@@ -567,30 +548,6 @@ public class City extends AbstractWorldObject {
return this . parentZone ;
}
public void setParent ( Zone zone ) {
try {
this . parentZone = zone ;
this . location = new Vector3fImmutable ( zone . absX , zone . absY , zone . absZ ) ;
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 ( Enum . CityBoundsType . GRID . halfExtents , Enum . CityBoundsType . GRID . halfExtents ) ,
0 . 0f ) ;
this . setBounds ( cityBounds ) ;
} catch ( Exception e ) {
Logger . error ( e ) ;
}
}
public AbstractCharacter getOwner ( ) {
if ( this . getTOL ( ) = = null )
@ -720,9 +677,31 @@ public class City extends AbstractWorldObject {
@@ -720,9 +677,31 @@ public class City extends AbstractWorldObject {
@Override
public void runAfterLoad ( ) {
// Set city bounds
// *** Note: Moved to SetParent()
// for some undocumented reason
this . setObjectTypeMask ( MBServerStatics . MASK_CITY ) ;
// Set parent
this . parentZone = ZoneManager . getZoneByUUID ( this . parentZoneUUID ) ;
// If it's not a player city then must be an NPC city
if ( ! parentZone . guild_zone )
parentZone . isNPCCity = true ;
// 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 ) ;
// 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 ( Enum . CityBoundsType . GRID . halfExtents , Enum . CityBoundsType . GRID . halfExtents ) ,
0 . 0f ) ;
this . setBounds ( cityBounds ) ;
// Set city motto to current guild motto
@ -749,8 +728,10 @@ public class City extends AbstractWorldObject {
@@ -749,8 +728,10 @@ public class City extends AbstractWorldObject {
for ( Guild sub : this . getGuild ( ) . getSubGuildList ( ) ) {
if ( ( sub . getGuildState ( ) = = GuildState . Protectorate ) | |
( sub . getGuildState ( ) = = GuildState . Province ) )
( sub . getGuildState ( ) = = GuildState . Province ) ) {
this . isCapital = 1 ;
break ;
}
}
ArrayList < PlayerCharacter > guildList = Guild . GuildRoster ( this . getGuild ( ) ) ;
@ -758,6 +739,26 @@ public class City extends AbstractWorldObject {
@@ -758,6 +739,26 @@ public class City extends AbstractWorldObject {
this . population = guildList . size ( ) ;
}
if ( this . cityName . equals ( "Perdition" ) | | this . cityName . equals ( "Bastion" ) ) {
this . noTeleport = true ;
this . noRepledge = true ;
} else {
this . noTeleport = false ;
this . noRepledge = false ;
}
// Add city entry to data warehouse if newly created
if ( ( ConfigManager . serverType . equals ( Enum . ServerType . WORLDSERVER ) ) & & ( this . getHash ( ) = = null ) ) {
this . setHash ( ) ;
if ( DataWarehouse . recordExists ( Enum . DataRecordType . CITY , this . getObjectUUID ( ) ) = = false ) {
CityRecord cityRecord = CityRecord . borrow ( this , Enum . RecordEventType . CREATE ) ;
DataWarehouse . pushToWarehouse ( cityRecord ) ;
}
}
// Banes are loaded for this city from the database at this point
if ( this . getBane ( ) = = null )
@ -765,12 +766,12 @@ public class City extends AbstractWorldObject {
@@ -765,12 +766,12 @@ public class City extends AbstractWorldObject {
// if this city is baned, add the siege effect
try {
this . getTOL ( ) . addEffectBit ( ( 1 < < 16 ) ) ;
this . getBane ( ) . getStone ( ) . addEffectBit ( ( 1 < < 19 ) ) ;
} catch ( Exception e ) {
Logger . info ( "Failed ao add bane effects on city." + e . getMessage ( ) ) ;
}
this . getTOL ( ) . addEffectBit ( ( 1 < < 16 ) ) ;
this . getBane ( ) . getStone ( ) . addEffectBit ( ( 1 < < 19 ) ) ;
// Spawn city
this . setLoc ( this . getLoc ( ) ) ;
}
public void addCityEffect ( EffectsBase effectBase , int rank ) {