From cc9f1fb45acca3427f49c206f640fd9a6c46e914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Mon, 23 Jun 2025 10:15:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(info):=20=E5=88=A0=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E4=BF=A1=E6=81=AF=E7=BB=93=E6=9E=84=E4=BD=93?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了多个未使用的 Java 和 Go 信息结构体文件 - 优化了项目结构,减少了冗余代码 - 这些文件可能是早期开发阶段的遗留代码,现在已不再需要 --- common/core/info/CrossDomainInfo.go | 12 - common/core/info/CrossDomainInfo.java | 13 - common/core/info/LoginSidInfo.go | 21 + .../info/battle/CatchMonsterInboundInfo.java | 21 - .../info/battle/CatchMonsterOutboundInfo.java | 23 -- .../info/battle/ChallengeBossInboundInfo.java | 15 - .../info/battle/ChangePetInboundInfo.java | 21 - common/core/info/battle/ChangePetInfo.java | 32 -- .../info/battle/ChangePetOutboundInfo.java | 18 - .../battle/FightNpcMonsterInboundInfo.java | 15 - common/core/info/battle/FightOverInfo.java | 25 -- .../info/battle/FightOverOutboundInfo.java | 20 - common/core/info/battle/FightPetInfo.java | 38 -- .../info/battle/FightStartOutboundInfo.java | 27 -- common/core/info/battle/FightUserInfo.java | 26 -- .../info/battle/NoteReadyToFightInfo.java | 31 -- .../battle/NoteReadyToFightOutboundInfo.java | 20 - .../info/battle/NoteUseSkillOutboundInfo.java | 24 -- .../core/info/battle/ReadyFightPetInfo.java | 42 -- .../info/battle/ReadyToFightInboundInfo.java | 16 - .../core/info/battle/UseSkillInboundInfo.java | 23 -- .../info/battle/UseSkillOutboundInfo.java | 12 - common/core/info/chat/ChatInboundInfo.java | 19 - common/core/info/chat/ChatOutboundInfo.java | 26 -- common/core/info/codec.go | 9 + common/core/info/item/ItemInfo.java | 15 - .../core/info/item/ItemListInboundInfo.java | 21 - .../core/info/item/ItemListOutboundInfo.java | 16 - common/core/info/item/PeopleItemInfo.java | 17 - .../core/info/item/SendItemOutboundInfo.java | 26 -- common/core/info/item/SingleItemInfo.java | 19 - common/core/info/login/CommendSvrInfo.go | 34 +- common/core/info/login/CommendSvrInfo.java | 25 -- common/core/info/login/LoginSidInfo.go | 21 - common/core/info/login/LoginSidInfo.java | 20 - common/core/info/login/LoginUserInfo.java | 172 --------- common/core/info/login/ServerInfo.go | 76 ++-- common/core/info/login/ServerInfo.java | 24 -- common/core/info/login/SidInfo.java | 14 - .../core/info/mail/MailUnreadInboundInfo.java | 14 - .../info/mail/MailUnreadOutboundInfo.java | 15 - common/core/info/map/LeaveMapInboundInfo.java | 12 - .../core/info/map/LeaveMapOutboundInfo.java | 15 - .../info/map/ListMapPlayerInboundInfo.java | 14 - .../info/map/ListMapPlayerOutboundInfo.java | 15 - common/core/info/map/MapHotInboundInfo.java | 14 - common/core/info/map/MapHotInfo.java | 19 - common/core/info/map/MapHotOutboundInfo.java | 15 - common/core/info/map/MapInfo.java | 24 -- .../info/map/MapOgreListOutboundInfo.java | 21 - common/core/info/map/PeopleInfo.java | 102 ----- .../core/info/map/PeopleWalkInboundInfo.java | 22 -- .../core/info/map/PeopleWalkOutboundInfo.java | 24 -- common/core/info/misc/AimatInboundInfo.java | 29 -- common/core/info/misc/AimatOutboundInfo.java | 31 -- common/core/info/misc/CateInfo.java | 19 - common/core/info/misc/DayTalkInfo.java | 23 -- .../misc/GetQuadrupleExeTimeInboundInfo.java | 17 - .../misc/GetQuadrupleExeTimeOutboundInfo.java | 17 - .../core/info/misc/SystemTimeInboundInfo.java | 12 - .../info/misc/SystemTimeOutboundInfo.java | 15 - .../core/info/misc/TalkCateInboundInfo.java | 23 -- .../core/info/misc/TalkCateOutboundInfo.java | 22 -- .../core/info/misc/TalkCountInboundInfo.java | 23 -- .../core/info/misc/TalkCountOutboundInfo.java | 23 -- .../nono/NonoFollowOrHomeInboundInfo.java | 15 - .../nono/NonoFollowOrHomeOutboundInfo.java | 28 -- common/core/info/nono/NonoInboundInfo.java | 17 - common/core/info/nono/NonoOutboundInfo.java | 52 --- .../core/info/pet/GetPetInfoOutboundInfo.java | 16 - common/core/info/pet/PetCureInboundInfo.java | 13 - common/core/info/pet/PetCureOutboundInfo.java | 13 - common/core/info/pet/PetEffectInfo.go | 49 +-- common/core/info/pet/PetEffectInfo.java | 34 -- common/core/info/pet/PetInfo.go | 142 +++---- common/core/info/pet/PetInfo.java | 80 ---- .../core/info/pet/PetOneCureInboundInfo.java | 17 - .../core/info/pet/PetOneCureOutboundInfo.java | 17 - .../core/info/pet/PetSetExpInboundInfo.java | 19 - .../core/info/pet/PetSetExpOutboundInfo.java | 19 - common/core/info/pet/PetShortInfo.java | 24 -- common/core/info/pet/PetShowInboundInfo.java | 16 - common/core/info/pet/PetShowOutboundInfo.java | 35 -- .../info/pet/PetSkillSwitchInboundInfo.java | 15 - .../info/pet/PetSkillSwitchOutboundInfo.java | 17 - .../info/pet/PetStudySkillInboundInfo.java | 15 - .../info/pet/PetStudySkillOutboundInfo.java | 17 - .../core/info/pet/PetUpdateOutboundInfo.java | 23 -- .../core/info/pet/RoomPetInfoInboundInfo.java | 21 - .../info/pet/RoomPetInfoOutboundInfo.java | 54 --- common/core/info/pet/UpdatePropInfo.java | 49 --- common/core/info/pet/UpdateSkillInfo.java | 21 - .../info/pet/UpdateSkillOutboundInfo.java | 18 - .../info/pet/bag/GetPetListInboundEmpty.java | 13 - .../info/pet/bag/GetPetListOutboundInfo.java | 19 - .../info/pet/bag/PetDefaultInboundInfo.java | 17 - .../info/pet/bag/PetDefaultOutboundInfo.java | 17 - .../info/pet/bag/PetReleaseInboundInfo.java | 19 - .../info/pet/bag/PetReleaseOutboundInfo.java | 29 -- .../info/pet/bag/PetRoweiInboundInfo.java | 21 - .../pet/bag/PetRoweiListInboundEmpty.java | 13 - .../pet/bag/PetRoweiListOutboundInfo.java | 19 - .../info/pet/bag/PetRoweiOutboundEmpty.java | 13 - .../core/info/pet/skill/ChangeSkillInfo.java | 19 - common/core/info/pet/skill/SkillInfo.java | 16 - .../pet/soulBead/GetSoulBeadInboundInfo.java | 14 - .../pet/soulBead/GetSoulBeadOutboundInfo.java | 17 - .../info/pet/soulBead/SoulBeadItemInfo.java | 14 - common/core/info/team/TeamInfo.java | 22 -- common/core/info/team/TeamPKInfo.java | 13 - .../user/ChangePlayerClothInboundInfo.java | 18 - .../user/ChangePlayerClothOutboundInfo.java | 24 -- .../user/ChangePlayerNameInboundInfo.java | 21 - .../user/ChangePlayerNameOutboundInfo.java | 25 -- .../core/info/user/GetPetExpInboundInfo.java | 11 - .../core/info/user/GetPetExpOutboundInfo.java | 19 - .../user/GoldOnlineRemainInboundInfo.java | 14 - .../user/GoldOnlineRemainOutboundInfo.java | 17 - .../info/user/MoreUserInfoInboundInfo.java | 17 - .../info/user/MoreUserInfoOutboundInfo.java | 44 --- .../info/user/SimUserInfoInboundInfo.java | 17 - .../info/user/SimUserInfoOutboundInfo.java | 57 --- .../info/user/SystemMessageOutboundInfo.java | 29 -- common/data/entity/Client.go | 30 +- common/data/entity/player.go | 8 +- common/serialize/Serialize_test.go | 4 +- common/serialize/sturc/.travis.yml | 10 + common/serialize/sturc/LICENSE | 19 + common/serialize/sturc/README.md | 104 +++++ common/serialize/sturc/bench_test.go | 203 ++++++++++ common/serialize/sturc/binary.go | 52 +++ common/serialize/sturc/custom.go | 33 ++ common/serialize/sturc/custom_float16.go | 78 ++++ common/serialize/sturc/custom_float16_test.go | 56 +++ common/serialize/sturc/custom_test.go | 360 ++++++++++++++++++ common/serialize/sturc/field.go | 288 ++++++++++++++ common/serialize/sturc/field_test.go | 77 ++++ common/serialize/sturc/fields.go | 177 +++++++++ common/serialize/sturc/fields_test.go | 81 ++++ common/serialize/sturc/go.mod | 3 + common/serialize/sturc/legacy.go | 16 + common/serialize/sturc/packable_test.go | 123 ++++++ common/serialize/sturc/packer.go | 13 + common/serialize/sturc/parse.go | 230 +++++++++++ common/serialize/sturc/parse_test.go | 62 +++ common/serialize/sturc/struc.go | 122 ++++++ common/serialize/sturc/struc_test.go | 310 +++++++++++++++ common/serialize/sturc/test_pack_init/doc.go | 4 + .../sturc/test_pack_init/pack_init_test.go | 29 ++ common/serialize/sturc/types.go | 136 +++++++ common/serialize/sturc/types_test.go | 53 +++ common/serialize/unSerialize.go | 336 ++++++++++++++++ common/socket/Server.go | 1 + common/socket/ServerEvent.go | 167 ++++---- common/socket/ServerOption.go | 2 +- common/socket/cmd/cmd.go | 200 +++++----- common/socket/cmd/cmd_test.go | 28 +- common/socket/codec/SocketCodec_Tomee.go | 222 +++++------ common/socket/handler/SocketHandler_Tomee.go | 40 +- go.work | 1 + logic/controller/login.go | 30 ++ logic/controller/service.go | 9 + logic/go.mod | 8 +- logic/go.sum | 2 + logic/main.go | 160 +++++++- logic/service/login/PlayerLoginService.go | 12 + logic/service/login/recv.go | 10 + 167 files changed, 3732 insertions(+), 3270 deletions(-) delete mode 100644 common/core/info/CrossDomainInfo.go delete mode 100644 common/core/info/CrossDomainInfo.java create mode 100644 common/core/info/LoginSidInfo.go delete mode 100644 common/core/info/battle/CatchMonsterInboundInfo.java delete mode 100644 common/core/info/battle/CatchMonsterOutboundInfo.java delete mode 100644 common/core/info/battle/ChallengeBossInboundInfo.java delete mode 100644 common/core/info/battle/ChangePetInboundInfo.java delete mode 100644 common/core/info/battle/ChangePetInfo.java delete mode 100644 common/core/info/battle/ChangePetOutboundInfo.java delete mode 100644 common/core/info/battle/FightNpcMonsterInboundInfo.java delete mode 100644 common/core/info/battle/FightOverInfo.java delete mode 100644 common/core/info/battle/FightOverOutboundInfo.java delete mode 100644 common/core/info/battle/FightPetInfo.java delete mode 100644 common/core/info/battle/FightStartOutboundInfo.java delete mode 100644 common/core/info/battle/FightUserInfo.java delete mode 100644 common/core/info/battle/NoteReadyToFightInfo.java delete mode 100644 common/core/info/battle/NoteReadyToFightOutboundInfo.java delete mode 100644 common/core/info/battle/NoteUseSkillOutboundInfo.java delete mode 100644 common/core/info/battle/ReadyFightPetInfo.java delete mode 100644 common/core/info/battle/ReadyToFightInboundInfo.java delete mode 100644 common/core/info/battle/UseSkillInboundInfo.java delete mode 100644 common/core/info/battle/UseSkillOutboundInfo.java delete mode 100644 common/core/info/chat/ChatInboundInfo.java delete mode 100644 common/core/info/chat/ChatOutboundInfo.java create mode 100644 common/core/info/codec.go delete mode 100644 common/core/info/item/ItemInfo.java delete mode 100644 common/core/info/item/ItemListInboundInfo.java delete mode 100644 common/core/info/item/ItemListOutboundInfo.java delete mode 100644 common/core/info/item/PeopleItemInfo.java delete mode 100644 common/core/info/item/SendItemOutboundInfo.java delete mode 100644 common/core/info/item/SingleItemInfo.java delete mode 100644 common/core/info/login/CommendSvrInfo.java delete mode 100644 common/core/info/login/LoginSidInfo.go delete mode 100644 common/core/info/login/LoginSidInfo.java delete mode 100644 common/core/info/login/LoginUserInfo.java delete mode 100644 common/core/info/login/ServerInfo.java delete mode 100644 common/core/info/login/SidInfo.java delete mode 100644 common/core/info/mail/MailUnreadInboundInfo.java delete mode 100644 common/core/info/mail/MailUnreadOutboundInfo.java delete mode 100644 common/core/info/map/LeaveMapInboundInfo.java delete mode 100644 common/core/info/map/LeaveMapOutboundInfo.java delete mode 100644 common/core/info/map/ListMapPlayerInboundInfo.java delete mode 100644 common/core/info/map/ListMapPlayerOutboundInfo.java delete mode 100644 common/core/info/map/MapHotInboundInfo.java delete mode 100644 common/core/info/map/MapHotInfo.java delete mode 100644 common/core/info/map/MapHotOutboundInfo.java delete mode 100644 common/core/info/map/MapInfo.java delete mode 100644 common/core/info/map/MapOgreListOutboundInfo.java delete mode 100644 common/core/info/map/PeopleInfo.java delete mode 100644 common/core/info/map/PeopleWalkInboundInfo.java delete mode 100644 common/core/info/map/PeopleWalkOutboundInfo.java delete mode 100644 common/core/info/misc/AimatInboundInfo.java delete mode 100644 common/core/info/misc/AimatOutboundInfo.java delete mode 100644 common/core/info/misc/CateInfo.java delete mode 100644 common/core/info/misc/DayTalkInfo.java delete mode 100644 common/core/info/misc/GetQuadrupleExeTimeInboundInfo.java delete mode 100644 common/core/info/misc/GetQuadrupleExeTimeOutboundInfo.java delete mode 100644 common/core/info/misc/SystemTimeInboundInfo.java delete mode 100644 common/core/info/misc/SystemTimeOutboundInfo.java delete mode 100644 common/core/info/misc/TalkCateInboundInfo.java delete mode 100644 common/core/info/misc/TalkCateOutboundInfo.java delete mode 100644 common/core/info/misc/TalkCountInboundInfo.java delete mode 100644 common/core/info/misc/TalkCountOutboundInfo.java delete mode 100644 common/core/info/nono/NonoFollowOrHomeInboundInfo.java delete mode 100644 common/core/info/nono/NonoFollowOrHomeOutboundInfo.java delete mode 100644 common/core/info/nono/NonoInboundInfo.java delete mode 100644 common/core/info/nono/NonoOutboundInfo.java delete mode 100644 common/core/info/pet/GetPetInfoOutboundInfo.java delete mode 100644 common/core/info/pet/PetCureInboundInfo.java delete mode 100644 common/core/info/pet/PetCureOutboundInfo.java delete mode 100644 common/core/info/pet/PetEffectInfo.java delete mode 100644 common/core/info/pet/PetInfo.java delete mode 100644 common/core/info/pet/PetOneCureInboundInfo.java delete mode 100644 common/core/info/pet/PetOneCureOutboundInfo.java delete mode 100644 common/core/info/pet/PetSetExpInboundInfo.java delete mode 100644 common/core/info/pet/PetSetExpOutboundInfo.java delete mode 100644 common/core/info/pet/PetShortInfo.java delete mode 100644 common/core/info/pet/PetShowInboundInfo.java delete mode 100644 common/core/info/pet/PetShowOutboundInfo.java delete mode 100644 common/core/info/pet/PetSkillSwitchInboundInfo.java delete mode 100644 common/core/info/pet/PetSkillSwitchOutboundInfo.java delete mode 100644 common/core/info/pet/PetStudySkillInboundInfo.java delete mode 100644 common/core/info/pet/PetStudySkillOutboundInfo.java delete mode 100644 common/core/info/pet/PetUpdateOutboundInfo.java delete mode 100644 common/core/info/pet/RoomPetInfoInboundInfo.java delete mode 100644 common/core/info/pet/RoomPetInfoOutboundInfo.java delete mode 100644 common/core/info/pet/UpdatePropInfo.java delete mode 100644 common/core/info/pet/UpdateSkillInfo.java delete mode 100644 common/core/info/pet/UpdateSkillOutboundInfo.java delete mode 100644 common/core/info/pet/bag/GetPetListInboundEmpty.java delete mode 100644 common/core/info/pet/bag/GetPetListOutboundInfo.java delete mode 100644 common/core/info/pet/bag/PetDefaultInboundInfo.java delete mode 100644 common/core/info/pet/bag/PetDefaultOutboundInfo.java delete mode 100644 common/core/info/pet/bag/PetReleaseInboundInfo.java delete mode 100644 common/core/info/pet/bag/PetReleaseOutboundInfo.java delete mode 100644 common/core/info/pet/bag/PetRoweiInboundInfo.java delete mode 100644 common/core/info/pet/bag/PetRoweiListInboundEmpty.java delete mode 100644 common/core/info/pet/bag/PetRoweiListOutboundInfo.java delete mode 100644 common/core/info/pet/bag/PetRoweiOutboundEmpty.java delete mode 100644 common/core/info/pet/skill/ChangeSkillInfo.java delete mode 100644 common/core/info/pet/skill/SkillInfo.java delete mode 100644 common/core/info/pet/soulBead/GetSoulBeadInboundInfo.java delete mode 100644 common/core/info/pet/soulBead/GetSoulBeadOutboundInfo.java delete mode 100644 common/core/info/pet/soulBead/SoulBeadItemInfo.java delete mode 100644 common/core/info/team/TeamInfo.java delete mode 100644 common/core/info/team/TeamPKInfo.java delete mode 100644 common/core/info/user/ChangePlayerClothInboundInfo.java delete mode 100644 common/core/info/user/ChangePlayerClothOutboundInfo.java delete mode 100644 common/core/info/user/ChangePlayerNameInboundInfo.java delete mode 100644 common/core/info/user/ChangePlayerNameOutboundInfo.java delete mode 100644 common/core/info/user/GetPetExpInboundInfo.java delete mode 100644 common/core/info/user/GetPetExpOutboundInfo.java delete mode 100644 common/core/info/user/GoldOnlineRemainInboundInfo.java delete mode 100644 common/core/info/user/GoldOnlineRemainOutboundInfo.java delete mode 100644 common/core/info/user/MoreUserInfoInboundInfo.java delete mode 100644 common/core/info/user/MoreUserInfoOutboundInfo.java delete mode 100644 common/core/info/user/SimUserInfoInboundInfo.java delete mode 100644 common/core/info/user/SimUserInfoOutboundInfo.java delete mode 100644 common/core/info/user/SystemMessageOutboundInfo.java create mode 100644 common/serialize/sturc/.travis.yml create mode 100644 common/serialize/sturc/LICENSE create mode 100644 common/serialize/sturc/README.md create mode 100644 common/serialize/sturc/bench_test.go create mode 100644 common/serialize/sturc/binary.go create mode 100644 common/serialize/sturc/custom.go create mode 100644 common/serialize/sturc/custom_float16.go create mode 100644 common/serialize/sturc/custom_float16_test.go create mode 100644 common/serialize/sturc/custom_test.go create mode 100644 common/serialize/sturc/field.go create mode 100644 common/serialize/sturc/field_test.go create mode 100644 common/serialize/sturc/fields.go create mode 100644 common/serialize/sturc/fields_test.go create mode 100644 common/serialize/sturc/go.mod create mode 100644 common/serialize/sturc/legacy.go create mode 100644 common/serialize/sturc/packable_test.go create mode 100644 common/serialize/sturc/packer.go create mode 100644 common/serialize/sturc/parse.go create mode 100644 common/serialize/sturc/parse_test.go create mode 100644 common/serialize/sturc/struc.go create mode 100644 common/serialize/sturc/struc_test.go create mode 100644 common/serialize/sturc/test_pack_init/doc.go create mode 100644 common/serialize/sturc/test_pack_init/pack_init_test.go create mode 100644 common/serialize/sturc/types.go create mode 100644 common/serialize/sturc/types_test.go create mode 100644 common/serialize/unSerialize.go create mode 100644 common/socket/Server.go create mode 100644 logic/controller/login.go create mode 100644 logic/controller/service.go create mode 100644 logic/go.sum create mode 100644 logic/service/login/PlayerLoginService.go create mode 100644 logic/service/login/recv.go diff --git a/common/core/info/CrossDomainInfo.go b/common/core/info/CrossDomainInfo.go deleted file mode 100644 index 105212eb2..000000000 --- a/common/core/info/CrossDomainInfo.go +++ /dev/null @@ -1,12 +0,0 @@ -package info - -/* - * CrossDomainInfo 跨域请求消息对象, 仅作为标记, 无任何意义 - */ -var Instance = &crossDomainInfo{} - -type crossDomainInfo struct{} - -func NewCrossDomainInfo() *crossDomainInfo { - return Instance -} diff --git a/common/core/info/CrossDomainInfo.java b/common/core/info/CrossDomainInfo.java deleted file mode 100644 index 17cef42cf..000000000 --- a/common/core/info/CrossDomainInfo.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info; - -import javax.annotation.Nonnull; - -/** - * 跨域请求消息对象, 仅作为标记, 无任何意义 - */ -public class CrossDomainInfo { - @SuppressWarnings("InstantiationOfUtilityClass") - public static final @Nonnull CrossDomainInfo INSTANCE = new CrossDomainInfo(); - - private CrossDomainInfo() {} -} diff --git a/common/core/info/LoginSidInfo.go b/common/core/info/LoginSidInfo.go new file mode 100644 index 000000000..a3e3127c1 --- /dev/null +++ b/common/core/info/LoginSidInfo.go @@ -0,0 +1,21 @@ +package info + +func (h InfoCodec) In_1001(data []byte) any { //EnumCommandID//todo c2s数据 + + //fmt.Printf(" 处理命令: %s, 数据长度: %d\n", len(data)) + return NewLoginSidInfo() +} +func (h InfoCodec) Out_1001(data []byte) { //EnumCommandID//TODO s2c数据 + + //fmt.Printf(" 处理命令: %s, 数据长度: %d\n", len(data)) +} + +// LoginSidInfo 登录携带的凭证结构体 +type LoginSidInfo struct { + Sid []byte `struc:"[16]byte"` // 登录会话ID,固定长度16字节 +} + +// NewLoginSidInfo 创建一个新的登录凭证实例 +func NewLoginSidInfo() LoginSidInfo { + return LoginSidInfo{} +} diff --git a/common/core/info/battle/CatchMonsterInboundInfo.java b/common/core/info/battle/CatchMonsterInboundInfo.java deleted file mode 100644 index 2371bb502..000000000 --- a/common/core/info/battle/CatchMonsterInboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -@InboundMessageType(MessageCommandIDRegistry.Catch_Monster) -public class CatchMonsterInboundInfo implements InboundMessage { - @FieldDescription("胶囊id") - private @UInt long capsuleId; -} diff --git a/common/core/info/battle/CatchMonsterOutboundInfo.java b/common/core/info/battle/CatchMonsterOutboundInfo.java deleted file mode 100644 index eaa050784..000000000 --- a/common/core/info/battle/CatchMonsterOutboundInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Catch_Monster) -public class CatchMonsterOutboundInfo implements OutboundMessage { - @FieldDescription("捕捉时间") - private @UInt long catchTime; - @FieldDescription("宠物编号") - private @UInt long petId; -} diff --git a/common/core/info/battle/ChallengeBossInboundInfo.java b/common/core/info/battle/ChallengeBossInboundInfo.java deleted file mode 100644 index 17edc33dc..000000000 --- a/common/core/info/battle/ChallengeBossInboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Challenge_Boss) -public class ChallengeBossInboundInfo implements InboundMessage { - @FieldDescription("boss的序号 从0开始") - private @UInt long bossId; -} diff --git a/common/core/info/battle/ChangePetInboundInfo.java b/common/core/info/battle/ChangePetInboundInfo.java deleted file mode 100644 index a8709d9d4..000000000 --- a/common/core/info/battle/ChangePetInboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -@InboundMessageType(MessageCommandIDRegistry.Change_Pet) -public class ChangePetInboundInfo implements InboundMessage { - @FieldDescription("捕捉时间") - private @UInt long catchTime; -} diff --git a/common/core/info/battle/ChangePetInfo.java b/common/core/info/battle/ChangePetInfo.java deleted file mode 100644 index 60f871cc3..000000000 --- a/common/core/info/battle/ChangePetInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ChangePetInfo { - @FieldDescription("米米号 野怪0") - private @UInt long userId; - @FieldDescription("切换上场的精灵编号") - private @UInt long petId; - @FieldDescription("精灵名字 16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String petName; - @FieldDescription("切换上场的等级") - private @UInt long level; - @FieldDescription("切换上场的生命") - private @UInt long hp; - @FieldDescription("切换上场的最大生命") - private @UInt long maxHp; - @FieldDescription("切换上场的捕捉时间") - private @UInt long catchTime; -} diff --git a/common/core/info/battle/ChangePetOutboundInfo.java b/common/core/info/battle/ChangePetOutboundInfo.java deleted file mode 100644 index 563dc4832..000000000 --- a/common/core/info/battle/ChangePetOutboundInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Change_Pet) -public class ChangePetOutboundInfo implements OutboundMessage { - private ChangePetInfo info; -} diff --git a/common/core/info/battle/FightNpcMonsterInboundInfo.java b/common/core/info/battle/FightNpcMonsterInboundInfo.java deleted file mode 100644 index 6254a43e1..000000000 --- a/common/core/info/battle/FightNpcMonsterInboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Fight_NPC_Monster) -public class FightNpcMonsterInboundInfo implements InboundMessage { - @FieldDescription("地图刷新怪物结构体对应的序号 1 - 9 的位置序号") - private @UInt long number; -} diff --git a/common/core/info/battle/FightOverInfo.java b/common/core/info/battle/FightOverInfo.java deleted file mode 100644 index fe0607a45..000000000 --- a/common/core/info/battle/FightOverInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class FightOverInfo { - @FieldDescription("固定值0") - private @UInt long reason; - @FieldDescription("胜者的米米号 野怪为0") - private @UInt long winnerId; - @FieldDescription("20个字节 保留字段 填0") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 20) - @Builder.Default - private byte [] reserved = new byte[20]; -} diff --git a/common/core/info/battle/FightOverOutboundInfo.java b/common/core/info/battle/FightOverOutboundInfo.java deleted file mode 100644 index 5f225ca87..000000000 --- a/common/core/info/battle/FightOverOutboundInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Fight_Over) -public class FightOverOutboundInfo implements OutboundMessage { - private FightOverInfo overInfo; -} diff --git a/common/core/info/battle/FightPetInfo.java b/common/core/info/battle/FightPetInfo.java deleted file mode 100644 index 2aea78f4b..000000000 --- a/common/core/info/battle/FightPetInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class FightPetInfo { - @FieldDescription("用户ID 野怪为0") - private @UInt long userId; - @FieldDescription("当前对战精灵ID") - private @UInt long petId; - @FieldDescription("空的16字节byte") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String petName; - @FieldDescription("精灵的捕获时间") - private @UInt long catchTime; - @FieldDescription("当前HP") - private @UInt long hp; - @FieldDescription("最大HP") - private @UInt long maxHp; - @FieldDescription("当前等级") - private @UInt long level; - @FieldDescription("精灵是否能捕捉. 1为能捕捉 0为不能捕捉") - private @UInt long catchable; - @FieldDescription("这里实际上应该是6个单字节byte, 内容为buff等级 攻击 速度 特攻 防御 特防 命中等." + - "但具体顺序未知可能需要测试. 具体数值为1-6等级") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 6) - private byte [] battleLV; -} diff --git a/common/core/info/battle/FightStartOutboundInfo.java b/common/core/info/battle/FightStartOutboundInfo.java deleted file mode 100644 index d4df6cf22..000000000 --- a/common/core/info/battle/FightStartOutboundInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Note_Start_Fight) -public class FightStartOutboundInfo implements OutboundMessage { - @FieldDescription("是否自动 默认给0 怀疑是自动战斗器使用的") - private @UInt long isCanAuto; - @FieldDescription("当前战斗精灵的信息 可能不准.看前端代码是以userid来判断哪个结构体是我方的") - private FightPetInfo info1; - @FieldDescription("当前战斗精灵的信息 可能不准.看前端代码是以userid来判断哪个结构体是我方的") - private FightPetInfo info2; -} diff --git a/common/core/info/battle/FightUserInfo.java b/common/core/info/battle/FightUserInfo.java deleted file mode 100644 index 96617e221..000000000 --- a/common/core/info/battle/FightUserInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -import javax.annotation.Nonnull; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class FightUserInfo { - public static final @Nonnull FightUserInfo NPC_MONSTER = new FightUserInfo(0, "-"); - - @FieldDescription("userID 如果为野怪则为0") - private @UInt long userId; - @FieldDescription("玩家名称 野怪为一个utf8的'-' 都为16字节byte ") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nickname; -} diff --git a/common/core/info/battle/NoteReadyToFightInfo.java b/common/core/info/battle/NoteReadyToFightInfo.java deleted file mode 100644 index 718fe73f4..000000000 --- a/common/core/info/battle/NoteReadyToFightInfo.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -import java.util.ArrayList; -import java.util.List; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class NoteReadyToFightInfo { - @FieldDescription("战斗类型ID 但前端好像没有用到 与野怪战斗为3,与人战斗似乎是1") - private @UInt long fightId; - @FieldDescription("我方信息") - private FightUserInfo ourInfo; - @FieldDescription("我方携带精灵的信息") - @Builder.Default - private List ourPetList = new ArrayList<>(); - @FieldDescription("对方信息") - private FightUserInfo opponentInfo; - @FieldDescription("敌方的精灵信息 如果是野怪 那么再给客户端发送这个包体时就提前生成好了这只精灵的PetInfo," + - "然后把从PetInfo中把部分信息写入到这个敌方的精灵信息中再发送这个包结构体") - @Builder.Default - private List opponentPetList = new ArrayList<>(); -} diff --git a/common/core/info/battle/NoteReadyToFightOutboundInfo.java b/common/core/info/battle/NoteReadyToFightOutboundInfo.java deleted file mode 100644 index 89a3b9000..000000000 --- a/common/core/info/battle/NoteReadyToFightOutboundInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Note_ReadyTo_Fight) -public class NoteReadyToFightOutboundInfo implements OutboundMessage { - private NoteReadyToFightInfo data; -} diff --git a/common/core/info/battle/NoteUseSkillOutboundInfo.java b/common/core/info/battle/NoteUseSkillOutboundInfo.java deleted file mode 100644 index a3d6e876d..000000000 --- a/common/core/info/battle/NoteUseSkillOutboundInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Note_Use_Skill) -public class NoteUseSkillOutboundInfo implements OutboundMessage { - @FieldDescription("本轮先手的精灵在释放技能结束后的状态") - private AttackValue firstAttackInfo; - @FieldDescription("本轮后手的精灵在释放技能结束后的状态") - private AttackValue secondAttackInfo; -} diff --git a/common/core/info/battle/ReadyFightPetInfo.java b/common/core/info/battle/ReadyFightPetInfo.java deleted file mode 100644 index 2c2305155..000000000 --- a/common/core/info/battle/ReadyFightPetInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.info.pet.skill.SkillInfo; - -import java.util.ArrayList; -import java.util.List; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class ReadyFightPetInfo { - @FieldDescription("精灵ID") - private @UInt long id; - @FieldDescription("精灵等级") - private @UInt long level; - @FieldDescription("精灵HP") - private @UInt long hp; - @FieldDescription("最大HP") - private @UInt long maxHp; - @FieldDescription("技能信息 技能ID跟剩余PP 固定32字节 没有给0") - @Builder.Default - private List skillList = new ArrayList<>(4); - @FieldDescription("精灵捕获时间") - private @UInt long catchTime; - @FieldDescription("捕捉地图 给0") - private @UInt long catchMap; - @FieldDescription("给0") - private @UInt long catchRect; - @FieldDescription("给0") - private @UInt long catchLevel; - @FieldDescription("精灵皮肤ID") - private @UInt long skinId; - @FieldDescription("精灵是否闪光") - private @UInt long shiny; -} diff --git a/common/core/info/battle/ReadyToFightInboundInfo.java b/common/core/info/battle/ReadyToFightInboundInfo.java deleted file mode 100644 index e7be30d3b..000000000 --- a/common/core/info/battle/ReadyToFightInboundInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Ready_To_Fight) -public class ReadyToFightInboundInfo implements InboundMessage { - public static final @Nonnull ReadyToFightInboundInfo INSTANCE = new ReadyToFightInboundInfo(); -} diff --git a/common/core/info/battle/UseSkillInboundInfo.java b/common/core/info/battle/UseSkillInboundInfo.java deleted file mode 100644 index 58e4108d1..000000000 --- a/common/core/info/battle/UseSkillInboundInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@InboundMessageType(MessageCommandIDRegistry.Use_Skill) -public class UseSkillInboundInfo implements InboundMessage { - @FieldDescription("技能id") - private @UInt long skillId; -} diff --git a/common/core/info/battle/UseSkillOutboundInfo.java b/common/core/info/battle/UseSkillOutboundInfo.java deleted file mode 100644 index 7d7f4b79b..000000000 --- a/common/core/info/battle/UseSkillOutboundInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nieo.seerproject.common.net.info.battle; - -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Use_Skill) -public class UseSkillOutboundInfo implements OutboundMessage { - public static final UseSkillOutboundInfo INSTANCE = new UseSkillOutboundInfo(); -} diff --git a/common/core/info/chat/ChatInboundInfo.java b/common/core/info/chat/ChatInboundInfo.java deleted file mode 100644 index bda8b11df..000000000 --- a/common/core/info/chat/ChatInboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.chat; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Chat) -public class ChatInboundInfo implements InboundMessage { - @FieldDescription("填充 默认值为0") - private @UInt long reserve; - @FieldDescription("消息内容, 结束符为utf-8的数字0") - private String message; -} diff --git a/common/core/info/chat/ChatOutboundInfo.java b/common/core/info/chat/ChatOutboundInfo.java deleted file mode 100644 index 844670e31..000000000 --- a/common/core/info/chat/ChatOutboundInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.nieo.seerproject.common.net.info.chat; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Chat) -public class ChatOutboundInfo implements OutboundMessage { - @FieldDescription("发送人的米米号") - private @UInt long senderId; - @FieldDescription("发送人的昵称 16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String senderNickname; - @FieldDescription("可能是私聊用的 公屏发送时为0") - private @UInt long toId; - @FieldDescription("这里的内容没有结束符") - private String message; -} diff --git a/common/core/info/codec.go b/common/core/info/codec.go new file mode 100644 index 000000000..39c7fbdf2 --- /dev/null +++ b/common/core/info/codec.go @@ -0,0 +1,9 @@ +package info + +//实现自动InfoCodec +type InfoCodec struct { +} + +func NewInfoCodec() *InfoCodec { + return &InfoCodec{} +} diff --git a/common/core/info/item/ItemInfo.java b/common/core/info/item/ItemInfo.java deleted file mode 100644 index 0911bb91b..000000000 --- a/common/core/info/item/ItemInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.item; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@SuperBuilder -@Data -public class ItemInfo { - @FieldDescription("发放物品ID") - private @UInt long itemId; - @FieldDescription("发放物品的数量") - private @UInt long itemCount; -} diff --git a/common/core/info/item/ItemListInboundInfo.java b/common/core/info/item/ItemListInboundInfo.java deleted file mode 100644 index 738a84100..000000000 --- a/common/core/info/item/ItemListInboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.item; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Item_List) -public class ItemListInboundInfo implements InboundMessage { - @FieldDescription("查询物品id的开始") - private @UInt long param1; - @FieldDescription("查询物品id的结尾") - private @UInt long param2; - @FieldDescription("默认值2") - private @UInt long param3; -} diff --git a/common/core/info/item/ItemListOutboundInfo.java b/common/core/info/item/ItemListOutboundInfo.java deleted file mode 100644 index 83b36504e..000000000 --- a/common/core/info/item/ItemListOutboundInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.nieo.seerproject.common.net.info.item; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.List; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Item_List) -public class ItemListOutboundInfo implements OutboundMessage { - private List itemList; -} diff --git a/common/core/info/item/PeopleItemInfo.java b/common/core/info/item/PeopleItemInfo.java deleted file mode 100644 index ba224f567..000000000 --- a/common/core/info/item/PeopleItemInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.item; - -import lombok.Builder; -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@SuperBuilder -public class PeopleItemInfo { - @FieldDescription("装备id") - public @UInt long id; - @FieldDescription("未知默认1") - @Builder.Default - public @UInt long level = 1; -} diff --git a/common/core/info/item/SendItemOutboundInfo.java b/common/core/info/item/SendItemOutboundInfo.java deleted file mode 100644 index 46a8508f4..000000000 --- a/common/core/info/item/SendItemOutboundInfo.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.nieo.seerproject.common.net.info.item; - -import lombok.Builder; -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.List; - -@SuperBuilder -@Data -@OutboundMessageType(MessageCommandIDRegistry.Get_Boss_Monster) -public class SendItemOutboundInfo implements OutboundMessage { - @FieldDescription("奖金ID?未知作用.写0") - private @UInt long bonusId; - @FieldDescription("可能是发放精灵时候用到的ID 发放物品给0") - private @UInt long petId; - @FieldDescription("可能是发放精灵时候对应的捕获时间 发放物品给0") - private @UInt long captureTime; - @FieldDescription("发放物品的数组.但只会给一个物品 发放多个物品只能重复发送这个包") - private List itemList; -} diff --git a/common/core/info/item/SingleItemInfo.java b/common/core/info/item/SingleItemInfo.java deleted file mode 100644 index c4b89ec60..000000000 --- a/common/core/info/item/SingleItemInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.item; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Builder -@Data -public class SingleItemInfo { - @FieldDescription("物品Id") - private @UInt long itemId; - @FieldDescription("物品数量") - private @UInt long itemCnt; - @FieldDescription("固定值360000") - private @UInt long leftTime; - @FieldDescription("固定值0") - private @UInt long itemLevel; -} diff --git a/common/core/info/login/CommendSvrInfo.go b/common/core/info/login/CommendSvrInfo.go index 7bed8b8d0..1bb29bd7d 100644 --- a/common/core/info/login/CommendSvrInfo.go +++ b/common/core/info/login/CommendSvrInfo.go @@ -1,17 +1,17 @@ -package login - -// CommendSvrInfo 初始连接请求信息结构体 -type CommendSvrInfo struct { - MaxOnlineID uint64 // 最大连接数 - IsVip uint64 // 建议为0 - ServerList []ServerInfo // 服务器具体信息 - Reversed int // 保留字段 -} - -func NewCommendSvrInfo() *CommendSvrInfo { - return &CommendSvrInfo{ - IsVip: 0, - ServerList: make([]ServerInfo, 0), - Reversed: 0, - } -} +package login + +// CommendSvrInfo 初始连接请求信息结构体 +type CommendSvrInfo struct { + MaxOnlineID uint32 // 最大连接数 + IsVip uint32 // 建议为0 + ServerList []ServerInfo // 服务器具体信息 + Reversed uint32 // 保留字段 +} + +func NewCommendSvrInfo() *CommendSvrInfo { + return &CommendSvrInfo{ + IsVip: 0, + ServerList: make([]ServerInfo, 0), + Reversed: 0, + } +} diff --git a/common/core/info/login/CommendSvrInfo.java b/common/core/info/login/CommendSvrInfo.java deleted file mode 100644 index 7ddb3cfab..000000000 --- a/common/core/info/login/CommendSvrInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nieo.seerproject.common.net.info.login; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.List; - -@Data -@AutoCodec -@FieldDescription("初始连接请求信息") -@OutboundMessageType(MessageCommandIDRegistry.Commend_OnLine) -public class CommendSvrInfo implements OutboundMessage { - @FieldDescription("最大连接数") - private @UInt long maxOnlineID; - @FieldDescription("建议为0") - private @UInt long isVip; - @FieldDescription("服务器具体信息") - private List serverList; - private int reversed; -} diff --git a/common/core/info/login/LoginSidInfo.go b/common/core/info/login/LoginSidInfo.go deleted file mode 100644 index e6827f09a..000000000 --- a/common/core/info/login/LoginSidInfo.go +++ /dev/null @@ -1,21 +0,0 @@ -package login - -// LoginSidInfo 登录携带的凭证结构体 -type LoginSidInfo struct { - Sid [16]byte // 登录会话ID,固定长度16字节 -} - -// NewLoginSidInfo 创建一个新的登录凭证实例 -func NewLoginSidInfo() *LoginSidInfo { - return &LoginSidInfo{} -} - -// SetSid 设置登录会话ID -func (l *LoginSidInfo) SetSid(sid []byte) { - copy(l.Sid[:], sid) -} - -// GetSid 获取登录会话ID -func (l *LoginSidInfo) GetSid() []byte { - return l.Sid[:] -} diff --git a/common/core/info/login/LoginSidInfo.java b/common/core/info/login/LoginSidInfo.java deleted file mode 100644 index 852ae673d..000000000 --- a/common/core/info/login/LoginSidInfo.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.nieo.seerproject.common.net.info.login; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - - -@Data -@FieldDescription("登录携带的凭证") -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Login_In) -public class LoginSidInfo implements InboundMessage { - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private byte[] sid; -} diff --git a/common/core/info/login/LoginUserInfo.java b/common/core/info/login/LoginUserInfo.java deleted file mode 100644 index bf5ab6c4f..000000000 --- a/common/core/info/login/LoginUserInfo.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.nieo.seerproject.common.net.info.login; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.annotations.serialize.UShort; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.item.PeopleItemInfo; -import org.nieo.seerproject.common.net.info.pet.PetInfo; -import org.nieo.seerproject.common.net.info.team.TeamInfo; -import org.nieo.seerproject.common.net.info.team.TeamPKInfo; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; -import org.nieo.seerproject.common.structs.Point; -import org.nieo.seerproject.common.util.ArrayUtilities; - -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("SpellCheckingInspection") -@Data -@AutoCodec -@FieldDescription("登录信息") -@OutboundMessageType(MessageCommandIDRegistry.Login_In) -public class LoginUserInfo implements OutboundMessage { - @FieldDescription("米米号 通过sid拿到") - private @UInt long userId; - @FieldDescription("注册时间(按秒的时间戳)") - private @UInt long registerTime; - @FieldDescription("16字节昵称") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nick; - @FieldDescription("暂时不明建议先给固定值0") - private @UShort int vip; - @FieldDescription("暂时不明建议先给固定值15") - private @UShort int viped = 15; - @FieldDescription("暂时不明建议先给固定值0") - private @UInt long dsFlag; - @FieldDescription("机器人人物颜色 00 rgb") - private @UInt long color; - @FieldDescription("暂时不明建议先给固定值0") - private @UInt long texture; - @FieldDescription("暂时不明建议先给固定值3000") - private @UInt long energy = 3000; - @FieldDescription("赛尔豆") - private @UInt long coins; - @FieldDescription("暂时不明建议先给固定值0") - private @UInt long fightBadge; - @FieldDescription("上线的地图id") - private @UInt long mapID; - @FieldDescription("上线的坐标 2个uint") - private Point pos = new Point(); - @FieldDescription("已经消耗掉的时间(秒为单位)") - private @UInt long timeToday; - @FieldDescription("总电池限制(秒为单位)") - private @UInt long timeLimit; - @FieldDescription("暂时不明感觉是某种活动建议先给固定值0(只能0或1)") - private byte isClothHalfDay; - @FieldDescription("暂时不明感觉是某种活动建议先给固定值0(只能0或1)") - private byte isRoomHalfDay; - @FieldDescription("暂时不明感觉是某种活动建议先给固定值0(只能0或1)") - private byte iFortressHalfDay; - @FieldDescription("暂时不明感觉是某种活动建议先给固定值0(只能0或1)") - private byte isHQHalfDay; - @FieldDescription("暂时不明建议先给固定值0") - private @UInt long loginCount; - @FieldDescription("邀请活动建议先给固定值0") - private @UInt long inviter; - @FieldDescription("邀请活动建议先给固定值0") - private @UInt long newInviteeCount; - @FieldDescription("超no等级建议固定8") - private @UInt long vipLevel = 8; - @FieldDescription("超no的vip值建议固定80000") - private @UInt long vipValue = 80000; - @FieldDescription("超no的外形等级建议固定1(暂定)") - private @UInt long vipStage = 1; - @FieldDescription("nono是否自动充电 建议固定1") - private @UInt long autoCharge = 1; - @FieldDescription("超no的结束时间建议尽可能大") - private @UInt long vipEndTime = Integer.MAX_VALUE; - @FieldDescription("邀请活动建议先给固定值0") - private @UInt long freshManBonus; - @FieldDescription("超no芯片列表*(80字节)") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 80) - private byte[] nonoChipList = new byte[80]; - @FieldDescription("50字节,默认值为3") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 50) - private byte[] dailyResArr - = ArrayUtilities.generateByteArrayWithInitialValueAndLength((byte) 3, 50); - @FieldDescription("教官id") - private @UInt long teacherID; - @FieldDescription("学员id") - private @UInt long studentID; - @FieldDescription("毕业人数") - private @UInt long graduationCount; - @FieldDescription("默认值为0") - private @UInt long maxPuniLv; - @FieldDescription("精灵的最高等级") - private @UInt long petMaxLevel; - @FieldDescription("所有的精灵的数量") - private @UInt long allPetNumber; - @FieldDescription("精灵王之战胜场") - private @UInt long monKingWin; - @FieldDescription("勇者之塔当前到达的层数") - private @UInt long currentStage; - @FieldDescription("试炼之塔最大胜利的层数") - private @UInt long maxStage; - @FieldDescription("试炼之塔当前到达的层数") - private @UInt long currentFreshStage; - @FieldDescription("试炼之塔最大胜利的层数") - private @UInt long maxFreshStage; - @FieldDescription("星际擂台连胜") - private @UInt long maxArenaWins; - @FieldDescription("未知默认0") - private @UInt long twoTimes; - @FieldDescription("未知默认0") - private @UInt long threeTimes; - @FieldDescription("是否自动战斗(未知默认值0)") - private @UInt long autoFight; - @FieldDescription("自动战斗剩余的场次(未知默认值0)") - private @UInt long autoFightTime; - @FieldDescription("能量吸收仪剩余次数(未知待定默认值0)") - private @UInt long energyTime; - @FieldDescription("学习力吸收仪剩余次数(未知待定默认值0)") - private @UInt long learnTimes; - @FieldDescription("未知默认0") - private @UInt long monBattleMedal; - @FieldDescription("未知默认0") - private @UInt long recordCount; - @FieldDescription("未知默认0") - private @UInt long obtainTm; - @FieldDescription("当前在孵化的元神珠id") - private @UInt long soulBeadItemID; - @FieldDescription("未知默认0") - private @UInt long expireTm; - @FieldDescription("未知默认0") - private @UInt long fuseTimes; - @FieldDescription("玩家有没有nono") - private @UInt long hasNono = 1; - @FieldDescription("玩家有没有超能nono") - private @UInt long superNono = 1; - @FieldDescription("默认值-1") - private @UInt long nonoState = 0xFFFFFFFFL; - @FieldDescription("nono的颜色") - private @UInt long nonoColor; - @FieldDescription("nono的名字 必须要补齐到16位") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nonoNick = "nono"; - @FieldDescription("猜测为战队信息24字节") - private TeamInfo teamInfo = new TeamInfo(); - @FieldDescription("8字节") - private TeamPKInfo teamPkInfo = new TeamPKInfo(); - @FieldDescription("1字节 无内容") - private byte reserved; - @FieldDescription("默认值为0") - private @UInt long badge; - @FieldDescription("未知(27字节,默认值为3)") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 27) - private byte[] reserved1 - = ArrayUtilities.generateByteArrayWithInitialValueAndLength((byte) 3, 27); - @FieldDescription("任务状态数组(500字节,3为已经完成,建议默认值为3)") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 500) - private byte[] taskList - = ArrayUtilities.generateByteArrayWithInitialValueAndLength((byte) 3, 500); - @FieldDescription("精灵背包内的信息由于特性精灵的存在精灵背包不定长 如果有特性占199字节 如果没特性 一个精灵占175字节") - private List petList = new ArrayList<>(); - @FieldDescription("穿戴装备 8字节") - private List clothes = new ArrayList<>(); -} diff --git a/common/core/info/login/ServerInfo.go b/common/core/info/login/ServerInfo.go index cf21dfaa1..c1ac4dba4 100644 --- a/common/core/info/login/ServerInfo.go +++ b/common/core/info/login/ServerInfo.go @@ -1,41 +1,35 @@ -package login - -// ServerInfo 服务器信息结构体 -type ServerInfo struct { - // 连接ID, 即服务器序号 - OnlineID uint32 - // 当前服务器玩家在线数量, 供SWF显示 - UserCnt uint32 - // 服务器IP, 16字节UTF-8, 不足16补齐到16 - IP string `serialize:"fixed:16"` // 定长模式:16字节 - // 端口 - Port uint16 - // 好友在线的个数 - Friends uint32 -} - -// NewServerInfo 创建新的服务器信息实例 -func NewServerInfo() *ServerInfo { - return &ServerInfo{ - OnlineID: 0, - UserCnt: 0, - IP: "", - Port: 0, - Friends: 0, - } -} - -// // SetIP 设置IP地址并自动填充到16字节 -// func (s *ServerInfo) SetIP(ip string) { -// copy(s.IP[:], ip) -// if len(ip) < 16 { -// for i := len(ip); i < 16; i++ { -// s.IP[i] = 0 // 用0填充剩余字节 -// } -// } -// } - -// // GetIP 获取IP地址(去除填充的0) -// func (s *ServerInfo) GetIP() string { -// return strings.TrimRight(string(s.IP[:]), "\x00") -// } +package login + +// ServerInfo 服务器信息结构体 +type ServerInfo struct { + // 连接ID, 即服务器序号 + OnlineID uint32 + // 当前服务器玩家在线数量, 供SWF显示 + UserCnt uint32 + // 服务器IP, 16字节UTF-8, 不足16补齐到16 + IP string `struc:"[16]byte"` // 定长模式:16字节 + // 端口 + Port uint16 + // 好友在线的个数 + Friends uint32 +} + +// NewServerInfo 创建新的服务器信息实例 +func NewServerInfo() *ServerInfo { + return &ServerInfo{} +} + +// // SetIP 设置IP地址并自动填充到16字节 +// func (s *ServerInfo) SetIP(ip string) { +// copy(s.IP[:], ip) +// if len(ip) < 16 { +// for i := len(ip); i < 16; i++ { +// s.IP[i] = 0 // 用0填充剩余字节 +// } +// } +// } + +// // GetIP 获取IP地址(去除填充的0) +// func (s *ServerInfo) GetIP() string { +// return strings.TrimRight(string(s.IP[:]), "\x00") +// } diff --git a/common/core/info/login/ServerInfo.java b/common/core/info/login/ServerInfo.java deleted file mode 100644 index 728981688..000000000 --- a/common/core/info/login/ServerInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nieo.seerproject.common.net.info.login; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.annotations.serialize.UShort; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@FieldDescription("服务器信息") -public class ServerInfo { - @FieldDescription("连接ID, 即服务器序号") - private @UInt long onlineId; - @FieldDescription("当前服务器玩家在线数量, 供SWF显示") - private @UInt long userCnt; - @FieldDescription("服务器IP, 16字节UTF-8, 不足16补齐到16") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String ip; - @FieldDescription("端口") - private @UShort int port; - @FieldDescription("好友在线的个数") - private @UInt long friends; -} diff --git a/common/core/info/login/SidInfo.java b/common/core/info/login/SidInfo.java deleted file mode 100644 index 8e2e4d466..000000000 --- a/common/core/info/login/SidInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.login; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@FieldDescription("SID") -@InboundMessageType(MessageCommandIDRegistry.Commend_OnLine) -public class SidInfo implements InboundMessage { - private byte [] sid; -} diff --git a/common/core/info/mail/MailUnreadInboundInfo.java b/common/core/info/mail/MailUnreadInboundInfo.java deleted file mode 100644 index dd63d63b3..000000000 --- a/common/core/info/mail/MailUnreadInboundInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.mail; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Mail_Get_Unread) -public class MailUnreadInboundInfo implements InboundMessage { - public static final @Nonnull MailUnreadInboundInfo INSTANCE = new MailUnreadInboundInfo(); -} diff --git a/common/core/info/mail/MailUnreadOutboundInfo.java b/common/core/info/mail/MailUnreadOutboundInfo.java deleted file mode 100644 index dc7ef20f4..000000000 --- a/common/core/info/mail/MailUnreadOutboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.mail; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.Mail_Get_Unread) -public class MailUnreadOutboundInfo implements OutboundMessage { - @FieldDescription("未读邮件的数量") - private @UInt long mailNumber; -} diff --git a/common/core/info/map/LeaveMapInboundInfo.java b/common/core/info/map/LeaveMapInboundInfo.java deleted file mode 100644 index 8e6562ca0..000000000 --- a/common/core/info/map/LeaveMapInboundInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Leave_Map) -public class LeaveMapInboundInfo implements InboundMessage { - public static final LeaveMapInboundInfo INSTANCE = new LeaveMapInboundInfo(); -} diff --git a/common/core/info/map/LeaveMapOutboundInfo.java b/common/core/info/map/LeaveMapOutboundInfo.java deleted file mode 100644 index 2a0b16ead..000000000 --- a/common/core/info/map/LeaveMapOutboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.Leave_Map) -public class LeaveMapOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userId; -} diff --git a/common/core/info/map/ListMapPlayerInboundInfo.java b/common/core/info/map/ListMapPlayerInboundInfo.java deleted file mode 100644 index 8777a9124..000000000 --- a/common/core/info/map/ListMapPlayerInboundInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@Data -@InboundMessageType(MessageCommandIDRegistry.List_Map_Player) -public class ListMapPlayerInboundInfo implements InboundMessage { - public static final @Nonnull ListMapPlayerInboundInfo INSTANCE = new ListMapPlayerInboundInfo(); -} diff --git a/common/core/info/map/ListMapPlayerOutboundInfo.java b/common/core/info/map/ListMapPlayerOutboundInfo.java deleted file mode 100644 index 9ececa0c0..000000000 --- a/common/core/info/map/ListMapPlayerOutboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.ArrayList; -import java.util.List; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.List_Map_Player) -public class ListMapPlayerOutboundInfo implements OutboundMessage { - private List mapPlayerInfo = new ArrayList<>(); -} diff --git a/common/core/info/map/MapHotInboundInfo.java b/common/core/info/map/MapHotInboundInfo.java deleted file mode 100644 index 0eee1284b..000000000 --- a/common/core/info/map/MapHotInboundInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Map_Hot) -public class MapHotInboundInfo implements InboundMessage { - public static final @Nonnull MapHotInboundInfo INSTANCE = new MapHotInboundInfo(); -} diff --git a/common/core/info/map/MapHotInfo.java b/common/core/info/map/MapHotInfo.java deleted file mode 100644 index 40fbd5dbe..000000000 --- a/common/core/info/map/MapHotInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MapHotInfo { - @FieldDescription("地图ID") - private @UInt long mapId; - @FieldDescription("地图里有多少人") - private @UInt long count; -} diff --git a/common/core/info/map/MapHotOutboundInfo.java b/common/core/info/map/MapHotOutboundInfo.java deleted file mode 100644 index f961f83fc..000000000 --- a/common/core/info/map/MapHotOutboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.ArrayList; -import java.util.List; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.Map_Hot) -public class MapHotOutboundInfo implements OutboundMessage { - private List hotInfos = new ArrayList<>(); -} diff --git a/common/core/info/map/MapInfo.java b/common/core/info/map/MapInfo.java deleted file mode 100644 index 8627aa6e7..000000000 --- a/common/core/info/map/MapInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.MessageName; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.structs.Point; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Enter_Map) -@MessageName("EnterMapInboundInfo") -public class MapInfo implements InboundMessage { - @FieldDescription("地图类型") - private @UInt long mapType; - @FieldDescription("地图ID") - private @UInt long mapId; - @FieldDescription("8字节, 人物地图坐标") - private Point pos = new Point(); -} diff --git a/common/core/info/map/MapOgreListOutboundInfo.java b/common/core/info/map/MapOgreListOutboundInfo.java deleted file mode 100644 index 21a444c83..000000000 --- a/common/core/info/map/MapOgreListOutboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.Map_Ogre_List) -public class MapOgreListOutboundInfo implements OutboundMessage { - private @UInt long petId1; - private @UInt long petId2; - private @UInt long petId3; - private @UInt long petId4; - private @UInt long petId5; - private @UInt long petId6; - private @UInt long petId7; - private @UInt long petId8; - private @UInt long petId9; -} diff --git a/common/core/info/map/PeopleInfo.java b/common/core/info/map/PeopleInfo.java deleted file mode 100644 index 51246574d..000000000 --- a/common/core/info/map/PeopleInfo.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.MessageName; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.annotations.serialize.UShort; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.item.PeopleItemInfo; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; -import org.nieo.seerproject.common.structs.Point; - -import java.util.ArrayList; -import java.util.List; - -@Data -@AutoCodec -@SuppressWarnings("SpellCheckingInspection") -@OutboundMessageType(MessageCommandIDRegistry.Enter_Map) -@MessageName("EnterMapOutboundInfo") -public class PeopleInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userId; - @FieldDescription("16字节昵称") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nick; - @FieldDescription("机器人人物颜色 00 rgb") - private @UInt long color; - @FieldDescription("固定值0") - private @UInt long texture; - @FieldDescription("暂时不明建议先给固定值0") - private @UShort int vip; - @FieldDescription("暂时不明建议先给固定值15") - private @UShort int viped = 15; - @FieldDescription("暂时不明建议先给固定值1") - private @UInt long vipStage; - @FieldDescription("人物状态 =0 步行 !=0 飞行") - private @UInt long actionType; - @FieldDescription("上线的地图id") - private Point pos = new Point(); - @FieldDescription("暂时不明给0") - private @UInt long action; - @FieldDescription("暂时不明给2") - private @UInt long direction = 2; - @FieldDescription("暂时不明给0") - private @UInt long changeShape; - @FieldDescription("暂时不明给0") - private @UInt long spiritTime; - @FieldDescription("暂时不明给0") - private @UInt long spiritID; - @FieldDescription("宠物ID暂时无法测试, 给0") - private @UInt long petDV; - @FieldDescription("宠物闪光暂时无法测试, 给0") - private @UInt long petShiny; - @FieldDescription("宠物皮肤暂时无法测试, 给0") - private @UInt long petSkin; - @FieldDescription("填充字符") - private @UInt long reserved; - @FieldDescription("填充字符") - private @UInt long reserved1; - @FieldDescription("填充字符") - private @UInt long reserved2; - @FieldDescription("暂时不明给0") - private @UInt long fightFlag; - @FieldDescription("教官ID") - private @UInt long teacherID; - @FieldDescription("学员ID") - private @UInt long studentID; - @FieldDescription("nono状态 固定值-1") - private @UInt long nonoState = 0xFFFFFFFFL; - @FieldDescription("nono颜色 00 FF FF FF") - private @UInt long nonoColor; - @FieldDescription("是不是超能nono 固定值1") - private @UInt long superNono = 1; - @FieldDescription("暂时不明给0") - private @UInt long playerForm; - @FieldDescription("暂时不明给0") - private @UInt long transTime; - @FieldDescription("暂时不明给0") - private @UInt long teamid; - @FieldDescription("暂时不明给0") - private @UInt long teamCoreCount; - @FieldDescription("暂时不明给0") - private @UInt long teamisShow; - @FieldDescription("暂时不明给0") - private short logoBg; - @FieldDescription("暂时不明给0") - private short logoIcon; - @FieldDescription("暂时不明给0") - private short logoColor; - @FieldDescription("暂时不明给0") - private short txtColor; - @FieldDescription("4字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 4) - private byte[] logoWord = new byte[4]; - @FieldDescription("穿戴装备的信息") - private List clothes = new ArrayList<>(); -} diff --git a/common/core/info/map/PeopleWalkInboundInfo.java b/common/core/info/map/PeopleWalkInboundInfo.java deleted file mode 100644 index 42584d6b8..000000000 --- a/common/core/info/map/PeopleWalkInboundInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.structs.Point; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.People_Walk) -public class PeopleWalkInboundInfo implements InboundMessage { - @FieldDescription("0为走,1为飞行模式") - private @UInt long flag; - @FieldDescription("直接给坐标x,y") - private Point point = new Point(); - @FieldDescription("暂定 占位字符2") - private String reverse2; -} diff --git a/common/core/info/map/PeopleWalkOutboundInfo.java b/common/core/info/map/PeopleWalkOutboundInfo.java deleted file mode 100644 index 5a3685ffa..000000000 --- a/common/core/info/map/PeopleWalkOutboundInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nieo.seerproject.common.net.info.map; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.structs.Point; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.People_Walk) -public class PeopleWalkOutboundInfo implements OutboundMessage { - @FieldDescription("0为走,1为飞行模式") - public @UInt long flag; - @FieldDescription("走动的人的米米号") - public @UInt long userID; - @FieldDescription("直接给坐标x,y") - public Point point = new Point(); - @FieldDescription("这个字段同C2S_People_Walk中的reserve2") - public String reserve2; -} diff --git a/common/core/info/misc/AimatInboundInfo.java b/common/core/info/misc/AimatInboundInfo.java deleted file mode 100644 index 5e4df6291..000000000 --- a/common/core/info/misc/AimatInboundInfo.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.structs.Point; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@InboundMessageType(MessageCommandIDRegistry.Aimat) -public class AimatInboundInfo implements InboundMessage { - @FieldDescription("物品id 射击激光 物品id为0") - private @UInt long itemId; - @FieldDescription("射击类型 未知 给0") - private @UInt long shootType; - @FieldDescription("射击的坐标 x y") - @Builder.Default - private Point point = new Point(); -} diff --git a/common/core/info/misc/AimatOutboundInfo.java b/common/core/info/misc/AimatOutboundInfo.java deleted file mode 100644 index a2eccbb53..000000000 --- a/common/core/info/misc/AimatOutboundInfo.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.structs.Point; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Aimat) -public class AimatOutboundInfo implements OutboundMessage { - @FieldDescription("射出子弹的人 米米号") - private @UInt long userId; - @FieldDescription("物品id 射击激光 物品id为0") - private @UInt long itemId; - @FieldDescription("射击类型 未知 给0") - private @UInt long shootType; - @FieldDescription("射击的坐标 x y") - @Builder.Default - private Point point = new Point(); -} diff --git a/common/core/info/misc/CateInfo.java b/common/core/info/misc/CateInfo.java deleted file mode 100644 index 95cbe91d2..000000000 --- a/common/core/info/misc/CateInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class CateInfo { - @FieldDescription("物品id") - private @UInt long id; - @FieldDescription("数量") - private @UInt long count; -} diff --git a/common/core/info/misc/DayTalkInfo.java b/common/core/info/misc/DayTalkInfo.java deleted file mode 100644 index 77863025a..000000000 --- a/common/core/info/misc/DayTalkInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; - -import java.util.ArrayList; -import java.util.List; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class DayTalkInfo { - @FieldDescription("要序列list数量字段 只序列数量 结构体数据给null") - @Builder.Default - private List cateList = new ArrayList<>(); - @FieldDescription("实际发放奖励使用的是outlist") - @Builder.Default - private List outList = new ArrayList<>(); -} diff --git a/common/core/info/misc/GetQuadrupleExeTimeInboundInfo.java b/common/core/info/misc/GetQuadrupleExeTimeInboundInfo.java deleted file mode 100644 index bac815ef9..000000000 --- a/common/core/info/misc/GetQuadrupleExeTimeInboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Get_Quadruple_Exe_Time) -public class GetQuadrupleExeTimeInboundInfo implements InboundMessage { - @FieldDescription("标志若标志为1 则返回已经使用的四倍时间") - private @UInt long flag; -} diff --git a/common/core/info/misc/GetQuadrupleExeTimeOutboundInfo.java b/common/core/info/misc/GetQuadrupleExeTimeOutboundInfo.java deleted file mode 100644 index 88998f9f3..000000000 --- a/common/core/info/misc/GetQuadrupleExeTimeOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Get_Quadruple_Exe_Time) -public class GetQuadrupleExeTimeOutboundInfo implements OutboundMessage { - @FieldDescription("返回已经使用的四倍时间, 以秒为单位") - private @UInt long quadrupleExeTime; -} diff --git a/common/core/info/misc/SystemTimeInboundInfo.java b/common/core/info/misc/SystemTimeInboundInfo.java deleted file mode 100644 index f322ccb78..000000000 --- a/common/core/info/misc/SystemTimeInboundInfo.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@InboundMessageType(MessageCommandIDRegistry.System_Time) -public class SystemTimeInboundInfo implements InboundMessage { - public static final @Nonnull SystemTimeInboundInfo INSTANCE = new SystemTimeInboundInfo(); -} diff --git a/common/core/info/misc/SystemTimeOutboundInfo.java b/common/core/info/misc/SystemTimeOutboundInfo.java deleted file mode 100644 index 3aed4e743..000000000 --- a/common/core/info/misc/SystemTimeOutboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.time.Instant; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.System_Time) -public class SystemTimeOutboundInfo implements OutboundMessage { - private @UInt long systemTime = Instant.now().getEpochSecond(); -} diff --git a/common/core/info/misc/TalkCateInboundInfo.java b/common/core/info/misc/TalkCateInboundInfo.java deleted file mode 100644 index e8da943a4..000000000 --- a/common/core/info/misc/TalkCateInboundInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@InboundMessageType(MessageCommandIDRegistry.Talk_Cate) -public class TalkCateInboundInfo implements InboundMessage { - @FieldDescription("奖品的type, 即ID") - private @UInt long id; -} diff --git a/common/core/info/misc/TalkCateOutboundInfo.java b/common/core/info/misc/TalkCateOutboundInfo.java deleted file mode 100644 index 4564ce3e4..000000000 --- a/common/core/info/misc/TalkCateOutboundInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Talk_Cate) -public class TalkCateOutboundInfo implements OutboundMessage { - @FieldDescription("返回的奖品信息") - private DayTalkInfo dayTalkInfo; -} diff --git a/common/core/info/misc/TalkCountInboundInfo.java b/common/core/info/misc/TalkCountInboundInfo.java deleted file mode 100644 index 06b56e0cf..000000000 --- a/common/core/info/misc/TalkCountInboundInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@InboundMessageType(MessageCommandIDRegistry.Talk_Count) -public class TalkCountInboundInfo implements InboundMessage { - @FieldDescription("奖品的Type, 即ID") - private @UInt long id; -} diff --git a/common/core/info/misc/TalkCountOutboundInfo.java b/common/core/info/misc/TalkCountOutboundInfo.java deleted file mode 100644 index 9bed8a4b9..000000000 --- a/common/core/info/misc/TalkCountOutboundInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.misc; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@NoArgsConstructor -@AllArgsConstructor -@OutboundMessageType(MessageCommandIDRegistry.Talk_Count) -public class TalkCountOutboundInfo implements OutboundMessage { - @FieldDescription("已领取奖励的次数") - private @UInt long giftCount; -} diff --git a/common/core/info/nono/NonoFollowOrHomeInboundInfo.java b/common/core/info/nono/NonoFollowOrHomeInboundInfo.java deleted file mode 100644 index ee0f244ba..000000000 --- a/common/core/info/nono/NonoFollowOrHomeInboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.nono; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Nono_Follow_Or_Home) -public class NonoFollowOrHomeInboundInfo implements InboundMessage { - @FieldDescription("1为跟随 0为收回 且如果为收回 那么后续结构不需要发送") - private @UInt long flag; -} diff --git a/common/core/info/nono/NonoFollowOrHomeOutboundInfo.java b/common/core/info/nono/NonoFollowOrHomeOutboundInfo.java deleted file mode 100644 index c18caeadc..000000000 --- a/common/core/info/nono/NonoFollowOrHomeOutboundInfo.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.nieo.seerproject.common.net.info.nono; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.Nono_Follow_Or_Home) -public class NonoFollowOrHomeOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userID; - @FieldDescription("设置的值与下面的flag变量相同") - private @UInt long superStage; - @FieldDescription("1为跟随 0为收回 且如果为收回 那么后续结构不需要发送, 不序列化") - private @UInt long flag; - @FieldDescription("nono名字 补到16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nonoNick; - @FieldDescription("nono颜色 rpg") - private @UInt long color; - @FieldDescription("能量值 前端显示除以1000后的值") - private @UInt long power; -} diff --git a/common/core/info/nono/NonoInboundInfo.java b/common/core/info/nono/NonoInboundInfo.java deleted file mode 100644 index 4399ed5d1..000000000 --- a/common/core/info/nono/NonoInboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.nono; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Nono_Info) -public class NonoInboundInfo implements InboundMessage { - @FieldDescription("米米号") - private @UInt long userId; -} diff --git a/common/core/info/nono/NonoOutboundInfo.java b/common/core/info/nono/NonoOutboundInfo.java deleted file mode 100644 index 98bcadadc..000000000 --- a/common/core/info/nono/NonoOutboundInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.nieo.seerproject.common.net.info.nono; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.annotations.serialize.UShort; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Nono_Info) -public class NonoOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userID; - @FieldDescription("未知") - private @UInt long num; - @FieldDescription("未知") - private @UInt long state; - @FieldDescription("16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nick; - @FieldDescription("是不是超能nono") - private @UInt long superNono; - @FieldDescription("nono颜色 00 rgb") - private @UInt long color; - @FieldDescription("未知, 返回的实际数值要*1000") - private @UInt long power; - @FieldDescription("未知, 返回的实际数值要*1000") - private @UInt long mate; - @FieldDescription("未知") - private @UInt long iq; - @FieldDescription("未知") - private @UShort int ai; - @FieldDescription("未知, 返回的实际数值要除以1000") - private @UInt long birth; - @FieldDescription("充电时间") - private @UInt long chargeTime; - @FieldDescription("20字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 20) - private byte[] func = new byte[20]; - @FieldDescription("超能nono能力") - private @UInt long superEnergy; - @FieldDescription("超能nono等级") - private @UInt long superLevel; - @FieldDescription("超能nono阶段") - private @UInt long superStage; -} diff --git a/common/core/info/pet/GetPetInfoOutboundInfo.java b/common/core/info/pet/GetPetInfoOutboundInfo.java deleted file mode 100644 index 8a7cb3913..000000000 --- a/common/core/info/pet/GetPetInfoOutboundInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@AutoCodec -@Data -@OutboundMessageType(MessageCommandIDRegistry.Get_Pet_Info) -public class GetPetInfoOutboundInfo implements OutboundMessage { - @FieldDescription("精灵信息") - private PetInfo petInfo; -} diff --git a/common/core/info/pet/PetCureInboundInfo.java b/common/core/info/pet/PetCureInboundInfo.java deleted file mode 100644 index 21d1a85f3..000000000 --- a/common/core/info/pet/PetCureInboundInfo.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Cure) -public class PetCureInboundInfo implements InboundMessage { -} diff --git a/common/core/info/pet/PetCureOutboundInfo.java b/common/core/info/pet/PetCureOutboundInfo.java deleted file mode 100644 index e4c486bb3..000000000 --- a/common/core/info/pet/PetCureOutboundInfo.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Cure) -public class PetCureOutboundInfo implements OutboundMessage { -} diff --git a/common/core/info/pet/PetEffectInfo.go b/common/core/info/pet/PetEffectInfo.go index 254de1e5b..494e5d25d 100644 --- a/common/core/info/pet/PetEffectInfo.go +++ b/common/core/info/pet/PetEffectInfo.go @@ -1,28 +1,21 @@ -package pet - -// SkillInfo 临时技能信息结构体(实际项目应补充完整定义) -type SkillInfo struct { - SkillId uint32 // 技能ID - Level uint32 // 技能等级 -} -package pet - -// PetEffectInfo 宠物特性信息 -type PetEffectInfo struct { - // ItemId 特性晶片对应的物品id - ItemId uint64 - // Status 默认为1 - Status byte - // LeftCount 未知默认为0 - LeftCount byte - // EffectId 特性id - EffectId uint16 - // Reserve1 保留字段1 - Reserve1 byte - // Reserve2 保留字段2无作用 - Reserve2 byte - // Reserve3 保留字段3 - Reserve3 byte - // Reserve4 保留字段4(13字节) - Reserve4 [13]byte -} +package pet + +// PetEffectInfo 宠物特性信息 +type PetEffectInfo struct { + // ItemId 特性晶片对应的物品id + ItemId uint64 + // Status 默认为1 + Status byte + // LeftCount 未知默认为0 + LeftCount byte + // EffectId 特性id + EffectId uint16 + // Reserve1 保留字段1 + Reserve1 byte + // Reserve2 保留字段2无作用 + Reserve2 byte + // Reserve3 保留字段3 + Reserve3 byte + // Reserve4 保留字段4(13字节) + Reserve4 [13]byte +} diff --git a/common/core/info/pet/PetEffectInfo.java b/common/core/info/pet/PetEffectInfo.java deleted file mode 100644 index c7ab02549..000000000 --- a/common/core/info/pet/PetEffectInfo.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Builder; -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.annotations.serialize.UShort; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@SuperBuilder -public class PetEffectInfo { - @FieldDescription("特性晶片对应的物品id") - public @UInt long itemID; - @FieldDescription("默认为1") - @Builder.Default - public byte status = 1; - @FieldDescription("未知默认为0") - public byte leftCount; - @FieldDescription("特性id") - public @UShort int effectID; - @FieldDescription("保留字段1") - public byte reserve1; - @FieldDescription("保留字段2无作用") - public byte reserve2; - @FieldDescription("保留字段3") - public byte reserve3; - @FieldDescription("保留字段4 占13字节") - @Builder.Default - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 13) - public byte[] reserve4 = new byte[13]; -} diff --git a/common/core/info/pet/PetInfo.go b/common/core/info/pet/PetInfo.go index 8b6164cd8..f080bc10c 100644 --- a/common/core/info/pet/PetInfo.go +++ b/common/core/info/pet/PetInfo.go @@ -1,69 +1,73 @@ -package pet - -import ( - "common/core/info/pet/skill" -) - -// PetInfo 宠物基本信息 -type PetInfo struct { - // Id 精灵编号 - Id uint64 - // Name 名字,长度为16字节 - Name [16]byte - // Dv 个体值 - Dv uint64 - // Nature 性格 - Nature uint64 - // Level 等级 - Level uint64 - // Exp 当前等级已获得的经验 - Exp uint64 - // LvExp 当前等级所需的经验 - LvExp uint64 - // NextLvExp 升到下一级的经验 - NextLvExp uint64 - // Hp 当前生命 - Hp uint64 - // MaxHp 最大生命 - MaxHp uint64 - // Attack 攻击 - Attack uint64 - // Defence 防御 - Defence uint64 - // SpecialAttack 特攻 - SpecialAttack uint64 - // SpecialDefence 特防 - SpecialDefence uint64 - // Speed 速度 - Speed uint64 - // EvHp 生命学习力 - EvHp uint64 - // EvAttack 攻击学习力 - EvAttack uint64 - // EvDefence 防御学习力 - EvDefence uint64 - // EvSpecialAttack 特攻学习力 - EvSpecialAttack uint64 - // EvSpecialDefense 特防学习力 - EvSpecialDefense uint64 - // EvSpeed 速度学习力 - EvSpeed uint64 - // SkillSize 技能个数 - SkillSize uint64 - // SkillList 技能信息列表 - SkillList []skill.SkillInfo - // CatchTime 捕捉时间 - CatchTime uint64 - // CatchMap 捕捉地图 - CatchMap uint64 - // CatchRect 未知默认为0 - CatchRect uint64 - // CatchLevel 捕获等级默认为0 - CatchLevel uint64 - // EffectInfo 特性列表 - EffectInfo []PetEffectInfo - // SkinID 皮肤id默认为0 - SkinID uint64 - // Shiny 是否为闪 - Shiny uint64 -} +package pet + +import ( + "blazing/common/core/info/pet/skill" +) + +// PetInfo 宠物基本信息 +type PetInfo struct { + // Id 精灵编号 + Id uint64 + // Name 名字,长度为16字节 + Name [16]byte + // Dv 个体值 + Dv uint64 + // Nature 性格 + Nature uint64 + // Level 等级 + Level uint64 + // Exp 当前等级已获得的经验 + Exp uint64 + // LvExp 当前等级所需的经验 + LvExp uint64 + // NextLvExp 升到下一级的经验 + NextLvExp uint64 + // Hp 当前生命 + Hp uint64 + // MaxHp 最大生命 + MaxHp uint64 + // Attack 攻击 + Attack uint64 + // Defence 防御 + Defence uint64 + // SpecialAttack 特攻 + SpecialAttack uint64 + // SpecialDefence 特防 + SpecialDefence uint64 + // Speed 速度 + Speed uint64 + // EvHp 生命学习力 + EvHp uint64 + // EvAttack 攻击学习力 + EvAttack uint64 + // EvDefence 防御学习力 + EvDefence uint64 + // EvSpecialAttack 特攻学习力 + EvSpecialAttack uint64 + // EvSpecialDefense 特防学习力 + EvSpecialDefense uint64 + // EvSpeed 速度学习力 + EvSpeed uint64 + // SkillSize 技能个数 + SkillSize uint64 + // SkillList 技能信息列表 + SkillList []skill.SkillInfo + // CatchTime 捕捉时间 + CatchTime uint64 + // CatchMap 捕捉地图 + CatchMap uint64 + // CatchRect 未知默认为0 + CatchRect uint64 + // CatchLevel 捕获等级默认为0 + CatchLevel uint64 + // EffectInfo 特性列表 + EffectInfo []PetEffectInfo + // SkinID 皮肤id默认为0 + SkinID uint64 + // Shiny 是否为闪 + Shiny uint64 +} + +func NewPetInfo() *PetInfo { + return &PetInfo{} +} diff --git a/common/core/info/pet/PetInfo.java b/common/core/info/pet/PetInfo.java deleted file mode 100644 index dcedd684f..000000000 --- a/common/core/info/pet/PetInfo.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.info.pet.skill.SkillInfo; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; -import org.nieo.seerproject.common.net.serialize.LengthFieldType; - -import java.util.ArrayList; -import java.util.List; - -@Data -public class PetInfo { - @FieldDescription("精灵编号") - private @UInt long id; - @FieldDescription("名字 默认为全0 但要补齐到16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private byte[] name = new byte[16]; - @FieldDescription("个体值") - private @UInt long dv; - @FieldDescription("性格") - private @UInt long nature; - @FieldDescription("等级") - private @UInt long level; - @FieldDescription("当前等级已经获得的经验 2538") - private @UInt long exp; - @FieldDescription("当前等级所需的经验") - private @UInt long lvExp; - @FieldDescription("升到下一级的经验") - private @UInt long nextLvExp; - @FieldDescription("当前生命") - private @UInt long hp; - @FieldDescription("最大生命") - private @UInt long maxHp; - @FieldDescription("攻击") - private @UInt long attack; - @FieldDescription("防御") - private @UInt long defence; - @FieldDescription("特攻") - private @UInt long specialAttack; - @FieldDescription("特防") - private @UInt long specialDefence; - @FieldDescription("速度") - private @UInt long speed; - @FieldDescription("生命学习力") - private @UInt long evHp; - @FieldDescription("攻击学习力") - private @UInt long evAttack; - @FieldDescription("防御学习力") - private @UInt long evDefence; - @FieldDescription("特攻学习力") - private @UInt long evSpecialAttack; - @FieldDescription("特防学习力") - private @UInt long evSpecialDefense; - @FieldDescription("速度学习力") - private @UInt long evSpeed; - @FieldDescription("技能个数") - private @UInt long skillSize; - @FieldDescription("32字节 技能信息 必须插入4条skillInfo,若技能信息为空则要赋值成0") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 8) - private List skillList; - @FieldDescription("捕捉时间") - private @UInt long catchTime; - @FieldDescription("捕捉地图") - private @UInt long catchMap; - @FieldDescription("未知默认为0") - private @UInt long catchRect; - @FieldDescription("捕获等级 默认为0") - private @UInt long catchLevel; - @FieldDescription("特性列表, 长度在头部以UShort存储") - @ArraySerialize(value = ArraySerializeType.LENGTH_FIRST, lengthType = LengthFieldType.UNSIGNED_SHORT) - private List effectInfo = new ArrayList<>(); - @FieldDescription("皮肤id默认为0") - private @UInt long skinID; - @FieldDescription("是不是闪") - private @UInt long shiny; -} diff --git a/common/core/info/pet/PetOneCureInboundInfo.java b/common/core/info/pet/PetOneCureInboundInfo.java deleted file mode 100644 index 54111c7ac..000000000 --- a/common/core/info/pet/PetOneCureInboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_One_Cure) -public class PetOneCureInboundInfo implements InboundMessage { - @FieldDescription("精灵捕捉时间") - private @UInt long catchTime; -} diff --git a/common/core/info/pet/PetOneCureOutboundInfo.java b/common/core/info/pet/PetOneCureOutboundInfo.java deleted file mode 100644 index 6b21aeb80..000000000 --- a/common/core/info/pet/PetOneCureOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_One_Cure) -public class PetOneCureOutboundInfo implements OutboundMessage { - @FieldDescription("精灵捕捉时间") - private @UInt long catchTime; -} diff --git a/common/core/info/pet/PetSetExpInboundInfo.java b/common/core/info/pet/PetSetExpInboundInfo.java deleted file mode 100644 index dc5f8ac29..000000000 --- a/common/core/info/pet/PetSetExpInboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@AutoCodec -@Data -@InboundMessageType(MessageCommandIDRegistry.Pet_Set_Exp) -public class PetSetExpInboundInfo implements InboundMessage { - @FieldDescription("精灵获取时间") - private @UInt long catchTime; - @FieldDescription("分配经验") - private @UInt long exp; -} diff --git a/common/core/info/pet/PetSetExpOutboundInfo.java b/common/core/info/pet/PetSetExpOutboundInfo.java deleted file mode 100644 index e83617e32..000000000 --- a/common/core/info/pet/PetSetExpOutboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@AutoCodec -@Data -@Builder -@OutboundMessageType(MessageCommandIDRegistry.Pet_Set_Exp) -public class PetSetExpOutboundInfo implements OutboundMessage { - @FieldDescription("剩余累计经验") - private @UInt long exp; -} diff --git a/common/core/info/pet/PetShortInfo.java b/common/core/info/pet/PetShortInfo.java deleted file mode 100644 index 1250fa9e7..000000000 --- a/common/core/info/pet/PetShortInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@AutoCodec -@SuperBuilder -public class PetShortInfo{ - - @FieldDescription("精灵类型ID") - private @UInt long typeId; - @FieldDescription("精灵生成时间") - private @UInt long catchTime; - @FieldDescription("当前等级") - private @UInt long level; - @FieldDescription("精灵皮肤ID") - private @UInt long skinId; - @FieldDescription("是否为闪光") - private @UInt long isShiny; -} diff --git a/common/core/info/pet/PetShowInboundInfo.java b/common/core/info/pet/PetShowInboundInfo.java deleted file mode 100644 index ff8c529f7..000000000 --- a/common/core/info/pet/PetShowInboundInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Show) -public class PetShowInboundInfo implements InboundMessage { - private @UInt long catchTime; - private @UInt long flag; -} diff --git a/common/core/info/pet/PetShowOutboundInfo.java b/common/core/info/pet/PetShowOutboundInfo.java deleted file mode 100644 index 03a810370..000000000 --- a/common/core/info/pet/PetShowOutboundInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Show) -public class PetShowOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long UserID; - @FieldDescription("精灵获得的时间") - private @UInt long CatchTime; - @FieldDescription("精灵编号") - private @UInt long PetID; - @FieldDescription("1为显示 0为收回") - private @UInt long flag; - @FieldDescription("个体") - private @UInt long dv; - @FieldDescription("闪") - private @UInt long shiny; - @FieldDescription("皮肤id") - private @UInt long skinID; - @FieldDescription("填充字段") - private @UInt long reserved; - @FieldDescription("填充字段") - private @UInt long reserved1; - @FieldDescription("填充字段") - private @UInt long reserved2; -} diff --git a/common/core/info/pet/PetSkillSwitchInboundInfo.java b/common/core/info/pet/PetSkillSwitchInboundInfo.java deleted file mode 100644 index d2545048b..000000000 --- a/common/core/info/pet/PetSkillSwitchInboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.info.pet.skill.ChangeSkillInfo; - -@AutoCodec -@Data -@InboundMessageType(MessageCommandIDRegistry.Pet_Skill_Switch) -public class PetSkillSwitchInboundInfo implements InboundMessage { - private ChangeSkillInfo skillInfo; -} diff --git a/common/core/info/pet/PetSkillSwitchOutboundInfo.java b/common/core/info/pet/PetSkillSwitchOutboundInfo.java deleted file mode 100644 index f7151a6a2..000000000 --- a/common/core/info/pet/PetSkillSwitchOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@AutoCodec -@Data -@Builder -@OutboundMessageType(MessageCommandIDRegistry.Pet_Skill_Switch) -public class PetSkillSwitchOutboundInfo implements OutboundMessage { - private @UInt long catchTime; -} diff --git a/common/core/info/pet/PetStudySkillInboundInfo.java b/common/core/info/pet/PetStudySkillInboundInfo.java deleted file mode 100644 index 98a55c4c0..000000000 --- a/common/core/info/pet/PetStudySkillInboundInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.info.pet.skill.ChangeSkillInfo; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Study_Skill) -public class PetStudySkillInboundInfo implements InboundMessage { - private ChangeSkillInfo skillInfo; -} diff --git a/common/core/info/pet/PetStudySkillOutboundInfo.java b/common/core/info/pet/PetStudySkillOutboundInfo.java deleted file mode 100644 index ed6387b41..000000000 --- a/common/core/info/pet/PetStudySkillOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Study_Skill) -public class PetStudySkillOutboundInfo implements OutboundMessage { - private @UInt long catchTime; -} diff --git a/common/core/info/pet/PetUpdateOutboundInfo.java b/common/core/info/pet/PetUpdateOutboundInfo.java deleted file mode 100644 index 3c43c530e..000000000 --- a/common/core/info/pet/PetUpdateOutboundInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.List; - -@AutoCodec -@SuperBuilder -@Data -@OutboundMessageType(MessageCommandIDRegistry.Note_Update_Prop) -public class PetUpdateOutboundInfo implements OutboundMessage { - @FieldDescription("未知字段,默认为0") - private @UInt long addition; - @FieldDescription("更新数据") - private List data; -} diff --git a/common/core/info/pet/RoomPetInfoInboundInfo.java b/common/core/info/pet/RoomPetInfoInboundInfo.java deleted file mode 100644 index f89230ae1..000000000 --- a/common/core/info/pet/RoomPetInfoInboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@AutoCodec -@Data -@InboundMessageType(MessageCommandIDRegistry.Pet_Room) -public class RoomPetInfoInboundInfo implements InboundMessage { - - @FieldDescription("精灵所属主人的用户ID") - private @UInt long ownerID; - - @FieldDescription("精灵的捕获时间") - private @UInt long catchTime; -} diff --git a/common/core/info/pet/RoomPetInfoOutboundInfo.java b/common/core/info/pet/RoomPetInfoOutboundInfo.java deleted file mode 100644 index 747ab92e3..000000000 --- a/common/core/info/pet/RoomPetInfoOutboundInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@AutoCodec -@Data -@OutboundMessageType(MessageCommandIDRegistry.Pet_Room) -public class RoomPetInfoOutboundInfo implements OutboundMessage { - - @FieldDescription("精灵所属主人的用户ID") - private @UInt long ownerID; // 与前端发送过来的包数据相同 - - @FieldDescription("精灵的捕获时间") - private @UInt long catchTime; // 与前端发送过来的包数据相同 - - @FieldDescription("精灵的类别ID") - public @UInt long id; - - @FieldDescription("精灵的性格id") - public @UInt long nature; - - @FieldDescription("精灵的等级") - public @UInt long lv; - - @FieldDescription("精灵的HP") - public @UInt long hp; - - @FieldDescription("精灵的攻击") - public @UInt long atk; - - @FieldDescription("精灵的防御") - public @UInt long def; - - @FieldDescription("精灵的特攻") - public @UInt long spatk; - - @FieldDescription("精灵的特防") - public @UInt long spdef; - - @FieldDescription("精灵的速度") - public @UInt long speed; - - @FieldDescription("填充字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 55) - public byte[] reserved = new byte[55]; -} diff --git a/common/core/info/pet/UpdatePropInfo.java b/common/core/info/pet/UpdatePropInfo.java deleted file mode 100644 index 466545b9a..000000000 --- a/common/core/info/pet/UpdatePropInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@AutoCodec -@SuperBuilder -public class UpdatePropInfo { - @FieldDescription("精灵的捕获时间") - private @UInt long catchTime; - @FieldDescription("精灵id") - private @UInt long id; - @FieldDescription("精灵等级") - private @UInt long level; - @FieldDescription("已获得的总经验") - private @UInt long exp; - @FieldDescription("升到下一级所需总经验") - private @UInt long currentLevelExp; - @FieldDescription("到下一级升级所需的经验") - private @UInt long nextLvExp; - @FieldDescription("最大血量") - private @UInt long maxHp; - @FieldDescription("攻击") - private @UInt long attack; - @FieldDescription("防御") - private @UInt long defence; - @FieldDescription("特攻") - private @UInt long sa; - @FieldDescription("特防") - private @UInt long sd; - @FieldDescription("速度") - private @UInt long sp; - @FieldDescription("hp学习力") - private @UInt long ev_hp; - @FieldDescription("攻击学习力") - private @UInt long ev_a; - @FieldDescription("防御学习力") - private @UInt long ev_d; - @FieldDescription("特攻学习力") - private @UInt long ev_sa; - @FieldDescription("特防学习力") - private @UInt long ev_sd; - @FieldDescription("速度学习力") - private @UInt long ev_sp; -} diff --git a/common/core/info/pet/UpdateSkillInfo.java b/common/core/info/pet/UpdateSkillInfo.java deleted file mode 100644 index 8d572b09a..000000000 --- a/common/core/info/pet/UpdateSkillInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -import java.util.List; - -@SuperBuilder -@Data -public class UpdateSkillInfo { - @FieldDescription("精灵获得时间") - private @UInt long petCatchTime; - @FieldDescription("能直接放到精灵技能列表里的技能数量, 若没有剩余空闲技能格子则为0, 上限为3") - private @UInt long activeSkillNum; - @FieldDescription("填充格子后精灵还能学习的技能个数, 若学习技能数量小于剩余格子数则为0") - private @UInt long unActiveSkillNum; - @FieldDescription("精灵升级后新学习的技能id列表") - private List<@UInt Integer> skillArray; -} diff --git a/common/core/info/pet/UpdateSkillOutboundInfo.java b/common/core/info/pet/UpdateSkillOutboundInfo.java deleted file mode 100644 index 178179537..000000000 --- a/common/core/info/pet/UpdateSkillOutboundInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.List; - -@Data -@SuperBuilder -@OutboundMessageType(MessageCommandIDRegistry.Note_Update_Skill) -public class UpdateSkillOutboundInfo implements OutboundMessage { - @FieldDescription("更新技能数据") - private List infoArray; -} diff --git a/common/core/info/pet/bag/GetPetListInboundEmpty.java b/common/core/info/pet/bag/GetPetListInboundEmpty.java deleted file mode 100644 index 4a8ab9ff3..000000000 --- a/common/core/info/pet/bag/GetPetListInboundEmpty.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Get_Pet_List) -public class GetPetListInboundEmpty implements InboundMessage { -} diff --git a/common/core/info/pet/bag/GetPetListOutboundInfo.java b/common/core/info/pet/bag/GetPetListOutboundInfo.java deleted file mode 100644 index a21850814..000000000 --- a/common/core/info/pet/bag/GetPetListOutboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.pet.PetShortInfo; - -import java.util.List; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Get_Pet_List) -public class GetPetListOutboundInfo implements OutboundMessage { - @FieldDescription("精灵摘要信息列表") - private List petShortInfo; -} diff --git a/common/core/info/pet/bag/PetDefaultInboundInfo.java b/common/core/info/pet/bag/PetDefaultInboundInfo.java deleted file mode 100644 index 163e33928..000000000 --- a/common/core/info/pet/bag/PetDefaultInboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Default) -public class PetDefaultInboundInfo implements InboundMessage { - @FieldDescription("精灵捕捉时间") - private @UInt long catchTime; -} diff --git a/common/core/info/pet/bag/PetDefaultOutboundInfo.java b/common/core/info/pet/bag/PetDefaultOutboundInfo.java deleted file mode 100644 index 176b00703..000000000 --- a/common/core/info/pet/bag/PetDefaultOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Default) -public class PetDefaultOutboundInfo implements OutboundMessage { - @FieldDescription("0: 首发设置失败,1: 首发设置成功") - private @UInt long isDefault; -} diff --git a/common/core/info/pet/bag/PetReleaseInboundInfo.java b/common/core/info/pet/bag/PetReleaseInboundInfo.java deleted file mode 100644 index 98e40098a..000000000 --- a/common/core/info/pet/bag/PetReleaseInboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@AutoCodec -@Data -@InboundMessageType(MessageCommandIDRegistry.Pet_Release) -public class PetReleaseInboundInfo implements InboundMessage { - @FieldDescription("精灵生成时间") - private @UInt long catchTime; - @FieldDescription("0为放入仓库,1为放入背包") - private @UInt long flag; -} diff --git a/common/core/info/pet/bag/PetReleaseOutboundInfo.java b/common/core/info/pet/bag/PetReleaseOutboundInfo.java deleted file mode 100644 index c28b53299..000000000 --- a/common/core/info/pet/bag/PetReleaseOutboundInfo.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.pet.PetInfo; - -import java.util.List; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Release) -public class PetReleaseOutboundInfo implements OutboundMessage { - @FieldDescription("暂定0") - private @UInt long homeEnergy; - @FieldDescription("精灵生成时间") - private @UInt long firstPetTime; - // @FieldDescription("0为放入仓库,1为放入背包") - // private @UInt long flag; - // petInfo 最大长度应该为1 - // 当flag为0时,放回仓库;当flag为1时,放回背包 - // 即:List长度为0时,表示放回仓库;长度为1时,表示放回背包 - @FieldDescription("精灵信息") - private List petInfo; -} diff --git a/common/core/info/pet/bag/PetRoweiInboundInfo.java b/common/core/info/pet/bag/PetRoweiInboundInfo.java deleted file mode 100644 index f3ed391a1..000000000 --- a/common/core/info/pet/bag/PetRoweiInboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Rowei) -public class PetRoweiInboundInfo implements InboundMessage { - - @FieldDescription("精灵类型ID") - private @UInt long typeId; - - @FieldDescription("精灵捕捉时间") - private @UInt long catchTime; -} diff --git a/common/core/info/pet/bag/PetRoweiListInboundEmpty.java b/common/core/info/pet/bag/PetRoweiListInboundEmpty.java deleted file mode 100644 index 149bee1ed..000000000 --- a/common/core/info/pet/bag/PetRoweiListInboundEmpty.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Rowei_List) -public class PetRoweiListInboundEmpty implements InboundMessage { -} diff --git a/common/core/info/pet/bag/PetRoweiListOutboundInfo.java b/common/core/info/pet/bag/PetRoweiListOutboundInfo.java deleted file mode 100644 index 326b7506a..000000000 --- a/common/core/info/pet/bag/PetRoweiListOutboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.pet.PetShortInfo; - -import java.util.List; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Rowei_List) -public class PetRoweiListOutboundInfo implements OutboundMessage { - @FieldDescription("精灵摘要信息列表") - private List petShortInfo; -} diff --git a/common/core/info/pet/bag/PetRoweiOutboundEmpty.java b/common/core/info/pet/bag/PetRoweiOutboundEmpty.java deleted file mode 100644 index f5058d81b..000000000 --- a/common/core/info/pet/bag/PetRoweiOutboundEmpty.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.bag; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Rowei) -public class PetRoweiOutboundEmpty implements OutboundMessage { -} diff --git a/common/core/info/pet/skill/ChangeSkillInfo.java b/common/core/info/pet/skill/ChangeSkillInfo.java deleted file mode 100644 index 64f8ef76e..000000000 --- a/common/core/info/pet/skill/ChangeSkillInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.skill; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -public class ChangeSkillInfo { - @FieldDescription("精灵生成时间") - private @UInt long catchTime; - @FieldDescription("填充字段,默认为1") - private @UInt long reserved; - @FieldDescription("填充字段,默认为1") - private @UInt long reserved1; - @FieldDescription("拥有的技能id") - private @UInt long hasSkill; - @FieldDescription("替换技能的id") - private @UInt long replaceSkill; -} diff --git a/common/core/info/pet/skill/SkillInfo.java b/common/core/info/pet/skill/SkillInfo.java deleted file mode 100644 index 446197232..000000000 --- a/common/core/info/pet/skill/SkillInfo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.skill; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class SkillInfo { - public @UInt long id; //技能id - public @UInt long pp; //剩余pp -} diff --git a/common/core/info/pet/soulBead/GetSoulBeadInboundInfo.java b/common/core/info/pet/soulBead/GetSoulBeadInboundInfo.java deleted file mode 100644 index e87eb4a42..000000000 --- a/common/core/info/pet/soulBead/GetSoulBeadInboundInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.soulBead; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Get_Soul_Bead_List) -public class GetSoulBeadInboundInfo implements InboundMessage { - public static final @Nonnull GetSoulBeadInboundInfo INSTANCE = new GetSoulBeadInboundInfo(); -} diff --git a/common/core/info/pet/soulBead/GetSoulBeadOutboundInfo.java b/common/core/info/pet/soulBead/GetSoulBeadOutboundInfo.java deleted file mode 100644 index f7dabb22a..000000000 --- a/common/core/info/pet/soulBead/GetSoulBeadOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.soulBead; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -import java.util.ArrayList; -import java.util.List; - -@Data -@OutboundMessageType(MessageCommandIDRegistry.Get_Soul_Bead_List) -public class GetSoulBeadOutboundInfo implements OutboundMessage { - @FieldDescription("元神珠信息") - private List soulBeadList = new ArrayList<>(); -} diff --git a/common/core/info/pet/soulBead/SoulBeadItemInfo.java b/common/core/info/pet/soulBead/SoulBeadItemInfo.java deleted file mode 100644 index a1153cf5e..000000000 --- a/common/core/info/pet/soulBead/SoulBeadItemInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.pet.soulBead; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@FieldDescription("元神珠信息") -public class SoulBeadItemInfo { - @FieldDescription("获得时间") - private @UInt long obtainTime; - @FieldDescription("物品ID") - private @UInt long itemId; -} diff --git a/common/core/info/team/TeamInfo.java b/common/core/info/team/TeamInfo.java deleted file mode 100644 index bfd793f99..000000000 --- a/common/core/info/team/TeamInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.nieo.seerproject.common.net.info.team; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -@SuppressWarnings("SpellCheckingInspection") -public class TeamInfo { - @FieldDescription("默认值0") - private @UInt long id; - @FieldDescription("默认值1") - private @UInt long priv = 1; - @FieldDescription("默认值1") - private @UInt long superCore = 1; - @FieldDescription("默认值1") - private @UInt long isShow = 1; - @FieldDescription("默认值1") - private @UInt long allContribution = 1; - @FieldDescription("默认值1") - private @UInt long canExContribution = 1; -} diff --git a/common/core/info/team/TeamPKInfo.java b/common/core/info/team/TeamPKInfo.java deleted file mode 100644 index 40f307708..000000000 --- a/common/core/info/team/TeamPKInfo.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.nieo.seerproject.common.net.info.team; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.serialize.UInt; - -@Data -public class TeamPKInfo { - @FieldDescription("默认值1") - private @UInt long groupID = 1; - @FieldDescription("默认值1") - private @UInt long homeTeamID = 1; -} diff --git a/common/core/info/user/ChangePlayerClothInboundInfo.java b/common/core/info/user/ChangePlayerClothInboundInfo.java deleted file mode 100644 index d14dd7975..000000000 --- a/common/core/info/user/ChangePlayerClothInboundInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import java.util.List; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Change_Cloth) -public class ChangePlayerClothInboundInfo implements InboundMessage { - @FieldDescription("玩家装备列表") - private List clothIds; -} diff --git a/common/core/info/user/ChangePlayerClothOutboundInfo.java b/common/core/info/user/ChangePlayerClothOutboundInfo.java deleted file mode 100644 index d3ed189c3..000000000 --- a/common/core/info/user/ChangePlayerClothOutboundInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Data; -import lombok.experimental.SuperBuilder; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.item.PeopleItemInfo; - -import java.util.List; - -@Data -@AutoCodec -@SuperBuilder -@OutboundMessageType(MessageCommandIDRegistry.Change_Cloth) -public class ChangePlayerClothOutboundInfo implements OutboundMessage { - @FieldDescription("玩家id") - private @UInt long userId; - @FieldDescription("玩家装备列表") - private List clothList; -} diff --git a/common/core/info/user/ChangePlayerNameInboundInfo.java b/common/core/info/user/ChangePlayerNameInboundInfo.java deleted file mode 100644 index 5952c0d63..000000000 --- a/common/core/info/user/ChangePlayerNameInboundInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; - -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Change_Nick_Name) -public class ChangePlayerNameInboundInfo implements InboundMessage { - @FieldDescription("修改的玩家名字") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String newPlayerName; -} diff --git a/common/core/info/user/ChangePlayerNameOutboundInfo.java b/common/core/info/user/ChangePlayerNameOutboundInfo.java deleted file mode 100644 index e697abf58..000000000 --- a/common/core/info/user/ChangePlayerNameOutboundInfo.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - - -@Data -@Builder -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Change_Nick_Name) -public class ChangePlayerNameOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userId; - @FieldDescription("修改的玩家名字") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String changeName; -} diff --git a/common/core/info/user/GetPetExpInboundInfo.java b/common/core/info/user/GetPetExpInboundInfo.java deleted file mode 100644 index d7303f89c..000000000 --- a/common/core/info/user/GetPetExpInboundInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Pet_Get_Exp) -public class GetPetExpInboundInfo implements InboundMessage { -} diff --git a/common/core/info/user/GetPetExpOutboundInfo.java b/common/core/info/user/GetPetExpOutboundInfo.java deleted file mode 100644 index 5324b9099..000000000 --- a/common/core/info/user/GetPetExpOutboundInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Data -@Builder -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Pet_Get_Exp) -public class GetPetExpOutboundInfo implements OutboundMessage { - @FieldDescription("剩余累计经验") - private @UInt long exp; -} diff --git a/common/core/info/user/GoldOnlineRemainInboundInfo.java b/common/core/info/user/GoldOnlineRemainInboundInfo.java deleted file mode 100644 index ce1c40195..000000000 --- a/common/core/info/user/GoldOnlineRemainInboundInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -import javax.annotation.Nonnull; - -@Data -@InboundMessageType(MessageCommandIDRegistry.Gold_Online_Check_Remain) -public class GoldOnlineRemainInboundInfo implements InboundMessage { - public static final @Nonnull GoldOnlineRemainInboundInfo INSTANCE = new GoldOnlineRemainInboundInfo(); -} diff --git a/common/core/info/user/GoldOnlineRemainOutboundInfo.java b/common/core/info/user/GoldOnlineRemainOutboundInfo.java deleted file mode 100644 index 324865069..000000000 --- a/common/core/info/user/GoldOnlineRemainOutboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; - -@Builder -@Data -@OutboundMessageType(MessageCommandIDRegistry.Gold_Online_Check_Remain) -public class GoldOnlineRemainOutboundInfo implements OutboundMessage { - @FieldDescription("金豆数量, 后端返回实际数量需要*100") - private @UInt long goldNumber; -} diff --git a/common/core/info/user/MoreUserInfoInboundInfo.java b/common/core/info/user/MoreUserInfoInboundInfo.java deleted file mode 100644 index 6490a4515..000000000 --- a/common/core/info/user/MoreUserInfoInboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Get_More_UserInfo) -public class MoreUserInfoInboundInfo implements InboundMessage { - @FieldDescription("米米号") - private @UInt long userId; -} diff --git a/common/core/info/user/MoreUserInfoOutboundInfo.java b/common/core/info/user/MoreUserInfoOutboundInfo.java deleted file mode 100644 index dbd58743b..000000000 --- a/common/core/info/user/MoreUserInfoOutboundInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Builder -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Get_More_UserInfo) -public class MoreUserInfoOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userID; - @FieldDescription("昵称 补齐16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nick; - @FieldDescription("注册时间 时间戳 按秒") - private @UInt long registerTime; - @FieldDescription("所有精灵数量") - private @UInt long petAllNum; - @FieldDescription("精灵最大等级") - private @UInt long petMaxLev; - @FieldDescription("spt boos成就 20字节 以任务状态完成 3为击败该boss, 目前spt只有12个, 剩下的长度以3填充") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 20) - @Builder.Default - private byte[] bossAchievement = new byte[20]; - @FieldDescription("教官成绩") - private @UInt long graduationCount; - @FieldDescription("精灵王胜场") - private @UInt long monKingWin; - @FieldDescription("大乱斗胜场") - private @UInt long messWin; - @FieldDescription("勇者之塔层数") - private @UInt long maxStage; - @FieldDescription("星际擂台胜场") - private @UInt long maxArenaWins; -} diff --git a/common/core/info/user/SimUserInfoInboundInfo.java b/common/core/info/user/SimUserInfoInboundInfo.java deleted file mode 100644 index 6113bf9b7..000000000 --- a/common/core/info/user/SimUserInfoInboundInfo.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.InboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.InboundMessage; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; - -@Data -@AutoCodec -@InboundMessageType(MessageCommandIDRegistry.Get_Sim_UserInfo) -public class SimUserInfoInboundInfo implements InboundMessage { - @FieldDescription("米米号") - private @UInt long userId; -} diff --git a/common/core/info/user/SimUserInfoOutboundInfo.java b/common/core/info/user/SimUserInfoOutboundInfo.java deleted file mode 100644 index d8d8ffb69..000000000 --- a/common/core/info/user/SimUserInfoOutboundInfo.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.info.item.PeopleItemInfo; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -import java.util.ArrayList; -import java.util.List; - -@Builder -@Data -@AutoCodec -@OutboundMessageType(MessageCommandIDRegistry.Get_Sim_UserInfo) -public class SimUserInfoOutboundInfo implements OutboundMessage { - @FieldDescription("米米号") - private @UInt long userid; - @FieldDescription("昵称 16字节") - @ArraySerialize(value = ArraySerializeType.FIXED_LENGTH, fixedLength = 16) - private String nick; - @FieldDescription("rgb颜色") - private @UInt long color; - @FieldDescription("纹理 0") - private @UInt long texture; - @FieldDescription("默认值 1 位置") - private @UInt long vip; - @FieldDescription("默认值0 未知") - private @UInt long status; - @FieldDescription("地图类型 进入地图包传入的字段") - private @UInt long mapType; - @FieldDescription("地图id") - private @UInt long mapID; - @FieldDescription("能不能做教官") - private @UInt long isCanBeTeacher; - @FieldDescription("教官id") - private @UInt long teacherID; - @FieldDescription("学生id") - private @UInt long studentID; - @FieldDescription("教官成绩") - private @UInt long graduationCount; - @FieldDescription("vip等级 8") - private @UInt long vipLevel; - @FieldDescription("战队id") - private @UInt long teamId; - @FieldDescription("有没有跟随的精灵") - private @UInt long isShow; - @FieldDescription("穿戴装备") - @Builder.Default - private List clothes = new ArrayList<>(); -} diff --git a/common/core/info/user/SystemMessageOutboundInfo.java b/common/core/info/user/SystemMessageOutboundInfo.java deleted file mode 100644 index 1ed8a5830..000000000 --- a/common/core/info/user/SystemMessageOutboundInfo.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.nieo.seerproject.common.net.info.user; - -import lombok.Builder; -import lombok.Data; -import org.nieo.seerproject.common.annotations.FieldDescription; -import org.nieo.seerproject.common.annotations.OutboundMessageType; -import org.nieo.seerproject.common.annotations.serialize.ArraySerialize; -import org.nieo.seerproject.common.annotations.serialize.AutoCodec; -import org.nieo.seerproject.common.annotations.serialize.UInt; -import org.nieo.seerproject.common.annotations.serialize.UShort; -import org.nieo.seerproject.common.net.MessageCommandIDRegistry; -import org.nieo.seerproject.common.net.OutboundMessage; -import org.nieo.seerproject.common.net.serialize.ArraySerializeType; - -@Data -@AutoCodec -@Builder -@OutboundMessageType(MessageCommandIDRegistry.System_Message) -public class SystemMessageOutboundInfo implements OutboundMessage { - @FieldDescription("参数未知默认为0") - private @UShort short type; - @FieldDescription("npc的id 0无npc 1船长 7博士") - private @UShort short npc; - @FieldDescription("消息时间, 当前的时间戳") - private @UInt long msgTime; - @FieldDescription("消息体") - @ArraySerialize(value = ArraySerializeType.LENGTH_FIRST) - private String msg; -} diff --git a/common/data/entity/Client.go b/common/data/entity/Client.go index b501522d3..c8a69d2ec 100644 --- a/common/data/entity/Client.go +++ b/common/data/entity/Client.go @@ -1,15 +1,15 @@ -package entity - -type ClientData struct { - IsCrossDomain bool //是否跨域过 - player *player //客户实体 -} - -func NewClientData() *ClientData { - cd := &ClientData{ - IsCrossDomain: false, - player: nil, - } - return cd - -} +package entity + +type ClientData struct { + IsCrossDomain bool //是否跨域过 + Player *Player //客户实体 +} + +func NewClientData() *ClientData { + cd := &ClientData{ + IsCrossDomain: false, + Player: nil, + } + return cd + +} diff --git a/common/data/entity/player.go b/common/data/entity/player.go index 7048fc9dd..369bc59dc 100644 --- a/common/data/entity/player.go +++ b/common/data/entity/player.go @@ -1,4 +1,4 @@ -package entity - -type player struct { -} +package entity + +type Player struct { +} diff --git a/common/serialize/Serialize_test.go b/common/serialize/Serialize_test.go index a1e3caeb8..90f0b1da6 100644 --- a/common/serialize/Serialize_test.go +++ b/common/serialize/Serialize_test.go @@ -1,7 +1,7 @@ package serialize import ( - "blazing/common/core/info" + "blazing/common/core/info/login" "blazing/common/core/info/pet" "fmt" "testing" @@ -10,7 +10,7 @@ import ( func TestDefaultPacketSerializer(t *testing.T) { serializer := NewFixedVarSerializer(nil) - tt := info.NewServerInfo() + tt := login.NewServerInfo() tt.OnlineID = 99 tt.IP = "127.0.0.1" // tt1 := serialize.NewDefaultPacketHandler[info.ServerInfo]() diff --git a/common/serialize/sturc/.travis.yml b/common/serialize/sturc/.travis.yml new file mode 100644 index 000000000..757ab37dc --- /dev/null +++ b/common/serialize/sturc/.travis.yml @@ -0,0 +1,10 @@ +language: go +sudo: false + +script: go test -v + +go: + - 1.3 + - 1.12 + - 1.13 + - tip diff --git a/common/serialize/sturc/LICENSE b/common/serialize/sturc/LICENSE new file mode 100644 index 000000000..42e82633f --- /dev/null +++ b/common/serialize/sturc/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 Ryan Hileman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/common/serialize/sturc/README.md b/common/serialize/sturc/README.md new file mode 100644 index 000000000..c4e8aa264 --- /dev/null +++ b/common/serialize/sturc/README.md @@ -0,0 +1,104 @@ +[![Build Status](https://travis-ci.org/lunixbochs/struc.svg?branch=master)](https://travis-ci.org/lunixbochs/struc) [![GoDoc](https://godoc.org/github.com/lunixbochs/struc?status.svg)](https://godoc.org/github.com/lunixbochs/struc) + +struc +==== + +Struc exists to pack and unpack C-style structures from bytes, which is useful for binary files and network protocols. It could be considered an alternative to `encoding/binary`, which requires massive boilerplate for some similar operations. + +Take a look at an [example comparing `struc` and `encoding/binary`](https://bochs.info/p/cxvm9) + +Struc considers usability first. That said, it does cache reflection data and aims to be competitive with `encoding/binary` struct packing in every way, including performance. + +Example struct +---- + +```Go +type Example struct { + Var int `struc:"int32,sizeof=Str"` + Str string + Weird []byte `struc:"[8]int64"` + Weird []byte `struc:"[32]byte"` + Var []int `struc:"[]int32,little"` +} +``` + +Struct tag format +---- + + - ```Var []int `struc:"[]int32,little,sizeof=StringField"` ``` will pack Var as a slice of little-endian int32, and link it as the size of `StringField`. + - `sizeof=`: Indicates this field is a number used to track the length of a another field. `sizeof` fields are automatically updated on `Pack()` based on the current length of the tracked field, and are used to size the target field during `Unpack()`. + - Bare values will be parsed as type and endianness. + +Endian formats +---- + + - `big` (default) + - `little` + +Recognized types +---- + + - `pad` - this type ignores field contents and is backed by a `[length]byte` containing nulls + - `bool` + - `byte` + - `int8`, `uint8` + - `int16`, `uint16` + - `int32`, `uint32` + - `int64`, `uint64` + - `float32` + - `float64` + +Types can be indicated as arrays/slices using `[]` syntax. Example: `[]int64`, `[8]int32`. + +Bare slice types (those with no `[size]`) must have a linked `Sizeof` field. + +Private fields are ignored when packing and unpacking. + +Example code +---- + +```Go +package main + +import ( + "bytes" + "github.com/lunixbochs/struc" +) + +type Example struct { + A int `struc:"big"` + + // B will be encoded/decoded as a 16-bit int (a "short") + // but is stored as a native int in the struct + B int `struc:"int16"` + + // the sizeof key links a buffer's size to any int field + Size int `struc:"int8,little,sizeof=Str"` + Str string + + // you can get freaky if you want + Str2 string `struc:"[5]int64"` +} + +func main() { + var buf bytes.Buffer + t := &Example{1, 2, 0, "test", "test2"} + err := struc.Pack(&buf, t) + o := &Example{} + err = struc.Unpack(&buf, o) +} +``` + +Benchmark +---- + +`BenchmarkEncode` uses struc. `Stdlib` benchmarks use equivalent `encoding/binary` code. `Manual` encodes without any reflection, and should be considered an upper bound on performance (which generated code based on struc definitions should be able to achieve). + +``` +BenchmarkEncode 1000000 1265 ns/op +BenchmarkStdlibEncode 1000000 1855 ns/op +BenchmarkManualEncode 5000000 284 ns/op +BenchmarkDecode 1000000 1259 ns/op +BenchmarkStdlibDecode 1000000 1656 ns/op +BenchmarkManualDecode 20000000 89.0 ns/op +``` diff --git a/common/serialize/sturc/bench_test.go b/common/serialize/sturc/bench_test.go new file mode 100644 index 000000000..126719b2a --- /dev/null +++ b/common/serialize/sturc/bench_test.go @@ -0,0 +1,203 @@ +package struc + +import ( + "bytes" + "encoding/binary" + "testing" +) + +type BenchExample struct { + Test [5]byte + A int32 + B, C, D int16 + Test2 [4]byte + Length int32 +} + +func BenchmarkArrayEncode(b *testing.B) { + for i := 0; i < b.N; i++ { + var buf bytes.Buffer + if err := Pack(&buf, arrayReference); err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkSliceEncode(b *testing.B) { + for i := 0; i < b.N; i++ { + var buf bytes.Buffer + if err := Pack(&buf, sliceReference); err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkArrayDecode(b *testing.B) { + var out ExampleArray + for i := 0; i < b.N; i++ { + buf := bytes.NewBuffer(arraySliceReferenceBytes) + if err := Unpack(buf, &out); err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkSliceDecode(b *testing.B) { + var out ExampleSlice + for i := 0; i < b.N; i++ { + buf := bytes.NewBuffer(arraySliceReferenceBytes) + if err := Unpack(buf, &out); err != nil { + b.Fatal(err) + } + } +} + +type BenchStrucExample struct { + Test [5]byte `struc:"[5]byte"` + A int `struc:"int32"` + B, C, D int `struc:"int16"` + Test2 [4]byte `struc:"[4]byte"` + Length int `struc:"int32,sizeof=Data"` + Data []byte +} + +var benchRef = &BenchExample{ + [5]byte{1, 2, 3, 4, 5}, + 1, 2, 3, 4, + [4]byte{1, 2, 3, 4}, + 8, +} + +var eightBytes = []byte("8bytestr") + +var benchStrucRef = &BenchStrucExample{ + [5]byte{1, 2, 3, 4, 5}, + 1, 2, 3, 4, + [4]byte{1, 2, 3, 4}, + 8, eightBytes, +} + +func BenchmarkEncode(b *testing.B) { + for i := 0; i < b.N; i++ { + var buf bytes.Buffer + err := Pack(&buf, benchStrucRef) + if err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkStdlibEncode(b *testing.B) { + for i := 0; i < b.N; i++ { + var buf bytes.Buffer + err := binary.Write(&buf, binary.BigEndian, benchRef) + if err != nil { + b.Fatal(err) + } + _, err = buf.Write(eightBytes) + if err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkManualEncode(b *testing.B) { + order := binary.BigEndian + s := benchStrucRef + for i := 0; i < b.N; i++ { + var buf bytes.Buffer + tmp := make([]byte, 29) + copy(tmp[0:5], s.Test[:]) + order.PutUint32(tmp[5:9], uint32(s.A)) + order.PutUint16(tmp[9:11], uint16(s.B)) + order.PutUint16(tmp[11:13], uint16(s.C)) + order.PutUint16(tmp[13:15], uint16(s.D)) + copy(tmp[15:19], s.Test2[:]) + order.PutUint32(tmp[19:23], uint32(s.Length)) + copy(tmp[23:], s.Data) + _, err := buf.Write(tmp) + if err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkDecode(b *testing.B) { + var out BenchStrucExample + var buf bytes.Buffer + if err := Pack(&buf, benchStrucRef); err != nil { + b.Fatal(err) + } + bufBytes := buf.Bytes() + for i := 0; i < b.N; i++ { + buf := bytes.NewReader(bufBytes) + err := Unpack(buf, &out) + if err != nil { + b.Fatal(err) + } + out.Data = nil + } +} + +func BenchmarkStdlibDecode(b *testing.B) { + var out BenchExample + var buf bytes.Buffer + binary.Write(&buf, binary.BigEndian, *benchRef) + _, err := buf.Write(eightBytes) + if err != nil { + b.Fatal(err) + } + bufBytes := buf.Bytes() + for i := 0; i < b.N; i++ { + buf := bytes.NewReader(bufBytes) + err := binary.Read(buf, binary.BigEndian, &out) + if err != nil { + b.Fatal(err) + } + tmp := make([]byte, out.Length) + _, err = buf.Read(tmp) + if err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkManualDecode(b *testing.B) { + var o BenchStrucExample + var buf bytes.Buffer + if err := Pack(&buf, benchStrucRef); err != nil { + b.Fatal(err) + } + tmp := buf.Bytes() + order := binary.BigEndian + for i := 0; i < b.N; i++ { + copy(o.Test[:], tmp[0:5]) + o.A = int(order.Uint32(tmp[5:9])) + o.B = int(order.Uint16(tmp[9:11])) + o.C = int(order.Uint16(tmp[11:13])) + o.D = int(order.Uint16(tmp[13:15])) + copy(o.Test2[:], tmp[15:19]) + o.Length = int(order.Uint32(tmp[19:23])) + o.Data = make([]byte, o.Length) + copy(o.Data, tmp[23:]) + } +} + +func BenchmarkFullEncode(b *testing.B) { + for i := 0; i < b.N; i++ { + var buf bytes.Buffer + if err := Pack(&buf, reference); err != nil { + b.Fatal(err) + } + } +} + +func BenchmarkFullDecode(b *testing.B) { + var out Example + for i := 0; i < b.N; i++ { + buf := bytes.NewBuffer(referenceBytes) + if err := Unpack(buf, &out); err != nil { + b.Fatal(err) + } + } +} diff --git a/common/serialize/sturc/binary.go b/common/serialize/sturc/binary.go new file mode 100644 index 000000000..4899d08fd --- /dev/null +++ b/common/serialize/sturc/binary.go @@ -0,0 +1,52 @@ +package struc + +import ( + "encoding/binary" + "io" + "reflect" +) + +type byteWriter struct { + buf []byte + pos int +} + +func (b byteWriter) Write(p []byte) (int, error) { + capacity := len(b.buf) - b.pos + if capacity < len(p) { + p = p[:capacity] + } + if len(p) > 0 { + copy(b.buf[b.pos:], p) + b.pos += len(p) + } + return len(p), nil +} + +type binaryFallback reflect.Value + +func (b binaryFallback) String() string { + return b.String() +} + +func (b binaryFallback) Sizeof(val reflect.Value, options *Options) int { + return binary.Size(val.Interface()) +} + +func (b binaryFallback) Pack(buf []byte, val reflect.Value, options *Options) (int, error) { + tmp := byteWriter{buf: buf} + var order binary.ByteOrder = binary.BigEndian + if options.Order != nil { + order = options.Order + } + err := binary.Write(tmp, order, val.Interface()) + return tmp.pos, err +} + +func (b binaryFallback) Unpack(r io.Reader, val reflect.Value, options *Options) error { + var order binary.ByteOrder = binary.BigEndian + if options.Order != nil { + order = options.Order + } + return binary.Read(r, order, val.Interface()) +} diff --git a/common/serialize/sturc/custom.go b/common/serialize/sturc/custom.go new file mode 100644 index 000000000..c468dce5c --- /dev/null +++ b/common/serialize/sturc/custom.go @@ -0,0 +1,33 @@ +package struc + +import ( + "io" + "reflect" +) + +type Custom interface { + Pack(p []byte, opt *Options) (int, error) + Unpack(r io.Reader, length int, opt *Options) error + Size(opt *Options) int + String() string +} + +type customFallback struct { + custom Custom +} + +func (c customFallback) Pack(p []byte, val reflect.Value, opt *Options) (int, error) { + return c.custom.Pack(p, opt) +} + +func (c customFallback) Unpack(r io.Reader, val reflect.Value, opt *Options) error { + return c.custom.Unpack(r, 1, opt) +} + +func (c customFallback) Sizeof(val reflect.Value, opt *Options) int { + return c.custom.Size(opt) +} + +func (c customFallback) String() string { + return c.custom.String() +} diff --git a/common/serialize/sturc/custom_float16.go b/common/serialize/sturc/custom_float16.go new file mode 100644 index 000000000..722be7657 --- /dev/null +++ b/common/serialize/sturc/custom_float16.go @@ -0,0 +1,78 @@ +package struc + +import ( + "encoding/binary" + "io" + "math" + "strconv" +) + +type Float16 float64 + +func (f *Float16) Pack(p []byte, opt *Options) (int, error) { + order := opt.Order + if order == nil { + order = binary.BigEndian + } + sign := uint16(0) + if *f < 0 { + sign = 1 + } + var frac, exp uint16 + if math.IsInf(float64(*f), 0) { + exp = 0x1f + frac = 0 + } else if math.IsNaN(float64(*f)) { + exp = 0x1f + frac = 1 + } else { + bits := math.Float64bits(float64(*f)) + exp64 := (bits >> 52) & 0x7ff + if exp64 != 0 { + exp = uint16((exp64 - 1023 + 15) & 0x1f) + } + frac = uint16((bits >> 42) & 0x3ff) + } + var out uint16 + out |= sign << 15 + out |= exp << 10 + out |= frac & 0x3ff + order.PutUint16(p, out) + return 2, nil +} +func (f *Float16) Unpack(r io.Reader, length int, opt *Options) error { + order := opt.Order + if order == nil { + order = binary.BigEndian + } + var tmp [2]byte + if _, err := r.Read(tmp[:]); err != nil { + return err + } + val := order.Uint16(tmp[:2]) + sign := (val >> 15) & 1 + exp := int16((val >> 10) & 0x1f) + frac := val & 0x3ff + if exp == 0x1f { + if frac != 0 { + *f = Float16(math.NaN()) + } else { + *f = Float16(math.Inf(int(sign)*-2 + 1)) + } + } else { + var bits uint64 + bits |= uint64(sign) << 63 + bits |= uint64(frac) << 42 + if exp > 0 { + bits |= uint64(exp-15+1023) << 52 + } + *f = Float16(math.Float64frombits(bits)) + } + return nil +} +func (f *Float16) Size(opt *Options) int { + return 2 +} +func (f *Float16) String() string { + return strconv.FormatFloat(float64(*f), 'g', -1, 32) +} diff --git a/common/serialize/sturc/custom_float16_test.go b/common/serialize/sturc/custom_float16_test.go new file mode 100644 index 000000000..11f73cbc4 --- /dev/null +++ b/common/serialize/sturc/custom_float16_test.go @@ -0,0 +1,56 @@ +package struc + +import ( + "bytes" + "encoding/binary" + "fmt" + "math" + "strconv" + "strings" + "testing" +) + +func TestFloat16(t *testing.T) { + // test cases from https://en.wikipedia.org/wiki/Half-precision_floating-point_format#Half_precision_examples + tests := []struct { + B string + F float64 + }{ + //s expnt significand + {"0 01111 0000000000", 1}, + {"0 01111 0000000001", 1.0009765625}, + {"1 10000 0000000000", -2}, + {"0 11110 1111111111", 65504}, + // {"0 00001 0000000000", 0.0000610352}, + // {"0 00000 1111111111", 0.0000609756}, + // {"0 00000 0000000001", 0.0000000596046}, + {"0 00000 0000000000", 0}, + // {"1 00000 0000000000", -0}, + {"0 11111 0000000000", math.Inf(1)}, + {"1 11111 0000000000", math.Inf(-1)}, + {"0 01101 0101010101", 0.333251953125}, + } + for _, test := range tests { + var buf bytes.Buffer + f := Float16(test.F) + if err := Pack(&buf, &f); err != nil { + t.Error("pack failed:", err) + continue + } + bitval, _ := strconv.ParseUint(strings.Replace(test.B, " ", "", -1), 2, 16) + tmp := binary.BigEndian.Uint16(buf.Bytes()) + if tmp != uint16(bitval) { + t.Errorf("incorrect pack: %s != %016b (%f)", test.B, tmp, test.F) + continue + } + var f2 Float16 + if err := Unpack(&buf, &f2); err != nil { + t.Error("unpack failed:", err) + continue + } + // let sprintf deal with (im)precision for me here + if fmt.Sprintf("%f", f) != fmt.Sprintf("%f", f2) { + t.Errorf("incorrect unpack: %016b %f != %f", bitval, f, f2) + } + } +} diff --git a/common/serialize/sturc/custom_test.go b/common/serialize/sturc/custom_test.go new file mode 100644 index 000000000..95d558859 --- /dev/null +++ b/common/serialize/sturc/custom_test.go @@ -0,0 +1,360 @@ +package struc + +import ( + "bytes" + "encoding/binary" + "io" + "reflect" + "strconv" + "testing" +) + +// Custom Type +type Int3 uint32 + +// newInt3 returns a pointer to an Int3 +func newInt3(in int) *Int3 { + i := Int3(in) + return &i +} + +type Int3Struct struct { + I Int3 +} + +func (i *Int3) Pack(p []byte, opt *Options) (int, error) { + var tmp [4]byte + binary.BigEndian.PutUint32(tmp[:], uint32(*i)) + copy(p, tmp[1:]) + return 3, nil +} +func (i *Int3) Unpack(r io.Reader, length int, opt *Options) error { + var tmp [4]byte + if _, err := r.Read(tmp[1:]); err != nil { + return err + } + *i = Int3(binary.BigEndian.Uint32(tmp[:])) + return nil +} +func (i *Int3) Size(opt *Options) int { + return 3 +} +func (i *Int3) String() string { + return strconv.FormatUint(uint64(*i), 10) +} + +// Array of custom type +type ArrayInt3Struct struct { + I [2]Int3 +} + +// Custom type of array of standard type +type DoubleUInt8 [2]uint8 + +type DoubleUInt8Struct struct { + I DoubleUInt8 +} + +func (di *DoubleUInt8) Pack(p []byte, opt *Options) (int, error) { + for i, value := range *di { + p[i] = value + } + + return 2, nil +} + +func (di *DoubleUInt8) Unpack(r io.Reader, length int, opt *Options) error { + for i := 0; i < 2; i++ { + var value uint8 + if err := binary.Read(r, binary.LittleEndian, &value); err != nil { + if err == io.EOF { + return io.ErrUnexpectedEOF + } + return err + } + di[i] = value + } + return nil +} + +func (di *DoubleUInt8) Size(opt *Options) int { + return 2 +} + +func (di *DoubleUInt8) String() string { + panic("not implemented") +} + +// Custom type of array of custom type +type DoubleInt3 [2]Int3 + +type DoubleInt3Struct struct { + D DoubleInt3 +} + +func (di *DoubleInt3) Pack(p []byte, opt *Options) (int, error) { + var out []byte + for _, value := range *di { + tmp := make([]byte, 3) + if _, err := value.Pack(tmp, opt); err != nil { + return 0, err + } + out = append(out, tmp...) + } + copy(p, out) + + return 6, nil +} + +func (di *DoubleInt3) Unpack(r io.Reader, length int, opt *Options) error { + for i := 0; i < 2; i++ { + di[i].Unpack(r, 0, opt) + } + return nil +} + +func (di *DoubleInt3) Size(opt *Options) int { + return 6 +} + +func (di *DoubleInt3) String() string { + panic("not implemented") +} + +// Custom type of slice of standard type +// Slice of uint8, stored in a zero terminated list. +type SliceUInt8 []uint8 + +type SliceUInt8Struct struct { + I SliceUInt8 + N uint8 // A field after to ensure the length is correct. +} + +func (ia *SliceUInt8) Pack(p []byte, opt *Options) (int, error) { + for i, value := range *ia { + p[i] = value + } + + return len(*ia) + 1, nil +} + +func (ia *SliceUInt8) Unpack(r io.Reader, length int, opt *Options) error { + for { + var value uint8 + if err := binary.Read(r, binary.LittleEndian, &value); err != nil { + if err == io.EOF { + return io.ErrUnexpectedEOF + } + return err + } + if value == 0 { + break + } + *ia = append(*ia, value) + } + return nil +} + +func (ia *SliceUInt8) Size(opt *Options) int { + return len(*ia) + 1 +} + +func (ia *SliceUInt8) String() string { + panic("not implemented") +} + +type ArrayOfUInt8Struct struct { + I [2]uint8 +} + +// Custom 4-character fixed string, similar to CHAR(4) in SQL. +type Char4 string + +func (*Char4) Size(opt *Options) int { + return 4 +} + +func (c *Char4) Pack(p []byte, opt *Options) (int, error) { + buf := []byte(*c) + buf = append(buf, make([]byte, c.Size(nil)-len(buf))...) + + copy(p, buf) + return len(buf), nil +} + +func (c *Char4) Unpack(r io.Reader, length int, opt *Options) error { + buf := bytes.Buffer{} + if _, err := buf.ReadFrom(r); err != nil { + if err == io.EOF { + return io.ErrUnexpectedEOF + } + return err + } + + *c = Char4(buf.String()) + return nil +} + +func (c *Char4) String() string { + return string(*c) +} + +type Char4Struct struct { + C Char4 +} + +func TestCustomTypes(t *testing.T) { + testCases := []struct { + name string + packObj interface{} + emptyObj interface{} + expectBytes []byte + skip bool // Skip the test, because it fails. + // Switch to expectFail when possible: + // https://github.com/golang/go/issues/25951 + }{ + // Start tests with unimplemented non-custom types. + { + name: "ArrayOfUInt8", + packObj: [2]uint8{32, 64}, + emptyObj: [2]uint8{0, 0}, + expectBytes: []byte{32, 64}, + skip: true, // Not implemented. + }, + { + name: "PointerToArrayOfUInt8", + packObj: &[2]uint8{32, 64}, + emptyObj: &[2]uint8{0, 0}, + expectBytes: []byte{32, 64}, + skip: true, // Not implemented. + }, + { + name: "ArrayOfUInt8Struct", + packObj: &ArrayOfUInt8Struct{I: [2]uint8{32, 64}}, + emptyObj: &ArrayOfUInt8Struct{}, + expectBytes: []byte{32, 64}, + }, + { + name: "CustomType", + packObj: newInt3(3), + emptyObj: newInt3(0), + expectBytes: []byte{0, 0, 3}, + }, + { + name: "CustomType-Big", + packObj: newInt3(4000), + emptyObj: newInt3(0), + expectBytes: []byte{0, 15, 160}, + }, + { + name: "CustomTypeStruct", + packObj: &Int3Struct{3}, + emptyObj: &Int3Struct{}, + expectBytes: []byte{0, 0, 3}, + }, + { + name: "ArrayOfCustomType", + packObj: [2]Int3{3, 4}, + emptyObj: [2]Int3{}, + expectBytes: []byte{0, 0, 3, 0, 0, 4}, + skip: true, // Not implemented. + }, + { + name: "PointerToArrayOfCustomType", + packObj: &[2]Int3{3, 4}, + emptyObj: &[2]Int3{}, + expectBytes: []byte{0, 0, 3, 0, 0, 4}, + skip: true, // Not implemented. + }, + { + name: "ArrayOfCustomTypeStruct", + packObj: &ArrayInt3Struct{[2]Int3{3, 4}}, + emptyObj: &ArrayInt3Struct{}, + expectBytes: []byte{0, 0, 3, 0, 0, 4}, + skip: true, // Not implemented. + }, + { + name: "CustomTypeOfArrayOfUInt8", + packObj: &DoubleUInt8{32, 64}, + emptyObj: &DoubleUInt8{}, + expectBytes: []byte{32, 64}, + }, + { + name: "CustomTypeOfArrayOfUInt8Struct", + packObj: &DoubleUInt8Struct{I: DoubleUInt8{32, 64}}, + emptyObj: &DoubleUInt8Struct{}, + expectBytes: []byte{32, 64}, + skip: true, // Not implemented. + }, + { + name: "CustomTypeOfArrayOfCustomType", + packObj: &DoubleInt3{Int3(128), Int3(256)}, + emptyObj: &DoubleInt3{}, + expectBytes: []byte{0, 0, 128, 0, 1, 0}, + }, + { + name: "CustomTypeOfArrayOfCustomTypeStruct", + packObj: &DoubleInt3Struct{D: DoubleInt3{Int3(128), Int3(256)}}, + emptyObj: &DoubleInt3Struct{}, + expectBytes: []byte{0, 0, 128, 0, 1, 0}, + skip: true, // Not implemented. + }, + { + name: "CustomTypeOfSliceOfUInt8", + packObj: &SliceUInt8{128, 64, 32}, + emptyObj: &SliceUInt8{}, + expectBytes: []byte{128, 64, 32, 0}, + }, + { + name: "CustomTypeOfSliceOfUInt8-Empty", + packObj: &SliceUInt8{}, + emptyObj: &SliceUInt8{}, + expectBytes: []byte{0}, + }, + { + name: "CustomTypeOfSliceOfUInt8Struct", + packObj: &SliceUInt8Struct{I: SliceUInt8{128, 64, 32}, N: 192}, + emptyObj: &SliceUInt8Struct{}, + expectBytes: []byte{128, 64, 32, 0, 192}, + skip: true, // Not implemented. + }, + { + name: "CustomTypeOfChar4Struct", + packObj: &Char4Struct{C: Char4("foo\x00")}, + emptyObj: &Char4Struct{}, + expectBytes: []byte{102, 111, 111, 0}, + }, + } + + for _, test := range testCases { + // TODO: Switch to t.Run() when Go 1.7 is the minimum supported version. + t.Log("RUN ", test.name) + runner := func(t *testing.T) { + defer func() { + if r := recover(); r != nil { + t.Log("unexpected panic:", r) + t.Error(r) + } + }() + if test.skip { + // TODO: Switch to t.Skip() when Go 1.7 is supported + t.Log("skipped unimplemented") + return + } + var buf bytes.Buffer + if err := Pack(&buf, test.packObj); err != nil { + t.Fatal(err) + } + if !bytes.Equal(buf.Bytes(), test.expectBytes) { + t.Fatal("error packing, expect:", test.expectBytes, "found:", buf.Bytes()) + } + if err := Unpack(&buf, test.emptyObj); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(test.packObj, test.emptyObj) { + t.Fatal("error unpacking, expect:", test.packObj, "found:", test.emptyObj) + } + } + runner(t) + } +} diff --git a/common/serialize/sturc/field.go b/common/serialize/sturc/field.go new file mode 100644 index 000000000..b1f766b38 --- /dev/null +++ b/common/serialize/sturc/field.go @@ -0,0 +1,288 @@ +package struc + +import ( + "bytes" + "encoding/binary" + "fmt" + "math" + "reflect" +) + +type Field struct { + Name string + Ptr bool + Index int + Type Type + defType Type + Array bool + Slice bool + Len int + Order binary.ByteOrder + Sizeof []int + Sizefrom []int + Fields Fields + kind reflect.Kind +} + +func (f *Field) String() string { + var out string + if f.Type == Pad { + return fmt.Sprintf("{type: Pad, len: %d}", f.Len) + } else { + out = fmt.Sprintf("type: %s, order: %v", f.Type.String(), f.Order) + } + if f.Sizefrom != nil { + out += fmt.Sprintf(", sizefrom: %v", f.Sizefrom) + } else if f.Len > 0 { + out += fmt.Sprintf(", len: %d", f.Len) + } + if f.Sizeof != nil { + out += fmt.Sprintf(", sizeof: %v", f.Sizeof) + } + return "{" + out + "}" +} + +func (f *Field) Size(val reflect.Value, options *Options) int { + typ := f.Type.Resolve(options) + size := 0 + if typ == Struct { + vals := []reflect.Value{val} + if f.Slice { + vals = make([]reflect.Value, val.Len()) + for i := 0; i < val.Len(); i++ { + vals[i] = val.Index(i) + } + } + for _, val := range vals { + size += f.Fields.Sizeof(val, options) + } + } else if typ == Pad { + size = f.Len + } else if typ == CustomType { + return val.Addr().Interface().(Custom).Size(options) + } else if f.Slice || f.kind == reflect.String { + length := val.Len() + if f.Len > 1 { + length = f.Len + } + size = length * typ.Size() + } else { + size = typ.Size() + } + align := options.ByteAlign + if align > 0 && size < align { + size = align + } + return size +} + +func (f *Field) packVal(buf []byte, val reflect.Value, length int, options *Options) (size int, err error) { + order := f.Order + if options.Order != nil { + order = options.Order + } + if f.Ptr { + val = val.Elem() + } + typ := f.Type.Resolve(options) + switch typ { + case Struct: + return f.Fields.Pack(buf, val, options) + case Bool, Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64: + size = typ.Size() + var n uint64 + switch f.kind { + case reflect.Bool: + if val.Bool() { + n = 1 + } else { + n = 0 + } + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + n = uint64(val.Int()) + default: + n = val.Uint() + } + switch typ { + case Bool: + if n != 0 { + buf[0] = 1 + } else { + buf[0] = 0 + } + case Int8, Uint8: + buf[0] = byte(n) + case Int16, Uint16: + order.PutUint16(buf, uint16(n)) + case Int32, Uint32: + order.PutUint32(buf, uint32(n)) + case Int64, Uint64: + order.PutUint64(buf, uint64(n)) + } + case Float32, Float64: + size = typ.Size() + n := val.Float() + switch typ { + case Float32: + order.PutUint32(buf, math.Float32bits(float32(n))) + case Float64: + order.PutUint64(buf, math.Float64bits(n)) + } + case String: + switch f.kind { + case reflect.String: + size = val.Len() + copy(buf, []byte(val.String())) + default: + // TODO: handle kind != bytes here + size = val.Len() + copy(buf, val.Bytes()) + } + case CustomType: + return val.Addr().Interface().(Custom).Pack(buf, options) + default: + panic(fmt.Sprintf("no pack handler for type: %s", typ)) + } + return +} + +func (f *Field) Pack(buf []byte, val reflect.Value, length int, options *Options) (int, error) { + typ := f.Type.Resolve(options) + if typ == Pad { + for i := 0; i < length; i++ { + buf[i] = 0 + } + return length, nil + } + if f.Slice { + // special case strings and byte slices for performance + end := val.Len() + if !f.Array && typ == Uint8 && (f.defType == Uint8 || f.kind == reflect.String) { + var tmp []byte + if f.kind == reflect.String { + tmp = []byte(val.String()) + } else { + tmp = val.Bytes() + } + copy(buf, tmp) + if end < length { + // TODO: allow configuring pad byte? + rep := bytes.Repeat([]byte{0}, length-end) + copy(buf[end:], rep) + return length, nil + } + return val.Len(), nil + } + pos := 0 + var zero reflect.Value + if end < length { + zero = reflect.Zero(val.Type().Elem()) + } + for i := 0; i < length; i++ { + cur := zero + if i < end { + cur = val.Index(i) + } + if n, err := f.packVal(buf[pos:], cur, 1, options); err != nil { + return pos, err + } else { + pos += n + } + } + return pos, nil + } else { + return f.packVal(buf, val, length, options) + } +} + +func (f *Field) unpackVal(buf []byte, val reflect.Value, length int, options *Options) error { + order := f.Order + if options.Order != nil { + order = options.Order + } + if f.Ptr { + val = val.Elem() + } + typ := f.Type.Resolve(options) + switch typ { + case Float32, Float64: + var n float64 + switch typ { + case Float32: + n = float64(math.Float32frombits(order.Uint32(buf))) + case Float64: + n = math.Float64frombits(order.Uint64(buf)) + } + switch f.kind { + case reflect.Float32, reflect.Float64: + val.SetFloat(n) + default: + return fmt.Errorf("struc: refusing to unpack float into field %s of type %s", f.Name, f.kind.String()) + } + case Bool, Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64: + var n uint64 + switch typ { + case Int8: + n = uint64(int64(int8(buf[0]))) + case Int16: + n = uint64(int64(int16(order.Uint16(buf)))) + case Int32: + n = uint64(int64(int32(order.Uint32(buf)))) + case Int64: + n = uint64(int64(order.Uint64(buf))) + case Bool, Uint8: + n = uint64(buf[0]) + case Uint16: + n = uint64(order.Uint16(buf)) + case Uint32: + n = uint64(order.Uint32(buf)) + case Uint64: + n = uint64(order.Uint64(buf)) + } + switch f.kind { + case reflect.Bool: + val.SetBool(n != 0) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + val.SetInt(int64(n)) + default: + val.SetUint(n) + } + default: + panic(fmt.Sprintf("no unpack handler for type: %s", typ)) + } + return nil +} + +func (f *Field) Unpack(buf []byte, val reflect.Value, length int, options *Options) error { + typ := f.Type.Resolve(options) + if typ == Pad || f.kind == reflect.String { + if typ == Pad { + return nil + } else { + val.SetString(string(buf)) + return nil + } + } else if f.Slice { + if val.Cap() < length { + val.Set(reflect.MakeSlice(val.Type(), length, length)) + } else if val.Len() < length { + val.Set(val.Slice(0, length)) + } + // special case byte slices for performance + if !f.Array && typ == Uint8 && f.defType == Uint8 { + copy(val.Bytes(), buf[:length]) + return nil + } + pos := 0 + size := typ.Size() + for i := 0; i < length; i++ { + if err := f.unpackVal(buf[pos:pos+size], val.Index(i), 1, options); err != nil { + return err + } + pos += size + } + return nil + } else { + return f.unpackVal(buf, val, length, options) + } +} diff --git a/common/serialize/sturc/field_test.go b/common/serialize/sturc/field_test.go new file mode 100644 index 000000000..45a07b210 --- /dev/null +++ b/common/serialize/sturc/field_test.go @@ -0,0 +1,77 @@ +package struc + +import ( + "bytes" + "testing" +) + +type badFloat struct { + BadFloat int `struc:"float64"` +} + +func TestBadFloatField(t *testing.T) { + buf := bytes.NewReader([]byte("00000000")) + err := Unpack(buf, &badFloat{}) + if err == nil { + t.Fatal("failed to error on bad float unpack") + } +} + +type emptyLengthField struct { + Strlen int `struc:"sizeof=Str"` + Str []byte +} + +func TestEmptyLengthField(t *testing.T) { + var buf bytes.Buffer + s := &emptyLengthField{0, []byte("test")} + o := &emptyLengthField{} + if err := Pack(&buf, s); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, o); err != nil { + t.Fatal(err) + } + if !bytes.Equal(s.Str, o.Str) { + t.Fatal("empty length field encode failed") + } +} + +type fixedSlicePad struct { + Field []byte `struc:"[4]byte"` +} + +func TestFixedSlicePad(t *testing.T) { + var buf bytes.Buffer + ref := []byte{0, 0, 0, 0} + s := &fixedSlicePad{} + if err := Pack(&buf, s); err != nil { + t.Fatal(err) + } + if !bytes.Equal(buf.Bytes(), ref) { + t.Fatal("implicit fixed slice pack failed") + } + if err := Unpack(&buf, s); err != nil { + t.Fatal(err) + } + if !bytes.Equal(s.Field, ref) { + t.Fatal("implicit fixed slice unpack failed") + } +} + +type sliceCap struct { + Len int `struc:"sizeof=Field"` + Field []byte +} + +func TestSliceCap(t *testing.T) { + var buf bytes.Buffer + tmp := &sliceCap{0, []byte("1234")} + if err := Pack(&buf, tmp); err != nil { + t.Fatal(err) + } + tmp.Field = make([]byte, 0, 4) + if err := Unpack(&buf, tmp); err != nil { + t.Fatal(err) + } +} diff --git a/common/serialize/sturc/fields.go b/common/serialize/sturc/fields.go new file mode 100644 index 000000000..50dc7b21a --- /dev/null +++ b/common/serialize/sturc/fields.go @@ -0,0 +1,177 @@ +package struc + +import ( + "encoding/binary" + "fmt" + "io" + "reflect" + "strings" +) + +type Fields []*Field + +func (f Fields) SetByteOrder(order binary.ByteOrder) { + for _, field := range f { + if field != nil { + field.Order = order + } + } +} + +func (f Fields) String() string { + fields := make([]string, len(f)) + for i, field := range f { + if field != nil { + fields[i] = field.String() + } + } + return "{" + strings.Join(fields, ", ") + "}" +} + +func (f Fields) Sizeof(val reflect.Value, options *Options) int { + for val.Kind() == reflect.Ptr { + val = val.Elem() + } + size := 0 + for i, field := range f { + if field != nil { + size += field.Size(val.Field(i), options) + } + } + return size +} + +func (f Fields) sizefrom(val reflect.Value, index []int) int { + field := val.FieldByIndex(index) + switch field.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return int(field.Int()) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + n := int(field.Uint()) + // all the builtin array length types are native int + // so this guards against weird truncation + if n < 0 { + return 0 + } + return n + default: + name := val.Type().FieldByIndex(index).Name + panic(fmt.Sprintf("sizeof field %T.%s not an integer type", val.Interface(), name)) + } +} + +func (f Fields) Pack(buf []byte, val reflect.Value, options *Options) (int, error) { + for val.Kind() == reflect.Ptr { + val = val.Elem() + } + pos := 0 + for i, field := range f { + if field == nil { + continue + } + v := val.Field(i) + length := field.Len + if field.Sizefrom != nil { + length = f.sizefrom(val, field.Sizefrom) + } + if length <= 0 && field.Slice { + length = v.Len() + } + if field.Sizeof != nil { + length := val.FieldByIndex(field.Sizeof).Len() + switch field.kind { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + // allocating a new int here has fewer side effects (doesn't update the original struct) + // but it's a wasteful allocation + // the old method might work if we just cast the temporary int/uint to the target type + v = reflect.New(v.Type()).Elem() + v.SetInt(int64(length)) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + v = reflect.New(v.Type()).Elem() + v.SetUint(uint64(length)) + default: + panic(fmt.Sprintf("sizeof field is not int or uint type: %s, %s", field.Name, v.Type())) + } + } + if n, err := field.Pack(buf[pos:], v, length, options); err != nil { + return n, err + } else { + pos += n + } + } + return pos, nil +} + +func (f Fields) Unpack(r io.Reader, val reflect.Value, options *Options) error { + for val.Kind() == reflect.Ptr { + val = val.Elem() + } + var tmp [8]byte + var buf []byte + for i, field := range f { + if field == nil { + continue + } + v := val.Field(i) + length := field.Len + if field.Sizefrom != nil { + length = f.sizefrom(val, field.Sizefrom) + } + if v.Kind() == reflect.Ptr && !v.Elem().IsValid() { + v.Set(reflect.New(v.Type().Elem())) + } + if field.Type == Struct { + if field.Slice { + vals := v + if !field.Array { + vals = reflect.MakeSlice(v.Type(), length, length) + } + for i := 0; i < length; i++ { + v := vals.Index(i) + fields, err := parseFields(v) + if err != nil { + return err + } + if err := fields.Unpack(r, v, options); err != nil { + return err + } + } + if !field.Array { + v.Set(vals) + } + } else { + // TODO: DRY (we repeat the inner loop above) + fields, err := parseFields(v) + if err != nil { + return err + } + if err := fields.Unpack(r, v, options); err != nil { + return err + } + } + continue + } else { + typ := field.Type.Resolve(options) + if typ == CustomType { + if err := v.Addr().Interface().(Custom).Unpack(r, length, options); err != nil { + return err + } + } else { + size := length * field.Type.Resolve(options).Size() + if size < 8 { + buf = tmp[:size] + } else { + buf = make([]byte, size) + } + if _, err := io.ReadFull(r, buf); err != nil { + return err + } + err := field.Unpack(buf[:size], v, length, options) + if err != nil { + return err + } + } + } + } + return nil +} diff --git a/common/serialize/sturc/fields_test.go b/common/serialize/sturc/fields_test.go new file mode 100644 index 000000000..47eb2ca06 --- /dev/null +++ b/common/serialize/sturc/fields_test.go @@ -0,0 +1,81 @@ +package struc + +import ( + "bytes" + "reflect" + "testing" +) + +var refVal = reflect.ValueOf(reference) + +func TestFieldsParse(t *testing.T) { + if _, err := parseFields(refVal); err != nil { + t.Fatal(err) + } +} + +func TestFieldsString(t *testing.T) { + fields, _ := parseFields(refVal) + fields.String() +} + +type sizefromStruct struct { + Size1 uint `struc:"sizeof=Var1"` + Var1 []byte + Size2 int `struc:"sizeof=Var2"` + Var2 []byte +} + +func TestFieldsSizefrom(t *testing.T) { + var test = sizefromStruct{ + Var1: []byte{1, 2, 3}, + Var2: []byte{4, 5, 6}, + } + var buf bytes.Buffer + err := Pack(&buf, &test) + if err != nil { + t.Fatal(err) + } + err = Unpack(&buf, &test) + if err != nil { + t.Fatal(err) + } +} + +type sizefromStructBad struct { + Size1 string `struc:"sizeof=Var1"` + Var1 []byte +} + +func TestFieldsSizefromBad(t *testing.T) { + var test = &sizefromStructBad{Var1: []byte{1, 2, 3}} + var buf bytes.Buffer + defer func() { + if err := recover(); err == nil { + t.Fatal("failed to panic on bad sizeof type") + } + }() + Pack(&buf, &test) +} + +type StructWithinArray struct { + a uint32 +} + +type StructHavingArray struct { + Props [1]StructWithinArray `struc:"[1]StructWithinArray"` +} + +func TestStrucArray(t *testing.T) { + var buf bytes.Buffer + a := &StructHavingArray{[1]StructWithinArray{}} + err := Pack(&buf, a) + if err != nil { + t.Fatal(err) + } + b := &StructHavingArray{} + err = Unpack(&buf, b) + if err != nil { + t.Fatal(err) + } +} diff --git a/common/serialize/sturc/go.mod b/common/serialize/sturc/go.mod new file mode 100644 index 000000000..e2b291eb1 --- /dev/null +++ b/common/serialize/sturc/go.mod @@ -0,0 +1,3 @@ +module github.com/lunixbochs/struc + +go 1.12 diff --git a/common/serialize/sturc/legacy.go b/common/serialize/sturc/legacy.go new file mode 100644 index 000000000..5baf70d98 --- /dev/null +++ b/common/serialize/sturc/legacy.go @@ -0,0 +1,16 @@ +package struc + +import ( + "encoding/binary" + "io" +) + +// Deprecated. Use PackWithOptions. +func PackWithOrder(w io.Writer, data interface{}, order binary.ByteOrder) error { + return PackWithOptions(w, data, &Options{Order: order}) +} + +// Deprecated. Use UnpackWithOptions. +func UnpackWithOrder(r io.Reader, data interface{}, order binary.ByteOrder) error { + return UnpackWithOptions(r, data, &Options{Order: order}) +} diff --git a/common/serialize/sturc/packable_test.go b/common/serialize/sturc/packable_test.go new file mode 100644 index 000000000..ec2bed9be --- /dev/null +++ b/common/serialize/sturc/packable_test.go @@ -0,0 +1,123 @@ +package struc + +import ( + "bytes" + "fmt" + "testing" +) + +var packableReference = []byte{ + 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 5, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, +} + +func TestPackable(t *testing.T) { + var ( + buf bytes.Buffer + + i8 int8 = 1 + i16 int16 = 2 + i32 int32 = 3 + i64 int64 = 4 + u8 uint8 = 5 + u16 uint16 = 6 + u32 uint32 = 7 + u64 uint64 = 8 + + u8a = [8]uint8{9, 10, 11, 12, 13, 14, 15, 16} + u16a = [8]uint16{17, 18, 19, 20, 21, 22, 23, 24} + ) + // pack tests + if err := Pack(&buf, i8); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, i16); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, i32); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, i64); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, u8); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, u16); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, u32); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, u64); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, u8a[:]); err != nil { + t.Fatal(err) + } + if err := Pack(&buf, u16a[:]); err != nil { + t.Fatal(err) + } + if !bytes.Equal(buf.Bytes(), packableReference) { + fmt.Println(buf.Bytes()) + fmt.Println(packableReference) + t.Fatal("Packable Pack() did not match reference.") + } + // unpack tests + i8 = 0 + i16 = 0 + i32 = 0 + i64 = 0 + u8 = 0 + u16 = 0 + u32 = 0 + u64 = 0 + if err := Unpack(&buf, &i8); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &i16); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &i32); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &i64); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &u8); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &u16); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &u32); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, &u64); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, u8a[:]); err != nil { + t.Fatal(err) + } + if err := Unpack(&buf, u16a[:]); err != nil { + t.Fatal(err) + } + // unpack checks + if i8 != 1 || i16 != 2 || i32 != 3 || i64 != 4 { + t.Fatal("Signed integer unpack failed.") + } + if u8 != 5 || u16 != 6 || u32 != 7 || u64 != 8 { + t.Fatal("Unsigned integer unpack failed.") + } + for i := 0; i < 8; i++ { + if u8a[i] != uint8(i+9) { + t.Fatal("uint8 array unpack failed.") + } + } + for i := 0; i < 8; i++ { + if u16a[i] != uint16(i+17) { + t.Fatal("uint16 array unpack failed.") + } + } +} diff --git a/common/serialize/sturc/packer.go b/common/serialize/sturc/packer.go new file mode 100644 index 000000000..a3a91a228 --- /dev/null +++ b/common/serialize/sturc/packer.go @@ -0,0 +1,13 @@ +package struc + +import ( + "io" + "reflect" +) + +type Packer interface { + Pack(buf []byte, val reflect.Value, options *Options) (int, error) + Unpack(r io.Reader, val reflect.Value, options *Options) error + Sizeof(val reflect.Value, options *Options) int + String() string +} diff --git a/common/serialize/sturc/parse.go b/common/serialize/sturc/parse.go new file mode 100644 index 000000000..be0afa706 --- /dev/null +++ b/common/serialize/sturc/parse.go @@ -0,0 +1,230 @@ +package struc + +import ( + "encoding/binary" + "errors" + "fmt" + "reflect" + "regexp" + "strconv" + "strings" + "sync" +) + +// struc:"int32,big,sizeof=Data,skip,sizefrom=Len" + +type strucTag struct { + Type string + Order binary.ByteOrder + Sizeof string + Skip bool + Sizefrom string +} + +func parseStrucTag(tag reflect.StructTag) *strucTag { + t := &strucTag{ + Order: binary.BigEndian, + } + tagStr := tag.Get("struc") + if tagStr == "" { + // someone's going to typo this (I already did once) + // sorry if you made a module actually using this tag + // and you're mad at me now + tagStr = tag.Get("struct") + } + for _, s := range strings.Split(tagStr, ",") { + if strings.HasPrefix(s, "sizeof=") { + tmp := strings.SplitN(s, "=", 2) + t.Sizeof = tmp[1] + } else if strings.HasPrefix(s, "sizefrom=") { + tmp := strings.SplitN(s, "=", 2) + t.Sizefrom = tmp[1] + } else if s == "big" { + t.Order = binary.BigEndian + } else if s == "little" { + t.Order = binary.LittleEndian + } else if s == "skip" { + t.Skip = true + } else { + t.Type = s + } + } + return t +} + +var typeLenRe = regexp.MustCompile(`^\[(\d*)\]`) + +func parseField(f reflect.StructField) (fd *Field, tag *strucTag, err error) { + tag = parseStrucTag(f.Tag) + var ok bool + fd = &Field{ + Name: f.Name, + Len: 1, + Order: tag.Order, + Slice: false, + kind: f.Type.Kind(), + } + switch fd.kind { + case reflect.Array: + fd.Slice = true + fd.Array = true + fd.Len = f.Type.Len() + fd.kind = f.Type.Elem().Kind() + case reflect.Slice: + fd.Slice = true + fd.Len = -1 + fd.kind = f.Type.Elem().Kind() + case reflect.Ptr: + fd.Ptr = true + fd.kind = f.Type.Elem().Kind() + } + // check for custom types + tmp := reflect.New(f.Type) + if _, ok := tmp.Interface().(Custom); ok { + fd.Type = CustomType + return + } + var defTypeOk bool + fd.defType, defTypeOk = reflectTypeMap[fd.kind] + // find a type in the struct tag + pureType := typeLenRe.ReplaceAllLiteralString(tag.Type, "") + if fd.Type, ok = typeLookup[pureType]; ok { + fd.Len = 1 + match := typeLenRe.FindAllStringSubmatch(tag.Type, -1) + if len(match) > 0 && len(match[0]) > 1 { + fd.Slice = true + first := match[0][1] + // Field.Len = -1 indicates a []slice + if first == "" { + fd.Len = -1 + } else { + fd.Len, err = strconv.Atoi(first) + } + } + return + } + // the user didn't specify a type + switch f.Type { + case reflect.TypeOf(Size_t(0)): + fd.Type = SizeType + case reflect.TypeOf(Off_t(0)): + fd.Type = OffType + default: + if defTypeOk { + fd.Type = fd.defType + } else { + err = errors.New(fmt.Sprintf("struc: Could not resolve field '%v' type '%v'.", f.Name, f.Type)) + } + } + return +} + +func parseFieldsLocked(v reflect.Value) (Fields, error) { + // we need to repeat this logic because parseFields() below can't be recursively called due to locking + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + t := v.Type() + if v.NumField() < 1 { + return nil, errors.New("struc: Struct has no fields.") + } + sizeofMap := make(map[string][]int) + fields := make(Fields, v.NumField()) + for i := 0; i < t.NumField(); i++ { + field := t.Field(i) + f, tag, err := parseField(field) + if tag.Skip { + continue + } + if err != nil { + return nil, err + } + if !v.Field(i).CanSet() { + continue + } + f.Index = i + if tag.Sizeof != "" { + target, ok := t.FieldByName(tag.Sizeof) + if !ok { + return nil, fmt.Errorf("struc: `sizeof=%s` field does not exist", tag.Sizeof) + } + f.Sizeof = target.Index + sizeofMap[tag.Sizeof] = field.Index + } + if sizefrom, ok := sizeofMap[field.Name]; ok { + f.Sizefrom = sizefrom + } + if tag.Sizefrom != "" { + source, ok := t.FieldByName(tag.Sizefrom) + if !ok { + return nil, fmt.Errorf("struc: `sizefrom=%s` field does not exist", tag.Sizefrom) + } + f.Sizefrom = source.Index + } + if f.Len == -1 && f.Sizefrom == nil { + return nil, fmt.Errorf("struc: field `%s` is a slice with no length or sizeof field", field.Name) + } + // recurse into nested structs + // TODO: handle loops (probably by indirecting the []Field and putting pointer in cache) + if f.Type == Struct { + typ := field.Type + if f.Ptr { + typ = typ.Elem() + } + if f.Slice { + typ = typ.Elem() + } + f.Fields, err = parseFieldsLocked(reflect.New(typ)) + if err != nil { + return nil, err + } + } + fields[i] = f + } + return fields, nil +} + +var fieldCache = make(map[reflect.Type]Fields) +var fieldCacheLock sync.RWMutex +var parseLock sync.Mutex + +func fieldCacheLookup(t reflect.Type) Fields { + fieldCacheLock.RLock() + defer fieldCacheLock.RUnlock() + if cached, ok := fieldCache[t]; ok { + return cached + } + return nil +} + +func parseFields(v reflect.Value) (Fields, error) { + for v.Kind() == reflect.Ptr { + v = v.Elem() + } + t := v.Type() + + // fast path: hopefully the field parsing is already cached + if cached := fieldCacheLookup(t); cached != nil { + return cached, nil + } + + // hold a global lock so multiple goroutines can't parse (the same) fields at once + parseLock.Lock() + defer parseLock.Unlock() + + // check cache a second time, in case parseLock was just released by + // another thread who filled the cache for us + if cached := fieldCacheLookup(t); cached != nil { + return cached, nil + } + + // no luck, time to parse and fill the cache ourselves + fields, err := parseFieldsLocked(v) + if err != nil { + return nil, err + } + fieldCacheLock.Lock() + fieldCache[t] = fields + fieldCacheLock.Unlock() + return fields, nil +} diff --git a/common/serialize/sturc/parse_test.go b/common/serialize/sturc/parse_test.go new file mode 100644 index 000000000..861fdd192 --- /dev/null +++ b/common/serialize/sturc/parse_test.go @@ -0,0 +1,62 @@ +package struc + +import ( + "bytes" + "reflect" + "testing" +) + +func parseTest(data interface{}) error { + _, err := parseFields(reflect.ValueOf(data)) + return err +} + +type empty struct{} + +func TestEmptyStruc(t *testing.T) { + if err := parseTest(&empty{}); err == nil { + t.Fatal("failed to error on empty struct") + } +} + +type chanStruct struct { + Test chan int +} + +func TestChanError(t *testing.T) { + if err := parseTest(&chanStruct{}); err == nil { + // TODO: should probably ignore channel fields + t.Fatal("failed to error on struct containing channel") + } +} + +type badSizeof struct { + Size int `struc:"sizeof=Bad"` +} + +func TestBadSizeof(t *testing.T) { + if err := parseTest(&badSizeof{}); err == nil { + t.Fatal("failed to error on missing Sizeof target") + } +} + +type missingSize struct { + Test []byte +} + +func TestMissingSize(t *testing.T) { + if err := parseTest(&missingSize{}); err == nil { + t.Fatal("failed to error on missing field size") + } +} + +type badNested struct { + Empty empty +} + +func TestNestedParseError(t *testing.T) { + var buf bytes.Buffer + if err := Pack(&buf, &badNested{}); err == nil { + t.Fatal("failed to error on bad nested struct") + } +} diff --git a/common/serialize/sturc/struc.go b/common/serialize/sturc/struc.go new file mode 100644 index 000000000..d83d9f6cb --- /dev/null +++ b/common/serialize/sturc/struc.go @@ -0,0 +1,122 @@ +package struc + +import ( + "encoding/binary" + "fmt" + "io" + "reflect" +) + +type Options struct { + ByteAlign int + PtrSize int + Order binary.ByteOrder +} + +func (o *Options) Validate() error { + if o.PtrSize == 0 { + o.PtrSize = 32 + } else { + switch o.PtrSize { + case 8, 16, 32, 64: + default: + return fmt.Errorf("Invalid Options.PtrSize: %d. Must be in (8, 16, 32, 64)", o.PtrSize) + } + } + return nil +} + +var emptyOptions = &Options{} + +func init() { + // fill default values to avoid data race to be reported by race detector. + emptyOptions.Validate() +} + +func prep(data interface{}) (reflect.Value, Packer, error) { + value := reflect.ValueOf(data) + for value.Kind() == reflect.Ptr { + next := value.Elem().Kind() + if next == reflect.Struct || next == reflect.Ptr { + value = value.Elem() + } else { + break + } + } + switch value.Kind() { + case reflect.Struct: + fields, err := parseFields(value) + return value, fields, err + default: + if !value.IsValid() { + return reflect.Value{}, nil, fmt.Errorf("Invalid reflect.Value for %+v", data) + } + if c, ok := data.(Custom); ok { + return value, customFallback{c}, nil + } + return value, binaryFallback(value), nil + } +} + +func Pack(w io.Writer, data interface{}) error { + return PackWithOptions(w, data, nil) +} + +func PackWithOptions(w io.Writer, data interface{}, options *Options) error { + if options == nil { + options = emptyOptions + } + if err := options.Validate(); err != nil { + return err + } + val, packer, err := prep(data) + if err != nil { + return err + } + if val.Type().Kind() == reflect.String { + val = val.Convert(reflect.TypeOf([]byte{})) + } + size := packer.Sizeof(val, options) + buf := make([]byte, size) + if _, err := packer.Pack(buf, val, options); err != nil { + return err + } + _, err = w.Write(buf) + return err +} + +func Unpack(r io.Reader, data interface{}) error { + return UnpackWithOptions(r, data, nil) +} + +func UnpackWithOptions(r io.Reader, data interface{}, options *Options) error { + if options == nil { + options = emptyOptions + } + if err := options.Validate(); err != nil { + return err + } + val, packer, err := prep(data) + if err != nil { + return err + } + return packer.Unpack(r, val, options) +} + +func Sizeof(data interface{}) (int, error) { + return SizeofWithOptions(data, nil) +} + +func SizeofWithOptions(data interface{}, options *Options) (int, error) { + if options == nil { + options = emptyOptions + } + if err := options.Validate(); err != nil { + return 0, err + } + val, packer, err := prep(data) + if err != nil { + return 0, err + } + return packer.Sizeof(val, options), nil +} diff --git a/common/serialize/sturc/struc_test.go b/common/serialize/sturc/struc_test.go new file mode 100644 index 000000000..f590bb282 --- /dev/null +++ b/common/serialize/sturc/struc_test.go @@ -0,0 +1,310 @@ +package struc + +import ( + "bytes" + "encoding/binary" + "fmt" + "reflect" + "testing" +) + +type Nested struct { + Test2 int `struc:"int8"` +} + +type Example struct { + Pad []byte `struc:"[5]pad"` // 00 00 00 00 00 + I8f int `struc:"int8"` // 01 + I16f int `struc:"int16"` // 00 02 + I32f int `struc:"int32"` // 00 00 00 03 + I64f int `struc:"int64"` // 00 00 00 00 00 00 00 04 + U8f int `struc:"uint8,little"` // 05 + U16f int `struc:"uint16,little"` // 06 00 + U32f int `struc:"uint32,little"` // 07 00 00 00 + U64f int `struc:"uint64,little"` // 08 00 00 00 00 00 00 00 + Boolf int `struc:"bool"` // 01 + Byte4f []byte `struc:"[4]byte"` // "abcd" + + I8 int8 // 09 + I16 int16 // 00 0a + I32 int32 // 00 00 00 0b + I64 int64 // 00 00 00 00 00 00 00 0c + U8 uint8 `struc:"little"` // 0d + U16 uint16 `struc:"little"` // 0e 00 + U32 uint32 `struc:"little"` // 0f 00 00 00 + U64 uint64 `struc:"little"` // 10 00 00 00 00 00 00 00 + BoolT bool // 01 + BoolF bool // 00 + Byte4 [4]byte // "efgh" + Float1 float32 // 41 a0 00 00 + Float2 float64 // 41 35 00 00 00 00 00 00 + + I32f2 int64 `struc:"int32"` // ff ff ff ff + U32f2 int64 `struc:"uint32"` // ff ff ff ff + + I32f3 int32 `struc:"int64"` // ff ff ff ff ff ff ff ff + + Size int `struc:"sizeof=Str,little"` // 0a 00 00 00 + Str string `struc:"[]byte"` // "ijklmnopqr" + Strb string `struc:"[4]byte"` // "stuv" + + Size2 int `struc:"uint8,sizeof=Str2"` // 04 + Str2 string // "1234" + + Size3 int `struc:"uint8,sizeof=Bstr"` // 04 + Bstr []byte // "5678" + + Size4 int `struc:"little"` // 07 00 00 00 + Str4a string `struc:"[]byte,sizefrom=Size4"` // "ijklmno" + Str4b string `struc:"[]byte,sizefrom=Size4"` // "pqrstuv" + + Size5 int `struc:"uint8"` // 04 + Bstr2 []byte `struc:"sizefrom=Size5"` // "5678" + + Nested Nested // 00 00 00 01 + NestedP *Nested // 00 00 00 02 + TestP64 *int `struc:"int64"` // 00 00 00 05 + + NestedSize int `struc:"sizeof=NestedA"` // 00 00 00 02 + NestedA []Nested // [00 00 00 03, 00 00 00 04] + + Skip int `struc:"skip"` + + CustomTypeSize Int3 `struc:"sizeof=CustomTypeSizeArr"` // 00 00 00 04 + CustomTypeSizeArr []byte // "ABCD" +} + +var five = 5 + +type ExampleStructWithin struct { + a uint8 +} + +type ExampleSlice struct { + PropsLen uint8 `struc:"sizeof=Props"` + Props []ExampleStructWithin +} + +type ExampleArray struct { + PropsLen uint8 + Props [16]ExampleStructWithin `struc:"[16]ExampleStructWithin"` +} + +var arraySliceReferenceBytes = []byte{ + 16, + 0, 0, 0, 1, + 0, 0, 0, 1, + 0, 0, 0, 2, + 0, 0, 0, 3, + 0, 0, 0, 4, + 0, 0, 0, 5, + 0, 0, 0, 6, + 0, 0, 0, 7, + 0, 0, 0, 8, + 0, 0, 0, 9, + 0, 0, 0, 10, + 0, 0, 0, 11, + 0, 0, 0, 12, + 0, 0, 0, 13, + 0, 0, 0, 14, + 0, 0, 0, 15, + 0, 0, 0, 16, +} + +var arrayReference = &ExampleArray{ + 16, + [16]ExampleStructWithin{ + ExampleStructWithin{1}, + ExampleStructWithin{2}, + ExampleStructWithin{3}, + ExampleStructWithin{4}, + ExampleStructWithin{5}, + ExampleStructWithin{6}, + ExampleStructWithin{7}, + ExampleStructWithin{8}, + ExampleStructWithin{9}, + ExampleStructWithin{10}, + ExampleStructWithin{11}, + ExampleStructWithin{12}, + ExampleStructWithin{13}, + ExampleStructWithin{14}, + ExampleStructWithin{15}, + ExampleStructWithin{16}, + }, +} + +var sliceReference = &ExampleSlice{ + 16, + []ExampleStructWithin{ + ExampleStructWithin{1}, + ExampleStructWithin{2}, + ExampleStructWithin{3}, + ExampleStructWithin{4}, + ExampleStructWithin{5}, + ExampleStructWithin{6}, + ExampleStructWithin{7}, + ExampleStructWithin{8}, + ExampleStructWithin{9}, + ExampleStructWithin{10}, + ExampleStructWithin{11}, + ExampleStructWithin{12}, + ExampleStructWithin{13}, + ExampleStructWithin{14}, + ExampleStructWithin{15}, + ExampleStructWithin{16}, + }, +} + +var reference = &Example{ + nil, + 1, 2, 3, 4, 5, 6, 7, 8, 0, []byte{'a', 'b', 'c', 'd'}, + 9, 10, 11, 12, 13, 14, 15, 16, true, false, [4]byte{'e', 'f', 'g', 'h'}, + 20, 21, + -1, + 4294967295, + -1, + 10, "ijklmnopqr", "stuv", + 4, "1234", + 4, []byte("5678"), + 7, "ijklmno", "pqrstuv", + 4, []byte("5678"), + Nested{1}, &Nested{2}, &five, + 6, []Nested{{3}, {4}, {5}, {6}, {7}, {8}}, + 0, + Int3(4), []byte("ABCD"), +} + +var referenceBytes = []byte{ + 0, 0, 0, 0, 0, // pad(5) + 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, // fake int8-int64(1-4) + 5, 6, 0, 7, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, // fake little-endian uint8-uint64(5-8) + 0, // fake bool(0) + 'a', 'b', 'c', 'd', // fake [4]byte + + 9, 0, 10, 0, 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 12, // real int8-int64(9-12) + 13, 14, 0, 15, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, // real little-endian uint8-uint64(13-16) + 1, 0, // real bool(1), bool(0) + 'e', 'f', 'g', 'h', // real [4]byte + 65, 160, 0, 0, // real float32(20) + 64, 53, 0, 0, 0, 0, 0, 0, // real float64(21) + + 255, 255, 255, 255, // fake int32(-1) + 255, 255, 255, 255, // fake uint32(4294967295) + + 255, 255, 255, 255, 255, 255, 255, 255, // fake int64(-1) + + 10, 0, 0, 0, // little-endian int32(10) sizeof=Str + 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', // Str + 's', 't', 'u', 'v', // fake string([4]byte) + 04, '1', '2', '3', '4', // real string + 04, '5', '6', '7', '8', // fake []byte(string) + + 7, 0, 0, 0, // little-endian int32(7) + 'i', 'j', 'k', 'l', 'm', 'n', 'o', // Str4a sizefrom=Size4 + 'p', 'q', 'r', 's', 't', 'u', 'v', // Str4b sizefrom=Size4 + 04, '5', '6', '7', '8', // fake []byte(string) + + 1, 2, // Nested{1}, Nested{2} + 0, 0, 0, 0, 0, 0, 0, 5, // &five + + 0, 0, 0, 6, // int32(6) + 3, 4, 5, 6, 7, 8, // [Nested{3}, ...Nested{8}] + + 0, 0, 4, 'A', 'B', 'C', 'D', // Int3(4), []byte("ABCD") +} + +func TestCodec(t *testing.T) { + var buf bytes.Buffer + if err := Pack(&buf, reference); err != nil { + t.Fatal(err) + } + out := &Example{} + if err := Unpack(&buf, out); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(reference, out) { + fmt.Printf("got: %#v\nwant: %#v\n", out, reference) + t.Fatal("encode/decode failed") + } +} + +func TestEncode(t *testing.T) { + var buf bytes.Buffer + if err := Pack(&buf, reference); err != nil { + t.Fatal(err) + } + if !bytes.Equal(buf.Bytes(), referenceBytes) { + fmt.Printf("got: %#v\nwant: %#v\n", buf.Bytes(), referenceBytes) + t.Fatal("encode failed") + } +} + +func TestDecode(t *testing.T) { + buf := bytes.NewReader(referenceBytes) + out := &Example{} + if err := Unpack(buf, out); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(reference, out) { + fmt.Printf("got: %#v\nwant: %#v\n", out, reference) + t.Fatal("decode failed") + } +} + +func TestSizeof(t *testing.T) { + size, err := Sizeof(reference) + if err != nil { + t.Fatal(err) + } + if size != len(referenceBytes) { + t.Fatalf("sizeof failed; expected %d, got %d", len(referenceBytes), size) + } +} + +type ExampleEndian struct { + T int `struc:"int16,big"` +} + +func TestEndianSwap(t *testing.T) { + var buf bytes.Buffer + big := &ExampleEndian{1} + if err := PackWithOrder(&buf, big, binary.BigEndian); err != nil { + t.Fatal(err) + } + little := &ExampleEndian{} + if err := UnpackWithOrder(&buf, little, binary.LittleEndian); err != nil { + t.Fatal(err) + } + if little.T != 256 { + t.Fatal("big -> little conversion failed") + } +} + +func TestNilValue(t *testing.T) { + var buf bytes.Buffer + if err := Pack(&buf, nil); err == nil { + t.Fatal("failed throw error for bad struct value") + } + if err := Unpack(&buf, nil); err == nil { + t.Fatal("failed throw error for bad struct value") + } + if _, err := Sizeof(nil); err == nil { + t.Fatal("failed to throw error for bad struct value") + } +} + +type sliceUnderrun struct { + Str string `struc:"[10]byte"` + Arr []uint16 `struc:"[10]uint16"` +} + +func TestSliceUnderrun(t *testing.T) { + var buf bytes.Buffer + v := sliceUnderrun{ + Str: "foo", + Arr: []uint16{1, 2, 3}, + } + if err := Pack(&buf, &v); err != nil { + t.Fatal(err) + } +} diff --git a/common/serialize/sturc/test_pack_init/doc.go b/common/serialize/sturc/test_pack_init/doc.go new file mode 100644 index 000000000..42288e400 --- /dev/null +++ b/common/serialize/sturc/test_pack_init/doc.go @@ -0,0 +1,4 @@ +package test_pack_init + +// This is a placeholder package for a test on specific race detector report on +// default Options initialization. diff --git a/common/serialize/sturc/test_pack_init/pack_init_test.go b/common/serialize/sturc/test_pack_init/pack_init_test.go new file mode 100644 index 000000000..b280aa31e --- /dev/null +++ b/common/serialize/sturc/test_pack_init/pack_init_test.go @@ -0,0 +1,29 @@ +package test_pack_init + +import ( + "bytes" + "github.com/lunixbochs/struc" + "sync" + "testing" +) + +type Example struct { + I int `struc:int` +} + +// TestParallelPack checks whether Pack is goroutine-safe. Run it with -race flag. +// Keep it as a single test in package since it is likely to be triggered on initialization +// of global objects reported as a data race by race detector. +func TestParallelPack(t *testing.T) { + var wg sync.WaitGroup + val := Example{} + for i := 0; i < 2; i++ { + wg.Add(1) + go func() { + defer wg.Done() + var buf bytes.Buffer + _ = struc.Pack(&buf, &val) + }() + } + wg.Wait() +} diff --git a/common/serialize/sturc/types.go b/common/serialize/sturc/types.go new file mode 100644 index 000000000..6ca97f48d --- /dev/null +++ b/common/serialize/sturc/types.go @@ -0,0 +1,136 @@ +package struc + +import ( + "fmt" + "reflect" +) + +type Type int + +const ( + Invalid Type = iota + Pad + Bool + Int + Int8 + Uint8 + Int16 + Uint16 + Int32 + Uint32 + Int64 + Uint64 + Float32 + Float64 + String + Struct + Ptr + + SizeType + OffType + CustomType +) + +func (t Type) Resolve(options *Options) Type { + switch t { + case OffType: + switch options.PtrSize { + case 8: + return Int8 + case 16: + return Int16 + case 32: + return Int32 + case 64: + return Int64 + default: + panic(fmt.Sprintf("unsupported ptr bits: %d", options.PtrSize)) + } + case SizeType: + switch options.PtrSize { + case 8: + return Uint8 + case 16: + return Uint16 + case 32: + return Uint32 + case 64: + return Uint64 + default: + panic(fmt.Sprintf("unsupported ptr bits: %d", options.PtrSize)) + } + } + return t +} + +func (t Type) String() string { + return typeNames[t] +} + +func (t Type) Size() int { + switch t { + case SizeType, OffType: + panic("Size_t/Off_t types must be converted to another type using options.PtrSize") + case Pad, String, Int8, Uint8, Bool: + return 1 + case Int16, Uint16: + return 2 + case Int32, Uint32, Float32: + return 4 + case Int64, Uint64, Float64: + return 8 + default: + panic("Cannot resolve size of type:" + t.String()) + } +} + +var typeLookup = map[string]Type{ + "pad": Pad, + "bool": Bool, + "byte": Uint8, + "int8": Int8, + "uint8": Uint8, + "int16": Int16, + "uint16": Uint16, + "int32": Int32, + "uint32": Uint32, + "int64": Int64, + "uint64": Uint64, + "float32": Float32, + "float64": Float64, + + "size_t": SizeType, + "off_t": OffType, +} + +var typeNames = map[Type]string{ + CustomType: "Custom", +} + +func init() { + for name, enum := range typeLookup { + typeNames[enum] = name + } +} + +type Size_t uint64 +type Off_t int64 + +var reflectTypeMap = map[reflect.Kind]Type{ + reflect.Bool: Bool, + reflect.Int8: Int8, + reflect.Int16: Int16, + reflect.Int: Int32, + reflect.Int32: Int32, + reflect.Int64: Int64, + reflect.Uint8: Uint8, + reflect.Uint16: Uint16, + reflect.Uint: Uint32, + reflect.Uint32: Uint32, + reflect.Uint64: Uint64, + reflect.Float32: Float32, + reflect.Float64: Float64, + reflect.String: String, + reflect.Struct: Struct, + reflect.Ptr: Ptr, +} diff --git a/common/serialize/sturc/types_test.go b/common/serialize/sturc/types_test.go new file mode 100644 index 000000000..d7a9192a8 --- /dev/null +++ b/common/serialize/sturc/types_test.go @@ -0,0 +1,53 @@ +package struc + +import ( + "bytes" + "testing" +) + +func TestBadType(t *testing.T) { + defer func() { recover() }() + Type(-1).Size() + t.Fatal("failed to panic for invalid Type.Size()") +} + +func TestTypeString(t *testing.T) { + if Pad.String() != "pad" { + t.Fatal("type string representation failed") + } +} + +type sizeOffTest struct { + Size Size_t + Off Off_t +} + +func TestSizeOffTypes(t *testing.T) { + bits := []int{8, 16, 32, 64} + var buf bytes.Buffer + test := &sizeOffTest{1, 2} + for _, b := range bits { + if err := PackWithOptions(&buf, test, &Options{PtrSize: b}); err != nil { + t.Fatal(err) + } + } + reference := []byte{ + 1, 2, + 0, 1, 0, 2, + 0, 0, 0, 1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, + } + if !bytes.Equal(reference, buf.Bytes()) { + t.Errorf("reference: %v != bytes: %v", reference, buf.Bytes()) + } + reader := bytes.NewReader(buf.Bytes()) + for _, b := range bits { + out := &sizeOffTest{} + if err := UnpackWithOptions(reader, out, &Options{PtrSize: b}); err != nil { + t.Fatal(err) + } + if out.Size != 1 || out.Off != 2 { + t.Errorf("Size_t/Off_t mismatch: {%d, %d}\n%v", out.Size, out.Off, buf.Bytes()) + } + } +} diff --git a/common/serialize/unSerialize.go b/common/serialize/unSerialize.go new file mode 100644 index 000000000..e62fe2b62 --- /dev/null +++ b/common/serialize/unSerialize.go @@ -0,0 +1,336 @@ +package serialize + +import ( + "bytes" + "encoding/binary" + "fmt" + "reflect" + "strconv" + + "github.com/gogf/gf/v2/frame/g" +) + +// FixedVarDeserializer 定长反序列化器 +type FixedVarDeserializer struct { + byteOrder binary.ByteOrder +} + +// NewFixedVarDeserializer 创建新的反序列化器 +func NewFixedVarDeserializer(order binary.ByteOrder) *FixedVarDeserializer { + if order == nil { + order = binary.BigEndian + } + return &FixedVarDeserializer{byteOrder: order} +} + +// Deserialize 反序列化字节数据到结构体 +func (d *FixedVarDeserializer) Deserialize(data []byte, obj reflect.Value) reflect.Value { + reader := bytes.NewReader(data) + g.Dump(obj) + // 获取传入值的类型并创建新实例 + valType := reflect.TypeOf(obj.Interface()) + newVal := reflect.New(valType).Elem() + + // 处理指针类型 + if newVal.Kind() == reflect.Ptr { + newVal = newVal.Elem() + } + + // 遍历所有字段进行反序列化 + for i := 0; i < newVal.NumField(); i++ { + field := newVal.Type().Field(i) + fieldVal := newVal.Field(i) + + tag := field.Tag.Get("serialize") + if tag == "" { + if err := binary.Read(reader, d.byteOrder, fieldVal.Addr().Interface()); err != nil { + return newVal + } + continue + } + + mode, params, err := parseTag(tag) + if err != nil { + return newVal + } + + switch mode { + case lengthtype.FIXED_LENGTH: + if err := d.deserializeFixedField(reader, fieldVal, params); err != nil { + return newVal + } + case lengthtype.LENGTH_FIRST: + if err := d.deserializeVarWithLenField(reader, fieldVal, params); err != nil { + return newVal + } + default: + return newVal + } + } + + return newVal +} + +// 反序列化值 + +// 反序列化结构体 +func (d *FixedVarDeserializer) deserializeStruct(reader *bytes.Reader, val reflect.Value) error { + typ := val.Type() + + for i := 0; i < val.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + // 跳过未导出字段 + if !field.IsExported() { + continue + } + + // 处理指针类型字段 + if fieldVal.Kind() == reflect.Ptr { + if fieldVal.IsNil() { + fieldVal.Set(reflect.New(fieldVal.Type().Elem())) + } + fieldVal = fieldVal.Elem() + } + + // 解析标签 + tag := field.Tag.Get("serialize") + if tag == "" { + // 无标签:按原生类型处理 + if err := d.deserializeValue(reader, fieldVal); err != nil { + return fmt.Errorf("字段 %s 反序列化失败: %v", field.Name, err) + } + continue + } + + // 解析模式和参数 + mode, params, err := parseTag(tag) + if err != nil { + return fmt.Errorf("字段 %s 标签解析失败: %v", field.Name, err) + } + + // 根据模式反序列化 + switch mode { + case lengthtype.FIXED_LENGTH: + if err := d.deserializeFixedField(reader, fieldVal, params); err != nil { + return fmt.Errorf("字段 %s 定长反序列化失败: %v", field.Name, err) + } + case lengthtype.LENGTH_FIRST: + if err := d.deserializeVarWithLenField(reader, fieldVal, params); err != nil { + return fmt.Errorf("字段 %s 变长反序列化失败: %v", field.Name, err) + } + default: + return fmt.Errorf("字段 %s 不支持的序列化模式: %s", field.Name, mode) + } + } + + return nil +} + +// 反序列化定长字段 +func (d *FixedVarDeserializer) deserializeValue(reader *bytes.Reader, val reflect.Value) error { + kind := val.Kind() + + switch kind { + case reflect.Struct: + return d.deserializeStruct(reader, val) + case reflect.Slice: + return d.deserializeSlice(reader, val) + default: + if err := binary.Read(reader, d.byteOrder, val.Addr().Interface()); err != nil { + return err + } + return nil + } +} + +func (d *FixedVarDeserializer) deserializeFixedField(reader *bytes.Reader, val reflect.Value, lengthStr string) error { + length, err := strconv.Atoi(lengthStr) + if err != nil { + return fmt.Errorf("无效的定长参数: %s", lengthStr) + } + + return d.deserializeFixedLengthValue(reader, val, length) +} + +// 反序列化带长度前缀的可变长度字段 +func (d *FixedVarDeserializer) deserializeVarWithLenField(reader *bytes.Reader, val reflect.Value, lenBytesStr string) error { + lenBytes, err := strconv.Atoi(lenBytesStr) + if err != nil { + return fmt.Errorf("无效的长度字节数: %s", lenBytesStr) + } + + if lenBytes < 1 || lenBytes > 8 { + return fmt.Errorf("长度字节数需在1-8之间") + } + + // 读取长度 + lenData := make([]byte, lenBytes) + if _, err := reader.Read(lenData); err != nil { + return err + } + + var contentLength uint64 + switch lenBytes { + case 1: + contentLength = uint64(lenData[0]) + case 2: + contentLength = uint64(d.byteOrder.Uint16(lenData)) + case 4: + contentLength = uint64(d.byteOrder.Uint32(lenData)) + case 8: + contentLength = d.byteOrder.Uint64(lenData) + default: + return fmt.Errorf("不支持的长度字节数: %d", lenBytes) + } + + // 读取内容 + contentData := make([]byte, contentLength) + if _, err := reader.Read(contentData); err != nil { + return err + } + + // 反序列化内容 + contentReader := bytes.NewReader(contentData) + return d.deserializeValue(contentReader, val) +} + +// 反序列化定长值 +func (d *FixedVarDeserializer) deserializeFixedLengthValue(reader *bytes.Reader, val reflect.Value, length int) error { + kind := val.Kind() + + if kind == reflect.String { + // 读取定长字符串 + data := make([]byte, length) + if _, err := reader.Read(data); err != nil { + return err + } + + // 找到字符串结束位置(去除填充的0) + var strLen int + for strLen = 0; strLen < length && data[strLen] != 0; strLen++ { + } + fmt.Println(val.CanSet()) + val.SetString(string(data[:strLen])) + g.Dump(val) + return nil + } + + // 其他类型:读取固定长度字节,然后反序列化 + data := make([]byte, length) + if _, err := reader.Read(data); err != nil { + return err + } + + // 如果是slice或array,特殊处理 + if kind == reflect.Slice || kind == reflect.Array { + sliceReader := bytes.NewReader(data) + return d.deserializeValue(sliceReader, val) + } + + // 基本类型 + fieldReader := bytes.NewReader(data) + return binary.Read(fieldReader, d.byteOrder, val.Addr().Interface()) +} + +// 反序列化slice +func (d *FixedVarDeserializer) deserializeSlice(reader *bytes.Reader, val reflect.Value) error { + // 获取slice元素类型 + elemType := val.Type().Elem() + + // 检查slice是否有标签 + var tag string + // 检查slice元素是否为结构体 + if elemType.Kind() == reflect.Struct { + // 如果元素是结构体,获取结构体的标签 + structType := elemType + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + if tag = field.Tag.Get("serialize"); tag != "" { + break + } + } + } + + if tag != "" { + // 元素有标签:按定长模式处理 + mode, params, err := parseTag(tag) + if err != nil { + return err + } + + if mode == lengthtype.FIXED_LENGTH { + // 定长slice:解析maxItems和itemLen + parts := splitTag(params) + if len(parts) != 2 { + return fmt.Errorf("定长slice标签需格式为 fixed:N,M") + } + maxItems, _ := strconv.Atoi(parts[0]) + itemLen, _ := strconv.Atoi(parts[1]) + return d.deserializeFixedSlice(reader, val, maxItems, itemLen) + } + } + + // // 无标签或不定长模式:按原生slice处理(先读长度,再读元素) + // var count int + + // // 尝试读取slice长度 + // // 这里假设使用int32作为长度类型,实际应根据序列化逻辑调整 + // var length int32 + // if err := binary.Read(reader, d.byteOrder, &length); err != nil { + // return err + // } + // count = int(length) + + // // 创建足够容量的slice + // if val.Kind() == reflect.Slice { + // val.Set(reflect.MakeSlice(val.Type(), count, count)) + // } + + // // 读取每个元素 + // for i := 0; i < count; i++ { + // item := val.Index(i) + // if err := binary.Read(reader, d.byteOrder, item.Addr().Interface()); err != nil { + // return err + // } + // } + + return nil +} + +// 反序列化定长slice +func (d *FixedVarDeserializer) deserializeFixedSlice(reader *bytes.Reader, val reflect.Value, maxItems, itemLen int) error { + // 读取实际元素数量 + countByte, err := reader.ReadByte() + if err != nil { + return err + } + count := int(countByte) + + if count > maxItems { + count = maxItems + } + + // 创建slice + if val.Kind() == reflect.Slice { + val.Set(reflect.MakeSlice(val.Type(), count, count)) + } + + // 读取每个元素 + for i := 0; i < maxItems; i++ { + if i < count { + item := val.Index(i) + if err := d.deserializeFixedLengthValue(reader, item, itemLen); err != nil { + return err + } + } else { + // 跳过填充字节 + if _, err := reader.Seek(int64(itemLen), 1); err != nil { + return err + } + } + } + + return nil +} diff --git a/common/socket/Server.go b/common/socket/Server.go new file mode 100644 index 000000000..0b72ddb70 --- /dev/null +++ b/common/socket/Server.go @@ -0,0 +1 @@ +package socket diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index c4626b85c..2dc8e0aa7 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -1,83 +1,84 @@ -package socket - -import ( - "context" - - "github.com/panjf2000/gnet/v2" - "github.com/panjf2000/gnet/v2/pkg/logging" - "blazing/common/data/entity" -) - -func (s *Server) Boot() error { - err := gnet.Run(s, s.addr, - gnet.WithMulticore(true), - gnet.WithSocketRecvBuffer(s.bufferSize)) - if err != nil { - return err - } - - return nil -} - -func (s *Server) Stop() error { - _ = s.eng.Stop(context.Background()) - s.workerPool.Release() - - return nil -} - -func (s *Server) OnBoot(eng gnet.Engine) gnet.Action { - s.eng = eng - - logging.Infof("syslog server is listening on %s\n", s.addr) - - return gnet.None -} - -func (s *Server) OnTraffic(conn gnet.Conn) (action gnet.Action) { - - conn.SetContext(entity.NewClientData())//注入data - if s.network == "tcp" { - return s.handleTcp(conn) - } - - return gnet.None -} - -func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) { - - for { - - data, err := s.codec.Decode(conn) - if err != nil { - break - } - - //client := conn.RemoteAddr().String() - _ = s.workerPool.Submit(func() { - s.parser(conn, data) - }) - - return gnet.None - } - - if conn.InboundBuffered() > 0 { - if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data - logging.Errorf("failed to wake up the connection, %v", err) - return gnet.Close - } - } - - return gnet.None - -} - -func (s *Server) parser(c gnet.Conn, line []byte) { - //todo 这里待实现注入player实体 - s.handler.Handle(line) -} -func (s *Server) Start() { - - err := gnet.Run(s, s.network+"://"+s.addr, gnet.WithMulticore(s.multicore)) - logging.Infof("server exits with error: %v", err) -} +package socket + +import ( + "context" + + "blazing/common/data/entity" + + "github.com/panjf2000/gnet/v2" + "github.com/panjf2000/gnet/v2/pkg/logging" +) + +func (s *Server) Boot() error { + err := gnet.Run(s, s.addr, + gnet.WithMulticore(true), + gnet.WithSocketRecvBuffer(s.bufferSize)) + if err != nil { + return err + } + + return nil +} + +func (s *Server) Stop() error { + _ = s.eng.Stop(context.Background()) + s.workerPool.Release() + + return nil +} + +func (s *Server) OnBoot(eng gnet.Engine) gnet.Action { + s.eng = eng + + logging.Infof("syslog server is listening on %s\n", s.addr) + + return gnet.None +} + +func (s *Server) OnTraffic(conn gnet.Conn) (action gnet.Action) { + + conn.SetContext(entity.NewClientData()) //注入data + if s.network == "tcp" { + return s.handleTcp(conn) + } + + return gnet.None +} + +func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) { + + for { + + data, err := s.codec.Decode(conn) + if err != nil { + break + } + + //client := conn.RemoteAddr().String() + _ = s.workerPool.Submit(func() { + s.parser(data) + }) + + return gnet.None + } + + if conn.InboundBuffered() > 0 { + if err := conn.Wake(nil); err != nil { // wake up the connection manually to avoid missing the leftover data + logging.Errorf("failed to wake up the connection, %v", err) + return gnet.Close + } + } + + return gnet.None + +} + +func (s *Server) parser(line []byte) { + //todo 这里待实现注入player实体 + s.handler.Handle(line) +} +func (s *Server) Start() { + + err := gnet.Run(s, s.network+"://"+s.addr, gnet.WithMulticore(s.multicore)) + logging.Infof("server exits with error: %v", err) +} diff --git a/common/socket/ServerOption.go b/common/socket/ServerOption.go index 135274774..59beb46c3 100644 --- a/common/socket/ServerOption.go +++ b/common/socket/ServerOption.go @@ -26,7 +26,7 @@ type Option func(*Server) func NewServer(options ...Option) *Server { server := &Server{ - handler: handler.NewTomeeHandler(), //请求返回 + // handler: handler.NewTomeeHandler(), //请求返回 codec: codec.NewTomeeSocketCodec(), //默认解码器 len+pack workerPool: goroutine.Default(), bufferSize: 4096, //默认缓冲区大小 diff --git a/common/socket/cmd/cmd.go b/common/socket/cmd/cmd.go index 1574a7dcf..5e6732a48 100644 --- a/common/socket/cmd/cmd.go +++ b/common/socket/cmd/cmd.go @@ -1,98 +1,102 @@ -package cmd - -import ( - "github.com/tnnmigga/enum" -) - -// Enum 辅助类型定义 -type EnumValue struct { - Value int - Name string -} - -// MessageCommandIDRegistry 消息命令ID注册表 -var MessageCommandIDRegistry = enum.New[struct { - // 在线相关命令 - Commend_OnLine int `enum:"105"` // 在线命令 - Login_In int `enum:"1001"` // 玩家登录 - System_Time int `enum:"1002"` // 返回当前时间戳 - Map_Hot int `enum:"1004"` // 显示地图热度(此地图内玩家数量) - Gold_Online_Check_Remain int `enum:"1106"` // 返回玩家金豆数量 - - // 地图相关命令 - Enter_Map int `enum:"2001"` // 告知后端玩家进入新地图 - Leave_Map int `enum:"2002"` // 玩家离开地图 - List_Map_Player int `enum:"2003"` // 返回当前地图玩家列表 - Map_Ogre_List int `enum:"2004"` // 精灵刷新 - - // 用户信息相关命令 - Get_Sim_UserInfo int `enum:"2051"` // 返回邮人物简单信息 - Get_More_UserInfo int `enum:"2052"` // 返回人物详细信息 - Change_Nick_Name int `enum:"2061"` // 修改玩家名字 - - // 动作相关命令 - People_Walk int `enum:"2101"` // 玩家走路包 - Chat int `enum:"2102"` // 公屏聊天 - Aimat int `enum:"2104"` // 射击 - - // 精灵相关命令 - Get_Pet_Info int `enum:"2301"` // 获取精灵详细信息 - Get_Pet_List int `enum:"2303"` // 获取所有的精灵列表 - Pet_Release int `enum:"2304"` // 精灵加入背包或放回仓库 - Pet_Show int `enum:"2305"` // 展示精灵 - Pet_Cure int `enum:"2306"` // 恢复精灵状态,NONO恢复所有精灵 - Pet_Study_Skill int `enum:"2307"` // 升级学习替换技能 - Pet_Default int `enum:"2308"` // 设置精灵首发 - Pet_One_Cure int `enum:"2310"` // 恢复精灵状态,精灵恢复单只精灵 - Pet_Skill_Switch int `enum:"2312"` // 切换精灵技能 - Pet_Set_Exp int `enum:"2318"` // 分配精灵经验 - Pet_Get_Exp int `enum:"2319"` // 获取积累经验 - Pet_Room int `enum:"2325"` // 跟随精灵获取信息 - Get_Soul_Bead_List int `enum:"2354"` // 返回元神珠信息 - - // 战斗相关命令 - Ready_To_Fight int `enum:"2404"` // 客户端通知服务端可以开始战斗, 此包表示客户端可以开始战斗, 无需服务端回复此包内容 - Use_Skill int `enum:"2405"` // 使用技能 - Change_Pet int `enum:"2407"` // 切换精灵 - Fight_NPC_Monster int `enum:"2408"` // 与野怪对战的申请进入战斗 - Catch_Monster int `enum:"2409"` // 捕捉精灵 - Challenge_Boss int `enum:"2411"` // 与当前地图的Boss类型野怪进入战斗 - Note_ReadyTo_Fight int `enum:"2503"` // 通知客户端已经可以开始战斗 - Note_Start_Fight int `enum:"2504"` // 在客户端告知服务端可以开始战斗后, 服务端回给客户端战斗开始 - Note_Use_Skill int `enum:"2505"` // 通知使用技能 - Fight_Over int `enum:"2506"` // 战斗结束 - Note_Update_Skill int `enum:"2507"` // 升级获得学习技能 - Note_Update_Prop int `enum:"2508"` // 返回升级后的信息 - - // 装备物品相关命令 - Change_Cloth int `enum:"2604"` // 修改玩家装备 - Item_List int `enum:"2605"` // 返回玩家物品列表 - - // 奖励相关命令 - Talk_Count int `enum:"2701"` // 玩家领取奖励的次数(挖矿,礼包等) - Talk_Cate int `enum:"2702"` // 领取奖品的内容 - Mail_Get_Unread int `enum:"2757"` // 返回邮件数量 - - // 系统相关命令 - System_Message int `enum:"8002"` // 后端主动发送面板消息 - Get_Boss_Monster int `enum:"8004"` // 返回战斗结束后的奖励包或主动发放奖励 - - // NONO相关命令 - Nono_Info int `enum:"9003"` // 通过米米号获取nono信息 - Nono_Follow_Or_Home int `enum:"9019"` // nono跟随或回家 - - // 特殊命令 - Get_Quadruple_Exe_Time int `enum:"50007"` // 返回已使用四倍剩余时间 - - // 暂未处理的包 - Item_Buy int `enum:"2601"` // 物品购买 - Item_Sale int `enum:"2602"` // 物品出售 - Friend_Add int `enum:"2151"` // 添加好友 - Friend_Remove int `enum:"2153"` // 移除好友 - Invite_To_Fight int `enum:"2401"` // 邀请战斗 - Escape_Fight int `enum:"2410"` // 逃离战斗 - Join_Game int `enum:"5001"` // 加入游戏 - Game_Over int `enum:"5002"` // 游戏结束 - Leave_Game int `enum:"5003"` // 离开游戏 -}]() - +package cmd + +import ( + "github.com/tnnmigga/enum" +) + +// Enum 辅助类型定义 +type EnumValue struct { + Value EnumCommandID + Name string +} +type EnumCommandID int + +func Isexist(t any, value EnumCommandID) bool { + return enum.Contains(CommandID, value) +} + +// CommandID 消息命令ID注册表 +var CommandID = enum.New[struct { + // 在线相关命令 + Commend_OnLine EnumCommandID `enum:"105"` // 在线命令 + Login_In EnumCommandID `enum:"1001"` // 玩家登录 + System_Time EnumCommandID `enum:"1002"` // 返回当前时间戳 + Map_Hot EnumCommandID `enum:"1004"` // 显示地图热度(此地图内玩家数量) + Gold_Online_Check_Remain EnumCommandID `enum:"1106"` // 返回玩家金豆数量 + + // 地图相关命令 + Enter_Map EnumCommandID `enum:"2001"` // 告知后端玩家进入新地图 + Leave_Map EnumCommandID `enum:"2002"` // 玩家离开地图 + List_Map_Player EnumCommandID `enum:"2003"` // 返回当前地图玩家列表 + Map_Ogre_List EnumCommandID `enum:"2004"` // 精灵刷新 + + // 用户信息相关命令 + Get_Sim_UserInfo EnumCommandID `enum:"2051"` // 返回邮人物简单信息 + Get_More_UserInfo EnumCommandID `enum:"2052"` // 返回人物详细信息 + Change_Nick_Name EnumCommandID `enum:"2061"` // 修改玩家名字 + + // 动作相关命令 + People_Walk EnumCommandID `enum:"2101"` // 玩家走路包 + Chat EnumCommandID `enum:"2102"` // 公屏聊天 + Aimat EnumCommandID `enum:"2104"` // 射击 + + // 精灵相关命令 + Get_Pet_Info EnumCommandID `enum:"2301"` // 获取精灵详细信息 + Get_Pet_List EnumCommandID `enum:"2303"` // 获取所有的精灵列表 + Pet_Release EnumCommandID `enum:"2304"` // 精灵加入背包或放回仓库 + Pet_Show EnumCommandID `enum:"2305"` // 展示精灵 + Pet_Cure EnumCommandID `enum:"2306"` // 恢复精灵状态,NONO恢复所有精灵 + Pet_Study_Skill EnumCommandID `enum:"2307"` // 升级学习替换技能 + Pet_Default EnumCommandID `enum:"2308"` // 设置精灵首发 + Pet_One_Cure EnumCommandID `enum:"2310"` // 恢复精灵状态,精灵恢复单只精灵 + Pet_Skill_Switch EnumCommandID `enum:"2312"` // 切换精灵技能 + Pet_Set_Exp EnumCommandID `enum:"2318"` // 分配精灵经验 + Pet_Get_Exp EnumCommandID `enum:"2319"` // 获取积累经验 + Pet_Room EnumCommandID `enum:"2325"` // 跟随精灵获取信息 + Get_Soul_Bead_List EnumCommandID `enum:"2354"` // 返回元神珠信息 + + // 战斗相关命令 + Ready_To_Fight EnumCommandID `enum:"2404"` // 客户端通知服务端可以开始战斗, 此包表示客户端可以开始战斗, 无需服务端回复此包内容 + Use_Skill EnumCommandID `enum:"2405"` // 使用技能 + Change_Pet EnumCommandID `enum:"2407"` // 切换精灵 + Fight_NPC_Monster EnumCommandID `enum:"2408"` // 与野怪对战的申请进入战斗 + Catch_Monster EnumCommandID `enum:"2409"` // 捕捉精灵 + Challenge_Boss EnumCommandID `enum:"2411"` // 与当前地图的Boss类型野怪进入战斗 + Note_ReadyTo_Fight EnumCommandID `enum:"2503"` // 通知客户端已经可以开始战斗 + Note_Start_Fight EnumCommandID `enum:"2504"` // 在客户端告知服务端可以开始战斗后, 服务端回给客户端战斗开始 + Note_Use_Skill EnumCommandID `enum:"2505"` // 通知使用技能 + Fight_Over EnumCommandID `enum:"2506"` // 战斗结束 + Note_Update_Skill EnumCommandID `enum:"2507"` // 升级获得学习技能 + Note_Update_Prop EnumCommandID `enum:"2508"` // 返回升级后的信息 + + // 装备物品相关命令 + Change_Cloth EnumCommandID `enum:"2604"` // 修改玩家装备 + Item_List EnumCommandID `enum:"2605"` // 返回玩家物品列表 + + // 奖励相关命令 + Talk_Count EnumCommandID `enum:"2701"` // 玩家领取奖励的次数(挖矿,礼包等) + Talk_Cate EnumCommandID `enum:"2702"` // 领取奖品的内容 + Mail_Get_Unread EnumCommandID `enum:"2757"` // 返回邮件数量 + + // 系统相关命令 + System_Message EnumCommandID `enum:"8002"` // 后端主动发送面板消息 + Get_Boss_Monster EnumCommandID `enum:"8004"` // 返回战斗结束后的奖励包或主动发放奖励 + + // NONO相关命令 + Nono_Info EnumCommandID `enum:"9003"` // 通过米米号获取nono信息 + Nono_Follow_Or_Home EnumCommandID `enum:"9019"` // nono跟随或回家 + + // 特殊命令 + Get_Quadruple_Exe_Time EnumCommandID `enum:"50007"` // 返回已使用四倍剩余时间 + + // 暂未处理的包 + Item_Buy EnumCommandID `enum:"2601"` // 物品购买 + Item_Sale EnumCommandID `enum:"2602"` // 物品出售 + Friend_Add EnumCommandID `enum:"2151"` // 添加好友 + Friend_Remove EnumCommandID `enum:"2153"` // 移除好友 + Invite_To_Fight EnumCommandID `enum:"2401"` // 邀请战斗 + Escape_Fight EnumCommandID `enum:"2410"` // 逃离战斗 + Join_Game EnumCommandID `enum:"5001"` // 加入游戏 + Game_Over EnumCommandID `enum:"5002"` // 游戏结束 + Leave_Game EnumCommandID `enum:"5003"` // 离开游戏 +}]() diff --git a/common/socket/cmd/cmd_test.go b/common/socket/cmd/cmd_test.go index e18bca649..58e3d0b07 100644 --- a/common/socket/cmd/cmd_test.go +++ b/common/socket/cmd/cmd_test.go @@ -1,14 +1,14 @@ -package cmd - -import ( - "testing" -) - -func BenchmarkCmd(b *testing.B) { - b.ReportAllocs() - //写入 - for i := 0; i < b.N; i++ { - b.Log(MessageCommandIDRegistry.Change_Cloth) - - } -} +package cmd + +import ( + "testing" +) + +func BenchmarkCmd(b *testing.B) { + b.ReportAllocs() + //写入 + for i := 0; i < b.N; i++ { + b.Log(CommandID.Change_Cloth) + + } +} diff --git a/common/socket/codec/SocketCodec_Tomee.go b/common/socket/codec/SocketCodec_Tomee.go index 44c36b6e2..95033b326 100644 --- a/common/socket/codec/SocketCodec_Tomee.go +++ b/common/socket/codec/SocketCodec_Tomee.go @@ -1,111 +1,111 @@ -package codec - -import ( - "blazing/common/data/entity" - "encoding/binary" - "errors" - "io" - "log" - - "github.com/panjf2000/gnet/v2" -) - -// CROSS_DOMAIN 定义跨域策略文件内容 -const CROSS_DOMAIN = "\x00" - -// TEXT 定义跨域请求的文本格式 -const TEXT = "\x00" - -var ErrIncompletePacket = errors.New("incomplete packet") - -// TomeeSocketCodec 协议格式: -// -// * 0 4 -// * +-----------+ -// * | body len | -// * +-----------+ -// * | | -// * + + -// * | body bytes| -// * + + -// * | ... ... | -// * +-----------+ -type TomeeSocketCodec struct{} - -var _ SocketCodec = (*TomeeSocketCodec)(nil) - -func NewTomeeSocketCodec() *TomeeSocketCodec { - return &TomeeSocketCodec{} - -} - -func handle(c gnet.Conn) { - clientdata:=c.Context().(*entity.ClientData) - if(clientdata.IsCrossDomain){ - return - - } - // 读取数据并检查是否为跨域请求 - data, err := c.Peek(len(TEXT)) - if err != nil { - log.Printf("Error reading cross-domain request: %v", err) - return - } - - if string(data) == TEXT { //判断是否是跨域请求 - log.Printf("Received cross-domain request from %s", c.RemoteAddr()) - // 处理跨域请求 - c.Write([]byte(CROSS_DOMAIN)) - c.Discard(len(TEXT)) - - clientdata.IsCrossDomain=true - return - } - - return -} -func (codec TomeeSocketCodec) Encode(buf []byte) ([]byte, error) { - bodyLen := len(buf) - data := make([]byte, 4+bodyLen) - - // 写入4字节的包长度 - binary.BigEndian.PutUint32(data[:4], uint32(bodyLen)) - // 写入包体 - copy(data[4:], buf) - - return data, nil -} - -func (codec TomeeSocketCodec) Decode(c gnet.Conn) ([]byte, error) { - - handle(c) - // 先读取4字节的包长度 - lenBuf, err := c.Peek(4) - if err != nil { - if errors.Is(err, io.ErrShortBuffer) { - return nil, ErrIncompletePacket - } - return nil, err - } - - bodyLen := binary.BigEndian.Uint32(lenBuf) - totalLen := 4 + int(bodyLen) - - // 检查整个包是否完整 - buf, err := c.Peek(totalLen) - if err != nil { - if errors.Is(err, io.ErrShortBuffer) { - return nil, ErrIncompletePacket - } - return nil, err - } - - // 提取包体 - body := make([]byte, bodyLen) - copy(body, buf[4:totalLen]) - - // 从缓冲区中丢弃已读取的数据 - _, _ = c.Discard(totalLen) - - return body, nil -} +package codec + +import ( + "blazing/common/data/entity" + "encoding/binary" + "errors" + "io" + "log" + + "github.com/panjf2000/gnet/v2" +) + +// CROSS_DOMAIN 定义跨域策略文件内容 +const CROSS_DOMAIN = "\x00" + +// TEXT 定义跨域请求的文本格式 +const TEXT = "\x00" + +var ErrIncompletePacket = errors.New("incomplete packet") + +// TomeeSocketCodec 协议格式: +// +// * 0 4 +// * +-----------+ +// * | body len | +// * +-----------+ +// * | | +// * + + +// * | body bytes| +// * + + +// * | ... ... | +// * +-----------+ +type TomeeSocketCodec struct{} + +var _ SocketCodec = (*TomeeSocketCodec)(nil) + +func NewTomeeSocketCodec() *TomeeSocketCodec { + return &TomeeSocketCodec{} + +} + +func handle(c gnet.Conn) { + clientdata := c.Context().(*entity.ClientData) + if clientdata.IsCrossDomain { + return + + } + // 读取数据并检查是否为跨域请求 + data, err := c.Peek(len(TEXT)) + if err != nil { + log.Printf("Error reading cross-domain request: %v", err) + return + } + + if string(data) == TEXT { //判断是否是跨域请求 + log.Printf("Received cross-domain request from %s", c.RemoteAddr()) + // 处理跨域请求 + c.Write([]byte(CROSS_DOMAIN)) + c.Discard(len(TEXT)) + + clientdata.IsCrossDomain = true + return + } + + //return +} +func (codec TomeeSocketCodec) Encode(buf []byte) ([]byte, error) { + bodyLen := len(buf) + data := make([]byte, 4+bodyLen) + + // 写入4字节的包长度 + binary.BigEndian.PutUint32(data[:4], uint32(bodyLen)) + // 写入包体 + copy(data[4:], buf) + + return data, nil +} + +func (codec TomeeSocketCodec) Decode(c gnet.Conn) ([]byte, error) { + + handle(c) + // 先读取4字节的包长度 + lenBuf, err := c.Peek(4) + if err != nil { + if errors.Is(err, io.ErrShortBuffer) { + return nil, ErrIncompletePacket + } + return nil, err + } + + bodyLen := binary.BigEndian.Uint32(lenBuf) + totalLen := 4 + int(bodyLen) + + // 检查整个包是否完整 + buf, err := c.Peek(int(bodyLen)) + if err != nil { + if errors.Is(err, io.ErrShortBuffer) { + return nil, ErrIncompletePacket + } + return nil, err + } + + // 提取包体 + body := make([]byte, bodyLen) + copy(body, buf) + + // 从缓冲区中丢弃已读取的数据 + _, _ = c.Discard(totalLen) + + return body, nil +} diff --git a/common/socket/handler/SocketHandler_Tomee.go b/common/socket/handler/SocketHandler_Tomee.go index 51a13dade..e0eba707e 100644 --- a/common/socket/handler/SocketHandler_Tomee.go +++ b/common/socket/handler/SocketHandler_Tomee.go @@ -1,24 +1,42 @@ package handler +import ( + "blazing/common/serialize/bytearray" +) + // TomeeHeader 结构体字段定义 type TomeeHeader struct { - Version string `json:"version"` - UserID int `json:"userId"` - Error int `json:"error"` - CMDID int `json:"cmdId"` - Result int `json:"result"` + Len uint32 `json:"len"` + Version string `json:"version"` + UserID uint32 `json:"userId"` + Error uint32 `json:"error"` + CMDID uint32 `json:"cmdId"` + Result uint32 `json:"result"` + Data []byte `json:"data"` } type TomeeHandler struct { - + Callback func(data TomeeHeader) } func NewTomeeHandler() *TomeeHandler { - return &TomeeHandler{ - - } + return &TomeeHandler{} } // Handle entry receiver -func (h *TomeeHandler) Handle(data []byte ) { +func (h *TomeeHandler) Handle(data []byte) { //处理接收到的数据 , + //fmt.Println("接收数据", data) -} \ No newline at end of file + header := TomeeHeader{} + + tempdata := bytearray.CreateByteArray(data) + header.Len, _ = tempdata.ReadUInt32() + header.Version, _ = tempdata.ReadString(1) + header.CMDID, _ = tempdata.ReadUInt32() + header.UserID, _ = tempdata.ReadUInt32() + + header.Result, _ = tempdata.ReadUInt32() + header.Data = tempdata.BytesAvailable() + //fmt.Println("接收封包", header) + h.Callback(header) + //return header +} diff --git a/go.work b/go.work index b273ddd4f..ee062fdc7 100644 --- a/go.work +++ b/go.work @@ -5,6 +5,7 @@ use ( ./common/contrib/drivers/mysql ./common/contrib/files/local ./common/cool + ./common/serialize/sturc ./logic ./login ./modules/base diff --git a/logic/controller/login.go b/logic/controller/login.go new file mode 100644 index 000000000..8cb2206ec --- /dev/null +++ b/logic/controller/login.go @@ -0,0 +1,30 @@ +package controller + +import ( + "blazing/common/core/info" + "blazing/common/data/entity" + "blazing/logic/service/login" + "bytes" + + "github.com/lunixbochs/struc" +) + +// todo 待实现自动编解码Recv_1001 +// 处理命令: 1001 +func (h Controller) Recv_1001(data []byte, player entity.Player) { + pinfo := info.NewLoginSidInfo() + struc.Unpack(bytes.NewBuffer(data), &pinfo) + + //fmt.Println(pinfo) + login.OnData_1001(pinfo, player) + //fmt.Println(data) +} + +func (h Controller) Recv_105(data []byte, player entity.Player) { + pinfo := info.NewLoginSidInfo() + struc.Unpack(bytes.NewBuffer(data), &pinfo) + + //fmt.Println(pinfo) + login.OnData_105(pinfo, player) + //fmt.Println(data) +} diff --git a/logic/controller/service.go b/logic/controller/service.go new file mode 100644 index 000000000..b72fca830 --- /dev/null +++ b/logic/controller/service.go @@ -0,0 +1,9 @@ +package controller + +//分发cmd逻辑实现Controller +type Controller struct { +} + +func NewController() *Controller { + return &Controller{} +} diff --git a/logic/go.mod b/logic/go.mod index a70bd6280..b27eadb9c 100644 --- a/logic/go.mod +++ b/logic/go.mod @@ -1,3 +1,5 @@ -module blazing/logic - -go 1.19 +module blazing/logic + +go 1.19 + +require github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543 diff --git a/logic/go.sum b/logic/go.sum new file mode 100644 index 000000000..b20aa0b31 --- /dev/null +++ b/logic/go.sum @@ -0,0 +1,2 @@ +github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543 h1:GxMuVb9tJajC1QpbQwYNY1ZAo1EIE8I+UclBjOfjz/M= +github.com/lunixbochs/struc v0.0.0-20241101090106-8d528fa2c543/go.mod h1:vy1vK6wD6j7xX6O6hXe621WabdtNkou2h7uRtTfRMyg= diff --git a/logic/main.go b/logic/main.go index 5fe24f468..26b56aa74 100644 --- a/logic/main.go +++ b/logic/main.go @@ -1,11 +1,149 @@ -package main - -import ( - "blazing/common/socket" -) - -func main() { - - //fmt.Println(tt) - socket.NewServer(socket.WithPort("9999")).Start() -} +package main + +import ( + "blazing/common/core/info" + "blazing/common/data/entity" + "blazing/common/socket" + "blazing/common/socket/cmd" + "blazing/common/socket/handler" + "blazing/logic/controller" + "fmt" + "reflect" + "strconv" + "sync" +) + +var ( + maininfocodec = info.NewInfoCodec() //创建一个InfoCodec实例 + maincontroller = controller.NewController() //注入service + mainplayer sync.Map //玩家数据 +) + +func main() { + + Start("27777") //注入service +} +func Start(port string) { + + head := handler.NewTomeeHandler() + head.Callback = recv + socket.NewServer(socket.WithPort(port), socket.WithSocketHandler(head)).Start() +} +func recv(data handler.TomeeHeader) { + // 处理接收到的TomeeHeader数据 + // fmt.Println("收到数据:", data) + processWithReflection(data) + +} + +// 遍历结构体方法并执行RECV_cmd +func processWithReflection(pp handler.TomeeHeader) { + // 获取对象的反射值和类型 + value := reflect.ValueOf(maincontroller) + + // 如果传入的是指针,获取其指向的值 + if value.Kind() == reflect.Ptr { + if value.IsNil() { + fmt.Println("错误: 传入的是nil指针") + return + } + value = value.Elem() + } + + // 获取类型 + typ := value.Type() + + // 遍历所有方法 + fmt.Printf("检查结构体 %s 的方法...\n", typ.Name(), typ.NumMethod()) + for i := 0; i < typ.NumMethod(); i++ { + method := typ.Method(i) + + if method.Type.NumIn() == 3 { //&& // TODO 接收者 + 2个参数 一个是类型,一个是player + //method.Type.In(1) == reflect.TypeOf([]byte{} + + // 获取方法值 + methodValue := value.MethodByName(method.Name) + + // 准备参数 + cmd1 := method.Name[len("Recv_"):len(method.Name)] + cmdint, _ := strconv.Atoi(cmd1) + if cmdint == int(pp.CMDID) { + if !cmd.Isexist(cmd.CommandID, cmd.EnumCommandID(pp.CMDID)) { + fmt.Println("ID方法存在cmd未注册", pp.CMDID, cmd.CommandID) + } + // fmt.Println(" 找到匹配的RECV_cmd方法,准备调用...", pp.Cmdid, Command.ID) + data := pp.Data + // trmp := getincodec(cmd.EnumCommandID(pp.CMDID), data) + //fmt.Println(trmp) + // serializer := serialize.NewFixedVarDeserializer(nil) + + // tt1 := serializer.Deserialize(data, trmp) + // g.Dump(trmp) + // g.Dump(tt1) + // 调用方法 + methodValue.Call([]reflect.Value{ + // reflect.ValueOf(cmdint), + reflect.ValueOf(data), + reflect.ValueOf(entity.Player{}), + }) + } + + //return + } + //} + } + +} + +func getincodec(cmdid cmd.EnumCommandID, data []byte) reflect.Value { + // 获取对象的反射值和类型 + value := reflect.ValueOf(maininfocodec) + + // 如果传入的是指针,获取其指向的值 + if value.Kind() == reflect.Ptr { + if value.IsNil() { + fmt.Println("错误: 传入的是nil指针") + return reflect.ValueOf(nil) + } + value = value.Elem() + } + + // 获取类型 + typ := value.Type() + + // 遍历所有方法 + fmt.Printf("检查结构体 %s 的方法...\n", typ.Name(), typ.NumMethod()) + for i := 0; i < typ.NumMethod(); i++ { + method := typ.Method(i) + + if method.Type.NumIn() == 2 && // 接收者 + 2个参数 + method.Type.In(1) == reflect.TypeOf([]byte{}) { + + // 获取方法值 + methodValue := value.MethodByName(method.Name) + + // 准备参数 + cmd1 := method.Name[len("In_"):len(method.Name)] + cmdint, _ := strconv.Atoi(cmd1) + if cmdint == int(cmdid) { + if !cmd.Isexist(cmd.CommandID, cmd.EnumCommandID(cmdid)) { + fmt.Println("ID方法存在cmd未注册", cmdid, cmd.CommandID) + } + + //data := pp.Data + + // 调用方法 + tt := methodValue.Call([]reflect.Value{ + // reflect.ValueOf(cmdint), + reflect.ValueOf(data), + }) + + return tt[0] + } + + //return + } + //} + } + return reflect.ValueOf(nil) +} diff --git a/logic/service/login/PlayerLoginService.go b/logic/service/login/PlayerLoginService.go new file mode 100644 index 000000000..c00a9ca2a --- /dev/null +++ b/logic/service/login/PlayerLoginService.go @@ -0,0 +1,12 @@ +package login + +import ( + "blazing/common/core/info" + "blazing/common/data/entity" + "fmt" +) + +func OnData_1001(c info.LoginSidInfo, p entity.Player) { + fmt.Println(c.Sid) + +} diff --git a/logic/service/login/recv.go b/logic/service/login/recv.go new file mode 100644 index 000000000..11b250287 --- /dev/null +++ b/logic/service/login/recv.go @@ -0,0 +1,10 @@ +package login + +import ( + "blazing/common/core/info" + "blazing/common/data/entity" +) + +func OnData_105(c info.LoginSidInfo, p entity.Player) { + +}