forked from MagicBane/Server
Garbage cleanup in SetZone().
Package reformat.
This commit is contained in:
@@ -104,7 +104,7 @@ public class dbCharacterPowerHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_character_power` WHERE CharacterID = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_character_power` WHERE CharacterID = ?")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) objectUUID);
|
preparedStatement.setLong(1, objectUUID);
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class dbCharacterRuneHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
preparedStatement.setInt(1, characterRune.getPlayerID());
|
preparedStatement.setInt(1, characterRune.getPlayerID());
|
||||||
preparedStatement.setInt(2, characterRune.getRuneBaseID());
|
preparedStatement.setInt(2, characterRune.getRuneBaseID());
|
||||||
preparedStatement.setLong(3, (long) characterRune.getObjectUUID());
|
preparedStatement.setLong(3, characterRune.getObjectUUID());
|
||||||
|
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class dbCharacterSkillHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_character_skill` SET `trains`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_character_skill` SET `trains`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setShort(1, (short) characterSkill.getNumTrains());
|
preparedStatement.setShort(1, (short) characterSkill.getNumTrains());
|
||||||
preparedStatement.setLong(2, (long) characterSkill.getObjectUUID());
|
preparedStatement.setLong(2, characterSkill.getObjectUUID());
|
||||||
|
|
||||||
if (preparedStatement.executeUpdate() != 0)
|
if (preparedStatement.executeUpdate() != 0)
|
||||||
characterSkill.syncTrains();
|
characterSkill.syncTrains();
|
||||||
@@ -162,7 +162,7 @@ public class dbCharacterSkillHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setInt(1, characterSkill.getSkillsBase().getObjectUUID());
|
preparedStatement.setInt(1, characterSkill.getSkillsBase().getObjectUUID());
|
||||||
preparedStatement.setInt(2, CharacterSkill.GetOwner(characterSkill).getObjectUUID());
|
preparedStatement.setInt(2, CharacterSkill.GetOwner(characterSkill).getObjectUUID());
|
||||||
preparedStatement.setShort(3, (short) characterSkill.getNumTrains());
|
preparedStatement.setShort(3, (short) characterSkill.getNumTrains());
|
||||||
preparedStatement.setLong(4, (long) characterSkill.getObjectUUID());
|
preparedStatement.setLong(4, characterSkill.getObjectUUID());
|
||||||
|
|
||||||
if (preparedStatement.executeUpdate() != 0)
|
if (preparedStatement.executeUpdate() != 0)
|
||||||
characterSkill.syncTrains();
|
characterSkill.syncTrains();
|
||||||
|
|||||||
@@ -27,6 +27,44 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<PlayerCharacter> GET_GUILD_BANISHED(final int id) {
|
||||||
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
// Bugfix
|
||||||
|
// prepareCallable("SELECT * FROM `obj_character`, `dyn_guild_banishlist` WHERE `obj_character.char_isActive` = 1 AND `dyn_guild_banishlist.CharacterID` = `obj_character.UID` AND `obj_character.GuildID`=?");
|
||||||
|
|
||||||
|
//prepareCallable("SELECT * FROM `obj_character` `,` `dyn_guild_banishlist` WHERE obj_character.char_isActive = 1 AND dyn_guild_banishlist.CharacterID = obj_character.UID AND dyn_guild_banishlist.GuildID = ?");
|
||||||
|
//setLong(1, (long) id);
|
||||||
|
|
||||||
|
//return getObjectList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LOAD_GUILD_HISTORY_FOR_PLAYER(PlayerCharacter playerCharacter) {
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ArrayList<GuildHistory> guildList = new ArrayList<>();
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guild_allianceenemylist` WHERE `GuildID` = ?")) {
|
||||||
|
|
||||||
|
preparedStatement.setInt(1, playerCharacter.getObjectUUID());
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
GuildHistory guildEntry = new GuildHistory(rs);
|
||||||
|
guildList.add(guildEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerCharacter.setGuildHistory(guildList);
|
||||||
|
}
|
||||||
|
|
||||||
public int BANISH_FROM_GUILD_OFFLINE(final int target, boolean sourceIsGuildLeader) {
|
public int BANISH_FROM_GUILD_OFFLINE(final int target, boolean sourceIsGuildLeader) {
|
||||||
|
|
||||||
String queryString;
|
String queryString;
|
||||||
@@ -55,13 +93,12 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return rowCount;
|
return rowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean ADD_TO_BANISHED_FROM_GUILDLIST(int target, long characterID) {
|
public boolean ADD_TO_BANISHED_FROM_GUILDLIST(int target, long characterID) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) target);
|
preparedStatement.setLong(1, target);
|
||||||
preparedStatement.setLong(2, characterID);
|
preparedStatement.setLong(2, characterID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
@@ -77,7 +114,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_guild_banishlist` (`GuildID`, `CharacterID`) VALUES (?,?)")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) target);
|
preparedStatement.setLong(1, target);
|
||||||
preparedStatement.setLong(2, characterID);
|
preparedStatement.setLong(2, characterID);
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
@@ -152,19 +189,6 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<PlayerCharacter> GET_GUILD_BANISHED(final int id) {
|
|
||||||
|
|
||||||
return new ArrayList<>();
|
|
||||||
|
|
||||||
// Bugfix
|
|
||||||
// prepareCallable("SELECT * FROM `obj_character`, `dyn_guild_banishlist` WHERE `obj_character.char_isActive` = 1 AND `dyn_guild_banishlist.CharacterID` = `obj_character.UID` AND `obj_character.GuildID`=?");
|
|
||||||
|
|
||||||
//prepareCallable("SELECT * FROM `obj_character` `,` `dyn_guild_banishlist` WHERE obj_character.char_isActive = 1 AND dyn_guild_banishlist.CharacterID = obj_character.UID AND dyn_guild_banishlist.GuildID = ?");
|
|
||||||
//setLong(1, (long) id);
|
|
||||||
|
|
||||||
//return getObjectList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Guild> GET_GUILD_ENEMIES(final int id) {
|
public ArrayList<Guild> GET_GUILD_ENEMIES(final int id) {
|
||||||
|
|
||||||
ArrayList<Guild> guildList = null;
|
ArrayList<Guild> guildList = null;
|
||||||
@@ -348,7 +372,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean SET_GUILD_LEADER(int objectUUID,int guildID) {
|
public boolean SET_GUILD_LEADER(int objectUUID, int guildID) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `leaderUID`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_guild` SET `leaderUID`=? WHERE `UID`=?")) {
|
||||||
@@ -485,6 +509,10 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// *** Refactor: Why are we saving tags/charter in update?
|
||||||
|
// It's not like this shit ever changes.
|
||||||
|
|
||||||
public int UPDATE_GUILD_STATUS_OFFLINE(int target, boolean isInnerCouncil, boolean isRecruiter, boolean isTaxCollector, int guildId) {
|
public int UPDATE_GUILD_STATUS_OFFLINE(int target, boolean isInnerCouncil, boolean isRecruiter, boolean isTaxCollector, int guildId) {
|
||||||
|
|
||||||
int updateMask = 0;
|
int updateMask = 0;
|
||||||
@@ -532,10 +560,6 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return row_count;
|
return row_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// *** Refactor: Why are we saving tags/charter in update?
|
|
||||||
// It's not like this shit ever changes.
|
|
||||||
|
|
||||||
public boolean updateDatabase(final Guild g) {
|
public boolean updateDatabase(final Guild g) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
@@ -552,7 +576,7 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setString(9, g.getICMOTD());
|
preparedStatement.setString(9, g.getICMOTD());
|
||||||
preparedStatement.setString(10, "");
|
preparedStatement.setString(10, "");
|
||||||
preparedStatement.setInt(11, g.getGuildLeaderUUID());
|
preparedStatement.setInt(11, g.getGuildLeaderUUID());
|
||||||
preparedStatement.setLong(12, (long) g.getObjectUUID());
|
preparedStatement.setLong(12, g.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -669,31 +693,6 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LOAD_GUILD_HISTORY_FOR_PLAYER(PlayerCharacter playerCharacter) {
|
|
||||||
|
|
||||||
if (playerCharacter == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ArrayList<GuildHistory> guildList = new ArrayList<>();
|
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guild_allianceenemylist` WHERE `GuildID` = ?")) {
|
|
||||||
|
|
||||||
preparedStatement.setInt(1, playerCharacter.getObjectUUID());
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
|
|
||||||
while (rs.next()) {
|
|
||||||
GuildHistory guildEntry = new GuildHistory(rs);
|
|
||||||
guildList.add(guildEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
playerCharacter.setGuildHistory(guildList);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO uncomment this when finished with guild history warehouse integration
|
//TODO uncomment this when finished with guild history warehouse integration
|
||||||
// public HashMap<Integer, GuildRecord> GET_WAREHOUSE_GUILD_HISTORY(){
|
// public HashMap<Integer, GuildRecord> GET_WAREHOUSE_GUILD_HISTORY(){
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ import java.util.HashSet;
|
|||||||
|
|
||||||
public abstract class dbHandlerBase {
|
public abstract class dbHandlerBase {
|
||||||
|
|
||||||
|
protected final ThreadLocal<CallableStatement> callableStatement = new ThreadLocal<>();
|
||||||
|
protected final ThreadLocal<Connection> connection = new ThreadLocal<>();
|
||||||
/*
|
/*
|
||||||
* CallableStatements handled below this line!
|
* CallableStatements handled below this line!
|
||||||
*/
|
*/
|
||||||
protected Class<? extends AbstractGameObject> localClass = null;
|
protected Class<? extends AbstractGameObject> localClass = null;
|
||||||
protected GameObjectType localObjectType;
|
protected GameObjectType localObjectType;
|
||||||
protected final ThreadLocal<CallableStatement> callableStatement = new ThreadLocal<>();
|
|
||||||
protected final ThreadLocal<Connection> connection = new ThreadLocal<>();
|
|
||||||
|
|
||||||
protected final void prepareCallable(final String sql) {
|
protected final void prepareCallable(final String sql) {
|
||||||
try {
|
try {
|
||||||
@@ -170,7 +170,7 @@ public abstract class dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Common return values from the database when calling stored procedures, abstracted to this layer
|
// Common return values from the database when calling stored procedures, abstracted to this layer
|
||||||
protected final String getResult(){
|
protected final String getResult() {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = this.executeQuery();
|
ResultSet rs = this.executeQuery();
|
||||||
if (rs.next() && !isError(rs))
|
if (rs.next() && !isError(rs))
|
||||||
@@ -200,7 +200,7 @@ public abstract class dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Common return values from the database when calling stored procedures, abstracted to this layer
|
// Common return values from the database when calling stored procedures, abstracted to this layer
|
||||||
protected final long getUUID(){
|
protected final long getUUID() {
|
||||||
try {
|
try {
|
||||||
ResultSet rs = this.executeQuery();
|
ResultSet rs = this.executeQuery();
|
||||||
if (rs.next() && !isError(rs))
|
if (rs.next() && !isError(rs))
|
||||||
@@ -380,7 +380,7 @@ public abstract class dbHandlerBase {
|
|||||||
if ((out != null && out instanceof AbstractWorldObject) &&
|
if ((out != null && out instanceof AbstractWorldObject) &&
|
||||||
(ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER) ||
|
(ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER) ||
|
||||||
(out.getObjectType() == GameObjectType.Guild)))
|
(out.getObjectType() == GameObjectType.Guild)))
|
||||||
((AbstractWorldObject)out).runAfterLoad();
|
((AbstractWorldObject) out).runAfterLoad();
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -392,7 +392,8 @@ public abstract class dbHandlerBase {
|
|||||||
|
|
||||||
this.connection.get().close();
|
this.connection.get().close();
|
||||||
|
|
||||||
} catch (SQLException e) {}
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T extends AbstractGameObject> ArrayList<T> getObjectList() {
|
protected <T extends AbstractGameObject> ArrayList<T> getObjectList() {
|
||||||
@@ -421,7 +422,7 @@ public abstract class dbHandlerBase {
|
|||||||
query = this.callableStatement.get().toString();
|
query = this.callableStatement.get().toString();
|
||||||
|
|
||||||
if (MBServerStatics.DB_ENABLE_QUERY_OUTPUT)
|
if (MBServerStatics.DB_ENABLE_QUERY_OUTPUT)
|
||||||
Logger.info( "[GetObjectList] Executing query:" + query);
|
Logger.info("[GetObjectList] Executing query:" + query);
|
||||||
|
|
||||||
ResultSet rs = this.callableStatement.get().executeQuery();
|
ResultSet rs = this.callableStatement.get().executeQuery();
|
||||||
|
|
||||||
@@ -437,7 +438,7 @@ public abstract class dbHandlerBase {
|
|||||||
out.add((T) toAdd);
|
out.add((T) toAdd);
|
||||||
|
|
||||||
if (toAdd != null && toAdd instanceof AbstractWorldObject)
|
if (toAdd != null && toAdd instanceof AbstractWorldObject)
|
||||||
((AbstractWorldObject)toAdd).runAfterLoad();
|
((AbstractWorldObject) toAdd).runAfterLoad();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,7 +459,7 @@ public abstract class dbHandlerBase {
|
|||||||
protected HashSet<Integer> getIntegerList(final int columnNumber) {
|
protected HashSet<Integer> getIntegerList(final int columnNumber) {
|
||||||
|
|
||||||
if (MBServerStatics.DB_ENABLE_QUERY_OUTPUT)
|
if (MBServerStatics.DB_ENABLE_QUERY_OUTPUT)
|
||||||
Logger.info("[GetIntegerList] Executing query:" + this.callableStatement.toString());
|
Logger.info("[GetIntegerList] Executing query:" + this.callableStatement);
|
||||||
|
|
||||||
HashSet<Integer> out = new HashSet<>();
|
HashSet<Integer> out = new HashSet<>();
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,26 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String formatTradeString(HashSet<Integer> list) {
|
||||||
|
int size = list.size();
|
||||||
|
|
||||||
|
String ret = "";
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
boolean start = true;
|
||||||
|
|
||||||
|
for (int i : list) {
|
||||||
|
if (start) {
|
||||||
|
ret += i;
|
||||||
|
start = false;
|
||||||
|
} else
|
||||||
|
ret += "," + i;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public Item ADD_ITEM(Item toAdd) {
|
public Item ADD_ITEM(Item toAdd) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
@@ -122,13 +142,13 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_TRADE`(?, ?, ?, ?, ?, ?, ?, ?)")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_TRADE`(?, ?, ?, ?, ?, ?, ?, ?)")) {
|
||||||
|
|
||||||
preparedStatement.setString(1, formatTradeString(from1));
|
preparedStatement.setString(1, formatTradeString(from1));
|
||||||
preparedStatement.setLong(2, (long) ac1.getObjectUUID());
|
preparedStatement.setLong(2, ac1.getObjectUUID());
|
||||||
preparedStatement.setString(3, formatTradeString(from2));
|
preparedStatement.setString(3, formatTradeString(from2));
|
||||||
preparedStatement.setLong(4, (long) ac2.getObjectUUID());
|
preparedStatement.setLong(4, ac2.getObjectUUID());
|
||||||
preparedStatement.setInt(5, goldFrom1);
|
preparedStatement.setInt(5, goldFrom1);
|
||||||
preparedStatement.setLong(6, (long) inventoryGold1.getObjectUUID());
|
preparedStatement.setLong(6, inventoryGold1.getObjectUUID());
|
||||||
preparedStatement.setInt(7, goldFrom2);
|
preparedStatement.setInt(7, goldFrom2);
|
||||||
preparedStatement.setLong(8, (long) inventoryGold2.getObjectUUID());
|
preparedStatement.setLong(8, inventoryGold2.getObjectUUID());
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
@@ -141,26 +161,6 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
return worked;
|
return worked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatTradeString(HashSet<Integer> list) {
|
|
||||||
int size = list.size();
|
|
||||||
|
|
||||||
String ret = "";
|
|
||||||
|
|
||||||
if (size == 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
boolean start = true;
|
|
||||||
|
|
||||||
for (int i : list) {
|
|
||||||
if (start) {
|
|
||||||
ret += i;
|
|
||||||
start = false;
|
|
||||||
} else
|
|
||||||
ret += "," + i;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Item> GET_EQUIPPED_ITEMS(final int targetId) {
|
public ArrayList<Item> GET_EQUIPPED_ITEMS(final int targetId) {
|
||||||
|
|
||||||
ArrayList<Item> itemList;
|
ArrayList<Item> itemList;
|
||||||
@@ -168,7 +168,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=? && `obj_item`.`item_container`='equip';")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) targetId);
|
preparedStatement.setLong(1, targetId);
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
itemList = getObjectsFromRs(rs, 10);
|
itemList = getObjectsFromRs(rs, 10);
|
||||||
@@ -207,7 +207,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?;")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) accountId);
|
preparedStatement.setLong(1, accountId);
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
itemList = getObjectsFromRs(rs, 100);
|
itemList = getObjectsFromRs(rs, 100);
|
||||||
@@ -245,7 +245,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_item`.*, `object`.`parent`, `object`.`type` FROM `object` INNER JOIN `obj_item` ON `object`.`UID` = `obj_item`.`UID` WHERE `object`.`parent`=?")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) id);
|
preparedStatement.setLong(1, id);
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
itemList = getObjectsFromRs(rs, 100);
|
itemList = getObjectsFromRs(rs, 100);
|
||||||
@@ -265,12 +265,12 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
int newFromAmt = from.getNumOfItems() - amt;
|
int newFromAmt = from.getNumOfItems() - amt;
|
||||||
int newToAmt = to.getNumOfItems() + amt;
|
int newToAmt = to.getNumOfItems() + amt;
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) from.getObjectUUID());
|
preparedStatement.setLong(1, from.getObjectUUID());
|
||||||
preparedStatement.setInt(2, newFromAmt);
|
preparedStatement.setInt(2, newFromAmt);
|
||||||
preparedStatement.setLong(3, (long) to.getObjectUUID());
|
preparedStatement.setLong(3, to.getObjectUUID());
|
||||||
preparedStatement.setInt(4, newToAmt);
|
preparedStatement.setInt(4, newToAmt);
|
||||||
preparedStatement.setLong(5, (long) from.getObjectUUID());
|
preparedStatement.setLong(5, from.getObjectUUID());
|
||||||
preparedStatement.setLong(6, (long) to.getObjectUUID());
|
preparedStatement.setLong(6, to.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` LEFT JOIN `object` ON `object`.`UID` = `obj_item`.`UID` SET `object`.`parent`=NULL, `obj_item`.`item_container`='none' WHERE `object`.`UID`=?;")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) item.getObjectUUID());
|
preparedStatement.setLong(1, item.getObjectUUID());
|
||||||
worked = (preparedStatement.executeUpdate() > 0);
|
worked = (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
if (worked)
|
if (worked)
|
||||||
@@ -383,8 +383,8 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_durabilityCurrent`=? WHERE `UID`=? AND `item_durabilityCurrent`=?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, value);
|
preparedStatement.setInt(1, value);
|
||||||
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
preparedStatement.setInt(3, (int) item.getDurabilityCurrent());
|
preparedStatement.setInt(3, item.getDurabilityCurrent());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_container` = ? WHERE `UID` = ? AND `item_container` = 'forge';")) {
|
||||||
|
|
||||||
preparedStatement.setString(1, "inventory");
|
preparedStatement.setString(1, "inventory");
|
||||||
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=? WHERE `UID`=?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, newValue);
|
preparedStatement.setInt(1, newValue);
|
||||||
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_chargesRemaining` = ? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, item.getChargesRemaining());
|
preparedStatement.setInt(1, item.getChargesRemaining());
|
||||||
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=0 WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_numberOfItems`=0 WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) item.getObjectUUID());
|
preparedStatement.setLong(1, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_flags`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_flags`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, item.getFlags());
|
preparedStatement.setInt(1, item.getFlags());
|
||||||
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -499,13 +499,13 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean UPDATE_VALUE(Item item,int value) {
|
public boolean UPDATE_VALUE(Item item, int value) {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_value`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_item` SET `item_value`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, value);
|
preparedStatement.setInt(1, value);
|
||||||
preparedStatement.setLong(2, (long) item.getObjectUUID());
|
preparedStatement.setLong(2, item.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_character`.*, `object`.`parent` FROM `object` INNER JOIN `obj_character` ON `obj_character`.`UID` = `object`.`UID` WHERE `object`.`parent`=? && `obj_character`.`char_isActive`='1';")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_character`.*, `object`.`parent` FROM `object` INNER JOIN `obj_character` ON `obj_character`.`UID` = `object`.`UID` WHERE `object`.`parent`=? && `obj_character`.`char_isActive`='1';")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) id);
|
preparedStatement.setLong(1, id);
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
characterList = getObjectsFromRs(rs, 10);
|
characterList = getObjectsFromRs(rs, 10);
|
||||||
|
|
||||||
@@ -135,12 +135,10 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* <code>getFirstName</code> looks up the first name of a PlayerCharacter by
|
* <code>getFirstName</code> looks up the first name of a PlayerCharacter by
|
||||||
* first checking the GOM cache and then querying the database.
|
* first checking the GOM cache and then querying the database.
|
||||||
* PlayerCharacter objects that are not already cached won't be instantiated
|
* PlayerCharacter objects that are not already cached won't be instantiated
|
||||||
* and cached.
|
* and cached.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ConcurrentHashMap<Integer, String> GET_IGNORE_LIST(final int objectUUID, final boolean skipActiveCheck) {
|
public ConcurrentHashMap<Integer, String> GET_IGNORE_LIST(final int objectUUID, final boolean skipActiveCheck) {
|
||||||
@@ -192,7 +190,6 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
;
|
|
||||||
return playerCharacter;
|
return playerCharacter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +253,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `char_isActive`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `char_isActive`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setBoolean(1, status);
|
preparedStatement.setBoolean(1, status);
|
||||||
preparedStatement.setLong(2, (long) pc.getObjectUUID());
|
preparedStatement.setLong(2, pc.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -272,7 +269,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `char_bindBuilding`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `char_bindBuilding`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, bindBuildingID);
|
preparedStatement.setInt(1, bindBuildingID);
|
||||||
preparedStatement.setLong(2, (long) pc.getObjectUUID());
|
preparedStatement.setLong(2, pc.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -288,7 +285,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `anniversery`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `anniversery`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setBoolean(1, flag);
|
preparedStatement.setBoolean(1, flag);
|
||||||
preparedStatement.setLong(2, (long) pc.getObjectUUID());
|
preparedStatement.setLong(2, pc.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -305,7 +302,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `char_experience`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `char_experience`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, pc.getExp());
|
preparedStatement.setInt(1, pc.getExp());
|
||||||
preparedStatement.setLong(2, (long) pc.getObjectUUID());
|
preparedStatement.setLong(2, pc.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -321,7 +318,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `guildUID`=? WHERE `UID` = ?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_character` SET `guildUID`=? WHERE `UID` = ?")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, guildUUID);
|
preparedStatement.setInt(1, guildUUID);
|
||||||
preparedStatement.setLong(2, (long) pc.getObjectUUID());
|
preparedStatement.setLong(2, pc.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -341,7 +338,7 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
preparedStatement.setInt(3, pc.getConMod());
|
preparedStatement.setInt(3, pc.getConMod());
|
||||||
preparedStatement.setInt(4, pc.getIntMod());
|
preparedStatement.setInt(4, pc.getIntMod());
|
||||||
preparedStatement.setInt(5, pc.getSpiMod());
|
preparedStatement.setInt(5, pc.getSpiMod());
|
||||||
preparedStatement.setLong(6, (long) pc.getObjectUUID());
|
preparedStatement.setLong(6, pc.getObjectUUID());
|
||||||
|
|
||||||
return (preparedStatement.executeUpdate() > 0);
|
return (preparedStatement.executeUpdate() > 0);
|
||||||
|
|
||||||
@@ -360,7 +357,6 @@ public class dbPlayerCharacterHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
preparedStatement.setLong(1, playerCharacter.getObjectUUID());
|
preparedStatement.setLong(1, playerCharacter.getObjectUUID());
|
||||||
preparedStatement.setString(2, name);
|
preparedStatement.setString(2, name);
|
||||||
;
|
|
||||||
preparedStatement.setString(3, String.valueOf(new_value));
|
preparedStatement.setString(3, String.valueOf(new_value));
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|||||||
@@ -72,17 +72,16 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase {
|
|||||||
HashMap<Integer, ArrayList<RuneBaseEffect>> runeBaseEffectSet;
|
HashMap<Integer, ArrayList<RuneBaseEffect>> runeBaseEffectSet;
|
||||||
runeBaseEffectSet = new HashMap<>();
|
runeBaseEffectSet = new HashMap<>();
|
||||||
|
|
||||||
for (AbstractGameObject runeBaseEffect:DbManager.getList(GameObjectType.RuneBaseEffect)){
|
for (AbstractGameObject runeBaseEffect : DbManager.getList(GameObjectType.RuneBaseEffect)) {
|
||||||
|
|
||||||
int runeBaseID = ((RuneBaseEffect)runeBaseEffect).getRuneBaseID();
|
int runeBaseID = ((RuneBaseEffect) runeBaseEffect).getRuneBaseID();
|
||||||
if (runeBaseEffectSet.get(runeBaseID) == null){
|
if (runeBaseEffectSet.get(runeBaseID) == null) {
|
||||||
ArrayList<RuneBaseEffect> runeBaseEffectList = new ArrayList<>();
|
ArrayList<RuneBaseEffect> runeBaseEffectList = new ArrayList<>();
|
||||||
runeBaseEffectList.add((RuneBaseEffect)runeBaseEffect);
|
runeBaseEffectList.add((RuneBaseEffect) runeBaseEffect);
|
||||||
runeBaseEffectSet.put(runeBaseID, runeBaseEffectList);
|
runeBaseEffectSet.put(runeBaseID, runeBaseEffectList);
|
||||||
}
|
} else {
|
||||||
else{
|
ArrayList<RuneBaseEffect> runeBaseEffectList = runeBaseEffectSet.get(runeBaseID);
|
||||||
ArrayList<RuneBaseEffect>runeBaseEffectList = runeBaseEffectSet.get(runeBaseID);
|
runeBaseEffectList.add((RuneBaseEffect) runeBaseEffect);
|
||||||
runeBaseEffectList.add((RuneBaseEffect)runeBaseEffect);
|
|
||||||
runeBaseEffectSet.put(runeBaseID, runeBaseEffectList);
|
runeBaseEffectSet.put(runeBaseID, runeBaseEffectList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,25 @@ public class dbShrineHandler extends dbHandlerBase {
|
|||||||
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<AbstractGameObject> CREATE_SHRINE( int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
public static void addObject(ArrayList<AbstractGameObject> list, ResultSet rs) throws SQLException {
|
||||||
|
|
||||||
|
String type = rs.getString("type");
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "building":
|
||||||
|
Building building = new Building(rs);
|
||||||
|
DbManager.addToCache(building);
|
||||||
|
list.add(building);
|
||||||
|
break;
|
||||||
|
case "shrine":
|
||||||
|
Shrine shrine = new Shrine(rs);
|
||||||
|
DbManager.addToCache(shrine);
|
||||||
|
list.add(shrine);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<AbstractGameObject> CREATE_SHRINE(int parentZoneID, int OwnerUUID, String name, int meshUUID,
|
||||||
Vector3fImmutable location, float meshScale, int currentHP,
|
Vector3fImmutable location, float meshScale, int currentHP,
|
||||||
ProtectionState protectionState, int currentGold, int rank,
|
ProtectionState protectionState, int currentGold, int rank,
|
||||||
DateTime upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
|
DateTime upgradeDate, int blueprintUUID, float w, float rotY, String shrineType) {
|
||||||
@@ -103,24 +121,6 @@ public class dbShrineHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addObject(ArrayList<AbstractGameObject> list, ResultSet rs) throws SQLException {
|
|
||||||
|
|
||||||
String type = rs.getString("type");
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case "building":
|
|
||||||
Building building = new Building(rs);
|
|
||||||
DbManager.addToCache(building);
|
|
||||||
list.add(building);
|
|
||||||
break;
|
|
||||||
case "shrine":
|
|
||||||
Shrine shrine = new Shrine(rs);
|
|
||||||
DbManager.addToCache(shrine);
|
|
||||||
list.add(shrine);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LOAD_ALL_SHRINES() {
|
public void LOAD_ALL_SHRINES() {
|
||||||
|
|
||||||
Shrine shrine;
|
Shrine shrine;
|
||||||
|
|||||||
@@ -91,19 +91,18 @@ public class dbSkillBaseHandler extends dbHandlerBase {
|
|||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
|
|
||||||
MaxSkills maxSKills = new MaxSkills(rs);
|
MaxSkills maxSKills = new MaxSkills(rs);
|
||||||
if (MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()) == null){
|
if (MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()) == null) {
|
||||||
ArrayList<MaxSkills> newMaxSkillsList = new ArrayList<>();
|
ArrayList<MaxSkills> newMaxSkillsList = new ArrayList<>();
|
||||||
newMaxSkillsList.add(maxSKills);
|
newMaxSkillsList.add(maxSKills);
|
||||||
MaxSkills.MaxSkillsSet.put(maxSKills.getRuneID(), newMaxSkillsList);
|
MaxSkills.MaxSkillsSet.put(maxSKills.getRuneID(), newMaxSkillsList);
|
||||||
}else
|
} else
|
||||||
MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()).add(maxSKills);
|
MaxSkills.MaxSkillsSet.get(maxSKills.getRuneID()).add(maxSKills);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error( e.getErrorCode() + ' ' + e.getMessage(), e);
|
Logger.error(e.getErrorCode() + ' ' + e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
closeCallable();
|
closeCallable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ package engine.db.handlers;
|
|||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.gameManager.ZoneManager;
|
||||||
|
import engine.math.Vector2f;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ public class dbZoneHandler extends dbHandlerBase {
|
|||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) {
|
||||||
|
|
||||||
preparedStatement.setLong(1, (long) objectUUID);
|
preparedStatement.setLong(1, objectUUID);
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
zoneList = getObjectsFromRs(rs, 2000);
|
zoneList = getObjectsFromRs(rs, 2000);
|
||||||
@@ -89,19 +91,24 @@ public class dbZoneHandler extends dbHandlerBase {
|
|||||||
return zoneList;
|
return zoneList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultSet GET_ZONE_EXTENTS(final int loadNum) {
|
public void LOAD_ZONE_EXTENTS() {
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size` WHERE `loadNum`=?;")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) {
|
||||||
|
|
||||||
preparedStatement.setInt(1, loadNum);
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
return preparedStatement.executeQuery();
|
while (rs.next()) {
|
||||||
|
Vector2f zoneSize = new Vector2f();
|
||||||
|
int loadNum = rs.getInt("loadNum");
|
||||||
|
zoneSize.x = rs.getFloat("xRadius");
|
||||||
|
zoneSize.y = rs.getFloat("zRadius");
|
||||||
|
ZoneManager._zone_size_data.put(loadNum, zoneSize);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean DELETE_ZONE(final Zone zone) {
|
public boolean DELETE_ZONE(final Zone zone) {
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import org.pmw.tinylog.Logger;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@@ -39,17 +36,18 @@ public enum ZoneManager {
|
|||||||
|
|
||||||
ZONEMANAGER;
|
ZONEMANAGER;
|
||||||
|
|
||||||
public static Instant hotZoneLastUpdate;
|
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
/* Instance variables */
|
|
||||||
private static Zone seaFloor = null;
|
|
||||||
public static Zone hotZone = null;
|
|
||||||
public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config.
|
|
||||||
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<Integer, Zone> zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
private static final ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
private static final ConcurrentHashMap<String, Zone> zonesByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD);
|
||||||
public static final Set<Zone> macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
|
||||||
private static final Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> npcCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private static final Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
private static final Set<Zone> playerCityZones = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
|
public static Instant hotZoneLastUpdate;
|
||||||
|
public static Zone hotZone = null;
|
||||||
|
public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config.
|
||||||
|
public static HashMap<Integer, Vector2f> _zone_size_data = new HashMap<>();
|
||||||
|
/* Instance variables */
|
||||||
|
private static Zone seaFloor = null;
|
||||||
|
|
||||||
// Find all zones coordinates fit into, starting with Sea Floor
|
// Find all zones coordinates fit into, starting with Sea Floor
|
||||||
|
|
||||||
@@ -170,14 +168,14 @@ public enum ZoneManager {
|
|||||||
return (Bounds.collide(loc, ZoneManager.hotZone.getBounds()) == true);
|
return (Bounds.collide(loc, ZoneManager.hotZone.getBounds()) == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSeaFloor(final Zone value) {
|
|
||||||
ZoneManager.seaFloor = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Zone getSeaFloor() {
|
public static Zone getSeaFloor() {
|
||||||
return ZoneManager.seaFloor;
|
return ZoneManager.seaFloor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setSeaFloor(final Zone value) {
|
||||||
|
ZoneManager.seaFloor = value;
|
||||||
|
}
|
||||||
|
|
||||||
public static final void populateWorldZones(final Zone zone) {
|
public static final void populateWorldZones(final Zone zone) {
|
||||||
|
|
||||||
int loadNum = zone.getLoadNum();
|
int loadNum = zone.getLoadNum();
|
||||||
|
|||||||
+110
-145
@@ -30,19 +30,25 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public class Zone extends AbstractGameObject {
|
public class Zone extends AbstractGameObject {
|
||||||
|
|
||||||
|
public final Set<Building> zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
|
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
|
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||||
private final int playerCityID;
|
private final int playerCityID;
|
||||||
private final String zoneName;
|
private final String zoneName;
|
||||||
private final float xCoord;
|
private final float xCoord;
|
||||||
private final float zCoord;
|
private final float zCoord;
|
||||||
private final float yCoord;
|
private final float yCoord;
|
||||||
public float absX = 0.0f;
|
|
||||||
public float absY = 0.0f;
|
|
||||||
public float absZ = 0.0f;
|
|
||||||
private final int loadNum;
|
private final int loadNum;
|
||||||
private final byte safeZone;
|
private final byte safeZone;
|
||||||
private final String Icon1;
|
private final String Icon1;
|
||||||
private final String Icon2;
|
private final String Icon2;
|
||||||
private final String Icon3;
|
private final String Icon3;
|
||||||
|
public float absX = 0.0f;
|
||||||
|
public float absY = 0.0f;
|
||||||
|
public float absZ = 0.0f;
|
||||||
|
public int minLvl;
|
||||||
|
public int maxLvl;
|
||||||
|
public boolean hasBeenHotzone = false;
|
||||||
private ArrayList<Zone> nodes = null;
|
private ArrayList<Zone> nodes = null;
|
||||||
private int parentZoneID;
|
private int parentZoneID;
|
||||||
private Zone parent = null;
|
private Zone parent = null;
|
||||||
@@ -50,16 +56,9 @@ public class Zone extends AbstractGameObject {
|
|||||||
private boolean isNPCCity = false;
|
private boolean isNPCCity = false;
|
||||||
private boolean isPlayerCity = false;
|
private boolean isPlayerCity = false;
|
||||||
private String hash;
|
private String hash;
|
||||||
public int minLvl;
|
|
||||||
public int maxLvl;
|
|
||||||
|
|
||||||
private float worldAltitude = 0;
|
private float worldAltitude = 0;
|
||||||
|
|
||||||
private float seaLevel = 0;
|
private float seaLevel = 0;
|
||||||
public final Set<Building> zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
|
||||||
public final Set<NPC> zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
|
||||||
public final Set<Mob> zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
|
||||||
public boolean hasBeenHotzone = false;
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
*/
|
*/
|
||||||
@@ -87,7 +86,7 @@ public class Zone extends AbstractGameObject {
|
|||||||
|
|
||||||
this.setParent(parentZone);
|
this.setParent(parentZone);
|
||||||
|
|
||||||
if (this.minLvl == 0 && parentZone != null){
|
if (this.minLvl == 0 && parentZone != null) {
|
||||||
this.minLvl = parentZone.minLvl;
|
this.minLvl = parentZone.minLvl;
|
||||||
this.maxLvl = parentZone.maxLvl;
|
this.maxLvl = parentZone.maxLvl;
|
||||||
}
|
}
|
||||||
@@ -103,6 +102,59 @@ public class Zone extends AbstractGameObject {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) {
|
||||||
|
|
||||||
|
if (zone.loadNum == 0 && zone.playerCityID == 0)
|
||||||
|
Logger.warn("Warning! WorldServerMap with ID " + zone.getObjectUUID() + " has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
|
||||||
|
|
||||||
|
// Player City Terraform values serialized here.
|
||||||
|
|
||||||
|
if (zone.playerCityID > 0) {
|
||||||
|
writer.put((byte) 1); // Player City - True
|
||||||
|
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
||||||
|
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
||||||
|
} else
|
||||||
|
writer.put((byte) 0); // Player City - False
|
||||||
|
|
||||||
|
writer.putFloat(zone.xCoord);
|
||||||
|
writer.putFloat(zone.zCoord);
|
||||||
|
writer.putFloat(zone.yCoord);
|
||||||
|
|
||||||
|
writer.putInt(0);
|
||||||
|
writer.putInt(0);
|
||||||
|
writer.putInt(zone.loadNum);
|
||||||
|
|
||||||
|
if (zone.playerCityID > 0) {
|
||||||
|
City k = City.getCity(zone.playerCityID);
|
||||||
|
|
||||||
|
if (k != null) {
|
||||||
|
writer.putInt(k.getObjectType().ordinal());
|
||||||
|
writer.putInt(k.getObjectUUID());
|
||||||
|
} else
|
||||||
|
writer.putLong(0x0);
|
||||||
|
} else {
|
||||||
|
writer.putInt(zone.getObjectType().ordinal());
|
||||||
|
writer.putInt(zone.getObjectUUID());
|
||||||
|
}
|
||||||
|
writer.putInt(zone.nodes.size());
|
||||||
|
|
||||||
|
City city = City.getCity(zone.playerCityID);
|
||||||
|
|
||||||
|
if (city != null)
|
||||||
|
writer.putString(city.getCityName());
|
||||||
|
else
|
||||||
|
writer.putString(zone.zoneName);
|
||||||
|
writer.put(zone.safeZone);
|
||||||
|
writer.putString(zone.Icon1);
|
||||||
|
writer.putString(zone.Icon2);
|
||||||
|
writer.putString(zone.Icon3);
|
||||||
|
writer.put((byte) 0); // Pad
|
||||||
|
|
||||||
|
for (Zone child : zone.nodes) {
|
||||||
|
Zone.serializeForClientMsg(child, writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Method sets a default value for player cities
|
/* Method sets a default value for player cities
|
||||||
* otherwise using values derived from the loadnum
|
* otherwise using values derived from the loadnum
|
||||||
* field in the obj_zone database table.
|
* field in the obj_zone database table.
|
||||||
@@ -123,38 +175,18 @@ public class Zone extends AbstractGameObject {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All other zones have bounding boxes loaded from database
|
Vector2f zoneSize = ZoneManager._zone_size_data.get(this.loadNum);
|
||||||
ResultSet rs = DbManager.ZoneQueries.GET_ZONE_EXTENTS(this.loadNum);
|
|
||||||
boolean loaded = false;
|
|
||||||
|
|
||||||
if (rs != null)
|
// Default to player zone size on error? Maybe log this
|
||||||
try {
|
|
||||||
if (rs.next()) {
|
|
||||||
halfExtentX = rs.getFloat("xRadius");
|
|
||||||
halfExtentY = rs.getFloat("zRadius");
|
|
||||||
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(halfExtentX, halfExtentY), 0.0f);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error("SQLException: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loaded) {
|
|
||||||
|
|
||||||
// Default to Citygrid size on error
|
|
||||||
|
|
||||||
|
if (zoneSize != null)
|
||||||
|
this.bounds.setBounds(new Vector2f(this.absX, this.absZ), zoneSize, 0.0f);
|
||||||
|
else
|
||||||
bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f);
|
bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Getters
|
|
||||||
*/
|
|
||||||
public int getPlayerCityUUID() {
|
public int getPlayerCityUUID() {
|
||||||
if (this.playerCityID == 0)
|
|
||||||
return 0;
|
|
||||||
return this.playerCityID;
|
return this.playerCityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,10 +210,6 @@ public class Zone extends AbstractGameObject {
|
|||||||
return loadNum;
|
return loadNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLoadNumClient() {
|
|
||||||
return loadNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getSafeZone() {
|
public byte getSafeZone() {
|
||||||
return safeZone;
|
return safeZone;
|
||||||
}
|
}
|
||||||
@@ -190,45 +218,9 @@ public class Zone extends AbstractGameObject {
|
|||||||
return Icon1;
|
return Icon1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIcon2() {
|
public void generateWorldAltitude() {
|
||||||
return Icon2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIcon3() {
|
if (ZoneManager.getSeaFloor().getObjectUUID() == this.getObjectUUID()) {
|
||||||
return Icon3;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParent(final Zone value) {
|
|
||||||
|
|
||||||
this.parent = value;
|
|
||||||
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
|
||||||
|
|
||||||
if (this.parent != null) {
|
|
||||||
this.absX = this.xCoord + parent.absX;
|
|
||||||
this.absY = this.yCoord + parent.absY;
|
|
||||||
this.absZ = this.zCoord + parent.absZ;
|
|
||||||
|
|
||||||
if (this.minLvl == 0 || this.maxLvl == 0){
|
|
||||||
this.minLvl = this.parent.minLvl;
|
|
||||||
this.maxLvl = this.parent.maxLvl;
|
|
||||||
}
|
|
||||||
} else { //only the Sea Floor zone does not have a parent
|
|
||||||
this.absX = this.xCoord;
|
|
||||||
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
|
||||||
this.absZ = this.zCoord;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zone AABB is set here as it's coordinate space is world requiring a parent.
|
|
||||||
this.setBounds();
|
|
||||||
|
|
||||||
if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0)
|
|
||||||
this.seaLevel = this.getHeightMap().getSeaLevel();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void generateWorldAltitude(){
|
|
||||||
|
|
||||||
if (ZoneManager.getSeaFloor().getObjectUUID() == this.getObjectUUID()){
|
|
||||||
this.worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
this.worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -240,9 +232,9 @@ public class Zone extends AbstractGameObject {
|
|||||||
|
|
||||||
//seafloor only zone with null parent;
|
//seafloor only zone with null parent;
|
||||||
|
|
||||||
while(parentZone != ZoneManager.getSeaFloor()){
|
while (parentZone != ZoneManager.getSeaFloor()) {
|
||||||
|
|
||||||
if(parentZone.getHeightMap() != null){
|
if (parentZone.getHeightMap() != null) {
|
||||||
|
|
||||||
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone);
|
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone);
|
||||||
altitude += parentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
altitude += parentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc);
|
||||||
@@ -258,12 +250,12 @@ public class Zone extends AbstractGameObject {
|
|||||||
if (ZoneManager.getSeaFloor().equals(this))
|
if (ZoneManager.getSeaFloor().equals(this))
|
||||||
this.seaLevel = 0;
|
this.seaLevel = 0;
|
||||||
else if
|
else if
|
||||||
(this.getHeightMap() != null && this.getHeightMap().getSeaLevel() == 0){
|
(this.getHeightMap() != null && this.getHeightMap().getSeaLevel() == 0) {
|
||||||
this.seaLevel = this.parent.seaLevel;
|
this.seaLevel = this.parent.seaLevel;
|
||||||
|
|
||||||
}else if (this.getHeightMap() != null){
|
} else if (this.getHeightMap() != null) {
|
||||||
this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel();
|
this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel();
|
||||||
}else {
|
} else {
|
||||||
this.seaLevel = this.parent.seaLevel;
|
this.seaLevel = this.parent.seaLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +265,34 @@ public class Zone extends AbstractGameObject {
|
|||||||
return this.parent;
|
return this.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setParent(final Zone value) {
|
||||||
|
|
||||||
|
this.parent = value;
|
||||||
|
this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0;
|
||||||
|
|
||||||
|
if (this.parent != null) {
|
||||||
|
this.absX = this.xCoord + parent.absX;
|
||||||
|
this.absY = this.yCoord + parent.absY;
|
||||||
|
this.absZ = this.zCoord + parent.absZ;
|
||||||
|
|
||||||
|
if (this.minLvl == 0 || this.maxLvl == 0) {
|
||||||
|
this.minLvl = this.parent.minLvl;
|
||||||
|
this.maxLvl = this.parent.maxLvl;
|
||||||
|
}
|
||||||
|
} else { //only the Sea Floor zone does not have a parent
|
||||||
|
this.absX = this.xCoord;
|
||||||
|
this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE;
|
||||||
|
this.absZ = this.zCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zone AABB is set here as it's coordinate space is world requiring a parent.
|
||||||
|
this.setBounds();
|
||||||
|
|
||||||
|
if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0)
|
||||||
|
this.seaLevel = this.getHeightMap().getSeaLevel();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public float getAbsX() {
|
public float getAbsX() {
|
||||||
return this.absX;
|
return this.absX;
|
||||||
}
|
}
|
||||||
@@ -302,14 +322,14 @@ public class Zone extends AbstractGameObject {
|
|||||||
return this.isNPCCity;
|
return this.isNPCCity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayerCity() {
|
|
||||||
return this.isPlayerCity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNPCCity(boolean value) {
|
public void setNPCCity(boolean value) {
|
||||||
this.isNPCCity = value;
|
this.isNPCCity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPlayerCity() {
|
||||||
|
return this.isPlayerCity;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPlayerCity(boolean value) {
|
public void setPlayerCity(boolean value) {
|
||||||
this.isPlayerCity = value;
|
this.isPlayerCity = value;
|
||||||
}
|
}
|
||||||
@@ -336,67 +356,12 @@ public class Zone extends AbstractGameObject {
|
|||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNode(Zone child) {
|
|
||||||
this.nodes.add(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serializing
|
* Serializing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public void addNode(Zone child) {
|
||||||
public static void serializeForClientMsg(Zone zone,ByteBufferWriter writer) {
|
this.nodes.add(child);
|
||||||
|
|
||||||
if (zone.loadNum == 0 && zone.playerCityID == 0)
|
|
||||||
Logger.warn( "Warning! WorldServerMap with ID " + zone.getObjectUUID() + " has a loadnum of 0 (player city) and no city linked. This will probably crash the client!");
|
|
||||||
|
|
||||||
// Player City Terraform values serialized here.
|
|
||||||
|
|
||||||
if (zone.playerCityID > 0) {
|
|
||||||
writer.put((byte) 1); // Player City - True
|
|
||||||
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
|
||||||
writer.putFloat(Enum.CityBoundsType.ZONE.extents);
|
|
||||||
} else
|
|
||||||
writer.put((byte) 0); // Player City - False
|
|
||||||
|
|
||||||
writer.putFloat(zone.xCoord);
|
|
||||||
writer.putFloat(zone.zCoord);
|
|
||||||
writer.putFloat(zone.yCoord);
|
|
||||||
|
|
||||||
writer.putInt(0);
|
|
||||||
writer.putInt(0);
|
|
||||||
writer.putInt(zone.loadNum);
|
|
||||||
|
|
||||||
if (zone.playerCityID > 0) {
|
|
||||||
City k = City.getCity(zone.playerCityID);
|
|
||||||
|
|
||||||
if (k != null) {
|
|
||||||
writer.putInt(k.getObjectType().ordinal());
|
|
||||||
writer.putInt(k.getObjectUUID());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
writer.putLong(0x0);
|
|
||||||
} else {
|
|
||||||
writer.putInt(zone.getObjectType().ordinal());
|
|
||||||
writer.putInt(zone.getObjectUUID());
|
|
||||||
}
|
|
||||||
writer.putInt(zone.nodes.size());
|
|
||||||
|
|
||||||
City city = City.getCity(zone.playerCityID);
|
|
||||||
|
|
||||||
if (city != null)
|
|
||||||
writer.putString(city.getCityName());
|
|
||||||
else
|
|
||||||
writer.putString(zone.zoneName);
|
|
||||||
writer.put(zone.safeZone);
|
|
||||||
writer.putString(zone.Icon1);
|
|
||||||
writer.putString(zone.Icon2);
|
|
||||||
writer.putString(zone.Icon3);
|
|
||||||
writer.put((byte) 0); // Pad
|
|
||||||
|
|
||||||
for (Zone child : zone.nodes) {
|
|
||||||
Zone.serializeForClientMsg(child,writer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user