Unlock all teleports in the guide menu

This commit is contained in:
Melledy
2023-11-24 16:28:24 -08:00
parent b7fc8b6a32
commit e1c203a165
4 changed files with 735 additions and 0 deletions

View File

@@ -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<GetUnlockTeleportCsReq> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>repeated uint32 entry_id_list = 15;</code>
*/
private final RepeatedInt entryIdList = RepeatedInt.newEmptyInstance();
private GetUnlockTeleportCsReq() {
}
/**
* @return a new empty instance of {@code GetUnlockTeleportCsReq}
*/
public static GetUnlockTeleportCsReq newInstance() {
return new GetUnlockTeleportCsReq();
}
/**
* <code>repeated uint32 entry_id_list = 15;</code>
* @return whether the entryIdList field is set
*/
public boolean hasEntryIdList() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>repeated uint32 entry_id_list = 15;</code>
* @return this
*/
public GetUnlockTeleportCsReq clearEntryIdList() {
bitField0_ &= ~0x00000001;
entryIdList.clear();
return this;
}
/**
* <code>repeated uint32 entry_id_list = 15;</code>
*
* 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;
}
/**
* <code>repeated uint32 entry_id_list = 15;</code>
*
* 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;
}
/**
* <code>repeated uint32 entry_id_list = 15;</code>
* @param value the entryIdList to add
* @return this
*/
public GetUnlockTeleportCsReq addEntryIdList(final int value) {
bitField0_ |= 0x00000001;
entryIdList.add(value);
return this;
}
/**
* <code>repeated uint32 entry_id_list = 15;</code>
* @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<GetUnlockTeleportCsReq> getFactory() {
return GetUnlockTeleportCsReqFactory.INSTANCE;
}
private enum GetUnlockTeleportCsReqFactory implements MessageFactory<GetUnlockTeleportCsReq> {
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");
}
}
}

View File

@@ -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<GetUnlockTeleportScRsp> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 retcode = 13;</code>
*/
private int retcode;
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
*/
private final RepeatedInt unlockedTeleportList = RepeatedInt.newEmptyInstance();
private GetUnlockTeleportScRsp() {
}
/**
* @return a new empty instance of {@code GetUnlockTeleportScRsp}
*/
public static GetUnlockTeleportScRsp newInstance() {
return new GetUnlockTeleportScRsp();
}
/**
* <code>optional uint32 retcode = 13;</code>
* @return whether the retcode field is set
*/
public boolean hasRetcode() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 retcode = 13;</code>
* @return this
*/
public GetUnlockTeleportScRsp clearRetcode() {
bitField0_ &= ~0x00000001;
retcode = 0;
return this;
}
/**
* <code>optional uint32 retcode = 13;</code>
* @return the retcode
*/
public int getRetcode() {
return retcode;
}
/**
* <code>optional uint32 retcode = 13;</code>
* @param value the retcode to set
* @return this
*/
public GetUnlockTeleportScRsp setRetcode(final int value) {
bitField0_ |= 0x00000001;
retcode = value;
return this;
}
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
* @return whether the unlockedTeleportList field is set
*/
public boolean hasUnlockedTeleportList() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
* @return this
*/
public GetUnlockTeleportScRsp clearUnlockedTeleportList() {
bitField0_ &= ~0x00000002;
unlockedTeleportList.clear();
return this;
}
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
*
* 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;
}
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
*
* 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;
}
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
* @param value the unlockedTeleportList to add
* @return this
*/
public GetUnlockTeleportScRsp addUnlockedTeleportList(final int value) {
bitField0_ |= 0x00000002;
unlockedTeleportList.add(value);
return this;
}
/**
* <code>repeated uint32 unlocked_teleport_list = 12;</code>
* @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<GetUnlockTeleportScRsp> getFactory() {
return GetUnlockTeleportScRspFactory.INSTANCE;
}
private enum GetUnlockTeleportScRspFactory implements MessageFactory<GetUnlockTeleportScRsp> {
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");
}
}
}

View File

@@ -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()));
}
}

View File

@@ -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);
}
}