Exemplo n.º 1
0
void ToggleFavorite(string srv)
{
	string s, s0, s1, s2, srv_resolved;
	float i, n;
	srv_resolved = netaddress_resolve(srv, 26000);
	s = cvar_string("net_slist_favorites");
	n = tokenize_console(s);
	for(i = 0; i < n; ++i)
		if(srv_resolved == netaddress_resolve(argv(i), 26000))
		{
			s0 = s1 = s2 = "";
			if(i > 0)
				s0 = substring(s, 0, argv_end_index(i - 1));
			if(i < n-1)
				s2 = substring(s, argv_start_index(i + 1), -1);
			if(s0 != "" && s2 != "")
				s1 = " ";
			print("s0 = >>", s0, "<<\ns1 = >>", s1, "<<\ns2 = >>", s2, "<<\n");
			cvar_set("net_slist_favorites", strcat(s0, s1, s2));
			return;
		}
	
	s1 = "";
	if(s != "")
		s1 = " ";
	cvar_set("net_slist_favorites", strcat(s, " ", srv));

	resorthostcache();
}
Exemplo n.º 2
0
float IsFavorite(string srv)
{
	string p;
	float i, n;
	if(srv == "")
		return FALSE;
	srv = netaddress_resolve(srv, 26000);
	if(srv == "")
		return FALSE;
	p = crypto_getidfp(srv);
	n = tokenize_console(cvar_string("net_slist_favorites"));
	for(i = 0; i < n; ++i)
	{
		if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
		{
			if(p)
				if(argv(i) == p)
					return TRUE;
		}
		else
		{
			if(srv == netaddress_resolve(argv(i), 26000))
				return TRUE;
		}
	}
	return FALSE;
}
Exemplo n.º 3
0
float IsFavorite(string srv)
{
	float i, n;
	srv = netaddress_resolve(srv, 26000);
	n = tokenize_console(cvar_string("net_slist_favorites"));
	for(i = 0; i < n; ++i)
		if(srv == netaddress_resolve(argv(i), 26000))
			return TRUE;
	return FALSE;
}
Exemplo n.º 4
0
void ToggleFavorite(string srv)
{
	string s, s0, s1, s2, srv_resolved, p;
	float i, n, f;
	srv_resolved = netaddress_resolve(srv, 26000);
	p = crypto_getidfp(srv_resolved);
	s = cvar_string("net_slist_favorites");
	n = tokenize_console(s);
	f = 0;
	for(i = 0; i < n; ++i)
	{
		if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
		{
			if(p)
				if(argv(i) != p)
					continue;
		}
		else
		{
			if(srv_resolved != netaddress_resolve(argv(i), 26000))
				continue;
		}
		s0 = s1 = s2 = "";
		if(i > 0)
			s0 = substring(s, 0, argv_end_index(i - 1));
		if(i < n-1)
			s2 = substring(s, argv_start_index(i + 1), -1);
		if(s0 != "" && s2 != "")
			s1 = " ";
		cvar_set("net_slist_favorites", strcat(s0, s1, s2));
		s = cvar_string("net_slist_favorites");
		n = tokenize_console(s);
		f = 1;
		--i;
	}
	
	if(!f)
	{
		s1 = "";
		if(s != "")
			s1 = " ";
		if(p)
			cvar_set("net_slist_favorites", strcat(s, s1, p));
		else
			cvar_set("net_slist_favorites", strcat(s, s1, srv));
	}

	resorthostcache();
}