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:
Houmgaor
2026-02-27 14:59:18 +01:00
parent fba8c2413c
commit d6938f2a27
9 changed files with 167 additions and 10 deletions

View File

@@ -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()