Пример #1
0
bool CReactorClass::FindDataField (const ReactorDesc &Desc, const CString &sField, CString *retsValue)

//	FindDataField
//
//	Finds a data field for the reactor desc.

	{
	if (strEquals(sField, FIELD_POWER))
		*retsValue = strFromInt(Desc.iMaxPower * 100);
	else if (strEquals(sField, FIELD_FUEL_CRITERIA))
		{
		if (Desc.pFuelCriteria)
			*retsValue = CItem::GenerateCriteria(*Desc.pFuelCriteria);
		else
			*retsValue = strPatternSubst(CONSTLIT("f L:%d-%d;"), Desc.iMinFuelLevel, Desc.iMaxFuelLevel);
		}
	else if (strEquals(sField, FIELD_FUEL_EFFICIENCY))
		*retsValue = strFromInt(Desc.iPowerPerFuelUnit);
	else if (strEquals(sField, FIELD_FUEL_CAPACITY))
		*retsValue = strFromInt(Desc.iMaxFuel / FUEL_UNITS_PER_STD_ROD);
	else
		return false;

	return true;
	}
Пример #2
0
CString CCInteger::Print (CCodeChain *pCC, DWORD dwFlags)

//	Print
//
//	Returns a text representation of this item

	{
	//	If this is an error code, translate it

	if (IsError())
		{
		switch (m_iValue)
			{
			case CCRESULT_NOTFOUND:
				return strPatternSubst(LITERAL("[%d] Item not found."), m_iValue);

			case CCRESULT_CANCEL:
				return strPatternSubst(LITERAL("[%d] Operation canceled."), m_iValue);

			case CCRESULT_DISKERROR:
				return strPatternSubst(LITERAL("[%d] Disk error."), m_iValue);

			default:
				return strPatternSubst(LITERAL("[%d] Unknown error."), m_iValue);
			}
		}

	//	Otherwise, just print the integer value

	else
		return strFromInt(m_iValue, TRUE);
	}
Пример #3
0
void CUIHelper::CreateClassInfoCargo (CShipClass *pClass, const CDeviceDescList &Devices, int x, int y, int cxWidth, DWORD dwOptions, int *retcyHeight, IAnimatron **retpInfo) const

//	CreateClassInfoCargo
//
//	Creates info about the ship class' cargo

	{
	const CVisualPalette &VI = m_HI.GetVisuals();

	CDeviceClass *pCargoExtension = Devices.GetNamedDevice(devCargo);
	int iCargoSpace = pClass->GetCargoSpace();
	if (pCargoExtension)
		iCargoSpace += pCargoExtension->GetCargoSpace();

	//	Icon

	CItemType *pItemIcon = (pCargoExtension ? pCargoExtension->GetItemType() : g_pUniverse->FindItemType(CARGO_HOLD_EXPANSION_UNID));

	//	Text

	CString sText = strPatternSubst(CONSTLIT("{/rtf {/f:LargeBold;/c:%d; %s} {/f:MediumBold;/c:%d; %s}\n{/f:Medium;/c:%d; %s}}"),
			CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogLabel)),
			strFromInt(iCargoSpace, TRUE),
			CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogInput)),
			(pCargoExtension ? strPatternSubst(CONSTLIT("ton %s"), CTextBlock::Escape(pCargoExtension->GetItemType()->GetNounPhrase(nounActual))) : CONSTLIT("ton cargo hold")),
			CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogLabel)),
			(iCargoSpace < pClass->GetMaxCargoSpace() ? strPatternSubst(CONSTLIT("optional expansion up to %d tons"), pClass->GetMaxCargoSpace()) : CONSTLIT("cargo space cannot be expanded")));

	CreateClassInfoSpecialItem(pItemIcon, sText, x, y, cxWidth, dwOptions, retcyHeight, retpInfo);
	}
void CArtifactStatPainter::Paint (CG32bitImage &Dest) const

//	Paint
//
//	Paint the stat

	{
	const CG16bitFont &LabelFont = m_VI.GetFont(fontSmall);
	const CG16bitFont &StatFont = m_VI.GetFont(fontLargeBold);

	CG32bitPixel rgbBack = AA_STYLECOLOR(colorCountermeasureLocusBack);
	CG32bitPixel rgbLabel = CG32bitPixel(0x80, 0x80, 0x80);
	CG32bitPixel rgbStat = AA_STYLECOLOR(colorAICoreFore);

	//	Paint the background first

	CGDraw::RoundedRect(Dest,
			m_rcRect.left,
			m_rcRect.top,
			RectWidth(m_rcRect),
			RectHeight(m_rcRect),
			CORNER_RADIUS,
			rgbBack);

	//	Paint the label

	LabelFont.DrawText(Dest, m_rcRect, rgbLabel, m_sLabel, 0, CG16bitFont::AlignCenter);

	//	Paint the stat

	RECT rcRect = m_rcRect;
	rcRect.top += LabelFont.GetHeight();
	StatFont.DrawText(Dest, rcRect, rgbStat, strFromInt(m_iValue), 0, CG16bitFont::AlignCenter);
	}
Пример #5
0
ALERROR CEffectCreator::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID, CEffectCreator **retpCreator)

//	CreateFromXML
//
//	Creates the creator from an XML element

	{
	ALERROR error;
	CEffectCreator *pCreator;

	//	Basic info

	CString sEffectUNID = sUNID;
	if (sEffectUNID.IsBlank())
		{
		DWORD dwUNID = pDesc->GetAttributeInteger(UNID_ATTRIB);
		if (dwUNID)
			sEffectUNID = strFromInt(dwUNID, FALSE);
		else
			sEffectUNID = STR_NO_UNID;
		}

	//	Create the effect based on the child tag

	if (pDesc->GetContentElementCount() == 0)
		{
		*retpCreator = NULL;
		return NOERROR;
		}
	else if (pDesc->GetContentElementCount() == 1)
		{
		if (error = CreateSimpleFromXML(Ctx, pDesc->GetContentElement(0), sEffectUNID, &pCreator))
			return error;
		}
	else
		{
		pCreator = new CEffectGroupCreator;
		if (pCreator == NULL)
			return ERR_MEMORY;

		pCreator->m_sUNID = sEffectUNID;

		//	Type-specific creation

		if (error = pCreator->OnEffectCreateFromXML(Ctx, pDesc, sEffectUNID))
			return error;
		}

	//	Sound Effect (resolved later)

	pCreator->m_dwSoundUNID = pDesc->GetAttributeInteger(SOUND_ATTRIB);
	pCreator->m_iSound = -1;
	
	//	Done

	*retpCreator = pCreator;

	return NOERROR;
	}
