diff --git a/server/imserver_new/guild/guildmgr.go b/server/imserver_new/guild/guildmgr.go index 0be68108..06394c9a 100644 --- a/server/imserver_new/guild/guildmgr.go +++ b/server/imserver_new/guild/guildmgr.go @@ -19,12 +19,14 @@ type guildMgr struct { idHash map[string]*guild nameHash map[string]*guild accountIdHash map[string]*guild + usingNameHash map[string]int64 } func (this *guildMgr) Init() { this.idHash = make(map[string]*guild) this.nameHash = make(map[string]*guild) this.accountIdHash = make(map[string]*guild) + this.usingNameHash = make(map[string]int64) this.loadFromDB() } @@ -124,14 +126,37 @@ func (this *guildMgr) GetGuildRank() []common.Guild { return guilds } +func (this *guildMgr) addUsingName(name string) { + this.usingNameHash[name] = f5.GetApp().GetNowSeconds(); +} + +func (this *guildMgr) isUsingName(name string) bool { + if _, ok := this.usingNameHash[name]; ok { + return true + } else { + return false + } +} + +func (this* guildMgr) removeUsingName(name string) { + delete(this.usingNameHash, name) +} + func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name string, cb func(int32, string, int64)) { if this.internalGetGuildByAccountId(accountId) != nil { - + cb(1, "", 0) + return } if this.internalGetGuildByGuildName(name) != nil { - + cb(1, "", 0) + return } + if this.isUsingName(name) { + cb(1, "", 0) + return + } + this.addUsingName(name) } func (this *guildMgr) AsyncGetApplyList(lastIdx int64, accountId string,