Example #1
0
File: ts2.c Project: Bubelbub/qstat
query_status_t send_ts2_request_packet( struct qserver *server )
{
	char buf[256];

	int serverport = get_param_i_value( server, "port", 0 );
	change_server_port( server, serverport, 1 );

	if ( get_player_info )
	{
		server->flags |= TF_PLAYER_QUERY|TF_RULES_QUERY;
		sprintf( buf, "si %d\npl %d\nquit\n", serverport, serverport );
		server->saved_data.pkt_index = 2;
	}
	else
	{
		server->flags |= TF_STATUS_QUERY;
		sprintf( buf, "si %d\nquit\n", serverport );
		server->saved_data.pkt_index = 1;
	}

	return send_packet( server, buf, strlen( buf ) );
}
Example #2
0
query_status_t
send_ts3_single_server_packet(struct qserver *server)
{
	char buf[256], *password, *username;
	int serverport;

	switch (server->challenge) {
	case 0:
		// Not seen a challenge yet, wait for it
		server->n_servers = 999;
		return (INPROGRESS);

	case 1:
		// Login if needed
		password = get_param_value(server, "password", "");
		if (0 != strlen(password)) {
			username = get_param_value(server, "username", "serveradmin");
			sprintf(buf, "login %s %s\015\012", username, password);
			break;
		}
		// NOTE: no break so we fall through
		server->challenge++;

	case 2:
		// Select port
		serverport = get_param_i_value(server, "port", 0);
		change_server_port(server, serverport, 1);
		// NOTE: we use n_servers as an indication of how many responses we are expecting to get
		if (get_player_info) {
			server->flags |= TF_PLAYER_QUERY | TF_RULES_QUERY;
			server->n_servers = 5;
		} else {
			server->flags |= TF_STATUS_QUERY;
			server->n_servers = 4;
		}
		sprintf(buf, "use port=%d\015\012", serverport);
		break;

	case 3:
		// Server Info
		sprintf(buf, "serverinfo\015\012");
		break;

	case 4:
		// Player Info, Quit or Done
		sprintf(buf, (get_player_info) ? "clientlist\015\012" : "quit\015\012");
		break;

	case 5:
		// Quit or Done
		if (get_player_info) {
			sprintf(buf, "quit\015\012");
		} else {
			return (DONE_FORCE);
		}
		break;
	}
	server->saved_data.pkt_max = -1;

	return (send_packet(server, buf, strlen(buf)));
}
Example #3
0
int
all_ts3_servers(struct qserver *server)
{
	return ((1 == get_param_i_value(server, "allservers", 0)) ? 1 : 0);
}