change Airou struct definition & remove airoulist.bin

This commit is contained in:
wish
2023-10-12 23:27:54 +11:00
parent 0de15e8440
commit 94f9174afa
2 changed files with 21 additions and 35 deletions

View File

@@ -92,8 +92,8 @@ func handleMsgMhfRegistGuildTresure(s *Session, p mhfpacket.MHFPacket) {
if catID > 0 { if catID > 0 {
catsUsed = stringsupport.CSVAdd(catsUsed, int(catID)) catsUsed = stringsupport.CSVAdd(catsUsed, int(catID))
for _, cat := range guildCats { for _, cat := range guildCats {
if cat.CatID == catID { if cat.ID == catID {
huntData.WriteBytes(cat.CatName) huntData.WriteBytes(cat.Name)
break break
} }
} }

View File

@@ -9,8 +9,6 @@ import (
"erupe-ce/server/channelserver/compression/nullcomp" "erupe-ce/server/channelserver/compression/nullcomp"
"go.uber.org/zap" "go.uber.org/zap"
"io" "io"
"os"
"path/filepath"
"time" "time"
) )
@@ -299,18 +297,12 @@ func handleMsgMhfSaveOtomoAirou(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfEnumerateAiroulist(s *Session, p mhfpacket.MHFPacket) { func handleMsgMhfEnumerateAiroulist(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateAiroulist) pkt := p.(*mhfpacket.MsgMhfEnumerateAiroulist)
resp := byteframe.NewByteFrame() resp := byteframe.NewByteFrame()
if _, err := os.Stat(filepath.Join(s.server.erupeConfig.BinPath, "airoulist.bin")); err == nil {
data, _ := os.ReadFile(filepath.Join(s.server.erupeConfig.BinPath, "airoulist.bin"))
resp.WriteBytes(data)
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
return
}
airouList := getGuildAirouList(s) airouList := getGuildAirouList(s)
resp.WriteUint16(uint16(len(airouList))) resp.WriteUint16(uint16(len(airouList)))
resp.WriteUint16(uint16(len(airouList))) resp.WriteUint16(uint16(len(airouList)))
for _, cat := range airouList { for _, cat := range airouList {
resp.WriteUint32(cat.CatID) resp.WriteUint32(cat.ID)
resp.WriteBytes(cat.CatName) resp.WriteBytes(cat.Name)
resp.WriteUint32(cat.Experience) resp.WriteUint32(cat.Experience)
resp.WriteUint8(cat.Personality) resp.WriteUint8(cat.Personality)
resp.WriteUint8(cat.Class) resp.WriteUint8(cat.Class)
@@ -321,11 +313,10 @@ func handleMsgMhfEnumerateAiroulist(s *Session, p mhfpacket.MHFPacket) {
doAckBufSucceed(s, pkt.AckHandle, resp.Data()) doAckBufSucceed(s, pkt.AckHandle, resp.Data())
} }
// CatDefinition holds values needed to populate the guild cat list type Airou struct {
type CatDefinition struct { ID uint32
CatID uint32 Name []byte
CatName []byte Task uint8
CurrentTask uint8
Personality uint8 Personality uint8
Class uint8 Class uint8
Experience uint32 Experience uint32
@@ -333,10 +324,10 @@ type CatDefinition struct {
WeaponID uint16 WeaponID uint16
} }
func getGuildAirouList(s *Session) []CatDefinition { func getGuildAirouList(s *Session) []Airou {
var guild *Guild var guild *Guild
var err error var err error
var guildCats []CatDefinition var guildCats []Airou
// returning 0 cats on any guild issues // returning 0 cats on any guild issues
// can probably optimise all of the guild queries pretty heavily // can probably optimise all of the guild queries pretty heavily
@@ -365,7 +356,6 @@ func getGuildAirouList(s *Session) []CatDefinition {
} }
} }
// ellie's GetGuildMembers didn't seem to pull leader?
rows, err = s.server.db.Query(`SELECT c.otomoairou rows, err = s.server.db.Query(`SELECT c.otomoairou
FROM characters c FROM characters c
INNER JOIN guild_characters gc INNER JOIN guild_characters gc
@@ -381,11 +371,7 @@ func getGuildAirouList(s *Session) []CatDefinition {
for rows.Next() { for rows.Next() {
var data []byte var data []byte
err = rows.Scan(&data) err = rows.Scan(&data)
if err != nil { if err != nil || len(data) == 0 {
s.logger.Warn("select failure", zap.Error(err))
continue
} else if len(data) == 0 {
// non extant cats that aren't null in DB
continue continue
} }
// first byte has cat existence in general, can skip if 0 // first byte has cat existence in general, can skip if 0
@@ -396,10 +382,10 @@ func getGuildAirouList(s *Session) []CatDefinition {
continue continue
} }
bf := byteframe.NewByteFrameFromBytes(decomp) bf := byteframe.NewByteFrameFromBytes(decomp)
cats := GetCatDetails(bf) cats := GetAirouDetails(bf)
for _, cat := range cats { for _, cat := range cats {
_, exists := bannedCats[cat.CatID] _, exists := bannedCats[cat.ID]
if cat.CurrentTask == 4 && !exists { if cat.Task == 4 && !exists {
guildCats = append(guildCats, cat) guildCats = append(guildCats, cat)
} }
} }
@@ -408,20 +394,20 @@ func getGuildAirouList(s *Session) []CatDefinition {
return guildCats return guildCats
} }
func GetCatDetails(bf *byteframe.ByteFrame) []CatDefinition { func GetAirouDetails(bf *byteframe.ByteFrame) []Airou {
catCount := bf.ReadUint8() catCount := bf.ReadUint8()
cats := make([]CatDefinition, catCount) cats := make([]Airou, catCount)
for x := 0; x < int(catCount); x++ { for x := 0; x < int(catCount); x++ {
var catDef CatDefinition var catDef Airou
// cat sometimes has additional bytes for whatever reason, gift items? timestamp? // cat sometimes has additional bytes for whatever reason, gift items? timestamp?
// until actual variance is known we can just seek to end based on start // until actual variance is known we can just seek to end based on start
catDefLen := bf.ReadUint32() catDefLen := bf.ReadUint32()
catStart, _ := bf.Seek(0, io.SeekCurrent) catStart, _ := bf.Seek(0, io.SeekCurrent)
catDef.CatID = bf.ReadUint32() catDef.ID = bf.ReadUint32()
bf.Seek(1, io.SeekCurrent) // unknown value, probably a bool bf.Seek(1, io.SeekCurrent) // unknown value, probably a bool
catDef.CatName = bf.ReadBytes(18) // always 18 len, reads first null terminated string out of section and discards rest catDef.Name = bf.ReadBytes(18) // always 18 len, reads first null terminated string out of section and discards rest
catDef.CurrentTask = bf.ReadUint8() catDef.Task = bf.ReadUint8()
bf.Seek(16, io.SeekCurrent) // appearance data and what is seemingly null bytes bf.Seek(16, io.SeekCurrent) // appearance data and what is seemingly null bytes
catDef.Personality = bf.ReadUint8() catDef.Personality = bf.ReadUint8()
catDef.Class = bf.ReadUint8() catDef.Class = bf.ReadUint8()