mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-15 08:25:09 +01:00
simplify guild code
This commit is contained in:
@@ -270,16 +270,22 @@ func handleMsgMhfStateFestaU(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
func handleMsgMhfStateFestaG(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfStateFestaG(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfStateFestaG)
|
pkt := p.(*mhfpacket.MsgMhfStateFestaG)
|
||||||
guild, err := GetGuildInfoByCharacterId(s, s.charID)
|
guild, err := GetGuildInfoByCharacterId(s, s.charID)
|
||||||
if err != nil || guild == nil {
|
applicant, _ := guild.HasApplicationForCharID(s, s.charID)
|
||||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
resp := byteframe.NewByteFrame()
|
||||||
|
if err != nil || guild == nil || applicant {
|
||||||
|
resp.WriteUint32(0)
|
||||||
|
resp.WriteUint32(0)
|
||||||
|
resp.WriteUint32(0xFFFFFFFF)
|
||||||
|
resp.WriteUint32(0)
|
||||||
|
resp.WriteUint32(0)
|
||||||
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp := byteframe.NewByteFrame()
|
|
||||||
resp.WriteUint32(guild.Souls)
|
resp.WriteUint32(guild.Souls)
|
||||||
resp.WriteUint32(1) // unk
|
resp.WriteUint32(0) // unk
|
||||||
resp.WriteUint32(1) // unk
|
|
||||||
resp.WriteUint32(1) // unk, rank?
|
resp.WriteUint32(1) // unk, rank?
|
||||||
resp.WriteUint32(1) // unk
|
resp.WriteUint32(0) // unk
|
||||||
|
resp.WriteUint32(0) // unk
|
||||||
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,18 +122,12 @@ SELECT
|
|||||||
leader_id,
|
leader_id,
|
||||||
lc.name as leader_name,
|
lc.name as leader_name,
|
||||||
comment,
|
comment,
|
||||||
pugi_name_1,
|
COALESCE(pugi_name_1, '') AS pugi_name_1,
|
||||||
pugi_name_2,
|
COALESCE(pugi_name_2, '') AS pugi_name_2,
|
||||||
pugi_name_3,
|
COALESCE(pugi_name_3, '') AS pugi_name_3,
|
||||||
recruiting,
|
recruiting,
|
||||||
CASE WHEN (
|
COALESCE((SELECT team FROM festa_registrations fr WHERE fr.guild_id = g.id), 'none') AS festival_colour,
|
||||||
SELECT team FROM festa_registrations fr WHERE fr.guild_id = g.id
|
(SELECT SUM(souls) FROM guild_characters gc WHERE gc.guild_id = g.id) AS souls,
|
||||||
) IS NULL THEN 'none' ELSE (
|
|
||||||
SELECT team FROM festa_registrations fr WHERE fr.guild_id = g.id
|
|
||||||
) END festival_colour,
|
|
||||||
(
|
|
||||||
SELECT SUM(souls) FROM guild_characters gc WHERE gc.guild_id = g.id
|
|
||||||
) AS souls,
|
|
||||||
CASE
|
CASE
|
||||||
WHEN rank_rp <= 48 THEN rank_rp/24
|
WHEN rank_rp <= 48 THEN rank_rp/24
|
||||||
WHEN rank_rp <= 288 THEN rank_rp/48+1
|
WHEN rank_rp <= 288 THEN rank_rp/48+1
|
||||||
@@ -142,21 +136,14 @@ SELECT
|
|||||||
WHEN rank_rp < 1200 THEN 16
|
WHEN rank_rp < 1200 THEN 16
|
||||||
ELSE 17
|
ELSE 17
|
||||||
END rank,
|
END rank,
|
||||||
CASE WHEN (
|
COALESCE((
|
||||||
SELECT id FROM guild_alliances ga WHERE
|
SELECT id FROM guild_alliances ga WHERE
|
||||||
ga.parent_id = g.id OR
|
ga.parent_id = g.id OR
|
||||||
ga.sub1_id = g.id OR
|
ga.sub1_id = g.id OR
|
||||||
ga.sub2_id = g.id
|
ga.sub2_id = g.id
|
||||||
) IS NULL THEN 0 ELSE (
|
), 0) AS alliance_id,
|
||||||
SELECT id FROM guild_alliances ga WHERE
|
|
||||||
ga.parent_id = g.id OR
|
|
||||||
ga.sub1_id = g.id OR
|
|
||||||
ga.sub2_id = g.id
|
|
||||||
) END alliance_id,
|
|
||||||
icon,
|
icon,
|
||||||
(
|
(SELECT count(1) FROM guild_characters gc WHERE gc.guild_id = g.id) AS member_count
|
||||||
SELECT count(1) FROM guild_characters gc WHERE gc.guild_id = g.id
|
|
||||||
) AS member_count
|
|
||||||
FROM guilds g
|
FROM guilds g
|
||||||
JOIN guild_characters lgc ON lgc.character_id = leader_id
|
JOIN guild_characters lgc ON lgc.character_id = leader_id
|
||||||
JOIN characters lc on leader_id = lc.id
|
JOIN characters lc on leader_id = lc.id
|
||||||
@@ -962,22 +949,9 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
bf.WriteBool(false) // Unk
|
bf.WriteBool(false) // Unk
|
||||||
bf.WriteBytes([]byte{0x02, 0x02}) // Unk
|
bf.WriteBytes([]byte{0x02, 0x02}) // Unk
|
||||||
bf.WriteUint32(guild.EventRP)
|
bf.WriteUint32(guild.EventRP)
|
||||||
|
|
||||||
if guild.PugiName1 == "" {
|
|
||||||
bf.WriteUint16(0x0100)
|
|
||||||
} else {
|
|
||||||
ps.Uint8(bf, guild.PugiName1, true)
|
ps.Uint8(bf, guild.PugiName1, true)
|
||||||
}
|
|
||||||
if guild.PugiName2 == "" {
|
|
||||||
bf.WriteUint16(0x0100)
|
|
||||||
} else {
|
|
||||||
ps.Uint8(bf, guild.PugiName2, true)
|
ps.Uint8(bf, guild.PugiName2, true)
|
||||||
}
|
|
||||||
if guild.PugiName3 == "" {
|
|
||||||
bf.WriteUint16(0x0100)
|
|
||||||
} else {
|
|
||||||
ps.Uint8(bf, guild.PugiName3, true)
|
ps.Uint8(bf, guild.PugiName3, true)
|
||||||
}
|
|
||||||
|
|
||||||
// probably guild pugi properties, should be status, stamina and luck outfits
|
// probably guild pugi properties, should be status, stamina and luck outfits
|
||||||
bf.WriteBytes([]byte{
|
bf.WriteBytes([]byte{
|
||||||
@@ -998,7 +972,7 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
} else {
|
} else {
|
||||||
bf.WriteUint32(alliance.ID)
|
bf.WriteUint32(alliance.ID)
|
||||||
bf.WriteUint32(uint32(alliance.CreatedAt.Unix()))
|
bf.WriteUint32(uint32(alliance.CreatedAt.Unix()))
|
||||||
bf.WriteUint16(uint16(alliance.TotalMembers))
|
bf.WriteUint16(alliance.TotalMembers)
|
||||||
bf.WriteUint16(0) // Unk0
|
bf.WriteUint16(0) // Unk0
|
||||||
ps.Uint16(bf, alliance.Name, true)
|
ps.Uint16(bf, alliance.Name, true)
|
||||||
if alliance.SubGuild1ID > 0 {
|
if alliance.SubGuild1ID > 0 {
|
||||||
@@ -1061,7 +1035,7 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
doAckBufSucceed(s, pkt.AckHandle, resp.Data())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil || characterGuildData.IsApplicant {
|
||||||
bf.WriteUint16(0)
|
bf.WriteUint16(0)
|
||||||
} else {
|
} else {
|
||||||
bf.WriteUint16(uint16(len(applicants)))
|
bf.WriteUint16(uint16(len(applicants)))
|
||||||
@@ -1109,6 +1083,7 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
} else {
|
} else {
|
||||||
bf.WriteUint8(0x00)
|
bf.WriteUint8(0x00)
|
||||||
}
|
}
|
||||||
|
bf.WriteUint8(0) // Unk
|
||||||
|
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user