General Tso
Panzer General
In the process of improving the AI in my mod I added the following function.
It is called at least 16 times per turn for each AI unit. Plus at least once for each group preforming an AutoMission. Needlessly to say, it's getting called many times per turn.
If I where to change the function so that the player object was passed as below.
Would that improve the speed at all?
Code:
bool CvUnit::isPhaseActive() const
{
if (canMove())
{
CvPlayer& pPlayer = GET_PLAYER(getOwnerINLINE());
if (getStartPhase(pPlayer.getPhaseMode()) != NO_PHASE)
{
if (getStartPhase(pPlayer.getPhaseMode()) <= pPlayer.getPhaseType())
{
return true;
}
}
}
return false;
}
It is called at least 16 times per turn for each AI unit. Plus at least once for each group preforming an AutoMission. Needlessly to say, it's getting called many times per turn.
If I where to change the function so that the player object was passed as below.
Code:
bool CvUnit::isPhaseActive(CvPlayer* pPlayer) const
{
if (canMove())
{
if (getStartPhase(pPlayer.getPhaseMode()) != NO_PHASE)
{
if (getStartPhase(pPlayer.getPhaseMode()) <= pPlayer.getPhaseType())
{
return true;
}
}
}
return false;
}
Would that improve the speed at all?