fix McoinExchangeHcoinRsp packet structure

This commit is contained in:
Kinesis 2022-05-01 16:24:23 +08:00 committed by Melledy
parent ec09bc28f2
commit d4e1b265e3
3 changed files with 9 additions and 9 deletions

View File

@ -3,6 +3,5 @@ syntax = "proto3";
option java_package = "emu.grasscutter.net.proto"; option java_package = "emu.grasscutter.net.proto";
message McoinExchangeHcoinRsp { message McoinExchangeHcoinRsp {
uint32 mCoinNum = 1; int32 retcode = 1;
uint32 hCoinNum = 2;
} }

View File

@ -4,6 +4,7 @@ import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.McoinExchangeHcoinReqOuterClass; import emu.grasscutter.net.proto.McoinExchangeHcoinReqOuterClass;
import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketMcoinExchangeHcoinRsp; import emu.grasscutter.server.packet.send.PacketMcoinExchangeHcoinRsp;
@ -15,13 +16,13 @@ public class HandlerMcoinExchangeHcoinReq extends PacketHandler {
McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq exchangeReq = McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq.parseFrom(payload); McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq exchangeReq = McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq.parseFrom(payload);
if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum() && exchangeReq.getMCoinNum() == exchangeReq.getHCoinNum()) { if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum() && exchangeReq.getMCoinNum() == exchangeReq.getHCoinNum()) {
session.send(new PacketMcoinExchangeHcoinRsp(RetcodeOuterClass.Retcode.RET_UNKNOWN_ERROR_VALUE));
return; return;
} }
session.getPlayer().setCrystals(session.getPlayer().getCrystals() - exchangeReq.getMCoinNum()); session.getPlayer().setCrystals(session.getPlayer().getCrystals() - exchangeReq.getMCoinNum());
session.getPlayer().setPrimogems(session.getPlayer().getPrimogems() + exchangeReq.getHCoinNum()); session.getPlayer().setPrimogems(session.getPlayer().getPrimogems() + exchangeReq.getHCoinNum());
session.getPlayer().save(); session.getPlayer().save();
session.send(new PacketMcoinExchangeHcoinRsp(RetcodeOuterClass.Retcode.RET_SUCC_VALUE));
session.send(new PacketMcoinExchangeHcoinRsp(session.getPlayer().getCrystals(), session.getPlayer().getPrimogems()));
} }
} }

View File

@ -6,13 +6,13 @@ import emu.grasscutter.net.proto.McoinExchangeHcoinRspOuterClass;
public class PacketMcoinExchangeHcoinRsp extends BasePacket { public class PacketMcoinExchangeHcoinRsp extends BasePacket {
public PacketMcoinExchangeHcoinRsp(int mcoin, int hcoin) { public PacketMcoinExchangeHcoinRsp(int retCode) {
super(PacketOpcodes.McoinExchangeHcoinRsp); super(PacketOpcodes.McoinExchangeHcoinRsp);
McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp mcoinExchangeHcoinRsp = McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp.newBuilder() McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp proto = McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp.newBuilder()
.setMCoinNum(mcoin) .setRetcode(retCode)
.setHCoinNum(hcoin).build(); .build();
this.setData(mcoinExchangeHcoinRsp); this.setData(proto);
} }
} }