diff --git a/server/mailserver/player/playermgr.go b/server/mailserver/player/playermgr.go index 97fe6152..9147c7fa 100644 --- a/server/mailserver/player/playermgr.go +++ b/server/mailserver/player/playermgr.go @@ -7,6 +7,7 @@ import ( type playerMgr struct { accountIdHash sync.Map + lock sync.Mutex } func (this *playerMgr) Init() { @@ -23,6 +24,15 @@ func (this *playerMgr) GetPlayerByAccountId(accountId string) common.Player { } } -func (this *playerMgr) ForceCreatePlayer(string, string) common.Player { - return nil +func (this *playerMgr) ForceCreatePlayer(accountId string, sessionId string) common.Player { + 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 }