diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index bcca3228..7721b052 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -123,9 +123,6 @@ public class ClientMessagePump implements NetMsgHandler { case ARCREQUESTTRADEBUSY: TradeManager.invalidTradeRequest((InvalidTradeRequestMsg) msg); break; - case TRAINERLIST: - WorldServer.trainerInfo((TrainerInfoMsg) msg, origin); - break; case POWERTARGNAME: PowersManager.summon((SendSummonsRequestMsg) msg, origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index 8d7cc663..f421f539 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -217,7 +217,7 @@ public enum Protocol { TRADECONFIRM(0x6911E65E, CommitToTradeMsg.class, null), // Commit to trade TRADECONFIRMSTATUS(0x9F85DAFC, null, null), // Other player commit/uncommit/add item TRADEUNCONFIRM(0xEBE280E0, UncommitToTradeMsg.class, null), // Uncommit to trade - TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, null), //Req/Send Trainer Info/Pricing + TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, TrainerInfoMsgHandler.class), //Req/Send Trainer Info/Pricing TRAINSKILL(0xB0BF68CD, TrainMsg.class, TrainMsgHandler.class), //Train skills/powers TRANSFERASSET(0x3EA1C4C9, TransferAssetMsg.class, TransferAssetMsgHandler.class), // Transfer Building TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error diff --git a/src/engine/net/client/handlers/TrainerInfoMsgHandler.java b/src/engine/net/client/handlers/TrainerInfoMsgHandler.java new file mode 100644 index 00000000..0d205354 --- /dev/null +++ b/src/engine/net/client/handlers/TrainerInfoMsgHandler.java @@ -0,0 +1,59 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum; +import engine.exception.MsgSendException; +import engine.net.Dispatch; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.TrainerInfoMsg; +import engine.objects.NPC; +import engine.objects.PlayerCharacter; + +public class TrainerInfoMsgHandler extends AbstractClientMsgHandler { + + public TrainerInfoMsgHandler() { + super(TrainerInfoMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = origin.getPlayerCharacter(); + + // Member variable declaration + + TrainerInfoMsg msg; + + // Member variable assignment + + msg = (TrainerInfoMsg) baseMsg; + + NPC npc = NPC.getFromCache(msg.getObjectID()); + float sellPercent = 1; + + if (npc != null) { + + if (origin.getPlayerCharacter() != null) + sellPercent = npc.getSellPercent(origin.getPlayerCharacter()); + else + sellPercent = npc.getSellPercent(); + + msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc)); + } + + Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); + DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); + + return true; + } + +} \ No newline at end of file diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 30af5b70..d6d1e890 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -25,7 +25,6 @@ import engine.job.JobScheduler; import engine.jobs.LogoutCharacterJob; import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.Respawner; -import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.ItemProductionManager; import engine.net.Network; @@ -33,7 +32,6 @@ import engine.net.client.ClientConnection; import engine.net.client.ClientConnectionManager; import engine.net.client.ClientMessagePump; import engine.net.client.Protocol; -import engine.net.client.msg.TrainerInfoMsg; import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; @@ -122,26 +120,6 @@ public class WorldServer { } } - public static void trainerInfo(TrainerInfoMsg msg, ClientConnection origin) { - - NPC npc = NPC.getFromCache(msg.getObjectID()); - float sellPercent = 1; - - if (npc != null) { - - if (origin.getPlayerCharacter() != null) - sellPercent = npc.getSellPercent(origin.getPlayerCharacter()); - else - sellPercent = npc.getSellPercent(); - - msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc)); - } - - Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - } - public static String getUptimeString() { String outString = null;