mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
implement guild recruiters
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
package mhfpacket
|
package mhfpacket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"erupe-ce/network/clientctx"
|
|
||||||
"erupe-ce/network"
|
|
||||||
"erupe-ce/common/byteframe"
|
"erupe-ce/common/byteframe"
|
||||||
|
"erupe-ce/network"
|
||||||
|
"erupe-ce/network/clientctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgMhfSetGuildManageRight represents the MSG_MHF_SET_GUILD_MANAGE_RIGHT
|
// MsgMhfSetGuildManageRight represents the MSG_MHF_SET_GUILD_MANAGE_RIGHT
|
||||||
type MsgMhfSetGuildManageRight struct{}
|
type MsgMhfSetGuildManageRight struct {
|
||||||
|
AckHandle uint32
|
||||||
|
CharID uint32
|
||||||
|
Allowed bool
|
||||||
|
Unk []byte
|
||||||
|
}
|
||||||
|
|
||||||
// Opcode returns the ID associated with this packet type.
|
// Opcode returns the ID associated with this packet type.
|
||||||
func (m *MsgMhfSetGuildManageRight) Opcode() network.PacketID {
|
func (m *MsgMhfSetGuildManageRight) Opcode() network.PacketID {
|
||||||
@@ -18,7 +23,11 @@ func (m *MsgMhfSetGuildManageRight) Opcode() network.PacketID {
|
|||||||
|
|
||||||
// Parse parses the packet from binary
|
// Parse parses the packet from binary
|
||||||
func (m *MsgMhfSetGuildManageRight) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
func (m *MsgMhfSetGuildManageRight) Parse(bf *byteframe.ByteFrame, ctx *clientctx.ClientContext) error {
|
||||||
return errors.New("NOT IMPLEMENTED")
|
m.AckHandle = bf.ReadUint32()
|
||||||
|
m.CharID = bf.ReadUint32()
|
||||||
|
m.Allowed = bf.ReadBool()
|
||||||
|
m.Unk = bf.ReadBytes(3)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build builds a binary packet from the current data.
|
// Build builds a binary packet from the current data.
|
||||||
|
|||||||
@@ -3,4 +3,7 @@ BEGIN;
|
|||||||
ALTER TABLE IF EXISTS public.guilds
|
ALTER TABLE IF EXISTS public.guilds
|
||||||
ADD COLUMN IF NOT EXISTS recruiting bool NOT NULL DEFAULT true;
|
ADD COLUMN IF NOT EXISTS recruiting bool NOT NULL DEFAULT true;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS public.guild_characters
|
||||||
|
ADD COLUMN IF NOT EXISTS recruiter bool NOT NULL DEFAULT false;
|
||||||
|
|
||||||
END;
|
END;
|
||||||
@@ -889,7 +889,9 @@ func handleMsgMhfInfoGuild(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
bf.WriteUint8(guild.SubMotto)
|
bf.WriteUint8(guild.SubMotto)
|
||||||
|
|
||||||
// Unk appears to be static
|
// Unk appears to be static
|
||||||
bf.WriteBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
bf.WriteBytes([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||||
|
|
||||||
|
bf.WriteBool(!guild.Recruiting)
|
||||||
|
|
||||||
if characterGuildData == nil || characterGuildData.IsApplicant {
|
if characterGuildData == nil || characterGuildData.IsApplicant {
|
||||||
bf.WriteUint16(0x00)
|
bf.WriteUint16(0x00)
|
||||||
@@ -1385,7 +1387,8 @@ func handleMsgMhfGetGuildManageRight(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
bf.WriteUint32(member.CharID)
|
bf.WriteUint32(member.CharID)
|
||||||
bf.WriteUint32(0x0)
|
bf.WriteBool(member.Recruiter)
|
||||||
|
bf.WriteBytes(make([]byte, 3))
|
||||||
}
|
}
|
||||||
|
|
||||||
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
doAckBufSucceed(s, pkt.AckHandle, bf.Data())
|
||||||
@@ -1877,7 +1880,12 @@ func handleMsgMhfGenerateUdGuildMap(s *Session, p mhfpacket.MHFPacket) {}
|
|||||||
|
|
||||||
func handleMsgMhfUpdateGuild(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgMhfUpdateGuild(s *Session, p mhfpacket.MHFPacket) {}
|
||||||
|
|
||||||
func handleMsgMhfSetGuildManageRight(s *Session, p mhfpacket.MHFPacket) {}
|
func handleMsgMhfSetGuildManageRight(s *Session, p mhfpacket.MHFPacket) {
|
||||||
|
pkt := p.(*mhfpacket.MsgMhfSetGuildManageRight)
|
||||||
|
s.server.db.Exec("UPDATE guild_characters SET recruiter=$1 WHERE character_id=$2", pkt.Allowed, pkt.CharID)
|
||||||
|
// TODO: What is this supposed to return? This works for now
|
||||||
|
doAckBufSucceed(s, pkt.AckHandle, []byte{0x01})
|
||||||
|
}
|
||||||
|
|
||||||
func handleMsgMhfEnumerateInvGuild(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfEnumerateInvGuild(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfEnumerateInvGuild)
|
pkt := p.(*mhfpacket.MsgMhfEnumerateInvGuild)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type GuildMember struct {
|
|||||||
IsApplicant bool `db:"is_applicant"`
|
IsApplicant bool `db:"is_applicant"`
|
||||||
OrderIndex uint8 `db:"order_index"`
|
OrderIndex uint8 `db:"order_index"`
|
||||||
LastLogin uint32 `db:"last_login"`
|
LastLogin uint32 `db:"last_login"`
|
||||||
|
Recruiter bool `db:"recruiter"`
|
||||||
AvoidLeadership bool `db:"avoid_leadership"`
|
AvoidLeadership bool `db:"avoid_leadership"`
|
||||||
IsLeader bool `db:"is_leader"`
|
IsLeader bool `db:"is_leader"`
|
||||||
HRP uint16 `db:"hrp"`
|
HRP uint16 `db:"hrp"`
|
||||||
@@ -43,36 +44,33 @@ func (gm *GuildMember) Save(s *Session) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO add the recruiter permission to this check when it exists
|
|
||||||
func (gm *GuildMember) IsRecruiter() bool {
|
|
||||||
return gm.IsLeader || gm.IsSubLeader()
|
|
||||||
}
|
|
||||||
|
|
||||||
const guildMembersSelectSQL = `
|
const guildMembersSelectSQL = `
|
||||||
SELECT g.id as guild_id,
|
SELECT
|
||||||
joined_at,
|
g.id as guild_id,
|
||||||
c.name,
|
joined_at,
|
||||||
character.character_id,
|
c.name,
|
||||||
coalesce(gc.order_index, 0) as order_index,
|
character.character_id,
|
||||||
c.last_login,
|
coalesce(gc.order_index, 0) as order_index,
|
||||||
coalesce(gc.avoid_leadership, false) as avoid_leadership,
|
c.last_login,
|
||||||
c.hrp,
|
coalesce(gc.recruiter, false) as recruiter,
|
||||||
c.gr,
|
coalesce(gc.avoid_leadership, false) as avoid_leadership,
|
||||||
c.weapon_id,
|
c.hrp,
|
||||||
c.weapon_type,
|
c.gr,
|
||||||
character.is_applicant,
|
c.weapon_id,
|
||||||
CASE WHEN g.leader_id = c.id THEN 1 ELSE 0 END as is_leader
|
c.weapon_type,
|
||||||
FROM (
|
character.is_applicant,
|
||||||
SELECT character_id, true as is_applicant, guild_id
|
CASE WHEN g.leader_id = c.id THEN 1 ELSE 0 END as is_leader
|
||||||
FROM guild_applications ga
|
FROM (
|
||||||
WHERE ga.application_type = 'applied'
|
SELECT character_id, true as is_applicant, guild_id
|
||||||
UNION
|
FROM guild_applications ga
|
||||||
SELECT character_id, false as is_applicant, guild_id
|
WHERE ga.application_type = 'applied'
|
||||||
FROM guild_characters gc
|
UNION
|
||||||
) character
|
SELECT character_id, false as is_applicant, guild_id
|
||||||
JOIN characters c on character.character_id = c.id
|
FROM guild_characters gc
|
||||||
LEFT JOIN guild_characters gc ON gc.character_id = character.character_id
|
) character
|
||||||
JOIN guilds g ON g.id = character.guild_id
|
JOIN characters c on character.character_id = c.id
|
||||||
|
LEFT JOIN guild_characters gc ON gc.character_id = character.character_id
|
||||||
|
JOIN guilds g ON g.id = character.guild_id
|
||||||
`
|
`
|
||||||
|
|
||||||
func GetGuildMembers(s *Session, guildID uint32, applicants bool) ([]*GuildMember, error) {
|
func GetGuildMembers(s *Session, guildID uint32, applicants bool) ([]*GuildMember, error) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ func handleMsgMhfPostGuildScout(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if actorCharGuildData == nil || !actorCharGuildData.IsRecruiter() {
|
if actorCharGuildData == nil || !actorCharGuildData.Recruiter {
|
||||||
doAckBufFail(s, pkt.AckHandle, make([]byte, 4))
|
doAckBufFail(s, pkt.AckHandle, make([]byte, 4))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ func handleMsgMhfCancelGuildScout(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if guildCharData == nil || !guildCharData.IsRecruiter() {
|
if guildCharData == nil || !guildCharData.Recruiter {
|
||||||
doAckBufFail(s, pkt.AckHandle, make([]byte, 4))
|
doAckBufFail(s, pkt.AckHandle, make([]byte, 4))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user