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; }
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()); }
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); }
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); }