コード例 #1
0
ファイル: tu.c プロジェクト: Cross777/COMP1927
int main(int argc, char **argv)
{
	URL_FILE *handle;
	char buffer[BUFSIZE];

	if(argc > 1)
		strcpy(BASE,argv[1]);
	else {
		fprintf(stderr, "Usage: %s BaseURL\n",argv[0]);
		exit(1);
	}
		
	handle = url_fopen(BASE, "r");
	if (!handle) {
		fprintf(stderr,"couldn't url_fopen() %s\n", BASE);
		return 2;
	}
	while(!url_feof(handle)) {
		url_fgets(buffer,sizeof(buffer),handle);
		strlower(buffer);
		fputs(buffer,stdout);
		char *cur, link[BUFSIZE], full_link[BUFSIZE];
		cur = buffer;
		while ((cur = nextURL(cur)) != NULL) {
			getURL(cur, link, BUFSIZE-1);
			normalise(link, full_link, BUFSIZE-1);
			printf("%s\n",full_link);
			cur += strlen(link);
		}
	}

	url_fclose(handle);
	return 0;
}
コード例 #2
0
ファイル: m3u.c プロジェクト: Akuaksh/soc
static int m3u_list_files(ByteIOContext *s, char ***flist_ptr, int *len_ptr)
{
    char **flist, **flist_tmp;
    int i, bufsize;
    flist = NULL;
    i = bufsize = 0;
    while (1) {
        char *q;
        char linebuf[1024] = {0};
        if ((q = url_fgets(s, linebuf, sizeof(linebuf))) == NULL) // EOF
            break;
        linebuf[sizeof(linebuf)-1] = 0; // cut off end if buffer overflowed
        while (*q != 0) {
            if (*q++ == '#')
                *(q-1) = 0;
        }
        if (*linebuf == 0) // hashed out
            continue;
        flist_tmp = av_fast_realloc(flist, &bufsize, i+2);
        if (!flist_tmp) {
            av_log(NULL, AV_LOG_ERROR, "av_realloc error in m3u_list_files\n");
            av_free(flist);
            return AVERROR_NOMEM;
        } else
            flist = flist_tmp;
        flist[i] = av_malloc(q-linebuf+1);
        av_strlcpy(flist[i], linebuf, q-linebuf+1);
        flist[i++][q-linebuf] = 0;
    }
    *flist_ptr = flist;
    *len_ptr = i;
    if (!flist) // no files have been found
        return AVERROR_EOF;
    flist[i] = 0;
    return 0;
}
コード例 #3
0
/* Small main program to retrive from a url using fgets and fread saving the
 * output to two test files (note the fgets method will corrupt binary files if
 * they contain 0 chars */