Пример #6
0
void WriteNumber (CMemoryWriteStream &Stream, int iNumber, int iLeadingZeros)
	{
	CString sNumber = strFromInt(iNumber, false);
	if (sNumber.GetLength() < iLeadingZeros)
		Stream.Write("0000000000", iLeadingZeros - sNumber.GetLength());

	Stream.Write(sNumber.GetASCIIZPointer(), sNumber.GetLength());
	}
Пример #7
0
bool CDriveClass::FindDataField (const CString &sField, CString *retsValue)

//	FindDataField
//
//	Returns meta-data

	{
	if (strEquals(sField, FIELD_MAX_SPEED))
		*retsValue = strFromInt((int)((100.0 * m_DriveDesc.rMaxSpeed / LIGHT_SPEED) + 0.5), FALSE);
	else if (strEquals(sField, FIELD_THRUST))
		*retsValue = strFromInt(m_DriveDesc.iThrust, FALSE);
	else if (strEquals(sField, FIELD_POWER))
		*retsValue = strFromInt(m_DriveDesc.iPowerUse * 100);
	else
		return false;

	return true;
	}
Пример #8
0
void WriteTimeValue (CMemoryWriteStream &Output, DWORD dwTime)
	{
	if (dwTime == INVALID_TIME)
		Output.Write(NIL_VALUE.GetASCIIZPointer(), NIL_VALUE.GetLength());
	else
		{
		CString sInt = strFromInt(dwTime);
		Output.Write(sInt.GetASCIIZPointer(), sInt.GetLength());
		}
	}
Пример #9
0
ALERROR OutputItemTable (CSymbolTable &AllSystems, int iSystemSample)
	{
	ALERROR error;
	int i, j;
	CSymbolTable AllItems(TRUE, TRUE);

	for (i = 0; i < AllSystems.GetCount(); i++)
		{
		SystemInfo *pSystemEntry = (SystemInfo *)AllSystems.GetValue(i);

		for (j = 0; j < pSystemEntry->Items.GetCount(); j++)
			{
			ItemInfo *pEntry = (ItemInfo *)pSystemEntry->Items.GetValue(j);

			CString sKey = strFromInt(pEntry->pType->GetUNID(), false);

			ItemInfo *pDestEntry;
			if (error = AllItems.Lookup(sKey, (CObject **)&pDestEntry))
				{
				pDestEntry = new ItemInfo;
				pDestEntry->pType = pEntry->pType;
				pDestEntry->rTotalCount = ((double)pEntry->iTotalCount / (double)iSystemSample);

				AllItems.AddEntry(sKey, pDestEntry);
				}
			else
				pDestEntry->rTotalCount += ((double)pEntry->iTotalCount / (double)iSystemSample);
			}
		}

	//	Output all items to a well-known file

	CTextFileLog Output(ITEM_COUNT_FILENAME);
	if (error = Output.Create(FALSE))
		{
		printf("ERROR: Unable to create output file: %s\n", ITEM_COUNT_FILENAME.GetASCIIZPointer());
		return error;
		}

	for (i = 0; i < AllItems.GetCount(); i++)
		{
		ItemInfo *pEntry = (ItemInfo *)AllItems.GetValue(i);
		Output.LogOutput(0, "0x%x\t%d", pEntry->pType->GetUNID(), (int)((pEntry->rTotalCount * 1000) + 0.5));
		}

	if (error = Output.Close())
		{
		printf("ERROR: Unable to create output file: %s\n", ITEM_COUNT_FILENAME.GetASCIIZPointer());
		return error;
		}

	return NOERROR;
	}
Пример #10
0
void AtrmMotors :: statusMotors(AStream *stream)
{
	stream->printPgm(TEXT("Status motor:"));
	AHardware *hardware = ptrHardware;
	char szBuffer[10];
	
	
	//текущие настройки моторов 1
	zeroMemory((BYTE*)szBuffer, 10);
	strFromInt(szBuffer, hardware->motors.getSpeedM1());
	AProxyTerminal::sendEnter(stream);
	stream->printPgm(TEXT("   left motor = "));
	stream->print(szBuffer);
	
	//текущие настройки моторов 2
	zeroMemory((BYTE*)szBuffer, 10);
	strFromInt(szBuffer, hardware->motors.getSpeedM2());
	AProxyTerminal::sendEnter(stream);
	stream->printPgm(TEXT("  right motor = "));
	stream->print(szBuffer);
}
Пример #11
0
CString CAISettings::GetValue (const CString &sSetting)

//	GetValue
//
//	Get the current value of the given setting

	{
	if (strEquals(sSetting, AGGRESSOR_ATTRIB))
		return (m_fAggressor ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, ASCEND_ON_GATE_ATTRIB))
		return (m_fAscendOnGate ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, COMBAT_SEPARATION_ATTRIB))
		return (m_rMinCombatSeparation > 0.0 ? strFromInt((int)(m_rMinCombatSeparation / g_KlicksPerPixel)) : NULL_STR);
	else if (strEquals(sSetting, COMBAT_STYLE_ATTRIB))
		return ConvertToID(m_iCombatStyle);
	else if (strEquals(sSetting, FIRE_ACCURACY_ATTRIB))
		return strFromInt(m_iFireAccuracy);
	else if (strEquals(sSetting, FIRE_RANGE_ADJ_ATTRIB))
		return strFromInt(m_iFireRangeAdj);
	else if (strEquals(sSetting, FIRE_RATE_ADJ_ATTRIB))
		return strFromInt(m_iFireRateAdj);
	else if (strEquals(sSetting, NO_DOGFIGHTS_ATTRIB))
		return (m_fNoDogfights ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, NO_SHIELD_RETREAT_ATTRIB))
		return (m_fNoShieldRetreat ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, NO_FRIENDLY_FIRE_ATTRIB))
		return (m_fNoFriendlyFire ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, NO_FRIENDLY_FIRE_CHECK_ATTRIB))
		return (m_fNoFriendlyFireCheck ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, NO_NAV_PATHS_ATTRIB))
		return (m_fNoNavPaths ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, NO_ORDER_GIVER_ATTRIB))
		return (m_fNoOrderGiver ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, NON_COMBATANT_ATTRIB))
		return (m_fNonCombatant ? STR_TRUE : NULL_STR);
	else if (strEquals(sSetting, PERCEPTION_ATTRIB))
		return strFromInt(m_iPerception);
	else
		return NULL_STR;
	}
