Exemplo n.º 1
0
Arquivo: db.go Projeto: mysll/flynet
func (d *DbBridge) savePlayer(p *BasePlayer, typ int) error {
	if p == nil || p.Entity == nil {
		return errors.New("player not created")
	}

	App.Save(p.Entity, typ)
	trans := App.GetLandpos(p.Entity)
	p.trans = trans
	save := share.UpdateUser{}
	save.Account = p.Account
	save.Name = p.ChooseRole
	save.Type = typ
	save.Scene, save.X, save.Y, save.Z, save.Dir = p.trans.Scene, p.trans.Pos.X, p.trans.Pos.Y, p.trans.Pos.Z, p.trans.Dir

	save.SaveData = *share.GetSaveData(p.Entity)
	db := server.GetAppByType("database")
	if db != nil {
		err := db.Call(&p.Mailbox, "Account.SavePlayer", save)
		if err == nil {
			p.Entity.ClearSaveFlag()
		}
		return err
	}

	return server.ErrAppNotFound

}
Exemplo n.º 2
0
func (status *StatusApp) OnShutdown() bool {
	if server.GetAppByType("base") == nil {
		status.Exit()
		return false
	}
	status.shutdown = 1
	return false
}
Exemplo n.º 3
0
Arquivo: db.go Projeto: mysll/flynet
func (d *DbBridge) getUserInfo(mailbox rpc.Mailbox, account string) error {
	db := server.GetAppByType("database")

	if db != nil {
		return db.Call(&mailbox, "Account.GetUserInfo", account)
	}

	return server.ErrAppNotFound
}
Exemplo n.º 4
0
Arquivo: db.go Projeto: mysll/flynet
func (d *DbBridge) SelectUserBak(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
	r := server.NewMessageReader(msg)
	save := share.LoadUserBak{}
	if server.Check(r.ReadObject(&save)) {
		return 0, nil
	}
	db := server.GetAppByType("database")
	info := share.ClearUser{save.Account, save.Name}
	player := App.Players.GetPlayer(mailbox.Id)
	if player == nil {
		log.LogError("player not found, id:", mailbox.Id)
		db.Call(&mailbox, "Account.ClearPlayerStatus", info)
		//角色没有找到
		return 0, nil
	}

	if player.State != STATE_LOGGED {
		log.LogError("player state not logged")
		db.Call(&mailbox, "Account.ClearPlayerStatus", info)
		player.Leave()
		return 0, nil
	}

	if save.Data == nil {
		db.Call(&mailbox, "Account.ClearPlayerStatus", info)
		server.Check(server.Error(nil, &mailbox, "Login.Error", share.ERROR_SELECT_ROLE_ERROR))
		return 0, nil
	}

	err := player.LoadPlayer(save)
	if server.Check(err) {
		db.Call(&mailbox, "Account.ClearPlayerStatus", info)
		return 0, nil
	}

	status := server.GetAppByType("status")
	if status != nil {
		status.Call(&mailbox, "PlayerList.UpdatePlayer", player.Account, player.ChooseRole, App.Name)
	}
	//App.AreaBridge.getArea(mailbox, save.Scene) //这里会自动加入场景
	return 0, nil
}
Exemplo n.º 5
0
Arquivo: area.go Projeto: mysll/flynet
func (a *AreaBridge) getArea(mailbox rpc.Mailbox, id string) error {
	app := server.GetAppByType("areamgr")
	if app == nil {
		return server.ErrAppNotFound
	}

	err := app.Call(&mailbox, "AreaMgr.GetArea", id)
	if err != nil {
		log.LogError(err)
	}
	return err
}
Exemplo n.º 6
0
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})
	}

}
Exemplo n.º 7
0
Arquivo: db.go Projeto: mysll/flynet
func (d *DbBridge) selectUser(mailbox rpc.Mailbox, account string, rolename string, index int) error {
	db := server.GetAppByType("database")

	if db != nil {
		loaduser := share.LoadUser{}
		loaduser.Account = account
		loaduser.RoleName = rolename
		loaduser.Index = index
		return db.Call(&mailbox, "Account.LoadUser", loaduser)
	}

	return server.ErrAppNotFound
}
Exemplo n.º 8
0
func (p *PlayerList) RemovePlayer(session int64) bool {
	if pl, exist := p.players[session]; exist && !pl.Deleted {
		status := server.GetAppByType("status")
		if status != nil {
			status.Call(nil, "PlayerList.UpdatePlayer", pl.Account, pl.ChooseRole, "")
		}

		pl.Deleted = true
		pl.State = STATE_DELETING
		log.LogDebug("Remove player:", pl.ChooseRole, " session:", session)
		return true
	}

	return false
}
Exemplo n.º 9
0
Arquivo: db.go Projeto: mysll/flynet
func (d *DbBridge) createRole(mailbox rpc.Mailbox, obj datatype.Entityer, account string, name string, index int, save *share.DbSave) error {
	db := server.GetAppByType("database")
	if db != nil {
		trans := App.GetLandpos(obj)
		cu := share.CreateUser{}
		cu.Account = account
		cu.Name = name
		cu.Index = index
		cu.Scene, cu.X, cu.Y, cu.Z, cu.Dir = trans.Scene, trans.Pos.X, trans.Pos.Y, trans.Pos.Z, trans.Dir
		cu.SaveData = *save
		return db.Call(&mailbox, "Account.CreateUser", cu)
	}

	return server.ErrAppNotFound
}
Exemplo n.º 10
0
Arquivo: db.go Projeto: mysll/flynet
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(&params)) {
		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
}
Exemplo n.º 11
0
Arquivo: base.go Projeto: mysll/flynet
func (b *BaseApp) StartInit() {
	db := server.GetAppByType("database")
	db.Call(nil, "Account.ClearStatus", b.Name)
}
Exemplo n.º 12
0
func (status *StatusApp) OnLost(app string) {
	if server.GetAppByType("base") == nil && status.shutdown == 1 {
		status.Exit()
	}
}