From b53c1b20d97a927d82de8592806817134aede35a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 14 Aug 2023 16:09:06 -0400 Subject: [PATCH] Add constants for message action type. --- .../handlers/PetitionReceivedMsgHandler.java | 14 ++++++++------ src/engine/net/client/msg/PetitionReceivedMsg.java | 8 +++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java b/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java index 905badae..e34be6d3 100644 --- a/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java +++ b/src/engine/net/client/handlers/PetitionReceivedMsgHandler.java @@ -13,6 +13,10 @@ import engine.objects.PlayerCharacter; public class PetitionReceivedMsgHandler extends AbstractClientMsgHandler { + public static final int PETITION_NEW = 1; + public static final int PETITION_CANCEL = 2; + public static final int PETITION_CLOSE = 4; + public PetitionReceivedMsgHandler() { super(PetitionReceivedMsg.class); } @@ -35,18 +39,16 @@ public class PetitionReceivedMsgHandler extends AbstractClientMsgHandler { Petition petition = new Petition(msg, origin); - if (petition == null) - return false; - try { // Write petition to database - DbManager.PetitionQueries.WRITE_PETITION_TO_TABLE(petition); + if (petitionReceivedMsg.petition == PETITION_NEW) + DbManager.PetitionQueries.WRITE_PETITION_TO_TABLE(petition); // Close the petition window - if (petitionReceivedMsg.petition != 2) - petitionReceivedMsg.petition = 4; + if (petitionReceivedMsg.petition == PETITION_NEW) + petitionReceivedMsg.petition = PETITION_CLOSE; petitionReceivedMsg.unknownByte01 = 0; petitionReceivedMsg.unknown04 = 0; diff --git a/src/engine/net/client/msg/PetitionReceivedMsg.java b/src/engine/net/client/msg/PetitionReceivedMsg.java index 8bbb0b36..2526cb9d 100644 --- a/src/engine/net/client/msg/PetitionReceivedMsg.java +++ b/src/engine/net/client/msg/PetitionReceivedMsg.java @@ -15,12 +15,10 @@ import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; import engine.net.client.Protocol; +import static engine.net.client.handlers.PetitionReceivedMsgHandler.PETITION_NEW; -public class PetitionReceivedMsg extends ClientNetMsg { - // TODO pull these statics out into SBEmuStatics.java - public static final int PETITION_NEW = 1; - public static final int PETITION_CANCEL = 2; +public class PetitionReceivedMsg extends ClientNetMsg { public int petition; public int unknown01; @@ -97,7 +95,7 @@ public class PetitionReceivedMsg extends ClientNetMsg { this.language = reader.getString(); this.unknown07 = reader.getInt(); this.message = reader.getUnicodeString(); - } else if (petition == PETITION_CANCEL) { + } else { this.unknown01 = reader.getInt(); this.unknown02 = reader.getInt(); this.unknownByte01 = reader.get();