[code] Filtering for property value

anilatx

Chieftain
Joined
Oct 16, 2009
Messages
8
I see that trunk has BuildingFilterIsProperty for all properties (including pollutions), but only for their existence. Would it be very tricky to filter for property value? E.g. "filter only buildings reducing pollution"? If not could you give me a hint how?
I've tried semi-blindly replacing
Code:
	if ((kInfo.getProperties()->getValueByProperty((int)m_eProperty) != 0) || (kInfo.getPropertiesAllCities()->getValueByProperty((int)m_eProperty)))
with
Code:
	if ((kInfo.getProperties()->getValueByProperty((int)m_eProperty) < 0) || (kInfo.getPropertiesAllCities()->getValueByProperty((int)m_eProperty) <0))
or
Code:
if ((kInfo.getProperties()->getValueByProperty((int)m_eProperty) < 0) )
but it does not work as intended

Context: CvBuildingFilters.cpp, function
bool BuildingFilterIsProperty::isNegativeFilteredBuilding(CvPlayer *pPlayer, CvCity *pCity, BuildingTypes eBuilding)
analogous to bool BuildingFilterIsProperty::isFilteredBuilding(CvPlayer *pPlayer, CvCity *pCity, BuildingTypes eBuilding)
 
That part is for static properties and only flammability uses that model.

For other properties you need to get the sources that have that effect, most of which are of the type CvPropertySourceConstant. So I'd suggest using dynamic_cast<CvPropertySourceConstant> on pMani->getSource(i), check for NULL and then use the method getAmountPerTurn on it.
 
Top Bottom