Пример #12
0
CString CEconomyType::RinHackGet (CSpaceObject *pObj)

//	RinHackGet
//
//	In previous version we used to store rin as object data on the player ship
//	This hack returns it from the proper place

	{
	CShip *pPlayerShip = pObj->AsShip();
	IShipController *pController = (pPlayerShip ? pPlayerShip->GetController() : NULL);
	CCurrencyBlock *pMoney = (pController ? pController->GetCurrencyBlock() : NULL);
	return (pMoney ? strFromInt((int)pMoney->GetCredits(CONSTLIT("rin"))) : NULL_STR);
	}
Пример #13
0
bool CMissionType::FindDataField (const CString &sField, CString *retsValue)

//	FindDataField
//
//	Returns the data field.

	{
	if (strEquals(sField, FIELD_LEVEL))
		*retsValue = strFromInt(GetLevel());

	else if (strEquals(sField, FIELD_MAX_LEVEL))
		*retsValue = strFromInt(m_iMaxLevel);

	else if (strEquals(sField, FIELD_MIN_LEVEL))
		*retsValue = strFromInt(m_iMinLevel);

	else if (strEquals(sField, FIELD_NAME))
		*retsValue = m_sName;
	else
		return false;

	return true;
	}
Пример #14
0
void CGameSettings::SetValueInteger (int iOption, int iValue, bool bSetSettings)

//	SetValueInteger
//
//	Sets an integer value

	{
	if (g_OptionData[iOption].iType != optionInteger)
		return;

	m_Options[iOption].iValue = iValue;

	if (bSetSettings)
		m_Options[iOption].sSettingsValue = strFromInt(iValue);
	}
Пример #15
0
ALERROR LoadTotalCount (const CString &sFilename, CSymbolTable &TotalCount)
	{
	ALERROR error;

	CFileReadBlock Input(sFilename);
	if (error = Input.Open())
		{
		printf("ERROR: Unable to open total count file. Use /generateSimTables.");
		return error;
		}

	char *pPos = Input.GetPointer(0, -1);
	char *pEndPos = pPos + Input.GetLength();

	while (pPos < pEndPos)
		{
		//	Read an UNID

		DWORD dwUNID = (DWORD)strParseInt(pPos, 0, &pPos);
		if (dwUNID == 0)
			break;

		//	Read an count

		if (pPos >= pEndPos)
			{
			printf("ERROR: Unexpected end of file.");
			return ERR_FAIL;
			}

		int iCount = strParseInt(pPos, 0, &pPos);

		//	Add the entry

		CString sKey = strFromInt(dwUNID, false);
		EntryInfo *pEntry = new EntryInfo;
		pEntry->dwUNID = dwUNID;
		pEntry->rTotalCount = (double)iCount / 1000.0;

		if (error = TotalCount.AddEntry(sKey, pEntry))
			{
			printf("ERROR: Invalid UNID.");
			return error;
			}
		}

	return NOERROR;
	}
Пример #16
0
CString CDatum::AsString (void) const

//	AsString
//
//	Coerces to a CString

	{
	switch (m_dwData & AEON_TYPE_MASK)
		{
		case AEON_TYPE_STRING:
			return (m_dwData == 0 ? NULL_STR : raw_GetString());

		case AEON_TYPE_NUMBER:
			switch (m_dwData & AEON_NUMBER_TYPE_MASK)
				{
				case AEON_NUMBER_CONSTANT:
					{
					switch (m_dwData)
						{
						case constTrue:
							return STR_TRUE;

						default:
							ASSERT(false);
							return NULL_STR;
						}
					}

				case AEON_NUMBER_28BIT:
				case AEON_NUMBER_32BIT:
					return strFromInt((int)*this);

				case AEON_NUMBER_DOUBLE:
					return strFromDouble(g_DoubleAlloc.Get(GetNumberIndex()));

				default:
					ASSERT(false);
					return NULL_STR;
				}

		case AEON_TYPE_COMPLEX:
			return raw_GetComplex()->AsString();

		default:
			ASSERT(false);
			return NULL_STR;
		}
	}
Пример #17
0
bool CItemTable::FindDataField (const CString &sField, CString *retsValue)

//	FindDataField
//
//	Returns meta-data

	{
	//	Deal with the meta-data that we know about

	if (strEquals(sField, FIELD_TREASURE_VALUE))
		*retsValue = strFromInt((int)GetAverageValue(1));
	else
		return CDesignType::FindDataField(sField, retsValue);

	return true;
	}
Пример #18
0
void CDockPane::SetCounterValue (int iValue)

//	SetCounterValue
//
//	Sets the value of the counter

	{
	SControl *pControl;
	if (pControl = GetControlByType(controlCounter))
		{
		CGTextArea *pTextArea = pControl->AsTextArea();
		CString sText = strFromInt(iValue);
		pTextArea->SetText(sText);
		pControl->bReplaceInput = true;
		}
	}
Пример #19
0
ALERROR CEffectCreator::OnCreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	OnCreateFromXML
//
//	Load from XML. This is only called if we go through the EffectType path
//	(as opposed to plain Effect).

	{
	ALERROR error;

	//	Basic info

	m_sUNID = strFromInt(GetUNID(), FALSE);
	m_dwSoundUNID = pDesc->GetAttributeInteger(SOUND_ATTRIB);
	m_iSound = -1;

	//	Allow our subclass to initialize based on the effect
	//	(We know we have one because we couldn't have gotten this far
	//	without one. See CreateTypeFromXML.)

	CXMLElement *pEffect = pDesc->GetContentElementByTag(EFFECT_TAG);
	ASSERT(pEffect);

	if (pEffect->GetContentElementCount() == 1)
		error = OnEffectCreateFromXML(Ctx, pEffect->GetContentElement(0), m_sUNID);
	else
		error = OnEffectCreateFromXML(Ctx, pEffect, m_sUNID);

	if (error)
		return error;

	//	Load damage descriptors

	CXMLElement *pDamageDesc = pDesc->GetContentElementByTag(DAMAGE_TAG);
	if (pDamageDesc)
		{
		m_pDamage = new CWeaponFireDesc;

		CString sUNID = strPatternSubst(CONSTLIT("%d/d"), GetUNID());
		if (error = m_pDamage->InitFromXML(Ctx, pDamageDesc, sUNID, true))
			return error;
		}
	
	return NOERROR;
	}
Пример #20
0
void CGameSettings::SetValueInteger (int iOption, int iValue, bool bSetSettings)

