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 } }
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 } } }
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 } }
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()) }
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() } }
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) } }
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 } } }