Some weird condition structure...to my understanding.

Assumign a BtS mod:
Any file not in the mod uses the file from BtS.
If it is not in BtS it uses the file from Warlords.
If it is not in Warlords it uses the file in regular Civ4.

Well, actually it starts at Custom Assets if the mod is not set to disallow that in the mod's .ini file.

In fact, all my questions revolve around the original game with expansions.
So, what happens if files are missing and this is the unmodded BTS?
It takes the missing files from a parent folder?
 
You can do a search for the variable name and find out where the data comes from and what it is being used for. If the variable name is not helpful, perhaps the name of the XML tag it is loaded from (assuming it is loaded and not generated some other way) will help. But in general the name of a variable does not really have anything to do with what it is used for - the computer doesn't care what you call it, only what you do with it. Therefore the only way to really know what it is for is to do that search and look at everything it is used for.

For example, say the InfoThing class has a variable m_iData. This is probably not a useful name, all variables hold data so it tells you pretty much nothing other than the "i" probably means it is an integer but you can tell that by how it is declared anyway. So you search for m_iData, focusing initially on the file where InfoThing is declared. It probably has an InfoThing::getData function that returns the value of m_iData and also an InfoThing::setData function that sets it, and maybe an InfoThing::changeData function as well. (The variable might not appear anywhere else other than perhaps the initialization code for InfoThing.) So search for setData and see where it is being called. If the variable is loaded from some data in an XML file then the XML parsing code for InfoThing must set it, so what tag in what XML file is the source? If it is not loaded, it must be used to hold some value that is somehow calculated from other things. What are those things? After seeing where the data in that variable comes from, you'd check to see where getData is called to see how it is being used.

:goodjob:

Just after studying how the granary works in CvCity.cpp, I finally got a grasp of what you meant.

Yes, there is an initialization, which happens in the beginning and is 0 being an integer, false/true if boolean, perhaps the NULL value. Whatever, we have to start somewhere.
Those member variables are not necessarily "fetch me passively" data from the game and can undergo many modification via get, set or change (mini-functions).
And get is also not necessarily a passive get info from the game, it can be retrieve the date that has underwent modifications via change (operation) or set (assignment; forced value).
 
@God-Emperor

Ok, I just realized (because I'm a C++ newb) a whole C++ file is like a giant function where it initializes those member variables, do some operations and assignments onto them and then put into functions for various purposes.

The missing link I couldn't understand was how it is linked to the game until I saw this:
Spoiler :

Code:
void CvCity::read(FDataStreamBase* pStream)
{
	int iI;
	int iNumElts;

	// Init data before load
	reset();

	uint uiFlag=0;
	pStream->Read(&uiFlag);	// flags for expansion

	pStream->Read(&m_iID);
	pStream->Read(&m_iX);
	pStream->Read(&m_iY);
	pStream->Read(&m_iRallyX);
	pStream->Read(&m_iRallyY);
	pStream->Read(&m_iGameTurnFounded);
	pStream->Read(&m_iGameTurnAcquired);
	pStream->Read(&m_iPopulation);
	pStream->Read(&m_iHighestPopulation);
	pStream->Read(&m_iWorkingPopulation);
	pStream->Read(&m_iSpecialistPopulation);<

[...]

}

I guess that's the commands to load a previous game save where lie those data for each member variable. That's the link I was missing I think.

So, when a game is loaded, we initialize, make some function operations onto those member variables, keep continuously info in some memory allocation I don't know, then when we're about to save a game, all those data are not lost and when we load the game, instead of the initializers, we use the alter ego of "read" and it is:

Code:
void CvCity::write(FDataStreamBase* pStream)

I would be really pleased if you just confirm my reasoning.
 
In fact, all my questions revolve around the original game with expansions.
So, what happens if files are missing and this is the unmodded BTS?
It takes the missing files from a parent folder?

In general yes.
Doesn't mean that deleting random files out of Bts will work, because there might be changes in the schema/structure/provided data.
 
Can someone nod me if I got right the understanding of this code part:

You have this conditional structure:

Code:
if (pLoopPlot->isPotentialCityWorkForArea(area()))

Some enumeration of plots will undergo the boolan test of isPotentialCityWorkForArea(area())).

Code:
bool CvPlot::isPotentialCityWorkForArea(CvArea* pArea) const
{
	PROFILE_FUNC();

	CvPlot* pLoopPlot;
	int iI;

	for (iI = 0; iI < NUM_CITY_PLOTS; ++iI)
	{
		pLoopPlot = plotCity(getX_INLINE(), getY_INLINE(), iI);

		if (pLoopPlot != NULL)
		{
			if (!(pLoopPlot->isWater()) || GC.getDefineINT("WATER_POTENTIAL_CITY_WORK_FOR_AREA"))
			{
				if (pLoopPlot->area() == pArea)
				{
					return true;
				}
			}
		}
	}

	return false;
}

On each plot of that enumation aforementioned, we centered some sort of abstract BFC of 21 tiles. Then, we test all those 21 tiles with two conditions: must not be a water tile AND must belong to the same area as the center of that abstract BFC. If those two are fulfilled, then that tested plot is returned to be true. The rest not fulfilling are false.

To come back of this list of plots:

Code:
if (pLoopPlot->isPotentialCityWorkForArea(area()))

That was the plots of a certain culture level; under testing to see those that won't receive actual culture like ocean tiles or another area's tiles.

Anyways, I find this function tortuous...

And lastly, in
Code:
if (!(pLoopPlot->isWater()) || GC.getDefineINT("WATER_POTENTIAL_CITY_WORK_FOR_AREA"))

WATER_POTENTIAL_CITY_WORK_FOR_AREA returns 0. I don't really see its use.
 
I cannot totally comprehend the logic of that code part, because it seems to be missing some things, but I guess I can answer something else:
WATER_POTENTIAL_CITY_WORK_FOR_AREA is not a hardcoded variable, but is defined in XML\GlobalDefines.xml, where it is set to 0 in BtS.
So this is an option for modding. It's used in FinalFrontier, where it's set to 1. I guess with a value of 0, the cities in FF would not be able to work any tiles.
 
Back
Top Bottom