Railway production bonus : how does it work?

Question

King
Joined
Mar 12, 2008
Messages
950
Does anyone know how it works (code wise)? Im trying to figure out how to give the capital the 20% production bonus as well but i cant find the game code that implements a 20% bonus when connected via railways to the capital.

I thought about making the tech itself give a 20% production to the capital instead, but there doesnt seem to be an existing row name that i can use for it...
 
See CvCity.cpp. The bonus is applied here:

Code:
int CvCity::getGeneralProductionModifiers(CvString* toolTipSink) const
{
	int iMultiplier = 0;

	// Railroad to capital?
	if(IsIndustrialRouteToCapital())
	{
		const int iTempMod = GC.getINDUSTRIAL_ROUTE_PRODUCTION_MOD();
		iMultiplier += iTempMod;
		if(toolTipSink && iTempMod)
		{
			GC.getGame().BuildProdModHelpText(toolTipSink, "TXT_KEY_PRODMOD_RAILROAD_CONNECTION", iTempMod);
		}
	}

	return iMultiplier;
}

The connection is checked here:
Code:
/// Connected to capital with industrial route? (Railroads)
void CvCity::DoUpdateIndustrialRouteToCapital()
{
	AI_PERF_FORMAT("City-AI-perf.csv", ("CvCity::DoUpdateIndustrialRouteToCapital, Turn %03d, %s, %s", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );
	// Capital - what do we want to do about this?
	if(isCapital())
	{
	}
	// Non-capital city
	else
	{
		if(GET_PLAYER(getOwner()).IsCapitalConnectedToCity(this, GC.getGame().GetIndustrialRoute()))
		{
			SetIndustrialRouteToCapital(true);
		}
	}
}

You can add your code to the currently empty block after if(isCapital()), for example it can set the connection to true when the railroad tech is discovered.


Edit: If you want to do it without DLL modding, you can create a hidden building that gives +20% production and add it to the capital using Lua, when the tech is researched.
 
Top Bottom