//	SetValueInteger
//
//	Sets an integer value

	{
	if (g_OptionData[iOption].iType != optionInteger)
		return;

	m_Options[iOption].iValue = iValue;

	if (bSetSettings)
		{
		if (g_OptionData[iOption].dwFlags & OPTION_FLAG_HEX)
			m_Options[iOption].sSettingsValue = strPatternSubst("0x%08x", iValue);
		else
			m_Options[iOption].sSettingsValue = strFromInt(iValue);
		}
	}
Пример #21
0
CString IEffectPainter::ReadUNID (SLoadCtx &Ctx)

//	ReadUNID
//
//	Returns the UNID saved to a stream

	{
	CString sUNID;

	if (Ctx.dwVersion >= 15)
		sUNID.ReadFromStream(Ctx.pStream);
	else
		{
		DWORD dwUNID;
		Ctx.pStream->Read((char *)&dwUNID, sizeof(DWORD));
		sUNID = strFromInt(dwUNID, FALSE);
		}

	return sUNID;
	}
Пример #22
0
CString CZoanthropeAI::DebugCrashInfo (void)

//	DebugCrashInfo
//
//	Returns debug crash info

	{
	CString sOrder;
	try
		{
		sOrder = strFromInt((int)GetCurrentOrder());
		}
	catch (...)
		{
		}

	//	If GetCurrentOrder crashes, try to determine why

	if (sOrder.IsBlank())
		{
		try
			{
			sOrder = strPatternSubst(CONSTLIT("crash in GetCurrentOrder; count = %d\r\n"), m_Orders.GetCount());
			}
		catch (...)
			{
			sOrder = CONSTLIT("crash in GetCurrentOrder\r\n");
			}
		}

	CString sResult = CONSTLIT("CZoanthropeAI\r\n");
	sResult.Append(strPatternSubst(CONSTLIT("Order: %s\r\n"), sOrder));
	sResult.Append(strPatternSubst(CONSTLIT("m_State: %d\r\n"), m_State));
	sResult.Append(strPatternSubst(CONSTLIT("m_pBase: %s\r\n"), CSpaceObject::DebugDescribe(m_pBase)));
	sResult.Append(strPatternSubst(CONSTLIT("m_pTarget: %s\r\n"), CSpaceObject::DebugDescribe(m_pTarget)));

	return sResult;
	}
Пример #23
0
CG32bitImage *CDesignCollection::GetImage (DWORD dwUNID, DWORD dwFlags)

//	GetImage
//
//	Returns an image

	{
	CDesignType *pType = m_AllTypes.FindByUNID(dwUNID);
	if (pType == NULL)
		return NULL;

	CObjectImage *pImage = CObjectImage::AsType(pType);
	if (pImage == NULL)
		return NULL;

	if (dwFlags & FLAG_IMAGE_COPY)
		return pImage->CreateCopy();
	else
		{
		CString sError;
		CG32bitImage *pRawImage = pImage->GetImage(strFromInt(dwUNID), &sError);

		if (pRawImage == NULL)
			kernelDebugLogMessage(sError);

		//	Lock, if requested. NOTE: Since we obtained the image above,
		//	this call is guaranteed to succeed.

		if (dwFlags & FLAG_IMAGE_LOCK)
			pImage->Lock(SDesignLoadCtx());

		//	Done

		return pRawImage;
		}
	}
Пример #24
0
void GenerateEncounterTable (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	ALERROR error;
	int i, j;

	//	Get the criteria from the command line

	SEncounterCriteria Criteria;
	ParseEncounterCriteria(pCmdLine->GetAttribute(CRITERIA_ATTRIB), &Criteria);
	bool bAll = pCmdLine->GetAttributeBool(ALL_ATTRIB);

	//	Generate a table of all matching encounters

	CSymbolTable Table(FALSE, TRUE);

	//	Loop over all items for this level and add them to
	//	a sorted table.

	for (i = 0; i < Universe.GetStationTypeCount(); i++)
		{
		CStationType *pType = Universe.GetStationType(i);
		int iLevel = pType->GetLevel();
		if (iLevel == 0 && !bAll)
			continue;

		//	If we don't match the criteria, then continue

		if (!MatchesEncounterCriteria(Criteria, pType->GetAttributes()))
			continue;

		//	Get the category and name

		CString sCategory = pType->GetDataField(FIELD_CATEGORY);
		CString sName = pType->GetDataField(FIELD_NAME);
		if (*sName.GetASCIIZPointer() == '(')
			sName = strSubString(sName, 1, -1);

		//	Figure out the sort order

		char szBuffer[1024];
		wsprintf(szBuffer, "%02d%s%s", 
				pType->GetLevel(),
				sCategory.GetASCIIZPointer(), 
				sName.GetASCIIZPointer());
		Table.AddEntry(CString(szBuffer), (CObject *)pType);
		}

	//	Generate a list of columns to display

	CStringArray Cols;
	Cols.AppendString(FIELD_LEVEL);
	Cols.AppendString(FIELD_CATEGORY);
	Cols.AppendString(FIELD_NAME);
	if (pCmdLine->GetAttributeBool(FIELD_ARMOR_CLASS))
		Cols.AppendString(FIELD_ARMOR_CLASS);
	if (pCmdLine->GetAttributeBool(FIELD_HP))
		Cols.AppendString(FIELD_HP);
	if (pCmdLine->GetAttributeBool(FIELD_FIRE_RATE_ADJ))
		Cols.AppendString(FIELD_FIRE_RATE_ADJ);
	if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT))
		Cols.AppendString(FIELD_TOTAL_COUNT);
	if (pCmdLine->GetAttributeBool(FIELD_CAN_ATTACK))
		Cols.AppendString(FIELD_CAN_ATTACK);
	if (pCmdLine->GetAttributeBool(FIELD_EXPLOSION_TYPE))
		Cols.AppendString(FIELD_EXPLOSION_TYPE);

	//	If we need to output total count, then load the table

	CSymbolTable TotalCount(TRUE, TRUE);
	if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT))
		{
		if (error = LoadTotalCount(TOTAL_COUNT_FILENAME, TotalCount))
			return;
		}

	//	If we've got any entries in the table, output now

	if (Table.GetCount())
		{
		//	Output the header

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

			printf(Cols.GetStringValue(j).GetASCIIZPointer());
			}

		printf("\n");

		//	Output each row

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

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

				CString sField = Cols.GetStringValue(j);
				CString sValue = pType->GetDataField(sField);

				if (strEquals(sField, FIELD_FIRE_RATE_ADJ))
					printf("%.2f", strToInt(sValue, 0, NULL) / 1000.0);
				else if (strEquals(sField, FIELD_TOTAL_COUNT))
					{
					double rCount = 0.0;

					CString sKey = strFromInt(pType->GetUNID(), FALSE);
					EntryInfo *pEntry;
					if (TotalCount.Lookup(sKey, (CObject **)&pEntry) == NOERROR)
						rCount = pEntry->rTotalCount;

					printf("%.2f", rCount);
					}
				else
					printf(sValue.GetASCIIZPointer());
				}

			printf("\n");
			}

		printf("\n");
		}
	else
		printf("No entries match criteria.\n");
	}
