From 66ccd304168bd7264622de5abdbbfd23a502f124 Mon Sep 17 00:00:00 2001 From: Melledy <52122272+Melledy@users.noreply.github.com> Date: Sat, 30 Apr 2022 22:51:21 -0700 Subject: [PATCH] Fix possible exploit with mcoin exchange --- .../server/packet/recv/HandlerMcoinExchangeHcoinReq.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java index 0f3d2e7f8..57ecaf42b 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java @@ -13,14 +13,15 @@ public class HandlerMcoinExchangeHcoinReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq exchangeReq = McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq.parseFrom(payload); - if (session == null) { - return; - } else if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum()) { + + if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum() && exchangeReq.getMCoinNum() == exchangeReq.getHCoinNum()) { return; } + session.getPlayer().setCrystals(session.getPlayer().getCrystals() - exchangeReq.getMCoinNum()); session.getPlayer().setPrimogems(session.getPlayer().getPrimogems() + exchangeReq.getHCoinNum()); session.getPlayer().save(); + session.send(new PacketMcoinExchangeHcoinRsp(session.getPlayer().getCrystals(), session.getPlayer().getPrimogems())); } }