From 255d0a041c344f16d2933af913c1db4bf7317740 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 28 Sep 2024 17:30:01 -0400 Subject: [PATCH] feat(5.0): Remove field setters which aren't available these have comments indicating why they were removed/unset --- .../packet/recv/HandlerAvatarUpgradeReq.java | 10 ++++++--- .../packet/send/PacketAvatarUpgradeRsp.java | 5 +++-- .../packet/send/PacketGetPlayerTokenRsp.java | 10 ++++----- .../send/PacketPlayerEnterSceneNotify.java | 22 +++++++++---------- .../packet/send/PacketPlayerLoginRsp.java | 12 +++++----- 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarUpgradeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarUpgradeReq.java index ee088664e..cee78244b 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarUpgradeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarUpgradeReq.java @@ -11,10 +11,14 @@ public class HandlerAvatarUpgradeReq extends PacketHandler { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { AvatarUpgradeReq req = AvatarUpgradeReq.parseFrom(payload); - // Level up avatar - session + // Changed in 5.0: + // Players can now pass multiple different kinds of books in at once. + // These are bundled into a list of items. + for (var item : req.getItemParamListList()) { + session .getServer() .getInventorySystem() - .upgradeAvatar(session.getPlayer(), req.getAvatarGuid(), req.getItemId(), req.getCount()); + .upgradeAvatar(session.getPlayer(), req.getAvatarGuid(), item.getItemId(), item.getCount()); + } } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarUpgradeRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarUpgradeRsp.java index a34d963bc..11a041b44 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarUpgradeRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarUpgradeRsp.java @@ -17,8 +17,9 @@ public class PacketAvatarUpgradeRsp extends BasePacket { .setAvatarGuid(avatar.getGuid()) .setOldLevel(oldLevel) .setCurLevel(avatar.getLevel()) - .putAllOldFightPropMap(oldFightPropMap) - .putAllCurFightPropMap(avatar.getFightProperties()) + // Removed in 5.0 + // .putAllOldFightPropMap(oldFightPropMap) + // .putAllCurFightPropMap(avatar.getFightProperties()) .build(); this.setData(proto); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java index 6a1ab63f0..8eb762a10 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java @@ -23,10 +23,10 @@ public class PacketGetPlayerTokenRsp extends BasePacket { .setSecretKeySeed(session.getEncryptSeed()) .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) .setPlatformType(3) - .setChannelId(1) + // .setChannelId(1) // Removed in 5.0; we don't know what it is .setCountryCode("US") .setClientVersionRandomKey("c25-314dd05b0b5f") - .setRegPlatform(3) + // .setRegPlatform(3) // Removed in 5.0; we don't know what it is .setClientIpStr(session.getAddress().getAddress().getHostAddress()) .build(); @@ -45,7 +45,7 @@ public class PacketGetPlayerTokenRsp extends BasePacket { .setRetcode(retcode) .setMsg(msg) .setBlackUidEndTime(blackEndTime) - .setRegPlatform(3) + // .setRegPlatform(3) // Removed in 5.0; we don't know what it is .setCountryCode("US") .setClientIpStr(session.getAddress().getAddress().getHostAddress()) .build(); @@ -69,10 +69,10 @@ public class PacketGetPlayerTokenRsp extends BasePacket { .setSecretKeySeed(session.getEncryptSeed()) .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) .setPlatformType(3) - .setChannelId(1) + // .setChannelId(1) // Removed in 5.0; we don't know what it is .setCountryCode("US") .setClientVersionRandomKey("c25-314dd05b0b5f") - .setRegPlatform(3) + // .setRegPlatform(3) // Removed in 5.0; we don't know what it is .setClientIpStr(session.getAddress().getAddress().getHostAddress()) .setServerRandKey(encryptedSeed) .setSign(encryptedSeedSign) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java index 51878221d..314c2d152 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java @@ -28,9 +28,9 @@ public class PacketPlayerEnterSceneNotify extends BasePacket { .setTargetUid(player.getUid()) .setEnterSceneToken(player.getEnterSceneToken()) .setWorldLevel(player.getWorldLevel()) - .setEnterReason(EnterReason.Login.getValue()) - .setIsFirstLoginEnterScene(player.isFirstLoginEnterScene()) - .setWorldType(1) + // .setEnterReason(EnterReason.Login.getValue()) // Removed in 5.0; we don't know what it is + // .setIsFirstLoginEnterScene(player.isFirstLoginEnterScene()) // Removed in 5.0; we don't know what it is + // .setWorldType(1) // Removed in 5.0; we don't know what it is .setSceneTransaction( "3-" + player.getUid() @@ -79,8 +79,8 @@ public class PacketPlayerEnterSceneNotify extends BasePacket { var proto = PlayerEnterSceneNotify.newBuilder() - .setPrevSceneId(player.getSceneId()) - .setPrevPos(player.getPosition().toProto()) + // .setPrevSceneId(player.getSceneId()) // Removed in 5.0; we don't know what it is + // .setPrevPos(player.getPosition().toProto()) // Removed in 5.0; we don't know what it is .setSceneId(teleportProperties.getSceneId()) .setPos(teleportProperties.getTeleportTo().toProto()) .setSceneBeginTime(System.currentTimeMillis()) @@ -88,8 +88,8 @@ public class PacketPlayerEnterSceneNotify extends BasePacket { .setTargetUid(target.getUid()) .setEnterSceneToken(player.getEnterSceneToken()) .setWorldLevel(target.getWorld().getWorldLevel()) - .setEnterReason(teleportProperties.getEnterReason().getValue()) - .setWorldType(1) + // .setEnterReason(teleportProperties.getEnterReason().getValue()) // Removed in 5.0; we don't know what it is + // .setWorldType(1) // Removed in 5.0; we don't know what it is .setSceneTransaction( teleportProperties.getSceneId() + "-" @@ -117,16 +117,16 @@ public class PacketPlayerEnterSceneNotify extends BasePacket { var proto = PlayerEnterSceneNotify.newBuilder() - .setPrevSceneId(player.getSceneId()) - .setPrevPos(player.getPosition().toProto()) + // .setPrevSceneId(player.getSceneId()) // Removed in 5.0; we don't know what it is + // .setPrevPos(player.getPosition().toProto()) // Removed in 5.0; we don't know what it is .setSceneId(teleportProperties.getSceneId()) .setPos(teleportProperties.getTeleportTo().toProto()) .setSceneBeginTime(System.currentTimeMillis()) .setType(other ? EnterType.ENTER_TYPE_OTHER_HOME : EnterType.ENTER_TYPE_SELF_HOME) .setTargetUid(targetUid) .setEnterSceneToken(player.getEnterSceneToken()) - .setEnterReason(teleportProperties.getEnterReason().getValue()) - .setWorldType(64) + // .setEnterReason(teleportProperties.getEnterReason().getValue()) // Removed in 5.0; we don't know what it is + // .setWorldType(64) // Removed in 5.0; we don't know what it is .setSceneTransaction( teleportProperties.getSceneId() + "-" diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java index 6db0767fd..9f3c94721 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java @@ -52,19 +52,19 @@ public class PacketPlayerLoginRsp extends BasePacket { PlayerLoginRsp p = PlayerLoginRsp.newBuilder() - .setIsUseAbilityHash(true) // true + // .setIsUseAbilityHash(true) // true, Removed in 5.0; we don't know what it is .setAbilityHashCode(1844674) // 1844674 .setGameBiz("hk4e_global") .setClientDataVersion(info.getClientDataVersion()) .setClientSilenceDataVersion(info.getClientSilenceDataVersion()) - .setClientMd5(info.getClientDataMd5()) - .setClientSilenceMd5(info.getClientSilenceDataMd5()) + // .setClientMd5(info.getClientDataMd5()) // Removed in 5.0; we don't know what it is + // .setClientSilenceMd5(info.getClientSilenceDataMd5()) // Removed in 5.0; we don't know what it is .setResVersionConfig(info.getResVersionConfig()) .setClientVersionSuffix(info.getClientVersionSuffix()) .setClientSilenceVersionSuffix(info.getClientSilenceVersionSuffix()) - // .setIsScOpen(false) - // .setScInfo(ByteString.copyFrom(new byte[] {})) - // .setRegisterCps("mihoyo") + // .setIsScOpen(false) // Unknown for ??.?? + // .setScInfo(ByteString.copyFrom(new byte[] {})) // Unknown for ??.?? + // .setRegisterCps("mihoyo") // Unknown for ??.?? .setCountryCode("US") .build();