This commit is contained in:
aozhiwei 2024-04-12 14:15:03 +08:00
parent dfe96fcd1f
commit 62eae3d17d
3 changed files with 28 additions and 7 deletions

View File

@ -91,7 +91,7 @@ type GuildMgr interface {
AsyncGetGuildRank(int32, func(int32, string, []string))
AsyncGetRecommendGuild(int32, func(int32, string, []string))
AsyncLeave(string, func(int32, string, []string))
AsyncLeave(string, func(int32, string, string, string, []string))
AsyncKickout(string, string, func(int32, string, string, string))
AsyncDisband(string, func(int32, string, []string))
AsyncSetGuildJob(string, string, int32, func(int32, string, string, string))

View File

@ -408,13 +408,14 @@ func (this *guildMgr) AsyncRejectApply(accountId string, targetId string,
})
}
func (this *guildMgr) AsyncLeave(accountId string, cb func(int32, string, []string)) {
func (this *guildMgr) AsyncLeave(accountId string,
cb func(int32, string, string, string, []string)) {
members := []string{}
keys := [][]string{}
{
guild := this.internalGetGuildByAccountId(accountId)
if guild == nil {
cb(0, "", members)
cb(0, "", "", "", members)
return
}
keys = [][]string{
@ -435,18 +436,18 @@ func (this *guildMgr) AsyncLeave(accountId string, cb func(int32, string, []stri
members := []string{}
if guild == nil {
task.SetSucc()
cb(0, "", members)
cb(0, "", guild.guildId, guild.guildName, members)
return
}
guild.asyncLeave(accountId,
func (errCode int32, errMsg string) {
if errCode != 0 {
task.SetFail()
cb(errCode, errMsg, members)
cb(errCode, errMsg, guild.guildId, guild.guildName, members)
return
}
task.SetSucc()
cb(0, "", members)
cb(0, "", guild.guildId, guild.guildName, members)
return
})
})

View File

@ -560,12 +560,32 @@ func (this *player) CMLeaveGuild(hdr *f5.MsgHdr, msg *cs.CMLeaveGuild) {
rspMsg := new(cs.SMLeaveGuild)
GetGuildMgr().AsyncLeave(
this.GetAccountId(),
func (errCode int32, errMsg string, members []string) {
func (errCode int32, errMsg string, guildId string, guildName string, members []string) {
if errCode != 0 {
this.SendMsg(rspMsg.Err(errCode, errMsg))
return
}
this.SendMsg(rspMsg)
{
{
pbGuilds := []*cs.MFGuildMember{}
GetCacheMgr().AsyncGetUsersAndFillMFGuildMember(
[]string{
this.GetAccountId(),
},
&pbGuilds,
func (errCode int32, errMsg string) {
if errCode == 0 && len(pbGuilds) > 0 {
notifyMsg := new(cs.SMLeaveGuildNotify)
notifyMsg.GuildId = proto.Int64(q5.ToInt64(guildId))
notifyMsg.Name = proto.String(guildName)
notifyMsg.AccountId = proto.String(pbGuilds[0].GetAccountId())
notifyMsg.Username = proto.String(pbGuilds[0].GetUsername())
GetGuildMgr().NotifyGuildMsg(guildId, notifyMsg)
}
})
}
}
})
}