full TextJoinQuery handler

This commit is contained in:
Hiro
2023-11-30 10:57:33 +02:00
parent 02e55301e4
commit ba432b4661
4 changed files with 471 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage; import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink; import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource; import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.RepeatedMessage;
public final class TextJoinQueryScRspOuterClass { public final class TextJoinQueryScRspOuterClass {
/** /**
@@ -23,6 +24,11 @@ public final class TextJoinQueryScRspOuterClass {
*/ */
private int retcode; private int retcode;
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</code>
*/
private final RepeatedMessage<TextJoinInfo> textJoinList = RepeatedMessage.newEmptyInstance(TextJoinInfo.getFactory());
private TextJoinQueryScRsp() { private TextJoinQueryScRsp() {
} }
@@ -70,12 +76,81 @@ public final class TextJoinQueryScRspOuterClass {
return this; return this;
} }
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</code>
* @return whether the textJoinList field is set
*/
public boolean hasTextJoinList() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</code>
* @return this
*/
public TextJoinQueryScRsp clearTextJoinList() {
bitField0_ &= ~0x00000002;
textJoinList.clear();
return this;
}
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</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 #getMutableTextJoinList()} if you want to modify it.
*
* @return internal storage object for reading
*/
public RepeatedMessage<TextJoinInfo> getTextJoinList() {
return textJoinList;
}
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</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 RepeatedMessage<TextJoinInfo> getMutableTextJoinList() {
bitField0_ |= 0x00000002;
return textJoinList;
}
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</code>
* @param value the textJoinList to add
* @return this
*/
public TextJoinQueryScRsp addTextJoinList(final TextJoinInfo value) {
bitField0_ |= 0x00000002;
textJoinList.add(value);
return this;
}
/**
* <code>repeated .TextJoinQueryScRsp.TextJoinInfo text_join_list = 4;</code>
* @param values the textJoinList to add
* @return this
*/
public TextJoinQueryScRsp addAllTextJoinList(final TextJoinInfo... values) {
bitField0_ |= 0x00000002;
textJoinList.addAll(values);
return this;
}
@Override @Override
public TextJoinQueryScRsp copyFrom(final TextJoinQueryScRsp other) { public TextJoinQueryScRsp copyFrom(final TextJoinQueryScRsp other) {
cachedSize = other.cachedSize; cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) { if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_; bitField0_ = other.bitField0_;
retcode = other.retcode; retcode = other.retcode;
textJoinList.copyFrom(other.textJoinList);
} }
return this; return this;
} }
@@ -89,6 +164,9 @@ public final class TextJoinQueryScRspOuterClass {
if (other.hasRetcode()) { if (other.hasRetcode()) {
setRetcode(other.retcode); setRetcode(other.retcode);
} }
if (other.hasTextJoinList()) {
getMutableTextJoinList().addAll(other.textJoinList);
}
return this; return this;
} }
@@ -100,6 +178,7 @@ public final class TextJoinQueryScRspOuterClass {
cachedSize = -1; cachedSize = -1;
bitField0_ = 0; bitField0_ = 0;
retcode = 0; retcode = 0;
textJoinList.clear();
return this; return this;
} }
@@ -110,6 +189,7 @@ public final class TextJoinQueryScRspOuterClass {
} }
cachedSize = -1; cachedSize = -1;
bitField0_ = 0; bitField0_ = 0;
textJoinList.clearQuick();
return this; return this;
} }
@@ -123,7 +203,8 @@ public final class TextJoinQueryScRspOuterClass {
} }
TextJoinQueryScRsp other = (TextJoinQueryScRsp) o; TextJoinQueryScRsp other = (TextJoinQueryScRsp) o;
return bitField0_ == other.bitField0_ return bitField0_ == other.bitField0_
&& (!hasRetcode() || retcode == other.retcode); && (!hasRetcode() || retcode == other.retcode)
&& (!hasTextJoinList() || textJoinList.equals(other.textJoinList));
} }
@Override @Override
@@ -132,6 +213,12 @@ public final class TextJoinQueryScRspOuterClass {
output.writeRawByte((byte) 104); output.writeRawByte((byte) 104);
output.writeUInt32NoTag(retcode); output.writeUInt32NoTag(retcode);
} }
if ((bitField0_ & 0x00000002) != 0) {
for (int i = 0; i < textJoinList.length(); i++) {
output.writeRawByte((byte) 34);
output.writeMessageNoTag(textJoinList.get(i));
}
}
} }
@Override @Override
@@ -140,6 +227,9 @@ public final class TextJoinQueryScRspOuterClass {
if ((bitField0_ & 0x00000001) != 0) { if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode); size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
} }
if ((bitField0_ & 0x00000002) != 0) {
size += (1 * textJoinList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(textJoinList);
}
return size; return size;
} }
@@ -155,6 +245,14 @@ public final class TextJoinQueryScRspOuterClass {
retcode = input.readUInt32(); retcode = input.readUInt32();
bitField0_ |= 0x00000001; bitField0_ |= 0x00000001;
tag = input.readTag(); tag = input.readTag();
if (tag != 34) {
break;
}
}
case 34: {
// textJoinList
tag = input.readRepeatedMessage(textJoinList, tag);
bitField0_ |= 0x00000002;
if (tag != 0) { if (tag != 0) {
break; break;
} }
@@ -179,6 +277,9 @@ public final class TextJoinQueryScRspOuterClass {
if ((bitField0_ & 0x00000001) != 0) { if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.retcode, retcode); output.writeUInt32(FieldNames.retcode, retcode);
} }
if ((bitField0_ & 0x00000002) != 0) {
output.writeRepeatedMessage(FieldNames.textJoinList, textJoinList);
}
output.endObject(); output.endObject();
} }
@@ -200,6 +301,18 @@ public final class TextJoinQueryScRspOuterClass {
} }
break; break;
} }
case -1670215371:
case 249668097: {
if (input.isAtField(FieldNames.textJoinList)) {
if (!input.trySkipNullValue()) {
input.readRepeatedMessage(textJoinList);
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
default: { default: {
input.skipUnknownField(); input.skipUnknownField();
break; break;
@@ -240,6 +353,333 @@ public final class TextJoinQueryScRspOuterClass {
return TextJoinQueryScRspFactory.INSTANCE; return TextJoinQueryScRspFactory.INSTANCE;
} }
/**
* Protobuf type {@code TextJoinInfo}
*/
public static final class TextJoinInfo extends ProtoMessage<TextJoinInfo> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 text_item_id = 2;</code>
*/
private int textItemId;
/**
* <code>optional uint32 text_item_config_id = 3;</code>
*/
private int textItemConfigId;
private TextJoinInfo() {
}
/**
* @return a new empty instance of {@code TextJoinInfo}
*/
public static TextJoinInfo newInstance() {
return new TextJoinInfo();
}
/**
* <code>optional uint32 text_item_id = 2;</code>
* @return whether the textItemId field is set
*/
public boolean hasTextItemId() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 text_item_id = 2;</code>
* @return this
*/
public TextJoinInfo clearTextItemId() {
bitField0_ &= ~0x00000001;
textItemId = 0;
return this;
}
/**
* <code>optional uint32 text_item_id = 2;</code>
* @return the textItemId
*/
public int getTextItemId() {
return textItemId;
}
/**
* <code>optional uint32 text_item_id = 2;</code>
* @param value the textItemId to set
* @return this
*/
public TextJoinInfo setTextItemId(final int value) {
bitField0_ |= 0x00000001;
textItemId = value;
return this;
}
/**
* <code>optional uint32 text_item_config_id = 3;</code>
* @return whether the textItemConfigId field is set
*/
public boolean hasTextItemConfigId() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>optional uint32 text_item_config_id = 3;</code>
* @return this
*/
public TextJoinInfo clearTextItemConfigId() {
bitField0_ &= ~0x00000002;
textItemConfigId = 0;
return this;
}
/**
* <code>optional uint32 text_item_config_id = 3;</code>
* @return the textItemConfigId
*/
public int getTextItemConfigId() {
return textItemConfigId;
}
/**
* <code>optional uint32 text_item_config_id = 3;</code>
* @param value the textItemConfigId to set
* @return this
*/
public TextJoinInfo setTextItemConfigId(final int value) {
bitField0_ |= 0x00000002;
textItemConfigId = value;
return this;
}
@Override
public TextJoinInfo copyFrom(final TextJoinInfo other) {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
textItemId = other.textItemId;
textItemConfigId = other.textItemConfigId;
}
return this;
}
@Override
public TextJoinInfo mergeFrom(final TextJoinInfo other) {
if (other.isEmpty()) {
return this;
}
cachedSize = -1;
if (other.hasTextItemId()) {
setTextItemId(other.textItemId);
}
if (other.hasTextItemConfigId()) {
setTextItemConfigId(other.textItemConfigId);
}
return this;
}
@Override
public TextJoinInfo clear() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
textItemId = 0;
textItemConfigId = 0;
return this;
}
@Override
public TextJoinInfo clearQuick() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TextJoinInfo)) {
return false;
}
TextJoinInfo other = (TextJoinInfo) o;
return bitField0_ == other.bitField0_
&& (!hasTextItemId() || textItemId == other.textItemId)
&& (!hasTextItemConfigId() || textItemConfigId == other.textItemConfigId);
}
@Override
public void writeTo(final ProtoSink output) throws IOException {
if ((bitField0_ & 0x00000001) != 0) {
output.writeRawByte((byte) 16);
output.writeUInt32NoTag(textItemId);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 24);
output.writeUInt32NoTag(textItemConfigId);
}
}
@Override
protected int computeSerializedSize() {
int size = 0;
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(textItemId);
}
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(textItemConfigId);
}
return size;
}
@Override
@SuppressWarnings("fallthrough")
public TextJoinInfo mergeFrom(final ProtoSource input) throws IOException {
// Enabled Fall-Through Optimization (QuickBuffers)
int tag = input.readTag();
while (true) {
switch (tag) {
case 16: {
// textItemId
textItemId = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 24) {
break;
}
}
case 24: {
// textItemConfigId
textItemConfigId = input.readUInt32();
bitField0_ |= 0x00000002;
tag = input.readTag();
if (tag != 0) {
break;
}
}
case 0: {
return this;
}
default: {
if (!input.skipField(tag)) {
return this;
}
tag = input.readTag();
break;
}
}
}
}
@Override
public void writeTo(final JsonSink output) throws IOException {
output.beginObject();
if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.textItemId, textItemId);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeUInt32(FieldNames.textItemConfigId, textItemConfigId);
}
output.endObject();
}
@Override
public TextJoinInfo mergeFrom(final JsonSource input) throws IOException {
if (!input.beginObject()) {
return this;
}
while (!input.isAtEnd()) {
switch (input.readFieldHash()) {
case 1565189915:
case -153409355: {
if (input.isAtField(FieldNames.textItemId)) {
if (!input.trySkipNullValue()) {
textItemId = input.readUInt32();
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
}
break;
}
case -1448403459:
case -1174236578: {
if (input.isAtField(FieldNames.textItemConfigId)) {
if (!input.trySkipNullValue()) {
textItemConfigId = input.readUInt32();
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
default: {
input.skipUnknownField();
break;
}
}
}
input.endObject();
return this;
}
@Override
public TextJoinInfo clone() {
return new TextJoinInfo().copyFrom(this);
}
@Override
public boolean isEmpty() {
return ((bitField0_) == 0);
}
public static TextJoinInfo parseFrom(final byte[] data) throws
InvalidProtocolBufferException {
return ProtoMessage.mergeFrom(new TextJoinInfo(), data).checkInitialized();
}
public static TextJoinInfo parseFrom(final ProtoSource input) throws IOException {
return ProtoMessage.mergeFrom(new TextJoinInfo(), input).checkInitialized();
}
public static TextJoinInfo parseFrom(final JsonSource input) throws IOException {
return ProtoMessage.mergeFrom(new TextJoinInfo(), input).checkInitialized();
}
/**
* @return factory for creating TextJoinInfo messages
*/
public static MessageFactory<TextJoinInfo> getFactory() {
return TextJoinInfoFactory.INSTANCE;
}
private enum TextJoinInfoFactory implements MessageFactory<TextJoinInfo> {
INSTANCE;
@Override
public TextJoinInfo create() {
return TextJoinInfo.newInstance();
}
}
/**
* Contains name constants used for serializing JSON
*/
static class FieldNames {
static final FieldName textItemId = FieldName.forField("textItemId", "text_item_id");
static final FieldName textItemConfigId = FieldName.forField("textItemConfigId", "text_item_config_id");
}
}
private enum TextJoinQueryScRspFactory implements MessageFactory<TextJoinQueryScRsp> { private enum TextJoinQueryScRspFactory implements MessageFactory<TextJoinQueryScRsp> {
INSTANCE; INSTANCE;
@@ -254,6 +694,8 @@ public final class TextJoinQueryScRspOuterClass {
*/ */
static class FieldNames { static class FieldNames {
static final FieldName retcode = FieldName.forField("retcode"); static final FieldName retcode = FieldName.forField("retcode");
static final FieldName textJoinList = FieldName.forField("textJoinList", "text_join_list");
} }
} }
} }

View File

@@ -4,6 +4,7 @@ import java.lang.reflect.Field;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import emu.lunarcore.data.config.FloorInfo; import emu.lunarcore.data.config.FloorInfo;
import emu.lunarcore.data.excel.*; import emu.lunarcore.data.excel.*;
import emu.lunarcore.game.battle.MazeBuff; import emu.lunarcore.game.battle.MazeBuff;
@@ -143,6 +144,19 @@ public class GameData {
return allIds; return allIds;
} }
public static int TextJoinItemFromId(int id) {
for (Int2ObjectMap.Entry<TextJoinExcel> entry : textJoinExcelMap.int2ObjectEntrySet()) {
TextJoinExcel textJoinExcel = entry.getValue();
if (textJoinExcel.getId() == id) {
IntArrayList textJoinItemList = textJoinExcel.getTextJoinItemList();
if (textJoinItemList.size() > 0) {
return textJoinItemList.getInt(textJoinItemList.size() - 1);
}
}
}
return id * 10; // or return a default value if needed
}
public static List<Integer> getAllQuestIds() { public static List<Integer> getAllQuestIds() {
List<Integer> allIds = new ArrayList<>(); List<Integer> allIds = new ArrayList<>();

View File

@@ -5,13 +5,15 @@ import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes; import emu.lunarcore.server.packet.Opcodes;
import emu.lunarcore.server.packet.PacketHandler; import emu.lunarcore.server.packet.PacketHandler;
import emu.lunarcore.server.packet.send.PacketTextJoinQueryScRsp; import emu.lunarcore.server.packet.send.PacketTextJoinQueryScRsp;
import emu.lunarcore.proto.TextJoinQueryCsReqOuterClass.TextJoinQueryCsReq;
@Opcodes(CmdId.TextJoinQueryCsReq) @Opcodes(CmdId.TextJoinQueryCsReq)
public class HandlerTextJoinQueryCsReq extends PacketHandler { public class HandlerTextJoinQueryCsReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] data) throws Exception { public void handle(GameSession session, byte[] data) throws Exception {
session.send(new PacketTextJoinQueryScRsp(session.getPlayer())); var req = TextJoinQueryCsReq.parseFrom(data);
session.send(new PacketTextJoinQueryScRsp(session.getPlayer(), req.getTextJoinIdList().toArray()));
} }
} }