Пример #25
0
void CGSelectorArea::PaintInstalledItem (CG32bitImage &Dest, const RECT &rcRect, const SEntry &Entry)

//	PaintInstalledItem
//
//	Paints the installed item.

	{
	const CItem &Item = Entry.pItemCtx->GetItem();
	if (Item.GetType() == NULL)
		return;

	CSpaceObject *pSource = Entry.pItemCtx->GetSource();
	CInstalledArmor *pArmor = Entry.pItemCtx->GetArmor();
	CInstalledDevice *pDevice = Entry.pItemCtx->GetDevice();
	CDeviceClass *pDeviceClass;

	//	Paint the item icon

	bool bGrayed = (pDevice && !pDevice->IsEnabled());
	int xIcon = rcRect.left + (RectWidth(rcRect) - ITEM_ICON_WIDTH) / 2;
	int yIcon = rcRect.top + ITEM_ENTRY_PADDING_TOP;
	DrawItemTypeIcon(Dest, xIcon, yIcon, Item.GetType(), ITEM_ICON_WIDTH, ITEM_ICON_HEIGHT, bGrayed);

	//	Paint the name of the item below.

	RECT rcText;
	rcText.left = rcRect.left + ITEM_ENTRY_PADDING_LEFT;
	rcText.right = rcRect.right - ITEM_ENTRY_PADDING_RIGHT;
	rcText.top = yIcon + ITEM_ICON_HEIGHT;
	rcText.bottom = rcRect.bottom;

	m_VI.GetFont(fontMedium).DrawText(Dest, 
			rcText,
			m_rgbTextColor,
			Item.GetNounPhrase(nounShort | nounNoModifiers),
			0,
			CG16bitFont::AlignCenter);


	//	If this is an armor segment, then paint HP, etc.

	if (pArmor)
		{
		int x = rcRect.right - ITEM_ENTRY_PADDING_RIGHT;
		int y = rcRect.top + ITEM_ENTRY_PADDING_TOP;

		//	HP

		CString sHP = strFromInt(pArmor->GetHitPoints());
		m_VI.GetFont(fontLarge).DrawText(Dest,
				x,
				y,
				m_rgbTextColor,
				sHP,
				CG16bitFont::AlignRight);
		y += m_VI.GetFont(fontLarge).GetHeight();

		//	Damage

		int iMaxHP = pArmor->GetMaxHP(pSource);
		if (iMaxHP != pArmor->GetHitPoints() && iMaxHP > 0)
			{
			int iPercent = ((1000 * pArmor->GetHitPoints() / iMaxHP) + 5) / 10;
			CString sPercent = strPatternSubst(CONSTLIT("%d%%"), iPercent);

			m_VI.GetFont(fontMedium).DrawText(Dest,
					x,
					y,
					m_VI.GetColor(colorTextDockWarning),
					sPercent,
					CG16bitFont::AlignRight);
			y += m_VI.GetFont(fontMedium).GetHeight();
			}

		//	Modifiers

		if (pArmor->GetMods().IsNotEmpty())
			{
			CString sMods = Item.GetEnhancedDesc(pSource);
			if (!sMods.IsBlank())
				{
				bool bIsDisadvantage = *sMods.GetASCIIZPointer() == '-';
				CG32bitPixel rgbBackColor = (bIsDisadvantage ? m_VI.GetColor(colorAreaDisadvantage) : m_VI.GetColor(colorAreaAdvantage));
				CG32bitPixel rgbTextColor = (bIsDisadvantage ? m_VI.GetColor(colorTextDisadvantage) : m_VI.GetColor(colorTextAdvantage));

				PaintModifier(Dest, x, y, sMods, rgbTextColor, rgbBackColor, &y);
				}
			}
		}

	//	If this is a device, then paint device-specific stuff

	else if (pDevice
				&& (pDeviceClass = pDevice->GetClass()))
		{
		int x = rcRect.right - ITEM_ENTRY_PADDING_RIGHT;
		int y = rcRect.top + ITEM_ENTRY_PADDING_TOP;

		//	HP

		if (pDevice->IsEnabled())
			{
			if (pDevice->GetCategory() == itemcatShields)
				{
				int iHP;
				int iMaxHP;
				pDevice->GetStatus(pSource, &iHP, &iMaxHP);

				CString sHP = strFromInt(iHP);
				m_VI.GetFont(fontLarge).DrawText(Dest,
						x,
						y,
						m_rgbTextColor,
						sHP,
						CG16bitFont::AlignRight);
				y += m_VI.GetFont(fontLarge).GetHeight();

				//	Shield level

				if (iMaxHP != iHP && iMaxHP > 0)
					{
					int iPercent = ((1000 * iHP / iMaxHP) + 5) / 10;
					CString sPercent = strPatternSubst(CONSTLIT("%d%%"), iPercent);

					m_VI.GetFont(fontMedium).DrawText(Dest,
							x,
							y,
							m_VI.GetColor(colorTextShields),
							sPercent,
							CG16bitFont::AlignRight);
					y += m_VI.GetFont(fontMedium).GetHeight();
					}
				}
			}
		else
			PaintModifier(Dest, x, y, CONSTLIT("disabled"), m_VI.GetColor(colorTextNormal), CG32bitPixel::Null(), &y);

		//	External

		if (pDevice->IsExternal() || pDeviceClass->IsExternal())
			PaintModifier(Dest, x, y, CONSTLIT("external"), m_VI.GetColor(colorTextNormal), CG32bitPixel::Null(), &y);

		//	Damaged

		if (pDevice->IsDamaged())
			PaintModifier(Dest, x, y, CONSTLIT("damaged"), m_VI.GetColor(colorTextDisadvantage), m_VI.GetColor(colorAreaDisadvantage), &y);

		if (pDevice->IsDisrupted())
			PaintModifier(Dest, x, y, CONSTLIT("ionized"), m_VI.GetColor(colorTextDisadvantage), m_VI.GetColor(colorAreaDisadvantage), &y);

		//	Modifiers

		if (pDevice->GetEnhancements() != NULL)
			{
			CString sMods = pDevice->GetEnhancedDesc(pSource, &Item);
			if (!sMods.IsBlank())
				{
				bool bIsDisadvantage = *sMods.GetASCIIZPointer() == '-';
				CG32bitPixel rgbBackColor = (bIsDisadvantage ? m_VI.GetColor(colorAreaDisadvantage) : m_VI.GetColor(colorAreaAdvantage));
				CG32bitPixel rgbTextColor = (bIsDisadvantage ? m_VI.GetColor(colorTextDisadvantage) : m_VI.GetColor(colorTextAdvantage));

				PaintModifier(Dest, x, y, sMods, rgbTextColor, rgbBackColor, &y);
				}
			}
		}
	}
