share all my series data

This commit is contained in:
wish
2022-07-25 17:18:06 +10:00
parent 23e2e25c72
commit fffb262322
3 changed files with 63 additions and 48 deletions

View File

@@ -1,15 +1,15 @@
package channelserver package channelserver
import ( import (
"encoding/hex"
"encoding/binary" "encoding/binary"
"encoding/hex"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"erupe-ce/common/byteframe"
"erupe-ce/common/bfutil" "erupe-ce/common/bfutil"
"erupe-ce/common/byteframe"
"erupe-ce/network/mhfpacket" "erupe-ce/network/mhfpacket"
"erupe-ce/server/channelserver/compression/deltacomp" "erupe-ce/server/channelserver/compression/deltacomp"
"erupe-ce/server/channelserver/compression/nullcomp" "erupe-ce/server/channelserver/compression/nullcomp"
@@ -61,7 +61,12 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) {
s.logger.Fatal("Failed to character weapon type in db", zap.Error(err)) s.logger.Fatal("Failed to character weapon type in db", zap.Error(err))
} }
s.house.tier = decompressedData[129904] s.myseries.houseTier = decompressedData[129900:129905] // 0x1FB6C + 5
s.myseries.houseData = decompressedData[130561:130756] // 0x1FE01 + 195
// Gallery data also exists at 0x21578, is this the contest submission?
s.myseries.galleryData = decompressedData[140064:141812] // 0x22320 + 1748
s.myseries.toreData = decompressedData[130228:130468] // 0x1FCB4 + 240
s.myseries.gardenData = decompressedData[142424:142492] // 0x22C58 + 68
isMale := uint8(decompressedData[80]) // 0x50 isMale := uint8(decompressedData[80]) // 0x50
if isMale == 1 { if isMale == 1 {

View File

@@ -5,6 +5,7 @@ import (
ps "erupe-ce/common/pascalstring" ps "erupe-ce/common/pascalstring"
"erupe-ce/common/stringsupport" "erupe-ce/common/stringsupport"
"erupe-ce/network/mhfpacket" "erupe-ce/network/mhfpacket"
"fmt"
"go.uber.org/zap" "go.uber.org/zap"
) )
@@ -89,8 +90,8 @@ func handleMsgMhfEnumerateHouse(s *Session, p mhfpacket.MHFPacket) {
if session.charID == house.CharID { if session.charID == house.CharID {
exists++ exists++
bf.WriteUint32(house.CharID) bf.WriteUint32(house.CharID)
bf.WriteUint8(session.house.state) bf.WriteUint8(session.myseries.state)
if len(session.house.password) > 0 { if len(session.myseries.password) > 0 {
bf.WriteUint8(3) bf.WriteUint8(3)
} else { } else {
bf.WriteUint8(0) bf.WriteUint8(0)
@@ -115,8 +116,8 @@ func handleMsgMhfUpdateHouse(s *Session, p mhfpacket.MHFPacket) {
// 03 = open friends // 03 = open friends
// 04 = open guild // 04 = open guild
// 05 = open friends+guild // 05 = open friends+guild
s.house.state = pkt.State s.myseries.state = pkt.State
s.house.password = pkt.Password s.myseries.password = pkt.Password
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4)) doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
} }
@@ -125,7 +126,7 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
bf := byteframe.NewByteFrame() bf := byteframe.NewByteFrame()
if pkt.Destination != 9 && len(pkt.Password) > 0 && pkt.CheckPass { if pkt.Destination != 9 && len(pkt.Password) > 0 && pkt.CheckPass {
for _, session := range s.server.sessions { for _, session := range s.server.sessions {
if session.charID == pkt.CharID && pkt.Password != session.house.password { if session.charID == pkt.CharID && pkt.Password != session.myseries.password {
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4)) doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
return return
} }
@@ -141,55 +142,59 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
furniture = make([]byte, 20) furniture = make([]byte, 20)
} }
// TODO: Find where the missing data comes from, savefile offset?
switch pkt.Destination { switch pkt.Destination {
case 3: // Others house case 3: // Others house
houseTier := uint8(2) // Fallback if can't find
for _, session := range s.server.sessions { for _, session := range s.server.sessions {
if session.charID == pkt.CharID { if session.charID == pkt.CharID {
houseTier = session.house.tier bf.WriteBytes(session.myseries.houseTier)
bf.WriteBytes(session.myseries.houseData)
bf.WriteBytes(make([]byte, 19)) // Padding?
bf.WriteBytes(furniture)
} }
} }
bf.WriteBytes(make([]byte, 4))
bf.WriteUint8(houseTier) // House tier 0x1FB70
bf.WriteBytes(make([]byte, 80))
// Item box style bitfield
// tier 1 = 0x09FE
// tier 2 = 0x69FF
// tier 3 = 0xE9FF
// unused = 0x0001
// unused = 0x6000
switch houseTier {
case 0:
bf.WriteUint16(0x0000)
case 1:
bf.WriteUint16(0x69FF)
case 2:
bf.WriteUint16(0xE9FF)
}
// Rastae
// Partner
bf.WriteBytes(make([]byte, 132))
bf.WriteBytes(furniture)
case 4: // Bookshelf case 4: // Bookshelf
// Hunting log // TODO: Find where the hunting log data offset is in the savefile
bf.WriteBytes(make([]byte, 5576)) bf.WriteBytes(make([]byte, 5576))
case 5: // Gallery case 5: // Gallery
// Furniture placement for _, session := range s.server.sessions {
bf.WriteBytes(make([]byte, 1748)) if session.charID == pkt.CharID {
bf.WriteBytes(session.myseries.galleryData)
}
}
case 8: // Tore case 8: // Tore
// Sister for _, session := range s.server.sessions {
// Cat shops if session.charID == pkt.CharID {
// Pugis bf.WriteBytes(session.myseries.toreData)
bf.WriteBytes(make([]byte, 240)) }
}
case 9: // Own house case 9: // Own house
bf.WriteBytes(furniture) bf.WriteBytes(furniture)
case 10: // Garden case 10: // Garden
// Gardening upgrades for _, session := range s.server.sessions {
// Gooks if session.charID == pkt.CharID {
bf.WriteBytes(make([]byte, 72)) bf.WriteBytes(session.myseries.gardenData)
// TODO: Convert EnumerateGuacot to function this can also call
var data []byte
var count uint16
gooks := byteframe.NewByteFrame()
for i := 0; i < 5; i++ {
err := s.server.db.QueryRow(fmt.Sprintf("SELECT gook%d FROM gook WHERE id=$1", i), pkt.CharID).Scan(&data)
if err == nil && data != nil {
count++
gooks.WriteBytes(data)
}
}
bf.WriteUint16(count)
bf.WriteUint16(0)
bf.WriteBytes(gooks.Data())
}
}
}
if len(bf.Data()) == 0 {
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
} else {
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} }
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
} }
func handleMsgMhfGetMyhouseInfo(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfGetMyhouseInfo(s *Session, p mhfpacket.MHFPacket) {

View File

@@ -27,7 +27,7 @@ type Session struct {
sendPackets chan []byte sendPackets chan []byte
clientContext *clientctx.ClientContext clientContext *clientctx.ClientContext
house House myseries MySeries
stageID string stageID string
stage *Stage stage *Stage
reservationStage *Stage // Required for the stateful MsgSysUnreserveStage packet. reservationStage *Stage // Required for the stateful MsgSysUnreserveStage packet.
@@ -55,10 +55,15 @@ type Session struct {
Name string Name string
} }
type House struct { type MySeries struct {
tier uint8 houseTier []byte
state uint8 houseData []byte
password string bookshelfData []byte
galleryData []byte
toreData []byte
gardenData []byte
state uint8
password string
} }
// NewSession creates a new Session type. // NewSession creates a new Session type.