From 6c3be9c32e2428ca4b1d1198de68a421871b002e Mon Sep 17 00:00:00 2001 From: wish Date: Mon, 7 Nov 2022 00:31:42 +1100 Subject: [PATCH] decode and support screenshot sharing --- config.json | 1 + config/config.go | 1 + .../mhfpacket/msg_mhf_apply_bbs_article.go | 27 +++++++++--- .../mhfpacket/msg_mhf_get_bbs_sns_status.go | 17 +++++--- .../mhfpacket/msg_mhf_get_bbs_user_status.go | 17 +++++--- server/channelserver/handlers.go | 4 -- server/channelserver/handlers_bbs.go | 41 +++++++++++++++++++ server/channelserver/handlers_users.go | 2 - 8 files changed, 86 insertions(+), 24 deletions(-) create mode 100644 server/channelserver/handlers_bbs.go diff --git a/config.json b/config.json index e996d4c7e..df09b1ceb 100644 --- a/config.json +++ b/config.json @@ -7,6 +7,7 @@ "LoginNotice": "
Welcome to Erupe SU9.1!
Erupe is experimental software, we are not liable for any
issues caused by installing the software!

■Report bugs on Discord!

■Test everything!

■Don't talk to softlocking NPCs!

■Fork the code on GitHub!

Thank you to all of the contributors,

