Bazaar developer reference

CvGame::getMaxTurnLen()

Defined in
CvGame.cpp, line 4662
Class
CvGame
Hook name
CivHooks::CvGame_getMaxTurnLen

Hooks

static bool BeforeCvGame_getMaxTurnLen(CvGame* self, int& result);static void AfterCvGame_getMaxTurnLen(CvGame* self, int& result);static int ReplaceCvGame_getMaxTurnLen(int (*original)(CvGame*), CvGame* self);CivRegisterBefore<CivHooks::CvGame_getMaxTurnLen>(host, &BeforeCvGame_getMaxTurnLen);CivRegisterAfter<CivHooks::CvGame_getMaxTurnLen>(host, &AfterCvGame_getMaxTurnLen);CivRegisterReplace<CivHooks::CvGame_getMaxTurnLen>(host, &ReplaceCvGame_getMaxTurnLen);

Code

4662int CvGame::getMaxTurnLen()4663{//returns the amount of time players are being given for this turn.4664	if(getPitbossTurnTime() != 0)4665	{//manually set turn time.4666		if(isPitboss())4667		{// Turn time is in hours4668			return (getPitbossTurnTime() * 3600);4669		}4670		else4671		{4672			return getPitbossTurnTime();4673		}4674	}4675	else4676	{4677		int iMaxUnits = 0;4678		int iMaxCities = 0;46794680		// Find out who has the most units and who has the most cities4681		// Calculate the max turn time based on the max number of units and cities4682		for(int i = 0; i < MAX_CIV_PLAYERS; ++i)4683		{4684			if(GET_PLAYER((PlayerTypes)i).isAlive())4685			{4686				if(GET_PLAYER((PlayerTypes)i).getNumUnits() > iMaxUnits)4687				{4688					iMaxUnits = GET_PLAYER((PlayerTypes)i).getNumUnits();4689				}4690				if(GET_PLAYER((PlayerTypes)i).getNumCities() > iMaxCities)4691				{4692					iMaxCities = GET_PLAYER((PlayerTypes)i).getNumCities();4693				}4694			}4695		}46964697		// Now return turn len based on base len and unit and city resources4698		const CvTurnTimerInfo& kTurnTimer = CvPreGame::turnTimerInfo();4699		int baseTurnTime = (kTurnTimer.getBaseTime() +4700		        (kTurnTimer.getCityResource() * iMaxCities) +4701		        (kTurnTimer.getUnitResource() * iMaxUnits));4702		4703		return baseTurnTime;4704	}4705}

Calls

Called by