Пример #26
0
bool CShieldClass::FindDataField (const CString &sField, CString *retsValue)

//	FindDataField
//
//	Returns meta-data

	{
	int i;

	if (strEquals(sField, FIELD_HP))
		*retsValue = strFromInt(m_iHitPoints);
	else if (strEquals(sField, FIELD_EFFECTIVE_HP))
		{
		int iHP;
		int iHPbyDamageType[damageCount];
		GetReferenceDamageAdj(NULL, NULL, &iHP, iHPbyDamageType);
		*retsValue = strFromInt(::CalcEffectiveHP(GetLevel(), iHP, iHPbyDamageType));
		}
	else if (strEquals(sField, FIELD_REGEN))
		*retsValue = strFromInt((int)m_Regen.GetHPPer180());
	else if (strEquals(sField, FIELD_ADJUSTED_HP))
		{
		int iHP;
		int iHPbyDamageType[damageCount];
		GetReferenceDamageAdj(NULL, NULL, &iHP, iHPbyDamageType);

		CString sResult;
		for (i = 0; i < damageCount; i++)
			{
			if (i > 0)
				sResult.Append(CONSTLIT("\t"));
			sResult.Append(strFromInt(iHPbyDamageType[i]));
			}
		*retsValue = sResult;
		}
	else if (strEquals(sField, FIELD_DAMAGE_ADJ))
		{
		retsValue->Truncate(0);

		for (i = 0; i < damageCount; i++)
			{
			if (i > 0)
				retsValue->Append(CONSTLIT("\t"));

			retsValue->Append(strFromInt(m_DamageAdj.GetAdj((DamageTypes)i)));
			}
		}
	else if (strEquals(sField, FIELD_POWER))
		*retsValue = strFromInt(m_iPowerUse * 100);
	else if (strEquals(sField, FIELD_HP_BONUS))
		{
		CString sResult;

		for (i = 0; i < damageCount; i++)
			{
			if (i > 0)
				sResult.Append(CONSTLIT(", "));

			int iBonus = m_DamageAdj.GetHPBonus((DamageTypes)i);
			if (iBonus == -100)
				sResult.Append(CONSTLIT("***"));
			else
				sResult.Append(strPatternSubst(CONSTLIT("%3d"), iBonus));
			}

		*retsValue = sResult;
		}
	else if (strEquals(sField, FIELD_BALANCE))
		*retsValue = strFromInt(CalcBalance());
	else if (strEquals(sField, FIELD_WEAPON_SUPPRESS))
		{
		if (m_WeaponSuppress.IsEmpty())
			*retsValue = NULL_STR;
		else
			{
			*retsValue = CONSTLIT("=(");

			bool bNeedSeparator = false;
			for (i = 0; i < damageCount; i++)
				if (m_WeaponSuppress.InSet(i))
					{
					if (bNeedSeparator)
						retsValue->Append(CONSTLIT(" "));

					retsValue->Append(::GetDamageType((DamageTypes)i));
					bNeedSeparator = true;
					}

			retsValue->Append(CONSTLIT(")"));
			}
		}
	else
		return false;

	return true;
	}
Пример #27
0
void GenerateSimTables (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	ALERROR error;
	int i, j;

	int iSystemSample = pCmdLine->GetAttributeInteger(CONSTLIT("count"));
	if (iSystemSample == 0)
		iSystemSample = DEFAULT_SYSTEM_SAMPLE;

	//	Generate systems for multiple games

	CSymbolTable AllSystems(TRUE, TRUE);
	for (i = 0; i < iSystemSample; i++)
		{
		printf("sample %d...\n", i+1);

		CTopologyNode *pNode = Universe.GetFirstTopologyNode();

		while (true)
			{
			//	Create the system

			CSystem *pSystem;
			if (error = Universe.CreateStarSystem(pNode, &pSystem))
				{
				printf("ERROR: Unable to create star system.\n");
				return;
				}

			//	Find this system in the table.

			SystemInfo *pSystemEntry;
			if (error = AllSystems.Lookup(pNode->GetSystemName(), (CObject **)&pSystemEntry))
				{
				pSystemEntry = new SystemInfo;
				pSystemEntry->sName = pNode->GetSystemName();
				pSystemEntry->iLevel = pNode->GetLevel();
				pSystemEntry->dwSystemType = pNode->GetSystemDescUNID();
				pSystemEntry->iCount = 1;

				AllSystems.AddEntry(pSystemEntry->sName, pSystemEntry);
				}
			else
				pSystemEntry->iCount++;

			//	Add the encounters to the appropriate tables

			for (j = 0; j < pSystem->GetObjectCount(); j++)
				{
				CSpaceObject *pObj = pSystem->GetObject(j);

				if (pObj)
					{
					//	Add this encounter to the table

					CStationType *pType;
					if (pType = pObj->GetEncounterInfo())
						{
						CString sKey = strFromInt(pType->GetUNID(), false);

						//	See if we have this type in the table

						StationInfo *pEntry;
						if (error = pSystemEntry->Stations.Lookup(sKey, (CObject **)&pEntry))
							{
							pEntry = new StationInfo;
							pEntry->pType = pType;
							pEntry->iSystemCount = 0;
							pEntry->iTotalCount = 1;

							pSystemEntry->Stations.AddEntry(sKey, pEntry);
							}
						else
							pEntry->iTotalCount++;
						}

					//	Enumerate the items in this object

					CItemListManipulator ItemList(pObj->GetItemList());
					ItemList.ResetCursor();
					while (ItemList.MoveCursorForward())
						{
						const CItem &Item(ItemList.GetItemAtCursor());

						if (!Item.IsInstalled() && !Item.IsDamaged())
							{
							CString sKey = strFromInt(Item.GetType()->GetUNID(), false);

							//	Find the item type in the table

							ItemInfo *pEntry;
							if (error = pSystemEntry->Items.Lookup(sKey, (CObject **)&pEntry))
								{
								pEntry = new ItemInfo;
								pEntry->pType = Item.GetType();
								pEntry->iTotalCount = Item.GetCount();

								pSystemEntry->Items.AddEntry(sKey, pEntry);
								}
							else
								pEntry->iTotalCount += Item.GetCount();
							}
						}
					}
				}

			//	Get the next node

			CString sEntryPoint;
			pNode = pSystem->GetStargateDestination(CONSTLIT("Outbound"), &sEntryPoint);
			if (pNode == NULL || pNode->IsEndGame())
				break;

			//	Done with old system

			Universe.DestroySystem(pSystem);
			}

		Universe.Reinit();
		}

	//	Output

	if (error = OutputItemTable(AllSystems, iSystemSample))
		return;

	if (error = OutputEncounterTable(AllSystems, iSystemSample))
		return;

	//	Create a table with the sum of all items for the game

	printf("Total count statistic computed.\n");
	}