this wouldn't exist without you.", "PatchServerManifest": "", "PatchServerFile": "", + "ScreenshotAPIURL": "", "DevMode": true, "DevModeOptions": { "AutoCreateAccount": true, diff --git a/config/config.go b/config/config.go index d306e8b9c..bfe11032e 100644 --- a/config/config.go +++ b/config/config.go @@ -20,6 +20,7 @@ type Config struct { LoginNotice string // MHFML string of the login notice displayed PatchServerManifest string // Manifest patch server override PatchServerFile string // File patch server override + ScreenshotAPIURL string // Destination for screenshots uploaded to BBS DevMode bool DevModeOptions DevModeOptions diff --git a/network/mhfpacket/msg_mhf_apply_bbs_article.go b/network/mhfpacket/msg_mhf_apply_bbs_article.go index df0218ce0..d2b9c803b 100644 --- a/network/mhfpacket/msg_mhf_apply_bbs_article.go +++ b/network/mhfpacket/msg_mhf_apply_bbs_article.go @@ -1,15 +1,24 @@ package mhfpacket -import ( - "errors" +import ( + "errors" + "erupe-ce/common/bfutil" + "erupe-ce/common/stringsupport" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfApplyBbsArticle represents the MSG_MHF_APPLY_BBS_ARTICLE -type MsgMhfApplyBbsArticle struct{} +type MsgMhfApplyBbsArticle struct { + AckHandle uint32 + Unk0 uint32 + Unk1 []byte + Name string + Title string + Description string +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfApplyBbsArticle) Opcode() network.PacketID { @@ -18,7 +27,13 @@ func (m *MsgMhfApplyBbsArticle) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfApplyBbsArticle) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.Unk0 = bf.ReadUint32() + m.Unk1 = bf.ReadBytes(16) + m.Name = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(32))) + m.Title = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(128))) + m.Description = stringsupport.SJISToUTF8(bfutil.UpToNull(bf.ReadBytes(256))) + return nil } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_get_bbs_sns_status.go b/network/mhfpacket/msg_mhf_get_bbs_sns_status.go index 07ab9e485..0c50f67e8 100644 --- a/network/mhfpacket/msg_mhf_get_bbs_sns_status.go +++ b/network/mhfpacket/msg_mhf_get_bbs_sns_status.go @@ -1,15 +1,18 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfGetBbsSnsStatus represents the MSG_MHF_GET_BBS_SNS_STATUS -type MsgMhfGetBbsSnsStatus struct{} +type MsgMhfGetBbsSnsStatus struct { + AckHandle uint32 + Unk []byte +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfGetBbsSnsStatus) Opcode() network.PacketID { @@ -18,7 +21,9 @@ func (m *MsgMhfGetBbsSnsStatus) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfGetBbsSnsStatus) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.Unk = bf.ReadBytes(12) + return nil } // Build builds a binary packet from the current data. diff --git a/network/mhfpacket/msg_mhf_get_bbs_user_status.go b/network/mhfpacket/msg_mhf_get_bbs_user_status.go index 69bcef671..9c44faa76 100644 --- a/network/mhfpacket/msg_mhf_get_bbs_user_status.go +++ b/network/mhfpacket/msg_mhf_get_bbs_user_status.go @@ -1,15 +1,18 @@ package mhfpacket -import ( - "errors" +import ( + "errors" - "erupe-ce/network/clientctx" - "erupe-ce/network" "erupe-ce/common/byteframe" + "erupe-ce/network" + "erupe-ce/network/clientctx" ) // MsgMhfGetBbsUserStatus represents the MSG_MHF_GET_BBS_USER_STATUS -type MsgMhfGetBbsUserStatus struct{} +type MsgMhfGetBbsUserStatus struct { + AckHandle uint32 + Unk []byte +} // Opcode returns the ID associated with this packet type. func (m *MsgMhfGetBbsUserStatus) Opcode() network.PacketID { @@ -18,7 +21,9 @@ func (m *MsgMhfGetBbsUserStatus) Opcode() network.PacketID { // Parse parses the packet from binary func (m *MsgMhfGetBbsUserStatus) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { - return errors.New("NOT IMPLEMENTED") + m.AckHandle = bf.ReadUint32() + m.Unk = bf.ReadBytes(12) + return nil } // Build builds a binary packet from the current data. diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index 47d3d6b4c..b1af93beb 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -1495,10 +1495,6 @@ func handleMsgMhfInfoScenarioCounter(s *Session, p mhfpacket.MHFPacket) { doAckBufSucceed(s, pkt.AckHandle, resp.Data()) } -func handleMsgMhfGetBbsSnsStatus(s *Session, p mhfpacket.MHFPacket) {} - -func handleMsgMhfApplyBbsArticle(s *Session, p mhfpacket.MHFPacket) {} - func handleMsgMhfGetEtcPoints(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfGetEtcPoints) diff --git a/server/channelserver/handlers_bbs.go b/server/channelserver/handlers_bbs.go new file mode 100644 index 000000000..222a8eadc --- /dev/null +++ b/server/channelserver/handlers_bbs.go @@ -0,0 +1,41 @@ +package channelserver + +import ( + "erupe-ce/common/byteframe" + "erupe-ce/common/stringsupport" + "erupe-ce/common/token" + "erupe-ce/network/mhfpacket" +) + +func handleMsgMhfGetBbsUserStatus(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfGetBbsUserStatus) + bf := byteframe.NewByteFrame() + bf.WriteUint32(200) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteUint32(0) + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) +} + +func handleMsgMhfGetBbsSnsStatus(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfGetBbsSnsStatus) + bf := byteframe.NewByteFrame() + bf.WriteUint32(200) + bf.WriteUint32(401) + bf.WriteUint32(401) + bf.WriteUint32(0) + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) +} + +func handleMsgMhfApplyBbsArticle(s *Session, p mhfpacket.MHFPacket) { + pkt := p.(*mhfpacket.MsgMhfApplyBbsArticle) + bf := byteframe.NewByteFrame() + articleToken := token.Generate(40) + bf.WriteUint32(200) + bf.WriteUint32(80) + bf.WriteUint32(0) + bf.WriteUint32(0) + bf.WriteBytes(stringsupport.PaddedString(articleToken, 64, false)) + bf.WriteBytes(stringsupport.PaddedString(s.server.erupeConfig.ScreenshotAPIURL, 64, false)) + doAckBufSucceed(s, pkt.AckHandle, bf.Data()) +} diff --git a/server/channelserver/handlers_users.go b/server/channelserver/handlers_users.go index c360b82a6..fc8b47a8d 100644 --- a/server/channelserver/handlers_users.go +++ b/server/channelserver/handlers_users.go @@ -54,5 +54,3 @@ func handleMsgSysGetUserBinary(s *Session, p mhfpacket.MHFPacket) { } func handleMsgSysNotifyUserBinary(s *Session, p mhfpacket.MHFPacket) {} - -func handleMsgMhfGetBbsUserStatus(s *Session, p mhfpacket.MHFPacket) {}