更新公会成员通知

This commit is contained in:
殷勇 2023-09-20 18:06:46 +08:00
parent 9b13566736
commit fcdf6c0c61
7 changed files with 763 additions and 399 deletions

View File

@ -365,6 +365,10 @@ func (this *SMApplyToGuild) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMApplyToGuild) return uint16(SMMessageIdE__SMApplyToGuild)
} }
func (this *SMApplyToGuildNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMApplyToGuildNotify)
}
func (this *CMApplyList) GetNetMsgId() uint16 { func (this *CMApplyList) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMApplyList) return uint16(CMMessageIdE__CMApplyList)
} }
@ -401,6 +405,10 @@ func (this *SMLeaveGuild) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMLeaveGuild) return uint16(SMMessageIdE__SMLeaveGuild)
} }
func (this *SMLeaveGuildNotify) GetNetMsgId() uint16 {
return uint16(SMMessageIdE__SMLeaveGuildNotify)
}
func (this *CMDismissMember) GetNetMsgId() uint16 { func (this *CMDismissMember) GetNetMsgId() uint16 {
return uint16(CMMessageIdE__CMDismissMember) return uint16(CMMessageIdE__CMDismissMember)
} }

View File

@ -229,6 +229,8 @@ const (
SMMessageIdE__SMApproveJoinGuildNotify SMMessageIdE = 1010 SMMessageIdE__SMApproveJoinGuildNotify SMMessageIdE = 1010
SMMessageIdE__SMDismissMemberNotify SMMessageIdE = 1011 SMMessageIdE__SMDismissMemberNotify SMMessageIdE = 1011
SMMessageIdE__SMSetMemberLevelNotify SMMessageIdE = 1012 SMMessageIdE__SMSetMemberLevelNotify SMMessageIdE = 1012
SMMessageIdE__SMApplyToGuildNotify SMMessageIdE = 1013
SMMessageIdE__SMLeaveGuildNotify SMMessageIdE = 1014
) )
// Enum value maps for SMMessageIdE. // Enum value maps for SMMessageIdE.
@ -275,6 +277,8 @@ var (
1010: "_SMApproveJoinGuildNotify", 1010: "_SMApproveJoinGuildNotify",
1011: "_SMDismissMemberNotify", 1011: "_SMDismissMemberNotify",
1012: "_SMSetMemberLevelNotify", 1012: "_SMSetMemberLevelNotify",
1013: "_SMApplyToGuildNotify",
1014: "_SMLeaveGuildNotify",
} }
SMMessageIdE_value = map[string]int32{ SMMessageIdE_value = map[string]int32{
"_SMPing": 101, "_SMPing": 101,
@ -318,6 +322,8 @@ var (
"_SMApproveJoinGuildNotify": 1010, "_SMApproveJoinGuildNotify": 1010,
"_SMDismissMemberNotify": 1011, "_SMDismissMemberNotify": 1011,
"_SMSetMemberLevelNotify": 1012, "_SMSetMemberLevelNotify": 1012,
"_SMApplyToGuildNotify": 1013,
"_SMLeaveGuildNotify": 1014,
} }
) )
@ -412,7 +418,7 @@ var file_cs_msgid_proto_rawDesc = []byte{
0x53, 0x65, 0x74, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x10, 0x89, 0x01, 0x12, 0x13, 0x0a, 0x0e, 0x53, 0x65, 0x74, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x10, 0x89, 0x01, 0x12, 0x13, 0x0a, 0x0e,
0x5f, 0x43, 0x4d, 0x53, 0x65, 0x74, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x10, 0x8a, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x74, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x10, 0x8a,
0x01, 0x12, 0x1a, 0x0a, 0x15, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x01, 0x12, 0x1a, 0x0a, 0x15, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e,
0x64, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x10, 0x8b, 0x01, 0x2a, 0xc1, 0x07, 0x64, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x10, 0x8b, 0x01, 0x2a, 0xf7, 0x07,
0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f, 0x0a, 0x0b,
0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66, 0x12, 0x0c, 0x0a, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66, 0x12, 0x0c, 0x0a,
@ -473,7 +479,10 @@ var file_cs_msgid_proto_rawDesc = []byte{
0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79,
0x10, 0xf3, 0x07, 0x12, 0x1c, 0x0a, 0x17, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x74, 0x4d, 0x65, 0x6d, 0x10, 0xf3, 0x07, 0x12, 0x1c, 0x0a, 0x17, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x74, 0x4d, 0x65, 0x6d,
0x62, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf4, 0x62, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf4,
0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73, 0x07, 0x12, 0x1a, 0x0a, 0x15, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47,
0x75, 0x69, 0x6c, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x10, 0xf5, 0x07, 0x12, 0x18, 0x0a,
0x13, 0x5f, 0x53, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4e, 0x6f,
0x74, 0x69, 0x66, 0x79, 0x10, 0xf6, 0x07, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
} }
var ( var (

File diff suppressed because it is too large Load Diff

View File

@ -136,20 +136,20 @@ func (gm *GuildMgr) CreateGuild(avatar int32, name *string, leaderId string,
} }
// ApplyToGuild 申请加入公会 // ApplyToGuild 申请加入公会
func (gm *GuildMgr) ApplyToGuild(guildId int64, applicantAccountId string, cb func(errCode int32, errMsg string)) { func (gm *GuildMgr) ApplyToGuild(guildId int64, applicantAccountId string, cb func(errCode int32, errMsg string, guild *Guild)) {
guild := gm.GetGuild(guildId) guild := gm.GetGuild(guildId)
if guild == nil { if guild == nil {
cb(ERR_CODE_GUILD_NO_EXISTS, "ApplyToGuild guild no exists") cb(ERR_CODE_GUILD_NO_EXISTS, "ApplyToGuild guild no exists", nil)
return return
} }
// 是否加入其他公会 // 是否加入其他公会
if gm.CheckJoinGuild(applicantAccountId) { if gm.CheckJoinGuild(applicantAccountId) {
cb(ERR_CODE_JOINED_GUILD, "ApplyToGuild joined guild") cb(ERR_CODE_JOINED_GUILD, "ApplyToGuild joined guild", nil)
return return
} }
if guild.IsFull() { if guild.IsFull() {
cb(ERR_CODE_GUILD_MEMBER_FULL, "ApplyToGuild guild member full") cb(ERR_CODE_GUILD_MEMBER_FULL, "ApplyToGuild guild member full", nil)
return return
} }
// 可直接加入 // 可直接加入
@ -161,11 +161,11 @@ func (gm *GuildMgr) ApplyToGuild(guildId int64, applicantAccountId string, cb fu
if guild.JoinCond == JoinCondStar { if guild.JoinCond == JoinCondStar {
profile := cacheMgr.GetPlayerProfile(applicantAccountId) profile := cacheMgr.GetPlayerProfile(applicantAccountId)
if profile == nil { if profile == nil {
cb(ERR_CODE_GUILD_MEMBER_NO_EXISTS, "applicantAccountId no exists") cb(ERR_CODE_GUILD_MEMBER_NO_EXISTS, "applicantAccountId no exists", nil)
return return
} }
if profile.Star < guild.JoinCondValue { if profile.Star < guild.JoinCondValue {
cb(ERR_CODE_APPLY_GUILD_FAIL, "ApplyToGuild Fail, user star error") cb(ERR_CODE_APPLY_GUILD_FAIL, "ApplyToGuild Fail, user star error", nil)
return return
} }
gm.JoinGuild(guild, applicantAccountId, cb) gm.JoinGuild(guild, applicantAccountId, cb)
@ -193,7 +193,7 @@ func (gm *GuildMgr) ApplyToGuild(guildId int64, applicantAccountId string, cb fu
insertKv, insertKv,
func(err error, lastInsertId int64, rowsAffected int64) { func(err error, lastInsertId int64, rowsAffected int64) {
if err != nil || rowsAffected <= 0 { if err != nil || rowsAffected <= 0 {
cb(ERR_CODE_UPDATE_GUILD_PENDING_REQUEST_DB_FAIL, "ApplyToGuild guild pending request db error") cb(ERR_CODE_UPDATE_GUILD_PENDING_REQUEST_DB_FAIL, "ApplyToGuild guild pending request db error", nil)
return return
} }
@ -214,7 +214,7 @@ func (gm *GuildMgr) ApplyToGuild(guildId int64, applicantAccountId string, cb fu
EVENT_APPLY, EVENT_APPLY,
prop, prop,
) )
cb(ERR_CODE_OK, "ApplyToGuild ok") cb(ERR_CODE_OK, "ApplyToGuild ok", guild)
}) })
} }
@ -350,19 +350,19 @@ func (gm *GuildMgr) Reject(operatorAccountId, accountId string, cb func(errCode
} }
// JoinGuild 直接加入公会 // JoinGuild 直接加入公会
func (gm *GuildMgr) JoinGuild(guild *Guild, accountId string, cb func(errCode int32, errMsg string)) { func (gm *GuildMgr) JoinGuild(guild *Guild, accountId string, cb func(errCode int32, errMsg string, guild *Guild)) {
newMember := GuildMember{AccountId: accountId, Level: GuildMemberLevelDefault} newMember := GuildMember{AccountId: accountId, Level: GuildMemberLevelDefault}
guildId := guild.GuildId guildId := guild.GuildId
gm.upsertGuildMember(guildId, &newMember, gm.upsertGuildMember(guildId, &newMember,
func(err error) { func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, "JoinGuild Fail, upsertGuildMember") cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, "JoinGuild Fail, upsertGuildMember", nil)
return return
} }
guild.AddMember(&newMember) guild.AddMember(&newMember)
gm.AddUserGuild(accountId, guildId) gm.AddUserGuild(accountId, guildId)
cb(ERR_CODE_OK, "ApplyToGuild OK") cb(ERR_CODE_OK, "ApplyToGuild OK", guild)
user := friendMgr.GetUser(accountId) user := friendMgr.GetUser(accountId)
cacheMgr.LoadPlayerProfile(user, func(playerProfile *PlayerProfile) {}) cacheMgr.LoadPlayerProfile(user, func(playerProfile *PlayerProfile) {})
@ -382,15 +382,15 @@ func (gm *GuildMgr) JoinGuild(guild *Guild, accountId string, cb func(errCode in
} }
// LeaveGuild 离开公会 // LeaveGuild 离开公会
func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg string)) { func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg string, guild *Guild)) {
guild := gm.GetGuildByAccountId(accountId) guild := gm.GetGuildByAccountId(accountId)
if guild == nil { if guild == nil {
cb(ERR_CODE_GUILD_NO_EXISTS, "no join guild]") cb(ERR_CODE_GUILD_NO_EXISTS, "no join guild]", nil)
return return
} }
member := guild.GetMember(accountId) member := guild.GetMember(accountId)
if member == nil { if member == nil {
cb(ERR_CODE_GUILD_MEMBER_NO_EXISTS, "LeaveGuild member no exists") cb(ERR_CODE_GUILD_MEMBER_NO_EXISTS, "LeaveGuild member no exists", nil)
return return
} }
membersCount := guild.GetMembersCount() membersCount := guild.GetMembersCount()
@ -404,7 +404,7 @@ func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg s
if accountId == guild.LeaderId { if accountId == guild.LeaderId {
newLeader := guild.NewLeader(accountId) newLeader := guild.NewLeader(accountId)
if newLeader == nil { if newLeader == nil {
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, "error") cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, "error", nil)
return return
} }
f5.GetSysLog().Info("LeaveGuild guildId:%d, newLeader:%s", guild.GuildId, newLeader.AccountId) f5.GetSysLog().Info("LeaveGuild guildId:%d, newLeader:%s", guild.GuildId, newLeader.AccountId)
@ -414,7 +414,7 @@ func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg s
} }
gm.updateGuild(guild, updateFields, func(err error) { gm.updateGuild(guild, updateFields, func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error()) cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error(), nil)
return return
} }
guild.LeaderId = newLeader.AccountId guild.LeaderId = newLeader.AccountId
@ -424,7 +424,7 @@ func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg s
gm.updateGuildMember(guild, newLeader.AccountId, newMemberFields, gm.updateGuildMember(guild, newLeader.AccountId, newMemberFields,
func(err error) { func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, err.Error()) cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, err.Error(), nil)
return return
} }
}) })
@ -435,7 +435,7 @@ func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg s
gm.updateGuildMember(guild, member.AccountId, fields, gm.updateGuildMember(guild, member.AccountId, fields,
func(err error) { func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, err.Error()) cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, err.Error(), nil)
return return
} }
@ -457,7 +457,7 @@ func (gm *GuildMgr) LeaveGuild(accountId string, cb func(errCode int32, errMsg s
EVENT_LEAVE, EVENT_LEAVE,
prop, prop,
) )
cb(ERR_CODE_OK, "LeaveGuild OK") cb(ERR_CODE_OK, "LeaveGuild OK", guild)
}) })
} }
@ -671,16 +671,16 @@ func (gm *GuildMgr) SetMemberLevel(operatorAccountId, accountId string, newLevel
} }
// Disband 解散公会 // Disband 解散公会
func (gm *GuildMgr) Disband(operatorAccountId string, cb func(errCode int32, errMsg string)) { func (gm *GuildMgr) Disband(operatorAccountId string, cb func(errCode int32, errMsg string, guild *Guild)) {
guild := gm.GetGuildByAccountId(operatorAccountId) guild := gm.GetGuildByAccountId(operatorAccountId)
if guild == nil { if guild == nil {
cb(ERR_CODE_GUILD_NO_EXISTS, "Disband guild no exists") cb(ERR_CODE_GUILD_NO_EXISTS, "Disband guild no exists", nil)
return return
} }
// 仅会长可操作 // 仅会长可操作
if operatorAccountId != guild.LeaderId { if operatorAccountId != guild.LeaderId {
cb(ERR_CODE_GUILD_NO_LEADER_PERM, "Disband only leader perm") cb(ERR_CODE_GUILD_NO_LEADER_PERM, "Disband only leader perm", nil)
return return
} }
guildId := guild.GuildId guildId := guild.GuildId
@ -692,18 +692,18 @@ func (gm *GuildMgr) Disband(operatorAccountId string, cb func(errCode int32, err
} }
gm.updateGuild(guild, updateFields, func(err error) { gm.updateGuild(guild, updateFields, func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error()) cb(ERR_CODE_UPDATE_GUILD_DB_FAIL, err.Error(), nil)
return return
} }
fields := [][]string{{"is_leave_guild", q5.ToString(1)}} fields := [][]string{{"is_leave_guild", q5.ToString(1)}}
gm.updateGuildMembers(guildId, fields, func(err error) { gm.updateGuildMembers(guildId, fields, func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, err.Error()) cb(ERR_CODE_UPDATE_GUILD_MEMBER_DB_FAIL, err.Error(), nil)
return return
} }
gm.updateAllPendingReqs(guildId, PendingReqIsJoinGuildStatusDisband, func(err error) { gm.updateAllPendingReqs(guildId, PendingReqIsJoinGuildStatusDisband, func(err error) {
if err != nil { if err != nil {
cb(ERR_CODE_UPDATE_GUILD_PENDING_REQUEST_DB_FAIL, err.Error()) cb(ERR_CODE_UPDATE_GUILD_PENDING_REQUEST_DB_FAIL, err.Error(), nil)
return return
} }
logContent := fmt.Sprintf("GuildDisbanded[%d-%s]", guildId, guildName) logContent := fmt.Sprintf("GuildDisbanded[%d-%s]", guildId, guildName)
@ -729,7 +729,7 @@ func (gm *GuildMgr) Disband(operatorAccountId string, cb func(errCode int32, err
prop, prop,
) )
cb(ERR_CODE_OK, "Disband ok") cb(ERR_CODE_OK, "Disband ok", guild)
}) })
}) })
}) })

