Esempio n. 1
0
func (s *Server) Serve() error {
	log.Printf("Entity server loading on %s\n", s.Addr)

	s.Players = make(map[string]*PlayerEntity)

	return network.ServeInternal(s.Addr, s)
}
Esempio n. 2
0
func (s *Server) Serve() error {
	log.Printf("Chunk server (%d, %d) loading on %s\n", s.OffsetX, s.OffsetZ, s.Addr)

	s.Listeners = make(map[*network.InternalConnection]bool)

	blockType := byte(((s.OffsetX+8)/8+(s.OffsetZ+8)/4)%4 + 1)

	for z := int64(0); z < world.ChunkWidthPerNode; z++ {
		for x := int64(0); x < world.ChunkWidthPerNode; x++ {
			c := world.NewChunk(s.OffsetX+x, s.OffsetZ+z)
			c.Generate(blockType)
			s.storage[z][x] = c
		}
	}

	s.blockUpdateChannel = make(chan *protobuf.BlockUpdate)
	go s.Loop()

	return network.ServeInternal(s.Addr, s)
}