fix alliance enumeration bugs

This commit is contained in:
wish
2022-10-01 01:26:00 +10:00
parent 665c2dd32f
commit 8f9648d9d8

View File

@@ -1197,14 +1197,28 @@ func handleMsgMhfEnumerateGuild(s *Session, p mhfpacket.MHFPacket) {
} }
} }
case mhfpacket.ENUMERATE_ALLIANCE_TYPE_ORDER_MEMBERS: case mhfpacket.ENUMERATE_ALLIANCE_TYPE_ORDER_MEMBERS:
sort.Slice(tempAlliances, func(i, j int) bool { sorting := bf.ReadBool()
return tempAlliances[i].TotalMembers < tempAlliances[j].TotalMembers if sorting {
}) sort.Slice(tempAlliances, func(i, j int) bool {
return tempAlliances[i].TotalMembers > tempAlliances[j].TotalMembers
})
} else {
sort.Slice(tempAlliances, func(i, j int) bool {
return tempAlliances[i].TotalMembers < tempAlliances[j].TotalMembers
})
}
alliances = tempAlliances alliances = tempAlliances
case mhfpacket.ENUMERATE_ALLIANCE_TYPE_ORDER_REGISTRATION: case mhfpacket.ENUMERATE_ALLIANCE_TYPE_ORDER_REGISTRATION:
sort.Slice(tempAlliances, func(i, j int) bool { sorting := bf.ReadBool()
return tempAlliances[i].CreatedAt.Unix() < tempAlliances[j].CreatedAt.Unix() if sorting {
}) sort.Slice(tempAlliances, func(i, j int) bool {
return tempAlliances[i].CreatedAt.Unix() > tempAlliances[j].CreatedAt.Unix()
})
} else {
sort.Slice(tempAlliances, func(i, j int) bool {
return tempAlliances[i].CreatedAt.Unix() < tempAlliances[j].CreatedAt.Unix()
})
}
alliances = tempAlliances alliances = tempAlliances
} }
} }
@@ -1218,8 +1232,8 @@ func handleMsgMhfEnumerateGuild(s *Session, p mhfpacket.MHFPacket) {
if pkt.Type > 8 { if pkt.Type > 8 {
bf.WriteUint16(uint16(len(alliances))) bf.WriteUint16(uint16(len(alliances)))
bf.WriteUint8(0x00) // Unk
for _, alliance := range alliances { for _, alliance := range alliances {
bf.WriteUint8(0x00) // Unk
bf.WriteUint32(alliance.ID) bf.WriteUint32(alliance.ID)
bf.WriteUint32(alliance.ParentGuild.LeaderCharID) bf.WriteUint32(alliance.ParentGuild.LeaderCharID)
bf.WriteUint16(alliance.TotalMembers) bf.WriteUint16(alliance.TotalMembers)