Commit b9f7c657 authored by Benjamin Elsdon's avatar Benjamin Elsdon
Browse files

Merge remote-tracking branch 'upstream/development' into dev-mail

parents eb495807 782618cd
...@@ -103,8 +103,8 @@ public final class DispatchServer { ...@@ -103,8 +103,8 @@ public final class DispatchServer {
byte[] decoded2 = Base64.getDecoder().decode(query_cur_region); byte[] decoded2 = Base64.getDecoder().decode(query_cur_region);
QueryCurrRegionHttpRsp regionQuery = QueryCurrRegionHttpRsp.parseFrom(decoded2); QueryCurrRegionHttpRsp regionQuery = QueryCurrRegionHttpRsp.parseFrom(decoded2);
List<RegionSimpleInfo> servers = new ArrayList<RegionSimpleInfo>(); List<RegionSimpleInfo> servers = new ArrayList<>();
List<String> usedNames = new ArrayList<String>(); // List to check for potential naming conflicts List<String> usedNames = new ArrayList<>(); // List to check for potential naming conflicts
if (Grasscutter.getConfig().RunMode.equalsIgnoreCase("HYBRID")) { // Automatically add the game server if in if (Grasscutter.getConfig().RunMode.equalsIgnoreCase("HYBRID")) { // Automatically add the game server if in
// hybrid mode // hybrid mode
RegionSimpleInfo server = RegionSimpleInfo.newBuilder() RegionSimpleInfo server = RegionSimpleInfo.newBuilder()
...@@ -126,10 +126,10 @@ public final class DispatchServer { ...@@ -126,10 +126,10 @@ public final class DispatchServer {
servers.add(server); servers.add(server);
RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder() RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder()
.setIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty() .setGateserverIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty()
? Grasscutter.getConfig().getGameServerOptions().Ip ? Grasscutter.getConfig().getGameServerOptions().Ip
: Grasscutter.getConfig().getGameServerOptions().PublicIp)) : Grasscutter.getConfig().getGameServerOptions().PublicIp))
.setPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0 .setGateserverPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0
? Grasscutter.getConfig().getGameServerOptions().PublicPort ? Grasscutter.getConfig().getGameServerOptions().PublicPort
: Grasscutter.getConfig().getGameServerOptions().Port) : Grasscutter.getConfig().getGameServerOptions().Port)
.setSecretKey(ByteString .setSecretKey(ByteString
...@@ -169,8 +169,8 @@ public final class DispatchServer { ...@@ -169,8 +169,8 @@ public final class DispatchServer {
servers.add(server); servers.add(server);
RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder() RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder()
.setIp(regionInfo.Ip) .setGateserverIp(regionInfo.Ip)
.setPort(regionInfo.Port) .setGateserverPort(regionInfo.Port)
.setSecretKey(ByteString .setSecretKey(ByteString
.copyFrom(FileUtils.read(Grasscutter.getConfig().KEY_FOLDER + "dispatchSeed.bin"))) .copyFrom(FileUtils.read(Grasscutter.getConfig().KEY_FOLDER + "dispatchSeed.bin")))
.build(); .build();
...@@ -181,7 +181,7 @@ public final class DispatchServer { ...@@ -181,7 +181,7 @@ public final class DispatchServer {
} }
QueryRegionListHttpRsp regionList = QueryRegionListHttpRsp.newBuilder() QueryRegionListHttpRsp regionList = QueryRegionListHttpRsp.newBuilder()
.addAllServers(servers) .addAllRegionList(servers)
.setClientSecretKey(rl.getClientSecretKey()) .setClientSecretKey(rl.getClientSecretKey())
.setClientCustomConfigEncrypted(rl.getClientCustomConfigEncrypted()) .setClientCustomConfigEncrypted(rl.getClientCustomConfigEncrypted())
.setEnableLoginPc(true) .setEnableLoginPc(true)
...@@ -268,7 +268,10 @@ public final class DispatchServer { ...@@ -268,7 +268,10 @@ public final class DispatchServer {
Grasscutter.getLogger() Grasscutter.getLogger()
.info(String.format("[Dispatch] Client %s request: query_region_list", t.getRemoteAddress())); .info(String.format("[Dispatch] Client %s request: query_region_list", t.getRemoteAddress()));
responseHTML(t, regionListBase64); // Invoke event.
QueryAllRegionsEvent event = new QueryAllRegionsEvent(regionListBase64); event.call();
// Respond with event result.
responseHTML(t, event.getRegionList());
}); });
for (String regionName : regions.keySet()) { for (String regionName : regions.keySet()) {
......
...@@ -10,6 +10,10 @@ public abstract class ServerEvent extends Event { ...@@ -10,6 +10,10 @@ public abstract class ServerEvent extends Event {
this.type = type; this.type = type;
} }
public Type getServerType() {
return this.type;
}
public enum Type { public enum Type {
DISPATCH, DISPATCH,
GAME GAME
......
package emu.grasscutter.server.event.game;
import emu.grasscutter.server.event.ServerEvent;
public final class ServerTickEvent extends ServerEvent {
public ServerTickEvent() {
super(Type.GAME);
}
}
package emu.grasscutter.server.event.internal;
import emu.grasscutter.server.event.ServerEvent;
import java.time.OffsetDateTime;
public final class ServerStartEvent extends ServerEvent {
private final OffsetDateTime startTime;
public ServerStartEvent(Type type, OffsetDateTime startTime) {
super(type);
this.startTime = startTime;
}
public OffsetDateTime getStartTime() {
return this.startTime;
}
}
package emu.grasscutter.server.event.internal;
import emu.grasscutter.server.event.ServerEvent;
import java.time.OffsetDateTime;
public final class ServerStopEvent extends ServerEvent {
private final OffsetDateTime stopTime;
public ServerStopEvent(Type type, OffsetDateTime stopTime) {
super(type);
this.stopTime = stopTime;
}
public OffsetDateTime getStopTime() {
return this.stopTime;
}
}
package emu.grasscutter.server.game; package emu.grasscutter.server.game;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.time.OffsetDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -20,7 +21,10 @@ import emu.grasscutter.game.shop.ShopManager; ...@@ -20,7 +21,10 @@ import emu.grasscutter.game.shop.ShopManager;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
import emu.grasscutter.netty.MihoyoKcpServer; import emu.grasscutter.netty.MihoyoKcpServer;
import org.greenrobot.eventbus.EventBus; import emu.grasscutter.server.event.ServerEvent;
import emu.grasscutter.server.event.game.ServerTickEvent;
import emu.grasscutter.server.event.internal.ServerStartEvent;
import emu.grasscutter.server.event.internal.ServerStopEvent;
public final class GameServer extends MihoyoKcpServer { public final class GameServer extends MihoyoKcpServer {
private final InetSocketAddress address; private final InetSocketAddress address;
...@@ -36,18 +40,10 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -36,18 +40,10 @@ public final class GameServer extends MihoyoKcpServer {
private final MultiplayerManager multiplayerManager; private final MultiplayerManager multiplayerManager;
private final DungeonManager dungeonManager; private final DungeonManager dungeonManager;
private final CommandMap commandMap; private final CommandMap commandMap;
public EventBus OnGameServerStartFinish;
public EventBus OnGameServerTick;
public EventBus OnGameServerStop;
public GameServer(InetSocketAddress address) { public GameServer(InetSocketAddress address) {
super(address); super(address);
OnGameServerStartFinish = EventBus.builder().throwSubscriberException(true).logNoSubscriberMessages(false).build();
OnGameServerTick = EventBus.builder().throwSubscriberException(true).logNoSubscriberMessages(false).build();
OnGameServerStop = EventBus.builder().throwSubscriberException(true).logNoSubscriberMessages(false).build();
this.setServerInitializer(new GameServerInitializer(this)); this.setServerInitializer(new GameServerInitializer(this));
this.address = address; this.address = address;
this.packetHandler = new GameServerPacketHandler(PacketHandler.class); this.packetHandler = new GameServerPacketHandler(PacketHandler.class);
...@@ -178,12 +174,8 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -178,12 +174,8 @@ public final class GameServer extends MihoyoKcpServer {
world.onTick(); world.onTick();
} }
for (GenshinPlayer player : this.getPlayers().values()) { ServerTickEvent event = new ServerTickEvent(); event.call();
player.onTick();
}
OnGameServerTick.post(new GameServerTickEvent());
} }
public void registerWorld(World world) { public void registerWorld(World world) {
...@@ -198,12 +190,11 @@ public final class GameServer extends MihoyoKcpServer { ...@@ -198,12 +190,11 @@ public final class GameServer extends MihoyoKcpServer {
@Override @Override
public void onStartFinish() { public void onStartFinish() {
Grasscutter.getLogger().info("Game Server started on port " + address.getPort()); Grasscutter.getLogger().info("Game Server started on port " + address.getPort());
ServerStartEvent event = new ServerStartEvent(ServerEvent.Type.GAME, OffsetDateTime.now()); event.call();
OnGameServerStartFinish.post(new GameServerStartFinishEvent());
} }
public void onServerShutdown() { public void onServerShutdown() {
OnGameServerStop.post(new GameServerStopEvent()); ServerStopEvent event = new ServerStopEvent(ServerEvent.Type.GAME, OffsetDateTime.now()); event.call();
// Kick and save all players // Kick and save all players
List<GenshinPlayer> list = new ArrayList<>(this.getPlayers().size()); List<GenshinPlayer> list = new ArrayList<>(this.getPlayers().size());
......
...@@ -89,7 +89,7 @@ public class GameServerPacketHandler { ...@@ -89,7 +89,7 @@ public class GameServerPacketHandler {
// Log unhandled packets // Log unhandled packets
if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) { if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) {
//Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + PacketOpcodesUtil.getOpcodeName(opcode)); Grasscutter.getLogger().info("Unhandled packet (" + opcode + "): " + emu.grasscutter.net.packet.PacketOpcodesUtil.getOpcodeName(opcode));
} }
} }
} }
...@@ -3,11 +3,14 @@ package emu.grasscutter.server.game; ...@@ -3,11 +3,14 @@ package emu.grasscutter.server.game;
import java.io.File; import java.io.File;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.HashSet;
import java.util.Set;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketOpcodesUtil; import emu.grasscutter.net.packet.PacketOpcodesUtil;
import emu.grasscutter.netty.MihoyoKcpChannel; import emu.grasscutter.netty.MihoyoKcpChannel;
import emu.grasscutter.server.event.game.SendPacketEvent; import emu.grasscutter.server.event.game.SendPacketEvent;
...@@ -177,10 +180,20 @@ public class GameSession extends MihoyoKcpChannel { ...@@ -177,10 +180,20 @@ public class GameSession extends MihoyoKcpChannel {
//Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(opcode)); //Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(opcode));
//System.out.println(Utils.bytesToHex(genshinPacket.getData())); //System.out.println(Utils.bytesToHex(genshinPacket.getData()));
} }
private static final Set<Integer> loopPacket = Set.of(
PacketOpcodes.PingReq,
PacketOpcodes.PingRsp,
PacketOpcodes.WorldPlayerRTTNotify,
PacketOpcodes.UnionCmdNotify,
PacketOpcodes.QueryPathReq
);
private void logPacket(GenshinPacket genshinPacket) { private void logPacket(GenshinPacket genshinPacket) {
Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(genshinPacket.getOpcode()) + " (" + genshinPacket.getOpcode() + ")"); if (!loopPacket.contains(genshinPacket.getOpcode())) {
System.out.println(Utils.bytesToHex(genshinPacket.getData())); Grasscutter.getLogger().info("SEND: " + PacketOpcodesUtil.getOpcodeName(genshinPacket.getOpcode()) + " (" + genshinPacket.getOpcode() + ")");
System.out.println(Utils.bytesToHex(genshinPacket.getData()));
}
} }
@Override @Override
...@@ -226,8 +239,10 @@ public class GameSession extends MihoyoKcpChannel { ...@@ -226,8 +239,10 @@ public class GameSession extends MihoyoKcpChannel {
// Log packet // Log packet
if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) { if (Grasscutter.getConfig().getGameServerOptions().LOG_PACKETS) {
Grasscutter.getLogger().info("RECV: " + PacketOpcodesUtil.getOpcodeName(opcode) + " (" + opcode + ")"); if (!loopPacket.contains(opcode)) {
System.out.println(Utils.bytesToHex(payload)); Grasscutter.getLogger().info("RECV: " + PacketOpcodesUtil.getOpcodeName(opcode) + " (" + opcode + ")");
System.out.println(Utils.bytesToHex(payload));
}
} }
// Handle // Handle
......
...@@ -19,12 +19,12 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { ...@@ -19,12 +19,12 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
for (CombatInvokeEntry entry : notif.getInvokeListList()) { for (CombatInvokeEntry entry : notif.getInvokeListList()) {
switch (entry.getArgumentType()) { switch (entry.getArgumentType()) {
case CombatEvtBeingHit: case COMBAT_EVT_BEING_HIT:
// Handle damage // Handle damage
EvtBeingHitInfo hitInfo = EvtBeingHitInfo.parseFrom(entry.getCombatData()); EvtBeingHitInfo hitInfo = EvtBeingHitInfo.parseFrom(entry.getCombatData());
session.getPlayer().getScene().handleAttack(hitInfo.getAttackResult()); session.getPlayer().getScene().handleAttack(hitInfo.getAttackResult());
break; break;
case EntityMove: case ENTITY_MOVE:
// Handle movement // Handle movement
EntityMoveInfo moveInfo = EntityMoveInfo.parseFrom(entry.getCombatData()); EntityMoveInfo moveInfo = EntityMoveInfo.parseFrom(entry.getCombatData());
GenshinEntity entity = session.getPlayer().getScene().getEntityById(moveInfo.getEntityId()); GenshinEntity entity = session.getPlayer().getScene().getEntityById(moveInfo.getEntityId());
......
...@@ -3,22 +3,18 @@ package emu.grasscutter.server.packet.recv; ...@@ -3,22 +3,18 @@ package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes; 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.SitReqOuterClass; import emu.grasscutter.net.proto.CombineReqOuterClass;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketSitRsp;
import emu.grasscutter.utils.Position;
@Opcodes(PacketOpcodes.SitReq) @Opcodes(PacketOpcodes.CombineReq)
public class HandleSitReq extends PacketHandler { public class HandlerCombineReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
SitReqOuterClass.SitReq req = SitReqOuterClass.SitReq.parseFrom(payload);
float x = req.getPosition().getX(); CombineReqOuterClass.CombineReq req = CombineReqOuterClass.CombineReq.parseFrom(payload);
float y = req.getPosition().getY();
float z = req.getPosition().getZ();
session.send(new PacketSitRsp(req.getChairId(), new Position(x, y, z), session.getPlayer().getTeamManager().getCurrentAvatarEntity().getId()));
} }
} }
\ No newline at end of file
...@@ -32,7 +32,7 @@ public class HandlerMarkMapReq extends PacketHandler { ...@@ -32,7 +32,7 @@ public class HandlerMarkMapReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
MarkMapReq req = MarkMapReq.parseFrom(payload); MarkMapReq req = MarkMapReq.parseFrom(payload);
if (req.getOp() != Operation.Add) { if (req.getOp() != MarkMapReq.Operation.ADD) {
return; return;
} }
......
...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.recv; ...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketPlayerGetForceQuitBanInfoRsp; import emu.grasscutter.server.packet.send.PacketPlayerGetForceQuitBanInfoRsp;
...@@ -14,10 +15,10 @@ public class HandlerPlayerGetForceQuitBanInfoReq extends PacketHandler { ...@@ -14,10 +15,10 @@ public class HandlerPlayerGetForceQuitBanInfoReq extends PacketHandler {
if (session.getServer().getMultiplayerManager().leaveCoop(session.getPlayer())) { if (session.getServer().getMultiplayerManager().leaveCoop(session.getPlayer())) {
// Success // Success
session.send(new PacketPlayerGetForceQuitBanInfoRsp(0)); session.send(new PacketPlayerGetForceQuitBanInfoRsp(RetcodeOuterClass.Retcode.RET_SUCC_VALUE));
} else { } else {
// Fail // Fail
session.send(new PacketPlayerGetForceQuitBanInfoRsp(1)); session.send(new PacketPlayerGetForceQuitBanInfoRsp(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE));
} }
} }
......
...@@ -11,7 +11,7 @@ public class PacketAvatarChangeCostumeNotify extends GenshinPacket { ...@@ -11,7 +11,7 @@ public class PacketAvatarChangeCostumeNotify extends GenshinPacket {
super(PacketOpcodes.AvatarChangeCostumeNotify); super(PacketOpcodes.AvatarChangeCostumeNotify);
AvatarChangeCostumeNotify proto = AvatarChangeCostumeNotify.newBuilder() AvatarChangeCostumeNotify proto = AvatarChangeCostumeNotify.newBuilder()
.setEntity(entity.toProto()) .setEntityInfo(entity.toProto())
.build(); .build();
this.setData(proto); this.setData(proto);
......
...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; ...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarChangeCostumeRspOuterClass.AvatarChangeCostumeRsp; import emu.grasscutter.net.proto.AvatarChangeCostumeRspOuterClass.AvatarChangeCostumeRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketAvatarChangeCostumeRsp extends GenshinPacket { public class PacketAvatarChangeCostumeRsp extends GenshinPacket {
...@@ -21,7 +22,7 @@ public class PacketAvatarChangeCostumeRsp extends GenshinPacket { ...@@ -21,7 +22,7 @@ public class PacketAvatarChangeCostumeRsp extends GenshinPacket {
super(PacketOpcodes.AvatarChangeCostumeRsp); super(PacketOpcodes.AvatarChangeCostumeRsp);
AvatarChangeCostumeRsp proto = AvatarChangeCostumeRsp.newBuilder() AvatarChangeCostumeRsp proto = AvatarChangeCostumeRsp.newBuilder()
.setRetcode(1) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build(); .build();
this.setData(proto); this.setData(proto);
......
...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; ...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarWearFlycloakRspOuterClass.AvatarWearFlycloakRsp; import emu.grasscutter.net.proto.AvatarWearFlycloakRspOuterClass.AvatarWearFlycloakRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketAvatarWearFlycloakRsp extends GenshinPacket { public class PacketAvatarWearFlycloakRsp extends GenshinPacket {
public PacketAvatarWearFlycloakRsp(long avatarGuid, int costumeId) { public PacketAvatarWearFlycloakRsp(long avatarGuid, int costumeId) {
...@@ -20,7 +21,7 @@ public class PacketAvatarWearFlycloakRsp extends GenshinPacket { ...@@ -20,7 +21,7 @@ public class PacketAvatarWearFlycloakRsp extends GenshinPacket {
super(PacketOpcodes.AvatarWearFlycloakRsp); super(PacketOpcodes.AvatarWearFlycloakRsp);
AvatarWearFlycloakRsp proto = AvatarWearFlycloakRsp.newBuilder() AvatarWearFlycloakRsp proto = AvatarWearFlycloakRsp.newBuilder()
.setRetcode(1) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build(); .build();
this.setData(proto); this.setData(proto);
......
...@@ -4,9 +4,9 @@ import java.util.List; ...@@ -4,9 +4,9 @@ import java.util.List;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.Retcode;
import emu.grasscutter.net.proto.CalcWeaponUpgradeReturnItemsRspOuterClass.CalcWeaponUpgradeReturnItemsRsp; import emu.grasscutter.net.proto.CalcWeaponUpgradeReturnItemsRspOuterClass.CalcWeaponUpgradeReturnItemsRsp;
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketCalcWeaponUpgradeReturnItemsRsp extends GenshinPacket { public class PacketCalcWeaponUpgradeReturnItemsRsp extends GenshinPacket {
...@@ -25,7 +25,7 @@ public class PacketCalcWeaponUpgradeReturnItemsRsp extends GenshinPacket { ...@@ -25,7 +25,7 @@ public class PacketCalcWeaponUpgradeReturnItemsRsp extends GenshinPacket {
super(PacketOpcodes.CalcWeaponUpgradeReturnItemsRsp); super(PacketOpcodes.CalcWeaponUpgradeReturnItemsRsp);
CalcWeaponUpgradeReturnItemsRsp proto = CalcWeaponUpgradeReturnItemsRsp.newBuilder() CalcWeaponUpgradeReturnItemsRsp proto = CalcWeaponUpgradeReturnItemsRsp.newBuilder()
.setRetcode(Retcode.FAIL) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build(); .build();
this.setData(proto); this.setData(proto);
......
...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send; ...@@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ChangeAvatarRspOuterClass.ChangeAvatarRsp; import emu.grasscutter.net.proto.ChangeAvatarRspOuterClass.ChangeAvatarRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketChangeAvatarRsp extends GenshinPacket { public class PacketChangeAvatarRsp extends GenshinPacket {
...@@ -10,8 +11,8 @@ public class PacketChangeAvatarRsp extends GenshinPacket { ...@@ -10,8 +11,8 @@ public class PacketChangeAvatarRsp extends GenshinPacket {
super(PacketOpcodes.ChangeAvatarRsp); super(PacketOpcodes.ChangeAvatarRsp);
ChangeAvatarRsp p = ChangeAvatarRsp.newBuilder() ChangeAvatarRsp p = ChangeAvatarRsp.newBuilder()
.setRetcode(0) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.setCurrGuid(guid) .setCurGuid(guid)
.build(); .build();
this.setData(p); this.setData(p);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.CombineReqOuterClass;
import emu.grasscutter.net.proto.CombineRspOuterClass;
import emu.grasscutter.net.proto.ItemParamOuterClass;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketCombineRsp extends GenshinPacket {
public PacketCombineRsp() {
super(PacketOpcodes.CombineRsp);
CombineRspOuterClass.CombineRsp proto = CombineRspOuterClass.CombineRsp.newBuilder()
.setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE).build();
this.setData(proto);
}
public PacketCombineRsp(int retcode) {
super(PacketOpcodes.CombineRsp);
CombineRspOuterClass.CombineRsp proto = CombineRspOuterClass.CombineRsp.newBuilder()
.setRetcode(retcode).build();
this.setData(proto);
}
public PacketCombineRsp(CombineReqOuterClass.CombineReq combineReq,
Iterable<ItemParamOuterClass.ItemParam> costItemList,
Iterable<ItemParamOuterClass.ItemParam> resultItemList,
Iterable<ItemParamOuterClass.ItemParam> totalRandomItemList,
Iterable<ItemParamOuterClass.ItemParam> totalReturnItemList,
Iterable<ItemParamOuterClass.ItemParam> totalExtraItemList) {
super(PacketOpcodes.CombineRsp);
CombineRspOuterClass.CombineRsp proto = CombineRspOuterClass.CombineRsp.newBuilder()
.setRetcode(RetcodeOuterClass.Retcode.RET_SUCC_VALUE)
.setCombineId(combineReq.getCombineId())
.setCombineCount(combineReq.getCombineCount())
.setAvatarGuid(combineReq.getAvatarGuid())
.addAllCostItemList(costItemList)
.addAllResultItemList(resultItemList)
.addAllTotalRandomItemList(totalRandomItemList)
.addAllTotalReturnItemList(totalReturnItemList)
.addAllTotalExtraItemList(totalExtraItemList)
.build();
this.setData(proto);
}
}
...@@ -7,6 +7,7 @@ import emu.grasscutter.net.packet.GenshinPacket; ...@@ -7,6 +7,7 @@ import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.DoGachaRspOuterClass.DoGachaRsp; import emu.grasscutter.net.proto.DoGachaRspOuterClass.DoGachaRsp;
import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem; import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketDoGachaRsp extends GenshinPacket { public class PacketDoGachaRsp extends GenshinPacket {
...@@ -33,7 +34,7 @@ public class PacketDoGachaRsp extends GenshinPacket { ...@@ -33,7 +34,7 @@ public class PacketDoGachaRsp extends GenshinPacket {
super(PacketOpcodes.DoGachaRsp); super(PacketOpcodes.DoGachaRsp);
DoGachaRsp p = DoGachaRsp.newBuilder() DoGachaRsp p = DoGachaRsp.newBuilder()
.setRetcode(1) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build(); .build();
this.setData(p); this.setData(p);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment