Browse Source

Handler created for TrainerInfoMsg

combat-2
MagicBot 8 months ago
parent
commit
ce403a6bd8
  1. 3
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 59
      src/engine/net/client/handlers/TrainerInfoMsgHandler.java
  4. 22
      src/engine/server/world/WorldServer.java

3
src/engine/net/client/ClientMessagePump.java

@ -123,9 +123,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -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;

2
src/engine/net/client/Protocol.java

@ -217,7 +217,7 @@ public enum Protocol { @@ -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

59
src/engine/net/client/handlers/TrainerInfoMsgHandler.java

@ -0,0 +1,59 @@ @@ -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;
}
}

22
src/engine/server/world/WorldServer.java

@ -25,7 +25,6 @@ import engine.job.JobScheduler; @@ -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; @@ -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 { @@ -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;

Loading…
Cancel
Save