Пример #28
0
void CUIHelper::PaintReferenceDamageAdj (CG16bitImage &Dest, int x, int y, int iLevel, int iHP, const int *iDamageAdj) const

//	PaintReferenceDamageAdj
//
//	Takes an array of damage type adj values and displays them

	{
	int i;
	bool bSortByDamageType = true;
	bool bOptionShowDamageAdjAsHP = false;

	const CVisualPalette &VI = m_HI.GetVisuals();
	const CG16bitFont &Small = VI.GetFont(fontSmall);
	const CG16bitFont &Medium = VI.GetFont(fontMedium);
	WORD wColorRef = VI.GetColor(colorTextHighlight);

	//	Must have positive HP

	if (iHP == 0)
		return;

	//	Sort damage types from highest to lowest

	CSymbolTable Sorted;
	int iLengthEstimate = 0;
	int iImmuneCount = 0;
	for (i = 0; i < damageCount; i++)
		{
		//	Skip if this damage type is not appropriate to our level

		int iDamageLevel = GetDamageTypeLevel((DamageTypes)i);
		if (iDamageLevel < iLevel - 5 || iDamageLevel > iLevel + 3)
			continue;

		//	Skip if the damage adj is 100%

		if (iDamageAdj[i] == iHP)
			continue;

		//	Figure out the sort order

		CString sKey;
		if (bSortByDamageType)
			sKey = strPatternSubst(CONSTLIT("%02d"), i);
		else
			{
			DWORD dwHighToLow = (iDamageAdj[i] == -1 ? 0 : 1000000 - iDamageAdj[i]);
			sKey = strPatternSubst(CONSTLIT("%08x %02d"), dwHighToLow, i);
			}

		//	Add to list

		DWORD dwValue = MAKELONG((WORD)i, (WORD)(short)iDamageAdj[i]);

		Sorted.AddEntry(sKey, (CObject *)dwValue);

		//	Estimate how many entries we will have (so we can decide the font size)
		//	We assume that immune entries get collapsed.

		if (iDamageAdj[i] != -1)
			iLengthEstimate++;
		else
			iImmuneCount++;
		}

	//	If we have six or more icons, then we need to paint smaller

	iLengthEstimate += Min(2, iImmuneCount);
	const CG16bitFont &TheFont = (iLengthEstimate >= 6 ? Small : Medium);
	int cyOffset = (Medium.GetHeight() - TheFont.GetHeight()) / 2;
	
	//	Paint the icons

	for (i = 0; i < Sorted.GetCount(); i++)
		{
		DWORD dwValue = (DWORD)Sorted.GetValue(i);
		int iDamageType = LOWORD(dwValue);
		int iDamageAdj = (int)(short)HIWORD(dwValue);
		int iPercentAdj = (100 * (iDamageAdj - iHP) / iHP);

		//	Prettify the % by rounding to a number divisible by 5

		int iPrettyPercent = 5 * ((iPercentAdj + 2 * Sign(iPercentAdj)) / 5);

		//	Skip if prettify results in 0%

		if (bOptionShowDamageAdjAsHP && iPrettyPercent == 0)
			continue;

		//	Draw icon

		g_pHI->GetVisuals().DrawDamageTypeIcon(Dest, x, y, (DamageTypes)iDamageType);
		x += DAMAGE_TYPE_ICON_WIDTH + DAMAGE_ADJ_ICON_SPACING_X;

		//	If we have a bunch of entries with "immune", then compress them

		if (i < (Sorted.GetCount() - 1)
				&& iDamageAdj == -1
				&& (iDamageAdj == (int)(short)HIWORD((DWORD)Sorted.GetValue(i + 1))))
			continue;

		//	Figure out how to display damage adj

		CString sStat;
		if (iDamageAdj == -1)
			sStat = CONSTLIT("immune");
		else if (bOptionShowDamageAdjAsHP)
			sStat = strFromInt(iDamageAdj);
		else
			sStat = strPatternSubst(CONSTLIT("%s%d%%"), (iPrettyPercent > 0 ? CONSTLIT("+") : NULL_STR), iPrettyPercent);
		
		//	Draw

		Dest.DrawText(x,
				y + cyOffset,
				TheFont,
				wColorRef,
				sStat,
				0,
				&x);

		x += DAMAGE_ADJ_SPACING_X;
		}
	}
