Exemple #1
0
func (serv *GServer) SavePlayers() {
	serv.Log.Printf("Saving Players...")
	for _, m := range serv.Maps {
		m.Run.Add(func() {
			for _, c := range m.Players {
				serv.DBRun.Add(func() { Data.SavePlayer(c.Player) })
			}
		})
	}
	serv.Sdr.AddMin(func() { serv.SavePlayers() }, 1)
	//serv.Sdr.AddSec(func() { serv.SavePlayers() }, 5)
}
Exemple #2
0
func (serv *GServer) OnShutdown() {
	serv.Run.StopAndWait()
	serv.Log.Printf("GServer runner stopped!")
	serv.DBRun.StopAndWait()
	serv.Log.Printf("GServer DB runner stopped!")
	for id, m := range serv.Maps {
		m.Run.StopAndWait()
		serv.Log.Printf("Mapid %d runner stopped!", id)
		for _, c := range m.Players {
			Data.SavePlayer(c.Player)
		}
	}
	serv.CoreServer.Socket.Close()
	serv.Log.Printf("GServer socket closed!")

	if serv.RPCListener != nil {
		e := serv.RPCListener.Close()
		if e != nil {
			panic(e)
		}
	}
}