예제 #1
0
ALERROR GetEconomyUNIDOrDefault (CCodeChain &CC, ICCItem *pItem, DWORD *retdwUNID)
	{
	if (pItem == NULL || pItem->IsNil())
		{
		if (retdwUNID)
			*retdwUNID = 0;
		}
	else if (pItem->IsInteger())
		{
		CDesignType *pType = g_pUniverse->FindDesignType(pItem->GetIntegerValue());
		if (pType == NULL)
			return ERR_FAIL;

		if (retdwUNID)
			*retdwUNID = pType->GetUNID();
		}
	else
		{
		CEconomyType *pEconomy = g_pUniverse->FindEconomyType(pItem->GetStringValue());
		if (pEconomy == NULL)
			return ERR_FAIL;

		if (retdwUNID)
			*retdwUNID = pEconomy->GetUNID();
		}

	return NOERROR;
	}
예제 #2
0
CurrencyValue CCurrencyBlock::GetCredits (const CString &sCurrency)

//	GetCredits
//
//	Returns the number of credits available in the given currency

{
    ASSERT(!sCurrency.IsBlank());

    CEconomyType *pEcon = g_pUniverse->FindEconomyType(sCurrency);
    if (pEcon == NULL)
        return 0;

    return GetCredits(pEcon->GetUNID());
}
예제 #3
0
CurrencyValue CCurrencyBlock::IncCredits (const CString &sCurrency, CurrencyValue iInc)

//	IncCredits
//
//	Increments/decrements credits

{
    ASSERT(!sCurrency.IsBlank());

    CEconomyType *pEcon = g_pUniverse->FindEconomyType(sCurrency);
    if (pEcon == NULL)
        return 0;

    return IncCredits(pEcon->GetUNID(), iInc);
}
예제 #4
0
void CCurrencyBlock::SetCredits (const CString &sCurrency, CurrencyValue iValue)

//	SetCredits
//
//	Sets the credit value for the given currency

{
    ASSERT(!sCurrency.IsBlank());

    CEconomyType *pEcon = g_pUniverse->FindEconomyType(sCurrency);
    if (pEcon == NULL)
        return;

    SetCredits(pEcon->GetUNID(), iValue);
}