int
main(int argc, char *argv[])
{
    URL_FILE *handle;
    FILE *outf;

    int nread;
    char buffer[256];
    const char *url;

    if(argc < 2)
    {
        url="http://192.168.7.3/testfile";/* default to testurl */
    }
    else
    {
        url=argv[1];/* use passed url */
    }

    /* copy from url line by line with fgets */
    outf=fopen("fgets.test","w+");
    if(!outf)
    {
        perror("couldn't open fgets output file\n");
        return 1;
    }

    handle = url_fopen(url, "r");
    if(!handle)
    {
        printf("couldn't url_fopen()\n");
        fclose(outf);
        return 2;
    }

    while(!url_feof(handle))
    {
        url_fgets(buffer,sizeof(buffer),handle);
        fwrite(buffer,1,strlen(buffer),outf);
    }

    url_fclose(handle);

    fclose(outf);


    /* Copy from url with fread */
    outf=fopen("fread.test","w+");
    if(!outf)
    {
        perror("couldn't open fread output file\n");
        return 1;
    }

    handle = url_fopen("testfile", "r");
    if(!handle) {
        printf("couldn't url_fopen()\n");
        fclose(outf);
        return 2;
    }

    do {
        nread = url_fread(buffer, 1,sizeof(buffer), handle);
        fwrite(buffer,1,nread,outf);
    } while(nread);

    url_fclose(handle);

    fclose(outf);


    /* Test rewind */
    outf=fopen("rewind.test","w+");
    if(!outf)
    {
        perror("couldn't open fread output file\n");
        return 1;
    }

    handle = url_fopen("testfile", "r");
    if(!handle) {
        printf("couldn't url_fopen()\n");
        fclose(outf);
        return 2;
    }

        nread = url_fread(buffer, 1,sizeof(buffer), handle);
        fwrite(buffer,1,nread,outf);
        url_rewind(handle);

        buffer[0]='\n';
        fwrite(buffer,1,1,outf);

        nread = url_fread(buffer, 1,sizeof(buffer), handle);
        fwrite(buffer,1,nread,outf);


    url_fclose(handle);

    fclose(outf);


    return 0;/* all done */
}
コード例 #4
0
ファイル: Source.cpp プロジェクト: krogenth/TWAUMM
int main(int argc, char *argv[]) {

	char *ally = "ally.txt", *play = "tribe.txt", *village = "village.txt", *oda = "kill_att.txt", *odd = "kill_def.txt", *ods = "kill_sup.txt", *odaT = "kill_att_tribe.txt", *oddT = "kill_def_tribe.txt", *conquer = "conquer.txt";
	char buffer[256];

	unsigned int topTribeRanks[15] = { 0 }, topPlayerRanks[15] = { 0 }, topODARanks[15] = { 0 }, topODDRanks[15] = { 0 }, topODSRanks[15] = { 0 }, topODATRanks[15] = { 0 }, topODDTRanks[15] = { 0 }, topPlayerConqRanks[15] = { 0 }, topPlayerLossRanks[15] = { 0 }, topTribeConqRanks[15] = { 0 }, topTribeLossRanks[15] = { 0 };

	URL_FILE *handle;
	std::string urlBase, urlFinish;
	const char *url;
	CURL *cURL;

	curl_global_init(CURL_GLOBAL_DEFAULT);
	cURL = curl_easy_init();

	std::string data, filePath;
	std::vector<std::string> servers, serverNames, serverEnds;
	std::ifstream serverFile;

	//read in server list
	int bytes = GetModuleFileName(NULL, buffer, 256);
	if (bytes == 0)
		return EXIT_FAILURE;
	else
		filePath = buffer;

	data = filePath.substr(0, filePath.find_last_of('\\'));

	data += "\\Servers\\servers.txt";
	serverFile.open(data);

	if (serverFile.is_open()) {

		while (std::getline(serverFile, data)) {//27 total

			unsigned int fstPos = 0, secPos = 0;

			if (data[0] == ';')
				continue;

			secPos = data.find(' ');
			servers.push_back(data.substr(fstPos, secPos- fstPos));

			fstPos = secPos + 1;
			secPos = data.find(' ', fstPos);
			serverNames.push_back(data.substr(fstPos, secPos - fstPos).c_str());
			serverEnds.push_back(data.substr(secPos + 1, data.length() - (secPos + 1)));

		}

	}
	else
		return EXIT_FAILURE;

	serverFile.close();

	//Read in colors to file
	std::ifstream inFile;
	inFile.open("colors.txt");

	unsigned int colors[45] = { 0 };

	for (int count = 0; std::getline(inFile, data); count++) {

		unsigned int fstPos = 0, secPos = 0;

		secPos = data.find(' ');
		colors[count * 3] = atoi(data.substr(fstPos, secPos - fstPos).c_str());

		fstPos = secPos + 1;
		secPos = data.find(' ', fstPos);
		colors[count * 3 + 1] = atoi(data.substr(fstPos, secPos - fstPos).c_str());

		colors[count * 3 + 2] = atoi(data.substr(secPos + 1, data.length() - (secPos + 1)).c_str());

	}

	inFile.close();
	time_t timer;

	while (true) {

		timer = std::time(NULL);

		if (timer % 86400 == 23250) {

			unsigned int ServerCount = 0;

			int bytes = GetModuleFileName(NULL, buffer, 256);
			if (bytes == 0)
				return EXIT_FAILURE;
			else
				filePath = buffer;

			std::string worldFileName = filePath.substr(0, filePath.find_last_of('\\')); 
			worldFileName += "\\Servers\\Worlds\\" + servers.at(ServerCount) + "worlds.txt";
			std::ifstream worldFile;
			worldFile.open(worldFileName);

			if (worldFile.is_open()) {

				while (std::getline(worldFile, data)) {

					if (data[0] == ';')
						continue;

					std::string world = servers.at(ServerCount) + data;

					urlBase = "https://";
					urlBase += world;
					//urlBase += ".tribalwars.net/map/";
					urlBase += '.' + serverNames.at(ServerCount) + '.' + serverEnds.at(ServerCount) + "/map/";

					urlFinish = urlBase + ally;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					For handling data, first the tribe data must be stored, then the player data, to be able to link players to tribes.
					Afterwards, everything can be handled at the same time - 3+ threads.
					*/

					std::vector<tribe> tribes;

					//Read in Tribe data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						size_t comFstPos = 0, comSecPos = 0;

						tribes.push_back(tribe());

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL) return EXIT_FAILURE;
						bufferString = buffer;

						comSecPos = bufferString.find(',');

						tribes.at(count).setID(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setName(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setTag(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setMemb(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setVills(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setTopPoints(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setPoints(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribes.at(count).setRank(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()) <= 15)
							topTribeRanks[atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()) - 1] = tribes.size() - 1;

						comFstPos = 0;
						comSecPos = 0;

					}

					url_fclose(handle);

					urlFinish = urlBase + play;
					url = urlFinish.c_str();
					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					std::vector<player> players;

					//Read in player data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						size_t comFstPos = 0, comSecPos = 0;
						unsigned int tribeIDCheck = 0, chkID = 0;

						players.push_back(player());

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL) return EXIT_FAILURE;
						bufferString = buffer;

						comSecPos = bufferString.find(',');

						players.at(count).setID(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						players.at(count).setName(bufferString.substr(comFstPos, comSecPos - comFstPos));

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribeIDCheck = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (tribeIDCheck != 0)
							tribeIDCheck = tbinarySearch(tribeIDCheck, 0, tribes.size(), tribes);

						if (tribeIDCheck != NULL) {

							players.at(count).setTribeID(tribeIDCheck);
							tribes.at(tribeIDCheck).addMember(players.size() - 1);

						}

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						players.at(count).setVill(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						players.at(count).setPoints(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						players.at(count).setRank(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()) <= 15)
							topPlayerRanks[atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()) - 1] = players.size() - 1;

						comFstPos = 0;
						comSecPos = 0;

					}

					url_fclose(handle);

					urlFinish = urlBase + village;
					url = urlFinish.c_str();

					unsigned int zoom = 500;

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					std::vector<villages> allVills;

					//Read village data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						unsigned int comFstPos = 0, comSecPos = 0;
						unsigned int playerIDCheck = 0;
						unsigned int x = 0, y = 0;
						unsigned int points = 0;

						allVills.push_back(villages());

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');

						allVills.at(count).setID(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						x = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (x < zoom)
							zoom = x;

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						y = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						playerIDCheck = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						points = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (playerIDCheck)
							playerIDCheck = pbinarySearch(playerIDCheck, 0, players.size(), players);
						if (playerIDCheck != NULL) {

							players.at(playerIDCheck).addVillage(x, y);

							allVills.at(count).setPlayerID(playerIDCheck);
							allVills.at(count).setX(x);
							allVills.at(count).setY(y);
							allVills.at(count).setPoints(points);

						}
					}

					if (zoom > 400)
						zoom = 5;
					else if (zoom > 300)
						zoom = 2;
					else
						zoom = 1;

					urlFinish = urlBase + oda;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					//read ODA data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						unsigned int comFstPos = 0, comSecPos = 0, rank = 0, player = 0;

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');
						rank = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						player = pbinarySearch(atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()), 0, players.size(), players);

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						if (player)
							players.at(player).setODA(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (rank <= 15)
							topODARanks[rank - 1] = player;

					}

					urlFinish = urlBase + odd;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					//read ODD data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						unsigned int comFstPos = 0, comSecPos = 0, rank = 0, player = 0;

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');
						rank = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						player = pbinarySearch(atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()), 0, players.size(), players);

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						if (player)
							players.at(player).setODD(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (rank <= 15)
							topODDRanks[rank - 1] = player;

					}

					urlFinish = urlBase + ods;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					//read ODS data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						unsigned int comFstPos = 0, comSecPos = 0, rank = 0, player = 0;

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');
						rank = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						player = pbinarySearch(atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()), 0, players.size(), players);

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						if (player)
							players.at(player).setODS(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (rank <= 15)
							topODSRanks[rank - 1] = player;

					}

					urlFinish = urlBase + odaT;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					//read Tribe ODA data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						unsigned int comFstPos = 0, comSecPos = 0, rank = 0, tribe = 0;

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');
						rank = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribe = tbinarySearch(atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()), 0, tribes.size(), tribes);

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						if (tribe)
							tribes.at(tribe).setODA(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (rank <= 15)
							topODATRanks[rank - 1] = tribe;

					}

					urlFinish = urlBase + oddT;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					//Read Tribe ODD Data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;
						unsigned int comFstPos = 0, comSecPos = 0, rank = 0, tribe = 0;

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');
						rank = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						tribe = tbinarySearch(atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()), 0, tribes.size(), tribes);

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						if (tribe)
							tribes.at(tribe).setODA(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

						if (rank <= 15)
							topODDTRanks[rank - 1] = tribe;

					}

					urlFinish = urlBase + conquer;
					url = urlFinish.c_str();

					handle = url_fopen(url, "r");
					if (!handle) {

						system("PAUSE");
						return EXIT_FAILURE;

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					std::time_t currTime = time(nullptr);
					std::time_t passTime = time(nullptr) - 86400;//604800 seconds = 7 days

					//read conquer data
					for (unsigned int count = 0; !url_feof(handle); count++) {

						std::string bufferString;

						unsigned int comFstPos = 0, comSecPos = 0, vill = 0, play = 0;

						if (url_fgets(buffer, sizeof(buffer), handle) == NULL)
							return EXIT_FAILURE;

						bufferString = buffer;

						comSecPos = bufferString.find(',');

						comFstPos = comSecPos + 1;
						comSecPos = bufferString.find(',', comFstPos);

						if (atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str()) >= passTime) {

							vill = vbinarySearch(atoi(bufferString.substr(0, comFstPos).c_str()), 0, allVills.size(), allVills);

							comFstPos = comSecPos + 1;
							comSecPos = bufferString.find(',', comFstPos);

							play = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

							if (vill) {

								unsigned int playerTribeID = players.at(pbinarySearch(play, 0, players.size(), players)).getTribeID();

								players.at(pbinarySearch(play, 0, players.size(), players)).setConq(allVills.at(vill).getPoints(), allVills.at(vill).getX(), allVills.at(vill).getY());

								if (playerTribeID != 0)
									tribes.at(playerTribeID).setConq(allVills.at(vill).getPoints(), allVills.at(vill).getX(), allVills.at(vill).getY());

								comFstPos = comSecPos + 1;
								comSecPos = bufferString.find(',', comFstPos);

								play = atoi(bufferString.substr(comFstPos, comSecPos - comFstPos).c_str());

								if (play) {

									players.at(pbinarySearch(play, 0, players.size(), players)).setLoss(allVills.at(vill).getPoints(), allVills.at(vill).getX(), allVills.at(vill).getY());

									playerTribeID = players.at(pbinarySearch(play, 0, players.size(), players)).getTribeID();

									if (playerTribeID != 0)
										tribes.at(playerTribeID).setLoss(allVills.at(vill).getPoints(), allVills.at(vill).getX(), allVills.at(vill).getY());

								}

							}

						}

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					for (unsigned int count = 0; count < players.size(); count++) {

						for (unsigned int counter = 0; counter < 15; counter++) {

							if (players.at(count).getConqPoints() > players.at(topPlayerConqRanks[counter]).getConqPoints()) {

								for (unsigned int counting = 14; counting > counter; counting--) {

									topPlayerConqRanks[counting] = topPlayerConqRanks[counting - 1];

								}

								topPlayerConqRanks[counter] = count;
								break;

							}

						}

					}

					for (unsigned int count = 0; count < players.size(); count++) {

						for (unsigned int counter = 0; counter < 15; counter++) {

							if (players.at(count).getLossPoints() > players.at(topPlayerLossRanks[counter]).getLossPoints()) {

								for (unsigned int counting = 14; counting > counter; counting--) {

									topPlayerLossRanks[counting] = topPlayerLossRanks[counting - 1];

								}

								topPlayerLossRanks[counter] = count;
								break;

							}

						}

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					for (unsigned int count = 0; count < tribes.size(); count++) {

						for (unsigned int counter = 0; counter < 15; counter++) {

							if (tribes.at(count).getConqPoints() > tribes.at(topTribeConqRanks[counter]).getConqPoints()) {

								for (unsigned int counting = 14; counting > counter; counting--) {

									topTribeConqRanks[counting] = topTribeConqRanks[counting - 1];

								}

								topTribeConqRanks[counter] = count;
								break;

							}

						}

					}

					for (unsigned int count = 0; count < tribes.size(); count++) {

						for (unsigned int counter = 0; counter < 15; counter++) {

							if (tribes.at(count).getLossPoints() > tribes.at(topTribeLossRanks[counter]).getLossPoints()) {

								for (unsigned int counting = 14; counting > counter; counting--) {

									topTribeLossRanks[counting] = topTribeLossRanks[counting - 1];

								}

								topTribeLossRanks[counter] = count;
								break;

							}

						}

					}

					/*
					***************************************************************************************************
					***************************************************************************************************
					*/

					std::vector<std::thread> threads;

					threads.push_back(std::thread(topTribes, world, colors, zoom, tribes, players, topTribeRanks));
					threads.push_back(std::thread(topODATribe, world, colors, zoom, tribes, players, topODATRanks));
					threads.push_back(std::thread(topODDTribe, world, colors, zoom, tribes, players, topODDTRanks));

					for (auto& th : threads)
						th.join();

					threads.clear();

					threads.push_back(std::thread(topPlayers, world, colors, zoom, players, topPlayerRanks));
					threads.push_back(std::thread(topODAPlay, world, colors, zoom, players, topODARanks));
					threads.push_back(std::thread(topODDPlay, world, colors, zoom, players, topODDRanks));
					threads.push_back(std::thread(topODSPlay, world, colors, zoom, players, topODSRanks));

					for (auto& th : threads)
						th.join();

					threads.clear();

					threads.push_back(std::thread(topConqTribes, world, colors, zoom, tribes, players, topTribeRanks, topTribeConqRanks));
					threads.push_back(std::thread(topLossTribes, world, colors, zoom, tribes, players, topTribeRanks, topTribeLossRanks));

					threads.push_back(std::thread(topConqPlayers, world, colors, zoom, players, topPlayerRanks, topPlayerConqRanks));
					threads.push_back(std::thread(topLossPlayers, world, colors, zoom, players, topPlayerRanks, topPlayerLossRanks));

					for (auto& th : threads)
						th.join();

					threads.clear();

				}

			}

			ServerCount++;

			worldFile.close();

		}

	}

	curl_easy_cleanup(cURL);

	system("PAUSE");
	return EXIT_SUCCESS;

}