diff --git a/src/engine/db/archive/GuildRecord.java b/src/engine/db/archive/GuildRecord.java index a2ad5a17..c093349d 100644 --- a/src/engine/db/archive/GuildRecord.java +++ b/src/engine/db/archive/GuildRecord.java @@ -89,7 +89,7 @@ public class GuildRecord extends DataRecord { guildRecord.guildHash = guildRecord.guild.getHash(); guildRecord.guildID = guildRecord.guild.getObjectUUID(); guildRecord.guildName = guildRecord.guild.getName(); - mbEnums.GuildCharterType guildCharterType = mbEnums.GuildCharterType.getGuildTypeFromInt(guildRecord.guild.getCharter()); + mbEnums.GuildCharterType guildCharterType = guild.charter; guildRecord.charterName = guildCharterType.name; guildRecord.GLHash = DataWarehouse.hasher.encrypt(guildRecord.guild.getGuildLeaderUUID()); diff --git a/src/engine/db/handlers/dbGuildHandler.java b/src/engine/db/handlers/dbGuildHandler.java index f0ca291b..d20a6dd1 100644 --- a/src/engine/db/handlers/dbGuildHandler.java +++ b/src/engine/db/handlers/dbGuildHandler.java @@ -427,7 +427,7 @@ public class dbGuildHandler extends dbHandlerBase { preparedStatement.setInt(6, guildTag.symbolColor); preparedStatement.setInt(7, guildTag.backgroundDesign); preparedStatement.setInt(8, guildTag.symbol); - preparedStatement.setInt(9, g.getCharter()); + preparedStatement.setInt(9, g.charter.templateID); preparedStatement.setString(10, g.getLeadershipType()); preparedStatement.setString(11, g.getMotto()); @@ -573,7 +573,7 @@ public class dbGuildHandler extends dbHandlerBase { preparedStatement.setInt(4, g.getGuildTag().symbolColor); preparedStatement.setInt(5, g.getGuildTag().backgroundDesign); preparedStatement.setInt(6, g.getGuildTag().symbol); - preparedStatement.setInt(7, g.getCharter()); + preparedStatement.setInt(7, g.charter.templateID); preparedStatement.setString(8, g.getMOTD()); preparedStatement.setString(9, g.getICMOTD()); preparedStatement.setString(10, ""); diff --git a/src/engine/gameManager/ChatManager.java b/src/engine/gameManager/ChatManager.java index d5a93bfa..366d2f10 100644 --- a/src/engine/gameManager/ChatManager.java +++ b/src/engine/gameManager/ChatManager.java @@ -339,8 +339,8 @@ public enum ChatManager { chatGuildMsg.setSourceID(sender.getObjectUUID()); chatGuildMsg.setSourceName(sender.getFirstName()); chatGuildMsg.setUnknown03(WorldServer.worldMapID); // Server ID - chatGuildMsg.setUnknown04(sender.getGuild() != null ? sender.getGuild() - .getCharter() : 0); // Charter? + Guild guild1 = sender.getGuild(); + chatGuildMsg.setUnknown04(sender.getGuild() != null ? guild1.charter.ordinal() : 0); // Charter? chatGuildMsg.setUnknown05(GuildStatusController.getTitle(sender.getGuildStatus())); // Title? chatGuildMsg.setUnknown06(sender.race.getRaceType().getCharacterSex().equals(mbEnums.CharacterSex.MALE) ? 1 : 2); // isMale?, seen 1 and 2 @@ -490,7 +490,7 @@ public enum ChatManager { msg.setName(sender.getFirstName()); msg.setGuildTitle(GuildStatusController.getTitle(sender.getGuildStatus())); msg.setGuildUUID(guild.getObjectUUID()); - msg.setCharter(guild.getCharter()); + msg.setCharter(guild.charter.ordinal()); // Send dispatch to each player diff --git a/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java b/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java index d0e5f2f6..6ebf4215 100644 --- a/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java +++ b/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java @@ -67,18 +67,13 @@ public class ChangeGuildLeaderHandler extends AbstractClientMsgHandler { if (!Guild.sameGuild(sourcePlayer.getGuild(), targetPlayer.getGuild())) return false; - //updateSource will generate a new promote/demote screen for sourcePlayer //updateTarget will sync guild info for the target and all players in range - String targetName = null; boolean isMale = true; boolean updateTarget; - mbEnums.GuildCharterType t = mbEnums.GuildCharterType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter()); - - if (!DbManager.GuildQueries.SET_GUILD_LEADER(targetPlayer.getObjectUUID(), glGuild.getObjectUUID())) { ChatManager.chatGuildError(sourcePlayer, "Failed to change guild leader!"); return false; diff --git a/src/engine/net/client/handlers/ChangeRankHandler.java b/src/engine/net/client/handlers/ChangeRankHandler.java index 202bace2..c8cde3e2 100644 --- a/src/engine/net/client/handlers/ChangeRankHandler.java +++ b/src/engine/net/client/handlers/ChangeRankHandler.java @@ -21,6 +21,7 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.guild.ChangeRankMsg; import engine.net.client.msg.guild.GuildInfoMsg; import engine.net.client.msg.guild.GuildListMsg; +import engine.objects.Guild; import engine.objects.GuildStatusController; import engine.objects.PlayerCharacter; @@ -60,7 +61,8 @@ public class ChangeRankHandler extends AbstractClientMsgHandler { boolean isMale; if (msg.getPreviousRank() != msg.getNewRank()) { - mbEnums.GuildCharterType t = mbEnums.GuildCharterType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter()); + Guild guild = sourcePlayer.getGuild(); + mbEnums.GuildCharterType t = mbEnums.GuildCharterType.getGuildTypeFromInt(guild.charter.ordinal()); if (targetPlayer != null) { targetPlayer.setGuildTitle(msg.getNewRank()); diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index ef241b6c..7860bd44 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -96,7 +96,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag()); - newGuild = new Guild(msg.getName(), null, charterType.ordinal(), + newGuild = new Guild(msg.getName(), null, charterType, charterType.getLeadershipType(leadershipType), msg.getGuildTag(), StringUtils.truncate(msg.getMotto(), 120)); diff --git a/src/engine/net/client/handlers/InviteToGuildHandler.java b/src/engine/net/client/handlers/InviteToGuildHandler.java index 92a0c060..79de3341 100644 --- a/src/engine/net/client/handlers/InviteToGuildHandler.java +++ b/src/engine/net/client/handlers/InviteToGuildHandler.java @@ -23,6 +23,7 @@ import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.guild.InviteToGuildMsg; +import engine.objects.Guild; import engine.objects.GuildStatusController; import engine.objects.PlayerCharacter; @@ -85,7 +86,8 @@ public class InviteToGuildHandler extends AbstractClientMsgHandler { return true; } - mbEnums.GuildCharterType guildCharterType = mbEnums.GuildCharterType.values()[sourcePlayer.getGuild().getCharter()]; + Guild guild = sourcePlayer.getGuild(); + mbEnums.GuildCharterType guildCharterType = guild.charter; if (guildCharterType == null) { ErrorPopupMsg.sendErrorPopup(sourcePlayer, GuildManager.NO_CHARTER_FOUND); diff --git a/src/engine/net/client/msg/WhoResponseMsg.java b/src/engine/net/client/msg/WhoResponseMsg.java index c89fe630..a52d827c 100644 --- a/src/engine/net/client/msg/WhoResponseMsg.java +++ b/src/engine/net/client/msg/WhoResponseMsg.java @@ -243,7 +243,7 @@ public class WhoResponseMsg extends ClientNetMsg { writer.put((byte) 1); // Send Guild Info writer.put((byte) 1); // SkipPartTwo writer.putString(guild.getName()); - writer.putInt(guild.getCharter()); // Charter Type + writer.putInt(guild.charter.ordinal()); // Charter Type writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); writer.putString("what"); // City?, Skip if SkipPartTwo = 0x00 } else { diff --git a/src/engine/net/client/msg/guild/GuildInfoMsg.java b/src/engine/net/client/msg/guild/GuildInfoMsg.java index fc692299..a2c2a3c4 100644 --- a/src/engine/net/client/msg/guild/GuildInfoMsg.java +++ b/src/engine/net/client/msg/guild/GuildInfoMsg.java @@ -289,7 +289,7 @@ class GuildInfoMessageType4 extends GuildInfoMessageType { writer.putString(nation.getName()); writer.putInt(GuildStatusController.getRank(pc.getGuildStatus())); writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); - writer.putInt(g.getCharter()); + writer.putInt(g.charter.ordinal()); writer.putString(cityName); //Shows City Name FUCK AbstractCharacter guildLeader; String guildLeaderName = ""; @@ -392,7 +392,7 @@ class GuildInfoMessageType5 extends GuildInfoMessageType { writer.putInt(GuildStatusController.getRank(pc.getGuildStatus())); //Rank writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); //Title - writer.putInt(g.getCharter()); + writer.putInt(g.charter.ordinal()); if (g.getNation().equals(Guild.getErrantNation())) writer.putString("Errant"); diff --git a/src/engine/net/client/msg/guild/GuildListMsg.java b/src/engine/net/client/msg/guild/GuildListMsg.java index 821745a7..2ca2ccbb 100644 --- a/src/engine/net/client/msg/guild/GuildListMsg.java +++ b/src/engine/net/client/msg/guild/GuildListMsg.java @@ -125,7 +125,7 @@ class GuildListMessageType1 extends GuildListMessageType { @Override void _serialize(ByteBufferWriter writer) { - mbEnums.GuildCharterType gt = mbEnums.GuildCharterType.getGuildTypeFromInt(g.getCharter()); + mbEnums.GuildCharterType gt = g.charter; writer.putInt(1); writer.putInt(gt.ordinal()); //Charter Type @@ -209,7 +209,7 @@ class GuildListMessageType2 extends GuildListMessageType { writer.putInt(2); //PAD writer.putInt(pc.getLevel()); - writer.putInt(g.getCharter()); + writer.putInt(g.charter.ordinal()); //TODO Get Guild History from the DB //ArrayList history = DbManager.GuildQueries.GET_GUILD_HISTORY_OF_PLAYER((int)pc.getPlayerUUID()); diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index b48804d8..fa9fee9d 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -205,7 +205,7 @@ public class City extends AbstractWorldObject { else writer.putString(guildRuler.getFirstName() + ' ' + guildRuler.getLastName()); - writer.putInt(rulingGuild.getCharter()); + writer.putInt(rulingGuild.charter.ordinal()); writer.putInt(0); // always 00000000 writer.put(city.isSafeHold); diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 49b4385d..012ad330 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -38,7 +38,7 @@ public class Guild extends AbstractWorldObject { private static Guild errantNation; private final String name; private final GuildTag guildTag; - private final int charter; + public final GuildCharterType charter; private final String leadershipType; // Have to see how this is sent to the client private final int repledgeMin; private final int repledgeMax; @@ -71,7 +71,7 @@ public class Guild extends AbstractWorldObject { /** * No Id Constructor */ - public Guild(String name, Guild nat, int charter, + public Guild(String name, Guild nat, GuildCharterType charter, String leadershipType, GuildTag gt, String motto) { super(); this.name = name; @@ -100,7 +100,7 @@ public class Guild extends AbstractWorldObject { /** * Normal Constructor */ - public Guild(String name, Guild nat, int charter, + public Guild(String name, Guild nat, GuildCharterType charter, String leadershipType, GuildTag gt, int newUUID) { super(newUUID); this.name = name; @@ -134,7 +134,7 @@ public class Guild extends AbstractWorldObject { DbObjectType objectType; this.name = rs.getString("name"); - this.charter = rs.getInt("charter"); + this.charter = GuildCharterType.templateLookup.get(rs.getInt("charter")); this.leadershipType = rs.getString("leadershipType"); this.guildTag = new GuildTag(rs.getInt("backgroundColor01"), @@ -311,7 +311,7 @@ public class Guild extends AbstractWorldObject { public static Guild getErrantGuild() { if (Guild.errantGuild == null) - Guild.errantGuild = new Guild("None", Guild.getErrantNation(), 0, + Guild.errantGuild = new Guild("None", Guild.getErrantNation(), GuildCharterType.NONE, "Anarchy", GuildTag.ERRANT, 0); return Guild.errantGuild; @@ -319,7 +319,7 @@ public class Guild extends AbstractWorldObject { public static Guild getErrantNation() { if (Guild.errantNation == null) - Guild.errantNation = new Guild("None", null, 10, "Despot Rule", GuildTag.ERRANT, 0); + Guild.errantNation = new Guild("None", null, GuildCharterType.NONE, "Despot Rule", GuildTag.ERRANT, 0); return Guild.errantNation; } @@ -456,10 +456,6 @@ public class Guild extends AbstractWorldObject { return this.guildTag; } - public int getCharter() { - return charter; - } - /* * Utils */