diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java index 52e16f36f..3fa82a9a8 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/typescript/GenerateTsUtils.java @@ -205,7 +205,7 @@ private static String readObject(ProtocolRegistration registration) { var field = fields[i]; var fieldRegistration = fieldRegistrations[i]; if (field.isAnnotationPresent(Compatible.class)) { - tsBuilder.append(TAB + TAB).append("if (buffer.compatibleRead(beforeReadIndex, length)) {").append(LS); + tsBuilder.append(TAB + TAB).append("if (!buffer.compatibleRead(beforeReadIndex, length)) {").append(LS); var compatibleReadObject = tsSerializer(fieldRegistration.serializer()).readObject(tsBuilder, 3, field, fieldRegistration); tsBuilder.append(TAB + TAB+ TAB).append(StringUtils.format("packet.{} = {};", field.getName(), compatibleReadObject)).append(LS); tsBuilder.append(TAB + TAB).append("}").append(LS);