View File

@@ -1,17 +1,26 @@
package emu.lunarcore.server.packet.send; package emu.lunarcore.server.packet.send;
import emu.lunarcore.game.mail.Mail; import emu.lunarcore.data.GameData;
import emu.lunarcore.game.player.Player; import emu.lunarcore.game.player.Player;
import emu.lunarcore.proto.TextJoinQueryScRspOuterClass.TextJoinQueryScRsp; import emu.lunarcore.proto.TextJoinQueryScRspOuterClass.TextJoinQueryScRsp;
import emu.lunarcore.proto.TextJoinQueryScRspOuterClass.TextJoinQueryScRsp.TextJoinInfo;
import emu.lunarcore.server.packet.BasePacket; import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId; import emu.lunarcore.server.packet.CmdId;
public class PacketTextJoinQueryScRsp extends BasePacket { public class PacketTextJoinQueryScRsp extends BasePacket {
public PacketTextJoinQueryScRsp(Player player) { public PacketTextJoinQueryScRsp(Player player, int[] textJoinIdList) {
super(CmdId.TextJoinQueryScRsp); super(CmdId.TextJoinQueryScRsp);
var data = TextJoinQueryScRsp.newInstance(); var data = TextJoinQueryScRsp.newInstance();
for (int joinId : textJoinIdList) {
TextJoinInfo joinInfo = TextJoinInfo.newInstance()
.setTextItemId(joinId)
.setTextItemConfigId(GameData.TextJoinItemFromId(joinId));
data.addTextJoinList(joinInfo);
}
this.setData(data); this.setData(data);
} }