From e688fdf3c5ad49a16cab6fb05f9ec0d1b9e9a3c7 Mon Sep 17 00:00:00 2001 From: wish Date: Tue, 17 Oct 2023 00:35:06 +1100 Subject: [PATCH] more GuildTresure optimisation --- network/mhfpacket/msg_mhf_enumerate_guild_tresure.go | 8 ++++---- server/channelserver/handlers_guild_tresure.go | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/network/mhfpacket/msg_mhf_enumerate_guild_tresure.go b/network/mhfpacket/msg_mhf_enumerate_guild_tresure.go index 61475d655..f03202bd4 100644 --- a/network/mhfpacket/msg_mhf_enumerate_guild_tresure.go +++ b/network/mhfpacket/msg_mhf_enumerate_guild_tresure.go @@ -12,7 +12,8 @@ import ( type MsgMhfEnumerateGuildTresure struct { AckHandle uint32 MaxHunts uint16 - Unk uint32 + Unk0 uint16 + Unk1 uint16 } // Opcode returns the ID associated with this packet type. @@ -24,9 +25,8 @@ func (m *MsgMhfEnumerateGuildTresure) Opcode() network.PacketID { func (m *MsgMhfEnumerateGuildTresure) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error { m.AckHandle = bf.ReadUint32() m.MaxHunts = bf.ReadUint16() - // Changes with MaxHunts - // 0 if MaxHunts = 1, 1 if MaxHunts = 30 - m.Unk = bf.ReadUint32() + m.Unk0 = bf.ReadUint16() + m.Unk1 = bf.ReadUint16() return nil } diff --git a/server/channelserver/handlers_guild_tresure.go b/server/channelserver/handlers_guild_tresure.go index e34e36d23..516991595 100644 --- a/server/channelserver/handlers_guild_tresure.go +++ b/server/channelserver/handlers_guild_tresure.go @@ -14,7 +14,7 @@ type TreasureHunt struct { Return uint32 `db:"return"` Acquired bool `db:"acquired"` Claimed bool `db:"claimed"` - Hunters string `db:"hunters"` + Hunters uint32 `db:"hunters"` Treasure string `db:"treasure"` HuntData []byte `db:"hunt_data"` } @@ -28,8 +28,10 @@ func handleMsgMhfEnumerateGuildTresure(s *Session, p mhfpacket.MHFPacket) { } var hunts []TreasureHunt var hunt TreasureHunt - rows, err := s.server.db.Queryx(`SELECT id, host_id, destination, level, return, acquired, claimed, hunters, treasure, hunt_data FROM guild_hunts WHERE guild_id=$1 AND $2 < return+$3 - `, guild.ID, TimeAdjusted().Unix(), s.server.erupeConfig.GameplayOptions.TreasureHuntExpiry) + rows, err := s.server.db.Queryx(`SELECT gh.id, gh.host_id, gh.destination, gh.level, gh.return, gh.acquired, gh.claimed, gh.treasure, gh.hunt_data, + (SELECT COUNT(*) FROM guild_characters gc WHERE gc.treasure_hunt = gh.id AND gc.character_id <> $1) AS hunters + FROM guild_hunts gh WHERE gh.guild_id=$2 AND $3 < gh.return+$4 + `, s.charID, guild.ID, TimeAdjusted().Unix(), s.server.erupeConfig.GameplayOptions.TreasureHuntExpiry) if err != nil { rows.Close() return @@ -39,8 +41,6 @@ func handleMsgMhfEnumerateGuildTresure(s *Session, p mhfpacket.MHFPacket) { if err != nil { continue } - // Remove self from other hunter count - hunt.Hunters = stringsupport.CSVRemove(hunt.Hunters, int(s.charID)) if pkt.MaxHunts == 1 { if hunt.HostID != s.charID || hunt.Acquired { continue @@ -63,7 +63,7 @@ func handleMsgMhfEnumerateGuildTresure(s *Session, p mhfpacket.MHFPacket) { bf.WriteUint32(h.HuntID) bf.WriteUint32(h.Destination) bf.WriteUint32(h.Level) - bf.WriteUint32(uint32(stringsupport.CSVLength(h.Hunters))) + bf.WriteUint32(h.Hunters) bf.WriteUint32(h.Return) bf.WriteBool(h.Claimed) bf.WriteBool(stringsupport.CSVContains(h.Treasure, int(s.charID)))