From de417029141f2321b3286625302863de6f7e23dc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 21 Jan 2023 07:24:50 -0500 Subject: [PATCH] Protocol handler created for ArcMineWindowAvailableTimeMsg. --- src/engine/net/client/ClientMessagePump.java | 34 ---------- src/engine/net/client/Protocol.java | 2 +- .../ArcMineWindowAvailableTimeHandler.java | 63 +++++++++++++++++++ 3 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 795c0889..6f493559 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -262,9 +262,6 @@ public class ClientMessagePump implements NetMsgHandler { case VENDORDIALOG: VendorDialogMsg.replyDialog((VendorDialogMsg) msg, origin); break; - case ARCMINEWINDOWAVAILABLETIME: - MineWindowAvailableTime((ArcMineWindowAvailableTimeMsg) msg, origin); - break; case ARCOWNEDMINESLIST: ListOwnedMines((ArcOwnedMinesListMsg) msg, origin); break; @@ -1426,37 +1423,6 @@ boolean updateCity = false; } - private static void MineWindowAvailableTime(ArcMineWindowAvailableTimeMsg msg, ClientConnection origin) { - Building tol = BuildingManager.getBuildingFromCache(msg.getBuildingUUID()); - Dispatch dispatch; - - if (tol == null) - return; - - if (tol.getBlueprintUUID() == 0) - return; - - if (tol.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) - return; - - PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); - - if (pc == null) - return; - - if (!Guild.sameGuild(tol.getGuild(), pc.getGuild())) - return; //must be same guild - - if (GuildStatusController.isInnerCouncil(pc.getGuildStatus()) == false) // is this only GL? - return; - - ArcMineWindowAvailableTimeMsg amwat = new ArcMineWindowAvailableTimeMsg(tol, 10); - amwat.configure(); - dispatch = Dispatch.borrow(pc, amwat); - DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); - - } - private static void ListOwnedMines(ArcOwnedMinesListMsg msg, ClientConnection origin) { PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 38965bb8..f3f543cc 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -35,7 +35,7 @@ public enum Protocol { ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world ARCMINECHANGEPRODUCTION(0x1EAA993F, ArcMineChangeProductionMsg.class, null), ARCMINETOWERCRESTUPDATE(0x34164D0D, null, null), - ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, null), + ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class), ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class), ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, null), ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack diff --git a/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java b/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java new file mode 100644 index 00000000..b3ab1d67 --- /dev/null +++ b/src/engine/net/client/handlers/ArcMineWindowAvailableTimeHandler.java @@ -0,0 +1,63 @@ +package engine.net.client.handlers; + +import engine.Enum; +import engine.Enum.DispatchChannel; +import engine.exception.MsgSendException; +import engine.gameManager.BuildingManager; +import engine.net.Dispatch; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ArcMineWindowAvailableTimeMsg; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.KeepAliveServerClientMsg; +import engine.objects.Building; +import engine.objects.Guild; +import engine.objects.GuildStatusController; +import engine.objects.PlayerCharacter; + +/* + * @Author: + * @Summary: Processes application protocol message which keeps + * client's tcp connection open. + */ + +public class ArcMineWindowAvailableTimeHandler extends AbstractClientMsgHandler { + + public ArcMineWindowAvailableTimeHandler() { + super(KeepAliveServerClientMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + ArcMineWindowAvailableTimeMsg msg = (ArcMineWindowAvailableTimeMsg) baseMsg; + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + Building treeOfLife = BuildingManager.getBuildingFromCache(msg.getBuildingUUID()); + Dispatch dispatch; + + if (treeOfLife == null) + return true; + + if (treeOfLife.getBlueprintUUID() == 0) + return true; + + if (treeOfLife.getBlueprint().getBuildingGroup() != Enum.BuildingGroup.TOL) + return true; + + if (playerCharacter == null) + return true; + + if (!Guild.sameGuild(treeOfLife.getGuild(), playerCharacter.getGuild())) + return true; + + if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) // is this only GL? + return true; + + ArcMineWindowAvailableTimeMsg outMsg = new ArcMineWindowAvailableTimeMsg(treeOfLife, 10); + outMsg.configure(); + dispatch = Dispatch.borrow(playerCharacter, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); + return true; + + } +} \ No newline at end of file