NeedsCityGood

Ekmek

on steam: ekmek_e
Joined
Aug 7, 2002
Messages
6,115
Location
San Diego, California
hmm apolyton is down, but in the chance that refugees migrate here....


I already posted my other code, I hope its done and looking to add this code to start the ball on adding resources:

Code:
	if(irec->GetNumNeedsCityGood() > 0) {
		sint32 s;
		sint32 resource;
		bool found = false;
		for(s = 0; s < irec->GetNumNeedsCityGood(); s++) {
			if(irec->GetNeedsCityGoodIndex(s) == HasResource(resource) {
				found = true;
				break;
			}
		}
		if(!found)
			return FALSE;
	}

HasResource is a function I found in citydata and unit.cpp and unitdata.cpp (the unit files reference m_city_data)
I figure if I put the above code into the CanBuildUnit(building and wonder)
it should compare the two to see if a unit can build. This is assuming that HasResource means what it says, and it looks like that is the same function to find if a city has a resource to trade.
 
Thanks Martin, when iposted this I was looking to do this code. And I have a feeling about what more I have to look up (like making sure that HasResource actually looks at the city properties and does the iterator etc). But I'm going to do some self study once the other code stuff is finished.
 
Ekmek said:
Martin,

I'm not looking to go into major coding, but out of curiosity how far off was I on this code?

To sum up what I have written on Apolyton: Everything you can find with a compiler very quickly. :D

-Martin
 
Back
Top Bottom