|
|
@ -199,117 +199,118 @@ public class City extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void serializeForClientMsg(City city, ByteBufferWriter writer) { |
|
|
|
public static void serializeForClientMsg(City city, ByteBufferWriter writer) { |
|
|
|
AbstractCharacter guildRuler; |
|
|
|
try { |
|
|
|
Guild rulingGuild; |
|
|
|
AbstractCharacter guildRuler; |
|
|
|
Guild rulingNation; |
|
|
|
Guild rulingGuild; |
|
|
|
java.time.LocalDateTime dateTime1900; |
|
|
|
Guild rulingNation; |
|
|
|
|
|
|
|
java.time.LocalDateTime dateTime1900; |
|
|
|
// Cities aren't a city without a TOL. Time to early exit.
|
|
|
|
|
|
|
|
// No need to spam the log here as non-existant TOL's are indicated
|
|
|
|
|
|
|
|
// during bootstrap routines.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (city.getTOL() == null) { |
|
|
|
// Cities aren't a city without a TOL. Time to early exit.
|
|
|
|
|
|
|
|
// No need to spam the log here as non-existant TOL's are indicated
|
|
|
|
|
|
|
|
// during bootstrap routines.
|
|
|
|
|
|
|
|
|
|
|
|
Logger.error("NULL TOL FOR " + city.cityName); |
|
|
|
if (city.getTOL() == null) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.error("NULL TOL FOR " + city.cityName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Assign city owner
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (city.getTOL() != null) |
|
|
|
// Assign city owner
|
|
|
|
guildRuler = city.getTOL().getOwner(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
guildRuler = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If is an errant tree, use errant guild for serialization.
|
|
|
|
if (city.getTOL() != null) |
|
|
|
// otherwise we serialize the soverign guild
|
|
|
|
guildRuler = city.getTOL().getOwner(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
guildRuler = null; |
|
|
|
|
|
|
|
|
|
|
|
if (guildRuler == null) |
|
|
|
// If is an errant tree, use errant guild for serialization.
|
|
|
|
rulingGuild = Guild.getErrantGuild(); |
|
|
|
// otherwise we serialize the soverign guild
|
|
|
|
else |
|
|
|
|
|
|
|
rulingGuild = guildRuler.getGuild(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rulingNation = rulingGuild.getNation(); |
|
|
|
if (guildRuler == null) |
|
|
|
|
|
|
|
rulingGuild = Guild.getErrantGuild(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
rulingGuild = guildRuler.getGuild(); |
|
|
|
|
|
|
|
|
|
|
|
// Begin Serialzing soverign guild data
|
|
|
|
rulingNation = rulingGuild.getNation(); |
|
|
|
writer.putInt(city.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(city.getObjectUUID()); |
|
|
|
|
|
|
|
writer.putString(city.cityName); |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putString(rulingGuild.getName()); |
|
|
|
// Begin Serialzing soverign guild data
|
|
|
|
writer.putString(city.motto); |
|
|
|
writer.putInt(city.getObjectType().ordinal()); |
|
|
|
writer.putString(rulingGuild.getLeadershipType()); |
|
|
|
writer.putInt(city.getObjectUUID()); |
|
|
|
|
|
|
|
writer.putString(city.cityName); |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectUUID()); |
|
|
|
|
|
|
|
|
|
|
|
// Serialize guild ruler's name
|
|
|
|
writer.putString(rulingGuild.getName()); |
|
|
|
// If tree is abandoned blank out the name
|
|
|
|
writer.putString(city.motto); |
|
|
|
// to allow them a rename.
|
|
|
|
writer.putString(rulingGuild.getLeadershipType()); |
|
|
|
|
|
|
|
|
|
|
|
if (guildRuler == null) |
|
|
|
// Serialize guild ruler's name
|
|
|
|
writer.putString(""); |
|
|
|
// If tree is abandoned blank out the name
|
|
|
|
else |
|
|
|
// to allow them a rename.
|
|
|
|
writer.putString(guildRuler.getFirstName() + ' ' + guildRuler.getLastName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getCharter()); |
|
|
|
if (guildRuler == null) |
|
|
|
writer.putInt(0); // always 00000000
|
|
|
|
writer.putString(""); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.putString(guildRuler.getFirstName() + ' ' + guildRuler.getLastName()); |
|
|
|
|
|
|
|
|
|
|
|
writer.put(city.isSafeHold); |
|
|
|
writer.putInt(rulingGuild.getCharter()); |
|
|
|
|
|
|
|
writer.putInt(0); // always 00000000
|
|
|
|
|
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
writer.put(city.isSafeHold); |
|
|
|
writer.put((byte) 1); // *** Refactor: What are these flags?
|
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GuildTag._serializeForDisplay(rulingGuild.getGuildTag(), writer); |
|
|
|
writer.put((byte) 1); |
|
|
|
GuildTag._serializeForDisplay(rulingNation.getGuildTag(), writer); |
|
|
|
writer.put((byte) 1); // *** Refactor: What are these flags?
|
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
|
|
|
|
writer.putInt(0);// TODO Implement description text
|
|
|
|
GuildTag._serializeForDisplay(rulingGuild.getGuildTag(), writer); |
|
|
|
|
|
|
|
GuildTag._serializeForDisplay(rulingNation.getGuildTag(), writer); |
|
|
|
|
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
writer.putInt(0);// TODO Implement description text
|
|
|
|
|
|
|
|
|
|
|
|
if (city.isCapital > 0) |
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
writer.put((byte) 1); |
|
|
|
else |
|
|
|
|
|
|
|
writer.put((byte) 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
if (city.isCapital > 0) |
|
|
|
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.put((byte) 0); |
|
|
|
|
|
|
|
|
|
|
|
// Begin serializing nation guild info
|
|
|
|
writer.put((byte) 1); |
|
|
|
|
|
|
|
|
|
|
|
if (rulingNation.isEmptyGuild()) { |
|
|
|
// Begin serializing nation guild info
|
|
|
|
writer.putInt(rulingGuild.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectUUID()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
writer.putInt(rulingNation.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(rulingNation.getObjectUUID()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rulingNation.isEmptyGuild()) { |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(rulingGuild.getObjectUUID()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
writer.putInt(rulingNation.getObjectType().ordinal()); |
|
|
|
|
|
|
|
writer.putInt(rulingNation.getObjectUUID()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Serialize nation name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rulingNation.isEmptyGuild()) |
|
|
|
// Serialize nation name
|
|
|
|
writer.putString("None"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.putString(rulingNation.getName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putInt(city.getTOL().getRank()); |
|
|
|
if (rulingNation.isEmptyGuild()) |
|
|
|
|
|
|
|
writer.putString("None"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.putString(rulingNation.getName()); |
|
|
|
|
|
|
|
|
|
|
|
if (city.isNoobIsle > 0) |
|
|
|
writer.putInt(city.getTOL().getRank()); |
|
|
|
writer.putInt(1); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.putInt(0xFFFFFFFF); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putInt(city.population); |
|
|
|
if (city.isNoobIsle > 0) |
|
|
|
|
|
|
|
writer.putInt(1); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.putInt(0xFFFFFFFF); |
|
|
|
|
|
|
|
|
|
|
|
if (rulingNation.isEmptyGuild()) |
|
|
|
writer.putInt(city.population); |
|
|
|
writer.putString(" "); |
|
|
|
|
|
|
|
else |
|
|
|
if (rulingNation.isEmptyGuild()) |
|
|
|
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName()); |
|
|
|
writer.putString(" "); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
writer.putString(Guild.GetGL(rulingNation).getFirstName() + ' ' + Guild.GetGL(rulingNation).getLastName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writer.putLocalDateTime(city.established); |
|
|
|
writer.putLocalDateTime(city.established); |
|
|
|
|
|
|
|
|
|
|
|
// writer.put((byte) city.established.getDayOfMonth());
|
|
|
|
// writer.put((byte) city.established.getDayOfMonth());
|
|
|
|
// writer.put((byte) city.established.minusMonths(1).getMonth().getValue());
|
|
|
|
// writer.put((byte) city.established.minusMonths(1).getMonth().getValue());
|
|
|
@ -318,16 +319,19 @@ public class City extends AbstractWorldObject { |
|
|
|
// writer.put((byte) minutes);
|
|
|
|
// writer.put((byte) minutes);
|
|
|
|
// writer.put((byte) seconds);
|
|
|
|
// writer.put((byte) seconds);
|
|
|
|
|
|
|
|
|
|
|
|
writer.putFloat(city.location.x); |
|
|
|
writer.putFloat(city.location.x); |
|
|
|
writer.putFloat(city.location.y); |
|
|
|
writer.putFloat(city.location.y); |
|
|
|
writer.putFloat(city.location.z); |
|
|
|
writer.putFloat(city.location.z); |
|
|
|
writer.putInt(ZergManager.getBaneCap(city.getGuild())); |
|
|
|
writer.putInt(ZergManager.getBaneCap(city.getGuild())); |
|
|
|
writer.put((byte) 1); |
|
|
|
writer.put((byte) 1); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.putInt(0x64); |
|
|
|
writer.putInt(0x64); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.put((byte) 0); |
|
|
|
writer.put((byte) 0); |
|
|
|
|
|
|
|
}catch(Exception e){ |
|
|
|
|
|
|
|
Logger.error(city.getObjectUUID() + " failed ot serialize because: " + e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Vector3fImmutable getBindLoc(int cityID) { |
|
|
|
public static Vector3fImmutable getBindLoc(int cityID) { |
|
|
|