[RaRE] Code optimizations

For later investigation...

Spoiler :
Code:
bool CvPlayerAI::AI_unitAIIsCombat(UnitAITypes eUnitAI)
{
	switch (eUnitAI)
	{
...
...
...
	case UNITAI_ANIMAL_SEA: // R&R, ray, Wild Animals
	[B]case UNITAI_TRANSPORT_SEA:[/B]
	case UNITAI_ASSAULT_SEA:
	case UNITAI_COMBAT_SEA:
	case UNITAI_PIRATE_SEA:
	case UNITAI_ESCORT_SEA: // TAC - AI Escort Sea - koma13
		return true;
		break;

	default:
		FAssert(false);
		break;
	}
	return false;
}
I wonder if UNITAI_TRANSPORT_SEA should really be estimated as combat AI...
This might be colliding with placing privateer attacks into the danger map, which should make naval transports avoid that area.
Well, something to investigate later.
 
Currently checking the combat system, I identified that units equipped with yields (in the current case a city defender) are running unnecessary checks:

Code:
 	CvGameCoreDLL.dll!CvUnit::canLoadYield(const CvPlot * pPlot, YieldTypes eYield, bool bTrade)  Zeile 4156	C++
 	CvGameCoreDLL.dll!CvUnit::canLoadYields(const CvPlot * pPlot, bool bTrade)  Zeile 4111 + 0x14 Bytes	C++
 	CvGameCoreDLL.dll!CvUnit::canLoadYield(const CvPlot * pPlot, YieldTypes eYield, bool bTrade)  Zeile 4131 + 0x10 Bytes	C++
>	CvGameCoreDLL.dll!CvUnit::canDoCommand(CommandTypes eCommand, int iData1, int iData2, bool bTestVisible, bool bTestBusy)  Zeile 2445 + 0x15 Bytes	C++
 	CvGameCoreDLL.dll!CvSelectionGroup::canDoCommand(CommandTypes eCommand, int iData1, int iData2, bool bTestVisible, bool bUseCache)  Zeile 1373 + 0x1a Bytes	C++
 	CvGameCoreDLL.dll!CvGame::canHandleAction(int iAction, CvPlot * pPlot, bool bTestVisible, bool bUseCache)  Zeile 2768 + 0x45 Bytes	C++
 	Colonization.exe!004ed819()
Not only that the whole sequence is completely unnecessary, but in canLoadYields(...) it iterates over all yields (in RaR currently 58).

I won't investigate this any further right now, but we should keep it in mind for the future.
 
Back
Top Bottom