func InitPlayerMgr() {
	InitConfigDB()
	qtPlayers = geom.NewQuadTree(-180, 180, -90, 90)
	lcPlayers = cache.NewLRUCache(&cache.LRUOptions{Capacity: 0, MaxAge: time.Minute * 5, NoAgeCheck: true})
	go PlayersPosHandleRem()

	tp, _ := db.Main.InitTable(Player{})
	tblPlayer = db.NewTableCached(tp, &db.CacheParams{1024, time.Minute * 30})
	//tblInvItem, _ = db.Main.InitTable(InvItem{})

	var err error
	techTree, err = util.LoadConfigFile("techtree.cfg")
	if err != nil {
		log.Println("Error: Invalid Config File:", err)
		return
	}
	InitResourceMgr()
	InitCreatureMgr()
	InitPOIs()
	InitFights()

	err = db.Main.ApplyRebuilds()
	if err != nil {
		panic(err)
	}
}
Exemple #2
0
func GetState() *util.JsonConfig {
	if state == nil {
		sCfg := "state.cfg"
		var err error
		state, err = util.LoadConfigFile(sCfg)
		if err != nil {
			log.Println("Error: Invalid State File:", err)
		}
		state.MakeObject()
	}
	return state
}
Exemple #3
0
func LoadConfig() {
	sCfg := util.GetExeName() + ".cfg"
	flag.StringVar(&sCfg, "cfg", sCfg, "config file")

	flag.Parse()
	log.Println("Load Config:", sCfg)

	var err error
	cfg, err = util.LoadConfigFile(sCfg)
	if err != nil {
		log.Println("Error: Invalid Config File:", err)
		return
	}

	log.Println("Config:", *cfg.Get("name"), *cfg.Get("version"))
}