mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 18:12:50 +01:00
fix(guild): implement alliance application toggle (#166)
Alliance applications were hardcoded to always-open. Add a `recruiting` column to guild_alliances and handle OperateJoint actions 0x06 (Allow) and 0x07 (Deny) confirmed via Wii U debug symbols. Only the parent guild leader can toggle the setting, matching the existing disband guard.
This commit is contained in:
@@ -15,6 +15,7 @@ type GuildAlliance struct {
|
||||
Name string `db:"name"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
TotalMembers uint16
|
||||
Recruiting bool `db:"recruiting"`
|
||||
|
||||
ParentGuildID uint32 `db:"parent_id"`
|
||||
SubGuild1ID uint32 `db:"sub1_id"`
|
||||
@@ -75,6 +76,24 @@ func handleMsgMhfOperateJoint(s *Session, p mhfpacket.MHFPacket) {
|
||||
)
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
case mhfpacket.OPERATE_JOINT_ALLOW:
|
||||
if guild.LeaderCharID == s.charID && alliance.ParentGuildID == guild.ID {
|
||||
if err := s.server.guildRepo.SetAllianceRecruiting(alliance.ID, true); err != nil {
|
||||
s.logger.Error("Failed to allow alliance applications", zap.Error(err))
|
||||
}
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
} else {
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
case mhfpacket.OPERATE_JOINT_DENY:
|
||||
if guild.LeaderCharID == s.charID && alliance.ParentGuildID == guild.ID {
|
||||
if err := s.server.guildRepo.SetAllianceRecruiting(alliance.ID, false); err != nil {
|
||||
s.logger.Error("Failed to deny alliance applications", zap.Error(err))
|
||||
}
|
||||
doAckSimpleSucceed(s, pkt.AckHandle, make([]byte, 4))
|
||||
} else {
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
}
|
||||
case mhfpacket.OPERATE_JOINT_KICK:
|
||||
if alliance.ParentGuild.LeaderCharID == s.charID {
|
||||
kickedGuildID := pkt.Data1.ReadUint32()
|
||||
|
||||
Reference in New Issue
Block a user