View File

@ -320,13 +320,33 @@ func (p *Player) CMCreateGuild(hdr *f5.MsgHdr, msg *cs.CMCreateGuild) {
func (p *Player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) { func (p *Player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) {
guildMgr.ApplyToGuild( guildMgr.ApplyToGuild(
msg.GetGuildId(), p.accountId, msg.GetGuildId(), p.accountId,
func(errCode int32, errMsg string) { func(errCode int32, errMsg string, guild *Guild) {
rspMsg := new(cs.SMApplyToGuild) rspMsg := new(cs.SMApplyToGuild)
if errCode != 0 { if errCode != 0 {
rspMsg.Errcode = &errCode rspMsg.Errcode = &errCode
rspMsg.Errmsg = &errMsg rspMsg.Errmsg = &errMsg
} }
p.SendMsg(rspMsg) p.SendMsg(rspMsg)
if guild != nil {
// 成员通知消息
rspNotify := new(cs.SMApplyToGuildNotify)
rspNotify.GuildId = &guild.GuildId
rspNotify.Name = &guild.Name
rspNotify.AccountId = &p.accountId
playerProfile := cacheMgr.GetPlayerProfile(p.accountId)
if playerProfile != nil {
rspNotify.Username = &playerProfile.Username
}
for targetAccountId := range guild.Members {
target := playerMgr.GetPlayerByAccountId(targetAccountId)
if target == nil {
continue
}
target.SendMsg(rspNotify)
}
}
}, },
) )
} }
@ -366,11 +386,22 @@ func (p *Player) CMApprove(hdr *f5.MsgHdr, msg *cs.CMApprove) {
} }
p.SendMsg(rspMsg) p.SendMsg(rspMsg)
if guild != nil { if guild != nil {
target := playerMgr.GetPlayerByAccountId(msg.GetApplicantAccountId()) // 成员通知消息
if target != nil { rspNotify := new(cs.SMApproveJoinGuildNotify)
rspNotify := new(cs.SMApproveJoinGuildNotify) rspNotify.GuildId = &guild.GuildId
rspNotify.GuildId = &guild.GuildId rspNotify.Name = &guild.Name
rspNotify.Name = &guild.Name
rspNotify.AccountId = msg.ApplicantAccountId
playerProfile := cacheMgr.GetPlayerProfile(msg.GetApplicantAccountId())
if playerProfile != nil {
rspNotify.Username = &playerProfile.Username
}
for targetAccountId := range guild.Members {
target := playerMgr.GetPlayerByAccountId(targetAccountId)
if target == nil {
continue
}
target.SendMsg(rspNotify) target.SendMsg(rspNotify)
} }
} }
@ -397,13 +428,33 @@ func (p *Player) CMReject(hdr *f5.MsgHdr, msg *cs.CMReject) {
func (p *Player) CMLeaveGuild(hdr *f5.MsgHdr, msg *cs.CMLeaveGuild) { func (p *Player) CMLeaveGuild(hdr *f5.MsgHdr, msg *cs.CMLeaveGuild) {
guildMgr.LeaveGuild( guildMgr.LeaveGuild(
p.accountId, p.accountId,
func(errCode int32, errMsg string) { func(errCode int32, errMsg string, guild *Guild) {
rspMsg := new(cs.SMLeaveGuild) rspMsg := new(cs.SMLeaveGuild)
if errCode != 0 { if errCode != 0 {
rspMsg.Errcode = &errCode rspMsg.Errcode = &errCode
rspMsg.Errmsg = &errMsg rspMsg.Errmsg = &errMsg
} }
p.SendMsg(rspMsg) p.SendMsg(rspMsg)
if guild != nil {
// 成员通知消息
rspNotify := new(cs.SMLeaveGuildNotify)
rspNotify.GuildId = &guild.GuildId
rspNotify.Name = &guild.Name
rspNotify.AccountId = &p.accountId
playerProfile := cacheMgr.GetPlayerProfile(p.accountId)
if playerProfile != nil {
rspNotify.Username = &playerProfile.Username
}
for targetAccountId := range guild.Members {
target := playerMgr.GetPlayerByAccountId(targetAccountId)
if target == nil {
continue
}
target.SendMsg(rspNotify)
}
}
}, },
) )
} }
@ -421,13 +472,28 @@ func (p *Player) CMDismissMember(hdr *f5.MsgHdr, msg *cs.CMDismissMember) {
} }
p.SendMsg(rspMsg) p.SendMsg(rspMsg)
if guild != nil { if guild != nil {
target := playerMgr.GetPlayerByAccountId(msg.GetDismissAccountId()) // 成员通知消息
if target != nil { rspNotify := new(cs.SMDismissMemberNotify)
rspNotify := new(cs.SMDismissMemberNotify) rspNotify.GuildId = &guild.GuildId
rspNotify.GuildId = &guild.GuildId rspNotify.Name = &guild.Name
rspNotify.Name = &guild.Name rspNotify.AccountId = msg.DismissAccountId
playerProfile := cacheMgr.GetPlayerProfile(msg.GetDismissAccountId())
if playerProfile != nil {
rspNotify.Username = &playerProfile.Username
}
for targetAccountId := range guild.Members {
target := playerMgr.GetPlayerByAccountId(targetAccountId)
if target == nil {
continue
}
target.SendMsg(rspNotify) target.SendMsg(rspNotify)
} }
dismissAccount := playerMgr.GetPlayerByAccountId(msg.GetDismissAccountId())
if dismissAccount != nil {
dismissAccount.SendMsg(rspNotify)
}
} }
}, },
) )
@ -447,12 +513,22 @@ func (p *Player) CMSetMemberLevel(hdr *f5.MsgHdr, msg *cs.CMSetMemberLevel) {
} }
p.SendMsg(rspMsg) p.SendMsg(rspMsg)
if guild != nil { if guild != nil {
target := playerMgr.GetPlayerByAccountId(msg.GetMemberAccountId()) for range guild.Members {
if target != nil { target := playerMgr.GetPlayerByAccountId(msg.GetMemberAccountId())
if target == nil {
continue
}
// 通知消息
rspNotify := new(cs.SMSetMemberLevelNotify) rspNotify := new(cs.SMSetMemberLevelNotify)
rspNotify.GuildId = &guild.GuildId rspNotify.GuildId = &guild.GuildId
rspNotify.Name = &guild.Name rspNotify.Name = &guild.Name
rspNotify.MemberLevel = msg.MemberLevel rspNotify.MemberLevel = msg.MemberLevel
rspNotify.AccountId = msg.MemberAccountId
playerProfile := cacheMgr.GetPlayerProfile(msg.GetMemberAccountId())
if playerProfile != nil {
rspNotify.Username = &playerProfile.Username
}
target.SendMsg(rspNotify) target.SendMsg(rspNotify)
} }
} }
@ -463,7 +539,7 @@ func (p *Player) CMSetMemberLevel(hdr *f5.MsgHdr, msg *cs.CMSetMemberLevel) {
func (p *Player) CMDisband(hdr *f5.MsgHdr, msg *cs.CMDisband) { func (p *Player) CMDisband(hdr *f5.MsgHdr, msg *cs.CMDisband) {
guildMgr.Disband( guildMgr.Disband(
p.accountId, p.accountId,
func(errCode int32, errMsg string) { func(errCode int32, errMsg string, guild *Guild) {
rspMsg := new(cs.SMDisband) rspMsg := new(cs.SMDisband)
if errCode != 0 { if errCode != 0 {
rspMsg.Errcode = &errCode rspMsg.Errcode = &errCode

View File

@ -100,4 +100,6 @@ enum SMMessageId_e
_SMApproveJoinGuildNotify = 1010; _SMApproveJoinGuildNotify = 1010;
_SMDismissMemberNotify = 1011; _SMDismissMemberNotify = 1011;
_SMSetMemberLevelNotify = 1012; _SMSetMemberLevelNotify = 1012;
_SMApplyToGuildNotify = 1013;
_SMLeaveGuildNotify = 1014;
} }

View File

@ -414,6 +414,15 @@ message SMApplyToGuild
optional string errmsg = 2; optional string errmsg = 2;
} }
//
message SMApplyToGuildNotify
{
optional int64 guild_id = 1;
optional string name = 2;
optional string accountId = 3;
optional string username = 4;
}
// //
message CMApplyList{} message CMApplyList{}
@ -443,6 +452,8 @@ message SMApproveJoinGuildNotify
{ {
optional int64 guild_id = 1; optional int64 guild_id = 1;
optional string name = 2; optional string name = 2;
optional string accountId = 3;
optional string username = 4;
} }
// //
@ -468,6 +479,15 @@ message SMLeaveGuild
optional string errmsg = 2; optional string errmsg = 2;
} }
//
message SMLeaveGuildNotify
{
optional int64 guild_id = 1;
optional string name = 2;
optional string accountId = 3;
optional string username = 4;
}
// //
message CMDismissMember message CMDismissMember
{ {
@ -486,6 +506,8 @@ message SMDismissMemberNotify
{ {
optional int64 guild_id = 1; optional int64 guild_id = 1;
optional string name = 2; optional string name = 2;
optional string accountId = 3;
optional string username = 4;
} }
// //
@ -508,6 +530,8 @@ message SMSetMemberLevelNotify
optional int64 guild_id = 1; optional int64 guild_id = 1;
optional string name = 2; optional string name = 2;
optional int32 memberLevel = 3; optional int32 memberLevel = 3;
optional string accountId = 4;
optional string username = 5;
} }
// //