From d4e1b265e31f16780897152250ab9df6076983cc Mon Sep 17 00:00:00 2001 From: Kinesis Date: Sun, 1 May 2022 16:24:23 +0800 Subject: [PATCH] fix McoinExchangeHcoinRsp packet structure --- proto/McoinExchangeHcoinRsp.proto | 3 +-- .../packet/recv/HandlerMcoinExchangeHcoinReq.java | 5 +++-- .../packet/send/PacketMcoinExchangeHcoinRsp.java | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/proto/McoinExchangeHcoinRsp.proto b/proto/McoinExchangeHcoinRsp.proto index b1904885b..090341308 100644 --- a/proto/McoinExchangeHcoinRsp.proto +++ b/proto/McoinExchangeHcoinRsp.proto @@ -3,6 +3,5 @@ syntax = "proto3"; option java_package = "emu.grasscutter.net.proto"; message McoinExchangeHcoinRsp { - uint32 mCoinNum = 1; - uint32 hCoinNum = 2; + int32 retcode = 1; } 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 57ecaf42b..37dc0fcc7 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java @@ -4,6 +4,7 @@ import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.McoinExchangeHcoinReqOuterClass; +import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketMcoinExchangeHcoinRsp; @@ -15,13 +16,13 @@ public class HandlerMcoinExchangeHcoinReq extends PacketHandler { McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq exchangeReq = McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq.parseFrom(payload); if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum() && exchangeReq.getMCoinNum() == exchangeReq.getHCoinNum()) { + session.send(new PacketMcoinExchangeHcoinRsp(RetcodeOuterClass.Retcode.RET_UNKNOWN_ERROR_VALUE)); 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())); + session.send(new PacketMcoinExchangeHcoinRsp(RetcodeOuterClass.Retcode.RET_SUCC_VALUE)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketMcoinExchangeHcoinRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketMcoinExchangeHcoinRsp.java index 65bef7b27..a37c12505 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketMcoinExchangeHcoinRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketMcoinExchangeHcoinRsp.java @@ -6,13 +6,13 @@ import emu.grasscutter.net.proto.McoinExchangeHcoinRspOuterClass; public class PacketMcoinExchangeHcoinRsp extends BasePacket { - public PacketMcoinExchangeHcoinRsp(int mcoin, int hcoin) { + public PacketMcoinExchangeHcoinRsp(int retCode) { super(PacketOpcodes.McoinExchangeHcoinRsp); - McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp mcoinExchangeHcoinRsp = McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp.newBuilder() - .setMCoinNum(mcoin) - .setHCoinNum(hcoin).build(); + McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp proto = McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp.newBuilder() + .setRetcode(retCode) + .build(); - this.setData(mcoinExchangeHcoinRsp); + this.setData(proto); } }