1
This commit is contained in:
parent
e815b9a0cc
commit
28337e69ae
@ -18,14 +18,14 @@ const (
|
||||
type guildMgr struct {
|
||||
idHash map[string]*guild
|
||||
nameHash map[string]*guild
|
||||
accountIdHash map[string]*guild
|
||||
memberIdHash map[string]*member
|
||||
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.memberIdHash = make(map[string]*member)
|
||||
this.usingNameHash = make(map[string]int64)
|
||||
this.loadFromDB()
|
||||
}
|
||||
@ -69,9 +69,9 @@ func (this *guildMgr) loadGuildMember() {
|
||||
g := this.internalGetGuildByGuildId(guildId)
|
||||
if g != nil {
|
||||
p := newMember()
|
||||
p.init(g.guildId, memberId, joinTime)
|
||||
p.init(g, memberId, joinTime)
|
||||
g.addMember(p)
|
||||
this.accountIdHash[memberId] = g
|
||||
this.memberIdHash[memberId] = p
|
||||
}
|
||||
},
|
||||
func (err error) {
|
||||
@ -79,28 +79,36 @@ func (this *guildMgr) loadGuildMember() {
|
||||
})
|
||||
f5.GetSysLog().Info("loadGuildMember end memberNum:%d",
|
||||
lastIdx,
|
||||
len(this.accountIdHash))
|
||||
len(this.memberIdHash))
|
||||
}
|
||||
|
||||
func (this *guildMgr) isNameTooLong(name string, maxNum int) bool {
|
||||
return len(name) > maxNum
|
||||
}
|
||||
|
||||
func (this *guildMgr) GetGuildByAccountId(accountId string) common.Guild {
|
||||
return this.internalGetGuildByAccountId(accountId)
|
||||
}
|
||||
|
||||
func (this *guildMgr) GetGuildByGuildId(guildId string) common.Guild {
|
||||
return this.internalGetGuildByGuildId(guildId)
|
||||
}
|
||||
|
||||
func (this *guildMgr) GetGuildByAccountId(accountId string) common.Guild {
|
||||
return this.internalGetGuildByGuildId(accountId)
|
||||
}
|
||||
|
||||
func (this *guildMgr) GetGuildByGuildName(guildName string) common.Guild {
|
||||
return this.internalGetGuildByGuildName(guildName)
|
||||
}
|
||||
|
||||
func (this *guildMgr) internalGetGuildByAccountId(accountId string) *guild {
|
||||
if guild, ok := this.accountIdHash[accountId]; ok {
|
||||
return guild
|
||||
m := this.internalGetMemberByAccountId(accountId)
|
||||
if m != nil {
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *guildMgr) internalGetMemberByAccountId(accountId string) *member {
|
||||
if m, ok := this.memberIdHash[accountId]; ok {
|
||||
return m
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -206,15 +214,15 @@ func (this *guildMgr) AsyncCreateGuild(accountId string, avatar int32, name stri
|
||||
guild := newGuild()
|
||||
this.idHash[guild.guildId] = guild
|
||||
this.nameHash[guild.guildName] = guild
|
||||
this.accountIdHash[accountId] = guild
|
||||
//this.accountIdHash[accountId] = guild
|
||||
oldGuild := this.internalGetGuildByAccountId(accountId)
|
||||
if oldGuild != nil {
|
||||
|
||||
} else {
|
||||
m := newMember()
|
||||
m.init(guildId, accountId, q5.ToInt32(nowTime))
|
||||
m.init(guild, accountId, q5.ToInt32(nowTime))
|
||||
guild.addMember(m)
|
||||
this.accountIdHash[accountId] = guild
|
||||
//this.accountIdHash[accountId] = guild
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -4,17 +4,26 @@ import (
|
||||
)
|
||||
|
||||
type member struct {
|
||||
guildId string
|
||||
guild *guild
|
||||
memberId string
|
||||
joinTime int32
|
||||
wLock int32
|
||||
}
|
||||
|
||||
func (this *member) init(guildId string, memberId string, joinTime int32) {
|
||||
this.guildId = guildId
|
||||
func (this *member) init(guild *guild, memberId string, joinTime int32) {
|
||||
this.guild = guild
|
||||
this.memberId = memberId
|
||||
this.joinTime = joinTime
|
||||
}
|
||||
|
||||
func (this *member) lock() {
|
||||
this.wLock++
|
||||
}
|
||||
|
||||
func (this *member) unlock() {
|
||||
this.wLock--
|
||||
}
|
||||
|
||||
func newMember() *member {
|
||||
p := new(member)
|
||||
return p
|
||||
|
Loading…
x
Reference in New Issue
Block a user