mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
more GuildTresure optimisation
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user