Browse Source

Charter template id is stored not ordinal

combat-2
MagicBot 8 months ago
parent
commit
3c4d8239db
  1. 2
      src/engine/db/archive/GuildRecord.java
  2. 4
      src/engine/db/handlers/dbGuildHandler.java
  3. 6
      src/engine/gameManager/ChatManager.java
  4. 5
      src/engine/net/client/handlers/ChangeGuildLeaderHandler.java
  5. 4
      src/engine/net/client/handlers/ChangeRankHandler.java
  6. 2
      src/engine/net/client/handlers/GuildCreationFinalizeHandler.java
  7. 4
      src/engine/net/client/handlers/InviteToGuildHandler.java
  8. 2
      src/engine/net/client/msg/WhoResponseMsg.java
  9. 4
      src/engine/net/client/msg/guild/GuildInfoMsg.java
  10. 4
      src/engine/net/client/msg/guild/GuildListMsg.java
  11. 2
      src/engine/objects/City.java
  12. 16
      src/engine/objects/Guild.java

2
src/engine/db/archive/GuildRecord.java

@ -89,7 +89,7 @@ public class GuildRecord extends DataRecord {
guildRecord.guildHash = guildRecord.guild.getHash(); guildRecord.guildHash = guildRecord.guild.getHash();
guildRecord.guildID = guildRecord.guild.getObjectUUID(); guildRecord.guildID = guildRecord.guild.getObjectUUID();
guildRecord.guildName = guildRecord.guild.getName(); guildRecord.guildName = guildRecord.guild.getName();
mbEnums.GuildCharterType guildCharterType = mbEnums.GuildCharterType.getGuildTypeFromInt(guildRecord.guild.getCharter()); mbEnums.GuildCharterType guildCharterType = guild.charter;
guildRecord.charterName = guildCharterType.name; guildRecord.charterName = guildCharterType.name;
guildRecord.GLHash = DataWarehouse.hasher.encrypt(guildRecord.guild.getGuildLeaderUUID()); guildRecord.GLHash = DataWarehouse.hasher.encrypt(guildRecord.guild.getGuildLeaderUUID());

4
src/engine/db/handlers/dbGuildHandler.java

@ -427,7 +427,7 @@ public class dbGuildHandler extends dbHandlerBase {
preparedStatement.setInt(6, guildTag.symbolColor); preparedStatement.setInt(6, guildTag.symbolColor);
preparedStatement.setInt(7, guildTag.backgroundDesign); preparedStatement.setInt(7, guildTag.backgroundDesign);
preparedStatement.setInt(8, guildTag.symbol); preparedStatement.setInt(8, guildTag.symbol);
preparedStatement.setInt(9, g.getCharter()); preparedStatement.setInt(9, g.charter.templateID);
preparedStatement.setString(10, g.getLeadershipType()); preparedStatement.setString(10, g.getLeadershipType());
preparedStatement.setString(11, g.getMotto()); preparedStatement.setString(11, g.getMotto());
@ -573,7 +573,7 @@ public class dbGuildHandler extends dbHandlerBase {
preparedStatement.setInt(4, g.getGuildTag().symbolColor); preparedStatement.setInt(4, g.getGuildTag().symbolColor);
preparedStatement.setInt(5, g.getGuildTag().backgroundDesign); preparedStatement.setInt(5, g.getGuildTag().backgroundDesign);
preparedStatement.setInt(6, g.getGuildTag().symbol); preparedStatement.setInt(6, g.getGuildTag().symbol);
preparedStatement.setInt(7, g.getCharter()); preparedStatement.setInt(7, g.charter.templateID);
preparedStatement.setString(8, g.getMOTD()); preparedStatement.setString(8, g.getMOTD());
preparedStatement.setString(9, g.getICMOTD()); preparedStatement.setString(9, g.getICMOTD());
preparedStatement.setString(10, ""); preparedStatement.setString(10, "");

6
src/engine/gameManager/ChatManager.java

@ -339,8 +339,8 @@ public enum ChatManager {
chatGuildMsg.setSourceID(sender.getObjectUUID()); chatGuildMsg.setSourceID(sender.getObjectUUID());
chatGuildMsg.setSourceName(sender.getFirstName()); chatGuildMsg.setSourceName(sender.getFirstName());
chatGuildMsg.setUnknown03(WorldServer.worldMapID); // Server ID chatGuildMsg.setUnknown03(WorldServer.worldMapID); // Server ID
chatGuildMsg.setUnknown04(sender.getGuild() != null ? sender.getGuild() Guild guild1 = sender.getGuild();
.getCharter() : 0); // Charter? chatGuildMsg.setUnknown04(sender.getGuild() != null ? guild1.charter.ordinal() : 0); // Charter?
chatGuildMsg.setUnknown05(GuildStatusController.getTitle(sender.getGuildStatus())); // Title? chatGuildMsg.setUnknown05(GuildStatusController.getTitle(sender.getGuildStatus())); // Title?
chatGuildMsg.setUnknown06(sender.race.getRaceType().getCharacterSex().equals(mbEnums.CharacterSex.MALE) ? 1 : 2); // isMale?, seen 1 and 2 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.setName(sender.getFirstName());
msg.setGuildTitle(GuildStatusController.getTitle(sender.getGuildStatus())); msg.setGuildTitle(GuildStatusController.getTitle(sender.getGuildStatus()));
msg.setGuildUUID(guild.getObjectUUID()); msg.setGuildUUID(guild.getObjectUUID());
msg.setCharter(guild.getCharter()); msg.setCharter(guild.charter.ordinal());
// Send dispatch to each player // Send dispatch to each player

5
src/engine/net/client/handlers/ChangeGuildLeaderHandler.java

@ -67,18 +67,13 @@ public class ChangeGuildLeaderHandler extends AbstractClientMsgHandler {
if (!Guild.sameGuild(sourcePlayer.getGuild(), targetPlayer.getGuild())) if (!Guild.sameGuild(sourcePlayer.getGuild(), targetPlayer.getGuild()))
return false; return false;
//updateSource will generate a new promote/demote screen for sourcePlayer //updateSource will generate a new promote/demote screen for sourcePlayer
//updateTarget will sync guild info for the target and all players in range //updateTarget will sync guild info for the target and all players in range
String targetName = null; String targetName = null;
boolean isMale = true; boolean isMale = true;
boolean updateTarget; boolean updateTarget;
mbEnums.GuildCharterType t = mbEnums.GuildCharterType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter());
if (!DbManager.GuildQueries.SET_GUILD_LEADER(targetPlayer.getObjectUUID(), glGuild.getObjectUUID())) { if (!DbManager.GuildQueries.SET_GUILD_LEADER(targetPlayer.getObjectUUID(), glGuild.getObjectUUID())) {
ChatManager.chatGuildError(sourcePlayer, "Failed to change guild leader!"); ChatManager.chatGuildError(sourcePlayer, "Failed to change guild leader!");
return false; return false;

4
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.ChangeRankMsg;
import engine.net.client.msg.guild.GuildInfoMsg; import engine.net.client.msg.guild.GuildInfoMsg;
import engine.net.client.msg.guild.GuildListMsg; import engine.net.client.msg.guild.GuildListMsg;
import engine.objects.Guild;
import engine.objects.GuildStatusController; import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
@ -60,7 +61,8 @@ public class ChangeRankHandler extends AbstractClientMsgHandler {
boolean isMale; boolean isMale;
if (msg.getPreviousRank() != msg.getNewRank()) { 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) { if (targetPlayer != null) {
targetPlayer.setGuildTitle(msg.getNewRank()); targetPlayer.setGuildTitle(msg.getNewRank());

2
src/engine/net/client/handlers/GuildCreationFinalizeHandler.java

@ -96,7 +96,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag()); 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(), charterType.getLeadershipType(leadershipType), msg.getGuildTag(),
StringUtils.truncate(msg.getMotto(), 120)); StringUtils.truncate(msg.getMotto(), 120));

4
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.ClientNetMsg;
import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.guild.InviteToGuildMsg; import engine.net.client.msg.guild.InviteToGuildMsg;
import engine.objects.Guild;
import engine.objects.GuildStatusController; import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
@ -85,7 +86,8 @@ public class InviteToGuildHandler extends AbstractClientMsgHandler {
return true; return true;
} }
mbEnums.GuildCharterType guildCharterType = mbEnums.GuildCharterType.values()[sourcePlayer.getGuild().getCharter()]; Guild guild = sourcePlayer.getGuild();
mbEnums.GuildCharterType guildCharterType = guild.charter;
if (guildCharterType == null) { if (guildCharterType == null) {
ErrorPopupMsg.sendErrorPopup(sourcePlayer, GuildManager.NO_CHARTER_FOUND); ErrorPopupMsg.sendErrorPopup(sourcePlayer, GuildManager.NO_CHARTER_FOUND);

2
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); // Send Guild Info
writer.put((byte) 1); // SkipPartTwo writer.put((byte) 1); // SkipPartTwo
writer.putString(guild.getName()); writer.putString(guild.getName());
writer.putInt(guild.getCharter()); // Charter Type writer.putInt(guild.charter.ordinal()); // Charter Type
writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus()));
writer.putString("what"); // City?, Skip if SkipPartTwo = 0x00 writer.putString("what"); // City?, Skip if SkipPartTwo = 0x00
} else { } else {

4
src/engine/net/client/msg/guild/GuildInfoMsg.java

@ -289,7 +289,7 @@ class GuildInfoMessageType4 extends GuildInfoMessageType {
writer.putString(nation.getName()); writer.putString(nation.getName());
writer.putInt(GuildStatusController.getRank(pc.getGuildStatus())); writer.putInt(GuildStatusController.getRank(pc.getGuildStatus()));
writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus()));
writer.putInt(g.getCharter()); writer.putInt(g.charter.ordinal());
writer.putString(cityName); //Shows City Name FUCK writer.putString(cityName); //Shows City Name FUCK
AbstractCharacter guildLeader; AbstractCharacter guildLeader;
String guildLeaderName = ""; String guildLeaderName = "";
@ -392,7 +392,7 @@ class GuildInfoMessageType5 extends GuildInfoMessageType {
writer.putInt(GuildStatusController.getRank(pc.getGuildStatus())); //Rank writer.putInt(GuildStatusController.getRank(pc.getGuildStatus())); //Rank
writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); //Title writer.putInt(GuildStatusController.getTitle(pc.getGuildStatus())); //Title
writer.putInt(g.getCharter()); writer.putInt(g.charter.ordinal());
if (g.getNation().equals(Guild.getErrantNation())) if (g.getNation().equals(Guild.getErrantNation()))
writer.putString("Errant"); writer.putString("Errant");

4
src/engine/net/client/msg/guild/GuildListMsg.java

@ -125,7 +125,7 @@ class GuildListMessageType1 extends GuildListMessageType {
@Override @Override
void _serialize(ByteBufferWriter writer) { void _serialize(ByteBufferWriter writer) {
mbEnums.GuildCharterType gt = mbEnums.GuildCharterType.getGuildTypeFromInt(g.getCharter()); mbEnums.GuildCharterType gt = g.charter;
writer.putInt(1); writer.putInt(1);
writer.putInt(gt.ordinal()); //Charter Type writer.putInt(gt.ordinal()); //Charter Type
@ -209,7 +209,7 @@ class GuildListMessageType2 extends GuildListMessageType {
writer.putInt(2); //PAD writer.putInt(2); //PAD
writer.putInt(pc.getLevel()); writer.putInt(pc.getLevel());
writer.putInt(g.getCharter()); writer.putInt(g.charter.ordinal());
//TODO Get Guild History from the DB //TODO Get Guild History from the DB
//ArrayList<GuildHistory> history = DbManager.GuildQueries.GET_GUILD_HISTORY_OF_PLAYER((int)pc.getPlayerUUID()); //ArrayList<GuildHistory> history = DbManager.GuildQueries.GET_GUILD_HISTORY_OF_PLAYER((int)pc.getPlayerUUID());

2
src/engine/objects/City.java

@ -205,7 +205,7 @@ public class City extends AbstractWorldObject {
else else
writer.putString(guildRuler.getFirstName() + ' ' + guildRuler.getLastName()); writer.putString(guildRuler.getFirstName() + ' ' + guildRuler.getLastName());
writer.putInt(rulingGuild.getCharter()); writer.putInt(rulingGuild.charter.ordinal());
writer.putInt(0); // always 00000000 writer.putInt(0); // always 00000000
writer.put(city.isSafeHold); writer.put(city.isSafeHold);

16
src/engine/objects/Guild.java

@ -38,7 +38,7 @@ public class Guild extends AbstractWorldObject {
private static Guild errantNation; private static Guild errantNation;
private final String name; private final String name;
private final GuildTag guildTag; 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 String leadershipType; // Have to see how this is sent to the client
private final int repledgeMin; private final int repledgeMin;
private final int repledgeMax; private final int repledgeMax;
@ -71,7 +71,7 @@ public class Guild extends AbstractWorldObject {
/** /**
* No Id Constructor * 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) { String leadershipType, GuildTag gt, String motto) {
super(); super();
this.name = name; this.name = name;
@ -100,7 +100,7 @@ public class Guild extends AbstractWorldObject {
/** /**
* Normal Constructor * Normal Constructor
*/ */
public Guild(String name, Guild nat, int charter, public Guild(String name, Guild nat, GuildCharterType charter,
String leadershipType, GuildTag gt, int newUUID) { String leadershipType, GuildTag gt, int newUUID) {
super(newUUID); super(newUUID);
this.name = name; this.name = name;
@ -134,7 +134,7 @@ public class Guild extends AbstractWorldObject {
DbObjectType objectType; DbObjectType objectType;
this.name = rs.getString("name"); this.name = rs.getString("name");
this.charter = rs.getInt("charter"); this.charter = GuildCharterType.templateLookup.get(rs.getInt("charter"));
this.leadershipType = rs.getString("leadershipType"); this.leadershipType = rs.getString("leadershipType");
this.guildTag = new GuildTag(rs.getInt("backgroundColor01"), this.guildTag = new GuildTag(rs.getInt("backgroundColor01"),
@ -311,7 +311,7 @@ public class Guild extends AbstractWorldObject {
public static Guild getErrantGuild() { public static Guild getErrantGuild() {
if (Guild.errantGuild == null) 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); "Anarchy", GuildTag.ERRANT, 0);
return Guild.errantGuild; return Guild.errantGuild;
@ -319,7 +319,7 @@ public class Guild extends AbstractWorldObject {
public static Guild getErrantNation() { public static Guild getErrantNation() {
if (Guild.errantNation == null) 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; return Guild.errantNation;
} }
@ -456,10 +456,6 @@ public class Guild extends AbstractWorldObject {
return this.guildTag; return this.guildTag;
} }
public int getCharter() {
return charter;
}
/* /*
* Utils * Utils
*/ */

Loading…
Cancel
Save