From e1c203a165e115851538f89e39da36a92bb8157d Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:28:24 -0800 Subject: [PATCH] Unlock all teleports in the guide menu --- .../GetUnlockTeleportCsReqOuterClass.java | 301 ++++++++++++++ .../GetUnlockTeleportScRspOuterClass.java | 381 ++++++++++++++++++ .../recv/HandlerGetUnlockTeleportCsReq.java | 20 + .../send/PacketGetUnlockTeleportScRsp.java | 33 ++ 4 files changed, 735 insertions(+) create mode 100644 src/generated/main/emu/lunarcore/proto/GetUnlockTeleportCsReqOuterClass.java create mode 100644 src/generated/main/emu/lunarcore/proto/GetUnlockTeleportScRspOuterClass.java create mode 100644 src/main/java/emu/lunarcore/server/packet/recv/HandlerGetUnlockTeleportCsReq.java create mode 100644 src/main/java/emu/lunarcore/server/packet/send/PacketGetUnlockTeleportScRsp.java diff --git a/src/generated/main/emu/lunarcore/proto/GetUnlockTeleportCsReqOuterClass.java b/src/generated/main/emu/lunarcore/proto/GetUnlockTeleportCsReqOuterClass.java new file mode 100644 index 0000000..d7b76a9 --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/GetUnlockTeleportCsReqOuterClass.java @@ -0,0 +1,301 @@ +// Code generated by protocol buffer compiler. Do not edit! +package emu.lunarcore.proto; + +import java.io.IOException; +import us.hebi.quickbuf.FieldName; +import us.hebi.quickbuf.InvalidProtocolBufferException; +import us.hebi.quickbuf.JsonSink; +import us.hebi.quickbuf.JsonSource; +import us.hebi.quickbuf.MessageFactory; +import us.hebi.quickbuf.ProtoMessage; +import us.hebi.quickbuf.ProtoSink; +import us.hebi.quickbuf.ProtoSource; +import us.hebi.quickbuf.RepeatedInt; + +public final class GetUnlockTeleportCsReqOuterClass { + /** + * Protobuf type {@code GetUnlockTeleportCsReq} + */ + public static final class GetUnlockTeleportCsReq extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + /** + * repeated uint32 entry_id_list = 15; + */ + private final RepeatedInt entryIdList = RepeatedInt.newEmptyInstance(); + + private GetUnlockTeleportCsReq() { + } + + /** + * @return a new empty instance of {@code GetUnlockTeleportCsReq} + */ + public static GetUnlockTeleportCsReq newInstance() { + return new GetUnlockTeleportCsReq(); + } + + /** + * repeated uint32 entry_id_list = 15; + * @return whether the entryIdList field is set + */ + public boolean hasEntryIdList() { + return (bitField0_ & 0x00000001) != 0; + } + + /** + * repeated uint32 entry_id_list = 15; + * @return this + */ + public GetUnlockTeleportCsReq clearEntryIdList() { + bitField0_ &= ~0x00000001; + entryIdList.clear(); + return this; + } + + /** + * repeated uint32 entry_id_list = 15; + * + * This method returns the internal storage object without modifying any has state. + * The returned object should not be modified and be treated as read-only. + * + * Use {@link #getMutableEntryIdList()} if you want to modify it. + * + * @return internal storage object for reading + */ + public RepeatedInt getEntryIdList() { + return entryIdList; + } + + /** + * repeated uint32 entry_id_list = 15; + * + * This method returns the internal storage object and sets the corresponding + * has state. The returned object will become part of this message and its + * contents may be modified as long as the has state is not cleared. + * + * @return internal storage object for modifications + */ + public RepeatedInt getMutableEntryIdList() { + bitField0_ |= 0x00000001; + return entryIdList; + } + + /** + * repeated uint32 entry_id_list = 15; + * @param value the entryIdList to add + * @return this + */ + public GetUnlockTeleportCsReq addEntryIdList(final int value) { + bitField0_ |= 0x00000001; + entryIdList.add(value); + return this; + } + + /** + * repeated uint32 entry_id_list = 15; + * @param values the entryIdList to add + * @return this + */ + public GetUnlockTeleportCsReq addAllEntryIdList(final int... values) { + bitField0_ |= 0x00000001; + entryIdList.addAll(values); + return this; + } + + @Override + public GetUnlockTeleportCsReq copyFrom(final GetUnlockTeleportCsReq other) { + cachedSize = other.cachedSize; + if ((bitField0_ | other.bitField0_) != 0) { + bitField0_ = other.bitField0_; + entryIdList.copyFrom(other.entryIdList); + } + return this; + } + + @Override + public GetUnlockTeleportCsReq mergeFrom(final GetUnlockTeleportCsReq other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + if (other.hasEntryIdList()) { + getMutableEntryIdList().addAll(other.entryIdList); + } + return this; + } + + @Override + public GetUnlockTeleportCsReq clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + entryIdList.clear(); + return this; + } + + @Override + public GetUnlockTeleportCsReq clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + entryIdList.clear(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof GetUnlockTeleportCsReq)) { + return false; + } + GetUnlockTeleportCsReq other = (GetUnlockTeleportCsReq) o; + return bitField0_ == other.bitField0_ + && (!hasEntryIdList() || entryIdList.equals(other.entryIdList)); + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + if ((bitField0_ & 0x00000001) != 0) { + for (int i = 0; i < entryIdList.length(); i++) { + output.writeRawByte((byte) 120); + output.writeUInt32NoTag(entryIdList.array()[i]); + } + } + } + + @Override + protected int computeSerializedSize() { + int size = 0; + if ((bitField0_ & 0x00000001) != 0) { + size += (1 * entryIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(entryIdList); + } + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public GetUnlockTeleportCsReq mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + case 122: { + // entryIdList [packed=true] + input.readPackedUInt32(entryIdList, tag); + bitField0_ |= 0x00000001; + tag = input.readTag(); + if (tag != 0) { + break; + } + } + case 0: { + return this; + } + default: { + if (!input.skipField(tag)) { + return this; + } + tag = input.readTag(); + break; + } + case 120: { + // entryIdList [packed=false] + tag = input.readRepeatedUInt32(entryIdList, tag); + bitField0_ |= 0x00000001; + break; + } + } + } + } + + @Override + public void writeTo(final JsonSink output) throws IOException { + output.beginObject(); + if ((bitField0_ & 0x00000001) != 0) { + output.writeRepeatedUInt32(FieldNames.entryIdList, entryIdList); + } + output.endObject(); + } + + @Override + public GetUnlockTeleportCsReq mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + case -1441102997: + case -1413189003: { + if (input.isAtField(FieldNames.entryIdList)) { + if (!input.trySkipNullValue()) { + input.readRepeatedUInt32(entryIdList); + bitField0_ |= 0x00000001; + } + } else { + input.skipUnknownField(); + } + break; + } + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public GetUnlockTeleportCsReq clone() { + return new GetUnlockTeleportCsReq().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static GetUnlockTeleportCsReq parseFrom(final byte[] data) throws + InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new GetUnlockTeleportCsReq(), data).checkInitialized(); + } + + public static GetUnlockTeleportCsReq parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetUnlockTeleportCsReq(), input).checkInitialized(); + } + + public static GetUnlockTeleportCsReq parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetUnlockTeleportCsReq(), input).checkInitialized(); + } + + /** + * @return factory for creating GetUnlockTeleportCsReq messages + */ + public static MessageFactory getFactory() { + return GetUnlockTeleportCsReqFactory.INSTANCE; + } + + private enum GetUnlockTeleportCsReqFactory implements MessageFactory { + INSTANCE; + + @Override + public GetUnlockTeleportCsReq create() { + return GetUnlockTeleportCsReq.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + static final FieldName entryIdList = FieldName.forField("entryIdList", "entry_id_list"); + } + } +} diff --git a/src/generated/main/emu/lunarcore/proto/GetUnlockTeleportScRspOuterClass.java b/src/generated/main/emu/lunarcore/proto/GetUnlockTeleportScRspOuterClass.java new file mode 100644 index 0000000..da53efc --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/GetUnlockTeleportScRspOuterClass.java @@ -0,0 +1,381 @@ +// Code generated by protocol buffer compiler. Do not edit! +package emu.lunarcore.proto; + +import java.io.IOException; +import us.hebi.quickbuf.FieldName; +import us.hebi.quickbuf.InvalidProtocolBufferException; +import us.hebi.quickbuf.JsonSink; +import us.hebi.quickbuf.JsonSource; +import us.hebi.quickbuf.MessageFactory; +import us.hebi.quickbuf.ProtoMessage; +import us.hebi.quickbuf.ProtoSink; +import us.hebi.quickbuf.ProtoSource; +import us.hebi.quickbuf.RepeatedInt; + +public final class GetUnlockTeleportScRspOuterClass { + /** + * Protobuf type {@code GetUnlockTeleportScRsp} + */ + public static final class GetUnlockTeleportScRsp extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + /** + * optional uint32 retcode = 13; + */ + private int retcode; + + /** + * repeated uint32 unlocked_teleport_list = 12; + */ + private final RepeatedInt unlockedTeleportList = RepeatedInt.newEmptyInstance(); + + private GetUnlockTeleportScRsp() { + } + + /** + * @return a new empty instance of {@code GetUnlockTeleportScRsp} + */ + public static GetUnlockTeleportScRsp newInstance() { + return new GetUnlockTeleportScRsp(); + } + + /** + * optional uint32 retcode = 13; + * @return whether the retcode field is set + */ + public boolean hasRetcode() { + return (bitField0_ & 0x00000001) != 0; + } + + /** + * optional uint32 retcode = 13; + * @return this + */ + public GetUnlockTeleportScRsp clearRetcode() { + bitField0_ &= ~0x00000001; + retcode = 0; + return this; + } + + /** + * optional uint32 retcode = 13; + * @return the retcode + */ + public int getRetcode() { + return retcode; + } + + /** + * optional uint32 retcode = 13; + * @param value the retcode to set + * @return this + */ + public GetUnlockTeleportScRsp setRetcode(final int value) { + bitField0_ |= 0x00000001; + retcode = value; + return this; + } + + /** + * repeated uint32 unlocked_teleport_list = 12; + * @return whether the unlockedTeleportList field is set + */ + public boolean hasUnlockedTeleportList() { + return (bitField0_ & 0x00000002) != 0; + } + + /** + * repeated uint32 unlocked_teleport_list = 12; + * @return this + */ + public GetUnlockTeleportScRsp clearUnlockedTeleportList() { + bitField0_ &= ~0x00000002; + unlockedTeleportList.clear(); + return this; + } + + /** + * repeated uint32 unlocked_teleport_list = 12; + * + * This method returns the internal storage object without modifying any has state. + * The returned object should not be modified and be treated as read-only. + * + * Use {@link #getMutableUnlockedTeleportList()} if you want to modify it. + * + * @return internal storage object for reading + */ + public RepeatedInt getUnlockedTeleportList() { + return unlockedTeleportList; + } + + /** + * repeated uint32 unlocked_teleport_list = 12; + * + * This method returns the internal storage object and sets the corresponding + * has state. The returned object will become part of this message and its + * contents may be modified as long as the has state is not cleared. + * + * @return internal storage object for modifications + */ + public RepeatedInt getMutableUnlockedTeleportList() { + bitField0_ |= 0x00000002; + return unlockedTeleportList; + } + + /** + * repeated uint32 unlocked_teleport_list = 12; + * @param value the unlockedTeleportList to add + * @return this + */ + public GetUnlockTeleportScRsp addUnlockedTeleportList(final int value) { + bitField0_ |= 0x00000002; + unlockedTeleportList.add(value); + return this; + } + + /** + * repeated uint32 unlocked_teleport_list = 12; + * @param values the unlockedTeleportList to add + * @return this + */ + public GetUnlockTeleportScRsp addAllUnlockedTeleportList(final int... values) { + bitField0_ |= 0x00000002; + unlockedTeleportList.addAll(values); + return this; + } + + @Override + public GetUnlockTeleportScRsp copyFrom(final GetUnlockTeleportScRsp other) { + cachedSize = other.cachedSize; + if ((bitField0_ | other.bitField0_) != 0) { + bitField0_ = other.bitField0_; + retcode = other.retcode; + unlockedTeleportList.copyFrom(other.unlockedTeleportList); + } + return this; + } + + @Override + public GetUnlockTeleportScRsp mergeFrom(final GetUnlockTeleportScRsp other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + if (other.hasRetcode()) { + setRetcode(other.retcode); + } + if (other.hasUnlockedTeleportList()) { + getMutableUnlockedTeleportList().addAll(other.unlockedTeleportList); + } + return this; + } + + @Override + public GetUnlockTeleportScRsp clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + retcode = 0; + unlockedTeleportList.clear(); + return this; + } + + @Override + public GetUnlockTeleportScRsp clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + unlockedTeleportList.clear(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof GetUnlockTeleportScRsp)) { + return false; + } + GetUnlockTeleportScRsp other = (GetUnlockTeleportScRsp) o; + return bitField0_ == other.bitField0_ + && (!hasRetcode() || retcode == other.retcode) + && (!hasUnlockedTeleportList() || unlockedTeleportList.equals(other.unlockedTeleportList)); + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + if ((bitField0_ & 0x00000001) != 0) { + output.writeRawByte((byte) 104); + output.writeUInt32NoTag(retcode); + } + if ((bitField0_ & 0x00000002) != 0) { + for (int i = 0; i < unlockedTeleportList.length(); i++) { + output.writeRawByte((byte) 96); + output.writeUInt32NoTag(unlockedTeleportList.array()[i]); + } + } + } + + @Override + protected int computeSerializedSize() { + int size = 0; + if ((bitField0_ & 0x00000001) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode); + } + if ((bitField0_ & 0x00000002) != 0) { + size += (1 * unlockedTeleportList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(unlockedTeleportList); + } + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public GetUnlockTeleportScRsp mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + case 104: { + // retcode + retcode = input.readUInt32(); + bitField0_ |= 0x00000001; + tag = input.readTag(); + if (tag != 98) { + break; + } + } + case 98: { + // unlockedTeleportList [packed=true] + input.readPackedUInt32(unlockedTeleportList, tag); + bitField0_ |= 0x00000002; + tag = input.readTag(); + if (tag != 0) { + break; + } + } + case 0: { + return this; + } + default: { + if (!input.skipField(tag)) { + return this; + } + tag = input.readTag(); + break; + } + case 96: { + // unlockedTeleportList [packed=false] + tag = input.readRepeatedUInt32(unlockedTeleportList, tag); + bitField0_ |= 0x00000002; + break; + } + } + } + } + + @Override + public void writeTo(final JsonSink output) throws IOException { + output.beginObject(); + if ((bitField0_ & 0x00000001) != 0) { + output.writeUInt32(FieldNames.retcode, retcode); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeRepeatedUInt32(FieldNames.unlockedTeleportList, unlockedTeleportList); + } + output.endObject(); + } + + @Override + public GetUnlockTeleportScRsp mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + case 1097936398: { + if (input.isAtField(FieldNames.retcode)) { + if (!input.trySkipNullValue()) { + retcode = input.readUInt32(); + bitField0_ |= 0x00000001; + } + } else { + input.skipUnknownField(); + } + break; + } + case 856936684: + case -10753834: { + if (input.isAtField(FieldNames.unlockedTeleportList)) { + if (!input.trySkipNullValue()) { + input.readRepeatedUInt32(unlockedTeleportList); + bitField0_ |= 0x00000002; + } + } else { + input.skipUnknownField(); + } + break; + } + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public GetUnlockTeleportScRsp clone() { + return new GetUnlockTeleportScRsp().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static GetUnlockTeleportScRsp parseFrom(final byte[] data) throws + InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new GetUnlockTeleportScRsp(), data).checkInitialized(); + } + + public static GetUnlockTeleportScRsp parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetUnlockTeleportScRsp(), input).checkInitialized(); + } + + public static GetUnlockTeleportScRsp parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetUnlockTeleportScRsp(), input).checkInitialized(); + } + + /** + * @return factory for creating GetUnlockTeleportScRsp messages + */ + public static MessageFactory getFactory() { + return GetUnlockTeleportScRspFactory.INSTANCE; + } + + private enum GetUnlockTeleportScRspFactory implements MessageFactory { + INSTANCE; + + @Override + public GetUnlockTeleportScRsp create() { + return GetUnlockTeleportScRsp.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + static final FieldName retcode = FieldName.forField("retcode"); + + static final FieldName unlockedTeleportList = FieldName.forField("unlockedTeleportList", "unlocked_teleport_list"); + } + } +} diff --git a/src/main/java/emu/lunarcore/server/packet/recv/HandlerGetUnlockTeleportCsReq.java b/src/main/java/emu/lunarcore/server/packet/recv/HandlerGetUnlockTeleportCsReq.java new file mode 100644 index 0000000..de2578a --- /dev/null +++ b/src/main/java/emu/lunarcore/server/packet/recv/HandlerGetUnlockTeleportCsReq.java @@ -0,0 +1,20 @@ +package emu.lunarcore.server.packet.recv; + +import emu.lunarcore.proto.GetUnlockTeleportCsReqOuterClass.GetUnlockTeleportCsReq; +import emu.lunarcore.server.game.GameSession; +import emu.lunarcore.server.packet.CmdId; +import emu.lunarcore.server.packet.Opcodes; +import emu.lunarcore.server.packet.PacketHandler; +import emu.lunarcore.server.packet.send.PacketGetUnlockTeleportScRsp; + +@Opcodes(CmdId.GetUnlockTeleportCsReq) +public class HandlerGetUnlockTeleportCsReq extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] data) throws Exception { + var req = GetUnlockTeleportCsReq.parseFrom(data); + + session.send(new PacketGetUnlockTeleportScRsp(req.getEntryIdList())); + } + +} diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketGetUnlockTeleportScRsp.java b/src/main/java/emu/lunarcore/server/packet/send/PacketGetUnlockTeleportScRsp.java new file mode 100644 index 0000000..09a8285 --- /dev/null +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketGetUnlockTeleportScRsp.java @@ -0,0 +1,33 @@ +package emu.lunarcore.server.packet.send; + +import emu.lunarcore.data.GameData; +import emu.lunarcore.data.config.FloorInfo; +import emu.lunarcore.data.excel.MapEntranceExcel; +import emu.lunarcore.proto.GetUnlockTeleportScRspOuterClass.GetUnlockTeleportScRsp; +import emu.lunarcore.server.packet.BasePacket; +import emu.lunarcore.server.packet.CmdId; +import us.hebi.quickbuf.RepeatedInt; + +public class PacketGetUnlockTeleportScRsp extends BasePacket { + + public PacketGetUnlockTeleportScRsp(RepeatedInt list) { + super(CmdId.GetUnlockTeleportScRsp); + + var data = GetUnlockTeleportScRsp.newInstance(); + + for (int entryId : list) { + MapEntranceExcel excel = GameData.getMapEntranceExcelMap().get(entryId); + if (excel == null) continue; + + FloorInfo floorInfo = GameData.getFloorInfo(excel.getPlaneID(), excel.getFloorID()); + if (floorInfo == null) continue; + + // Add unlocked teleport ids + for (var teleport : floorInfo.getCachedTeleports().values()) { + data.addAllUnlockedTeleportList(teleport.getMappingInfoID()); + } + } + + this.setData(data); + } +}