Exemplo n.º 1
0
func patchGender(c *C) func() {
	d := c.MkDir()
	ioutil.WriteFile(filepath.Join(d, "gender.toml"), genderData, 0666)
	f := testutil.PatchEnv(config.CLAYMUD_DATADIR, d)
	gender.Initialize()
	return f
}
Exemplo n.º 2
0
func Main() {
	flag.Parse()

	// config must be first!
	maybeFatal(config.Initialize())

	maybeFatal(gender.Initialize())
	maybeFatal(emote.Initialize())
	maybeFatal(auth.Initialize())

	// db must be before world!
	maybeFatal(db.Initialize())

	// World needs to be last.
	maybeFatal(world.Initialize())

	host := net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
	log.Printf("Running ClayMUD on %v", host)

	addr, err := net.ResolveTCPAddr("tcp", host)
	if err != nil {
		log.Printf("Error resolving host %v: %v", host, err)
		return
	}

	listener, err := net.ListenTCP("tcp", addr)
	if err != nil {
		log.Fatalf("Failed listening for connections: %s", err)
	}
	for {
		conn, err := listener.AcceptTCP()
		if err != nil {
			log.Printf("Error accepting TCP connection: %v", err)
			continue
		}
		conn.SetKeepAlive(false)
		conn.SetLinger(0)

		log.Printf("New connection from %v", conn.RemoteAddr())
		go auth.Login(conn, conn.RemoteAddr())
	}
}