func (p *BasePlayer) updatemin(intervalid server.TimerID, count int32, args interface{}) { p.CheckNewDay() //任务更新 App.tasksystem.OnUpdate(p.Entity.(*entity.Player)) //清理过期的邮件 DeleteExpiredLetter(p.Entity.(*entity.Player)) db := server.GetAppByType("database") if db != nil { server.NewDBWarp(db).LookLetter(nil, p.Entity.GetDbId(), "DbBridge.LookLetterBack", share.DBParams{"mailbox": p.Mailbox}) } }
func (d *DbBridge) LookLetterBack(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) { params := share.DBParams{} r := server.NewMessageReader(msg) if server.Check(r.ReadObject(¶ms)) { return 0, nil } if !params["result"].(bool) { return 0, nil } mailbox = params["mailbox"].(rpc.Mailbox) p := App.Players.GetPlayer(mailbox.Id) if p == nil { log.LogError("player not found, id:", mailbox.Id) //角色没有找到 return 0, nil } player := p.Entity.(*entity.Player) db := server.GetAppByType("database") if db == nil { log.LogError(server.ErrAppNotFound) return 0, nil } warp := server.NewDBWarp(db) letters := params["letters"].([]*share.LetterInfo) for _, letter := range letters { idx := player.MailBox_r.AddRowValue(-1, letter.Source, letter.Source_name, util.UTC2Loc(letter.Send_time.Time.UTC()).Unix(), letter.Title, letter.Content, letter.Appendix, 0, letter.Serial_no, letter.Msg_type) if idx == -1 { //邮箱满了 server.Error(nil, &mailbox, "Letter.Error", ERR_MAILBOX_FULL) break } //删信 warp.RecvLetter(nil, player.GetDbId(), letter.Serial_no, "_", share.DBParams{}) } return 0, nil }