This commit is contained in:
aozhiwei 2024-04-04 09:57:58 +08:00
parent d2c335ecce
commit a2a2038d20

View File

@ -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,