Exemplo n.º 1
0
func LoadRanks(Done chan bool) {
	defer func() {
		if x := recover(); x != nil {
			log.Printf("%v\n%s", x, C.PanicPath())
			Done <- false
		} else {
			Done <- true
		}
	}()

	f, e := os.Open(ranksPath)
	if e != nil {
		log.Panicln(e)
	}

	defer f.Close()

	type dummyXML struct {
		XMLName xml.Name    `xml:"Ranks"`
		Ranks   []*RankData `xml:"Rank"`
	}

	l := &dummyXML{}

	e = xml.NewDecoder(f).Decode(l)
	if e != nil {
		log.Panicln(e)
	}

	for _, rank := range l.Ranks {
		Ranks[rank.Level] = rank
	}
}
Exemplo n.º 2
0
func LoadItems(Done chan bool) {
	defer func() {
		if x := recover(); x != nil {
			log.Printf("%v\n%s", x, C.PanicPath())
			Done <- false
		} else {
			Done <- true
		}
	}()

	f, e := os.Open(itemPath)
	if e != nil {
		log.Panicln(e)
	}

	defer f.Close()

	type xmlitems struct {
		XMLName       xml.Name         `xml:"Items"`
		ItemDataGroup []*ItemDataGroup `xml:"ItemGroup"`
	}

	items := new(xmlitems)
	e = xml.NewDecoder(f).Decode(items)
	if e != nil {
		log.Panicln(e)
	}

	for _, ig := range items.ItemDataGroup {
		ItemsByGroup[ig.GID] = ig.ItemData
		for _, it := range ig.ItemData {
			Items[it.ID] = it
		}
	}
}
Exemplo n.º 3
0
func LoadBinds(Done chan bool) {
	defer func() {
		if x := recover(); x != nil {
			log.Printf("%v\n%s", x, C.PanicPath())
			Done <- false
		} else {
			Done <- true
		}
	}()
	f, e := os.Open(bindsPath)
	if e != nil {
		log.Panicln(e)
	}

	defer f.Close()

	bf := &BindingFile{}

	e = xml.NewDecoder(f).Decode(bf)
	if e != nil {
		log.Panicln(e)
	}

	for _, group := range bf.Groups {
		Binds[group.UID] = group
	}
}
Exemplo n.º 4
0
func (client *LClient) OnDisconnect() {
	if x := recover(); x != nil {
		client.Log().Printf_Warning("panic : %v \n %s", x, C.PanicPath())
	}

	if client.Disconnecting {
		return
	}
	client.Disconnecting = true

	client.Socket.Close()
	client.MainServer.Server().Log.Println_Info("Client Disconnected! %s", client.Socket.RemoteAddr())
}
Exemplo n.º 5
0
func OnClose() {
	if Closing {
		return
	}
	Closing = true

	if x := recover(); x != nil {
		log.Printf("%v %s\n", x, C.PanicPath())
	}

	defer func() {
		if x := recover(); x != nil {
			log.Printf("%v %s\n", x, C.PanicPath())
		}
		cmd := ""
		log.Println("Press enter to quit...")
		fmt.Scanln(&cmd)
		os.Exit(0)
	}()

	if Server != nil {
		Server.OnShutdown()
	}
}
Exemplo n.º 6
0
func LoadShop(Done chan bool) {
	defer func() {
		if x := recover(); x != nil {
			log.Printf("%v\n%s", x, C.PanicPath())
			Done <- false
		} else {
			Done <- true
		}
	}()
	f, e := os.Open(shopPath)
	if e != nil {
		log.Panicln(e)
	}

	defer f.Close()

	e = xml.NewDecoder(f).Decode(Shopdata)
	if e != nil {
		log.Panicln(e)
	}
}
Exemplo n.º 7
0
func LoadUnits(Done chan bool) {
	defer func() {
		if x := recover(); x != nil {
			log.Printf("%v\n%s", x, C.PanicPath())
			Done <- false
		} else {
			Done <- true
		}
	}()

	type dummyXML struct {
		XMLName       xml.Name         `xml:"Units"`
		UnitGroupData []*UnitGroupData `xml:"UnitGroup"`
	}

	f, e := os.Open(unitsPath)
	if e != nil {
		log.Panicln(e)
	}

	defer f.Close()

	dum := &dummyXML{}

	e = xml.NewDecoder(f).Decode(dum)
	if e != nil {
		log.Panicln(e)
	}

	for _, group := range dum.UnitGroupData {
		d, e := Divisions[group.Division]
		if !e {
			d = Other
		}
		for _, unit := range group.Units {
			unit.DType = d
			Units[unit.Name] = unit
		}
	}
}