Esempio n. 1
0
Compressor::FrequencyChar& Compressor::getChar(FrequencyVector& vec, char character)
{
    for (unsigned i = 0; i < vec.size(); i++)
    {
        if (vec[i].character == character)
            return vec[i];
    }

    vec.push_back(FrequencyChar(character));
    return vec.back();
}
Esempio n. 2
0
void GenerateStationFrequencyTable (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	int i, j;

	printf("STATION FREQUENCY TABLE\n\n");

	//	Figure out which columns to show

	TArray<CString> Cols;
	Cols.Insert(CONSTLIT("Level"));
	Cols.Insert(CONSTLIT("Freq"));
	Cols.Insert(CONSTLIT("Name"));
	Cols.Insert(CONSTLIT("Type"));
	Cols.Insert(CONSTLIT("Environment"));

	//	Print the header

	for (i = 0; i < Cols.GetCount(); i++)
		{
		if (i != 0)
			printf("\t");
		printf("%s", (LPSTR)Cols[i]);
		}

	printf("\n");

	//	For all levels, 1-25

	int iLevel;
	for (iLevel = 1; iLevel <= MAX_ITEM_LEVEL; iLevel++)
		{
		CSymbolTable Sort(FALSE, TRUE);

		//	Find all stations for this level and add them to
		//	a sorting table

		for (i = 0; i < Universe.GetStationTypeCount(); i++)
			{
			CStationType *pType = Universe.GetStationType(i);

			if (pType->GetFrequencyByLevel(iLevel) > 0)
				{
				char szBuffer[256];
				wsprintf(szBuffer, "%02d %s", 
						ftCommon - pType->GetFrequencyByLevel(iLevel),
						pType->GetName().GetASCIIZPointer());
						
				Sort.AddEntry(CString(szBuffer), (CObject *)pType);
				}
			}

		//	Print out the stations for this level

		if (Sort.GetCount() > 0)
			{
			for (i = 0; i < Sort.GetCount(); i++)
				{
				CStationType *pType = (CStationType *)Sort.GetValue(i);

				for (j = 0; j < Cols.GetCount(); j++)
					{
					if (j != 0)
						printf("\t");

					if (strEquals(Cols[j], CONSTLIT("Level")))
						printf("%d", iLevel);
					else if (strEquals(Cols[j], CONSTLIT("Freq")))
						printf((LPSTR)FrequencyChar(pType->GetFrequencyByLevel(iLevel)));
					else if (strEquals(Cols[j], CONSTLIT("Name")))
						printf((LPSTR)pType->GetName());
					else if (strEquals(Cols[j], CONSTLIT("Type")))
						{
						if (pType->HasAttribute(CONSTLIT("enemy")))
							printf("Enemy");
						else if (pType->HasAttribute(CONSTLIT("debris")))
							printf("Debris");
						else
							printf("Friend");
						}
					else if (strEquals(Cols[j], CONSTLIT("Environment")))
						{
						bool bElements = false;

						if (pType->HasAttribute(CONSTLIT("envAir")))
							{
							if (bElements)
								printf(", ");

							printf("envAir");
							bElements = true;
							}

						if (pType->HasAttribute(CONSTLIT("envEarth")))
							{
							if (bElements)
								printf(", ");

							printf("envEarth");
							bElements = true;
							}

						if (pType->HasAttribute(CONSTLIT("envFire")))
							{
							if (bElements)
								printf(", ");

							printf("envFire");
							bElements = true;
							}

						if (pType->HasAttribute(CONSTLIT("envWater")))
							{
							if (bElements)
								printf(", ");

							printf("envWater");
							bElements = true;
							}

						if (!bElements)
							printf("None");
						}
					}

				printf("\n");
				}
			}
		}
	}