This commit is contained in:
aozhiwei 2024-04-27 09:08:56 +08:00
parent dc2670bfb8
commit 98729ea223

View File

@ -7,6 +7,7 @@ import (
type playerMgr struct { type playerMgr struct {
accountIdHash sync.Map accountIdHash sync.Map
lock sync.Mutex
} }
func (this *playerMgr) Init() { func (this *playerMgr) Init() {
@ -23,6 +24,15 @@ func (this *playerMgr) GetPlayerByAccountId(accountId string) common.Player {
} }
} }
func (this *playerMgr) ForceCreatePlayer(string, string) common.Player { func (this *playerMgr) ForceCreatePlayer(accountId string, sessionId string) common.Player {
return nil defer this.lock.Unlock()
this.lock.Lock()
hum := this.GetPlayerByAccountId(accountId)
if hum == nil {
p := newPlayer()
p.accountId = accountId
p.sessionId = sessionId
hum = p
}
return hum
} }