Пример #29
0
void GenerateEncounterTable (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	ALERROR error;
	int i, j;

	//	Get the criteria from the command line. Always append 't' because we
	//	want station types.

	CString sCriteria = strPatternSubst(CONSTLIT("%s t"), pCmdLine->GetAttribute(CRITERIA_ATTRIB));

	//	Parse it

	CDesignTypeCriteria Criteria;
	if (CDesignTypeCriteria::ParseCriteria(sCriteria, &Criteria) != NOERROR)
		{
		printf("ERROR: Unable to parse criteria.\n");
		return;
		}

	bool bAll = pCmdLine->GetAttributeBool(ALL_ATTRIB);

	//	Generate a table of all matching encounters

	CSymbolTable Table(FALSE, TRUE);

	//	Loop over all items for this level and add them to
	//	a sorted table.

	for (i = 0; i < Universe.GetStationTypeCount(); i++)
		{
		CStationType *pType = Universe.GetStationType(i);
		int iLevel = pType->GetLevel();
		if (iLevel == 0 && !bAll)
			continue;

		//	If we don't match the criteria, then continue

		if (!pType->MatchesCriteria(Criteria))
			continue;

		//	Get the category and name

		CString sCategory = pType->GetDataField(FIELD_CATEGORY);
		CString sName = pType->GetDataField(FIELD_NAME);
		if (*sName.GetASCIIZPointer() == '(')
			sName = strSubString(sName, 1, -1);

		//	Figure out the sort order

		char szBuffer[1024];
		wsprintf(szBuffer, "%02d%s%s", 
				pType->GetLevel(),
				sCategory.GetASCIIZPointer(), 
				sName.GetASCIIZPointer());
		Table.AddEntry(CString(szBuffer), (CObject *)pType);
		}

	//	Generate a list of columns to display

	TArray<CString> Cols;
	Cols.Insert(FIELD_LEVEL);
	Cols.Insert(FIELD_CATEGORY);
	Cols.Insert(FIELD_NAME);

	for (i = 0; i < pCmdLine->GetAttributeCount(); i++)
		{
		CString sAttrib = pCmdLine->GetAttributeName(i);

		if (!strEquals(sAttrib, CONSTLIT("all"))
				&& !strEquals(sAttrib, CONSTLIT("criteria"))
				&& !strEquals(sAttrib, CONSTLIT("encountertable"))
				&& !strEquals(sAttrib, CONSTLIT("nologo")))
			{
			CString sValue = pCmdLine->GetAttribute(i);
			
			if (!strEquals(sValue, CONSTLIT("true")))
				Cols.Insert(strPatternSubst(CONSTLIT("%s:%s"), sAttrib, sValue));
			else
				Cols.Insert(sAttrib);
			}
		}

#if 0
	if (pCmdLine->GetAttributeBool(FIELD_ARMOR_CLASS))
		Cols.Insert(FIELD_ARMOR_CLASS);
	if (pCmdLine->GetAttributeBool(FIELD_HP))
		Cols.Insert(FIELD_HP);
	if (pCmdLine->GetAttributeBool(FIELD_FIRE_RATE_ADJ))
		Cols.Insert(FIELD_FIRE_RATE_ADJ);
	if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT))
		Cols.Insert(FIELD_TOTAL_COUNT);
	if (pCmdLine->GetAttributeBool(FIELD_CAN_ATTACK))
		Cols.Insert(FIELD_CAN_ATTACK);
	if (pCmdLine->GetAttributeBool(FIELD_EXPLOSION_TYPE))
		Cols.Insert(FIELD_EXPLOSION_TYPE);
#endif

	//	If we need to output total count, then load the table

	CSymbolTable TotalCount(TRUE, TRUE);
	if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT))
		{
		if (error = LoadTotalCount(TOTAL_COUNT_FILENAME, TotalCount))
			return;
		}

	//	If we've got any entries in the table, output now

	if (Table.GetCount())
		{
		//	Output the header

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

			printf(Cols[j].GetASCIIZPointer());
			}

		printf("\n");

		//	Output each row

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

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

				const CString &sField = Cols[j];
				CString sValue = pType->GetDataField(sField);

				if (strEquals(sField, FIELD_FIRE_RATE_ADJ))
					printf("%.2f", strToInt(sValue, 0, NULL) / 1000.0);
				else if (strEquals(sField, FIELD_TOTAL_COUNT))
					{
					double rCount = 0.0;

					CString sKey = strFromInt(pType->GetUNID(), false);
					EntryInfo *pEntry;
					if (TotalCount.Lookup(sKey, (CObject **)&pEntry) == NOERROR)
						rCount = pEntry->rTotalCount;

					printf("%.2f", rCount);
					}
				else
					printf(sValue.GetASCIIZPointer());
				}

			printf("\n");
			}

		printf("\n");
		}
	else
		printf("No entries match criteria.\n");
	}
Пример #30
0
bool CArmorClass::FindDataField (const CString &sField, CString *retsValue)

//	FindDataField
//
//	Returns meta-data

	{
	int i;

	if (strEquals(sField, FIELD_HP))
		*retsValue = strFromInt(m_iHitPoints);
	else if (strEquals(sField, FIELD_BALANCE))
		*retsValue = strFromInt(CalcBalance());
	else if (strEquals(sField, FIELD_EFFECTIVE_HP))
		{
		int iHP;
		int iHPbyDamageType[damageCount];
		GetReferenceDamageAdj(NULL, NULL, &iHP, iHPbyDamageType);
		*retsValue = strFromInt(::CalcEffectiveHP(m_pItemType->GetLevel(), iHP, iHPbyDamageType));
		}
	else if (strEquals(sField, FIELD_ADJUSTED_HP))
		{
		int iHP;
		int iHPbyDamageType[damageCount];
		GetReferenceDamageAdj(NULL, NULL, &iHP, iHPbyDamageType);

		CString sResult;
		for (i = 0; i < damageCount; i++)
			{
			if (i > 0)
				sResult.Append(CONSTLIT("\t"));
			sResult.Append(strFromInt(iHPbyDamageType[i]));
			}
		*retsValue = sResult;
		}
	else if (strEquals(sField, FIELD_DAMAGE_ADJ))
		{
		retsValue->Truncate(0);

		for (i = 0; i < damageCount; i++)
			{
			if (i > 0)
				retsValue->Append(CONSTLIT("\t"));

			retsValue->Append(strFromInt(m_DamageAdj.GetAdj((DamageTypes)i)));
			}
		}
	else if (strEquals(sField, FIELD_HP_BONUS))
		{
		CString sResult;

		for (i = 0; i < damageCount; i++)
			{
			if (i > 0)
				sResult.Append(CONSTLIT(", "));

			int iBonus = m_DamageAdj.GetHPBonus((DamageTypes)i);
			if (iBonus == -100)
				sResult.Append(CONSTLIT("***"));
			else
				sResult.Append(strPatternSubst(CONSTLIT("%3d"), iBonus));
			}

		*retsValue = sResult;
		}
	else if (strEquals(sField, FIELD_REPAIR_COST))
		*retsValue = strFromInt(m_iRepairCost);
	else if (strEquals(sField, FIELD_REGEN))
		*retsValue = strFromInt((int)m_Regen.GetHPPer180());
	else if (strEquals(sField, FIELD_INSTALL_COST))
		*retsValue = strFromInt(m_iInstallCost);
	else if (strEquals(sField, FIELD_SHIELD_INTERFERENCE))
		{
		if (m_fShieldInterference)
			*retsValue = CONSTLIT("True");
		else
			*retsValue = NULL_STR;
		}
	else
		return false;

	return true;
	}