Exemplo n.º 1
0
func TestEtf2lHighlander(t *testing.T) {
	config := NewServerConfig()
	config.League = LeagueEtf2l
	config.Type = LobbyTypeHighlander
	config.Map = "pl_badwater"
	cfg, cfgErr := config.Get()

	assert.Nil(t, cfgErr, "cfg error")
	assert.NotEmpty(t, cfg, "cfg shouldn't be empty")
}
Exemplo n.º 2
0
func TestUgcSixes(t *testing.T) {
	config := NewServerConfig()
	config.League = LeagueUgc
	config.Type = LobbyTypeSixes
	config.Map = "cp_badlands"
	cfg, cfgErr := config.Get()

	assert.Nil(t, cfgErr, "cfg error")
	assert.NotEmpty(t, cfg, "cfg shouldn't be empty")
}
Exemplo n.º 3
0
func TestEtf2lSixes(t *testing.T) {
	config := NewServerConfig()
	config.League = LeagueEtf2l
	config.Type = LobbyTypeSixes
	config.Map = "cp_gullywash_final1"
	cfg, cfgErr := config.Get()

	assert.Nil(t, cfgErr, "cfg error")
	assert.NotEmpty(t, cfg, "cfg shouldn't be empty")
}
Exemplo n.º 4
0
func (s *Server) Setup() error {
	if config.Constants.ServerMockUp {
		return nil
	}

	helpers.Logger.Debug("[Server.Setup]: Setting up server -> [" + s.Info.Host + "] from lobby [" + fmt.Sprint(s.LobbyId) + "]")

	// connect to rcon if not connected before
	if s.Rcon == nil {
		var err error
		s.Rcon, err = TF2RconWrapper.NewTF2RconConnection(s.Info.Host, s.Info.RconPassword)

		if err != nil {
			return err
		}
	}

	// changing server password
	passErr := s.Rcon.ChangeServerPassword(s.ServerPassword)

	if passErr != nil {
		return passErr
	}

	// kick players
	helpers.Logger.Debug("[Server.Setup]: Connected to server, getting players...")
	kickErr := s.KickAll()

	if kickErr != nil {
		return kickErr
	} else {
		helpers.Logger.Debug("[Server.Setup]: Players kicked, running config!")
	}

	// run config
	config := NewServerConfig()
	config.League = s.League
	config.Type = s.Type
	config.Map = s.Map
	cfg, cfgErr := config.Get()

	if cfgErr == nil {
		config.Data = cfg
		configErr := s.ExecConfig(config)

		if configErr != nil {
			return configErr
		}
	} else {
		return cfgErr
	}

	// change map
	mapErr := s.Rcon.ChangeMap(s.Map)

	if mapErr != nil {
		return mapErr
	}

	return nil
}