I noticed that using boats to blockade takes very long time...
I re-programmed two functions in the DLL to speed it up:
and
With these modified functions, placing a blockade on my normal sized test-map dropped from 20 secs to less than 1 sec
I re-programmed two functions in the DLL to speed it up:
Code:
void CvUnit::updatePlunder(int iChange)
{
int iBlockadeRange = GC.getDefineINT("SHIP_BLOCKADE_RANGE");
bool btradeNetChanged[MAX_TEAMS];
bool bOldTradeNet;
for (int iTeam = 0; iTeam < MAX_TEAMS; ++iTeam)
{
btradeNetChanged[iTeam] = false;
if (isEnemy((TeamTypes)iTeam))
{
for (int i = -iBlockadeRange; i <= iBlockadeRange; ++i)
{
for (int j = -iBlockadeRange; j <= iBlockadeRange; ++j)
{
CvPlot* pLoopPlot = ::plotXY(getX_INLINE(), getY_INLINE(), i, j);
if (NULL != pLoopPlot && pLoopPlot->isWater() && pLoopPlot->area() == area())
{
if(!btradeNetChanged[iTeam])
{
bOldTradeNet = pLoopPlot->isTradeNetwork((TeamTypes)iTeam);
}
pLoopPlot->changeBlockadedCount((TeamTypes)iTeam, iChange);
if(!btradeNetChanged[iTeam])
{
btradeNetChanged[iTeam] = (bOldTradeNet != pLoopPlot->isTradeNetwork((TeamTypes)iTeam));
}
}
}
}
}
}
bool bChanged=false;
for (int iTeam = 0; iTeam < MAX_TEAMS; ++iTeam)
{
bChanged = bChanged || btradeNetChanged[iTeam];
}
if(bChanged)
{
gDLL->getInterfaceIFace()->setDirty(BlockadedPlots_DIRTY_BIT, true);
for (int iPlayer = 0; iPlayer < MAX_PLAYERS; ++iPlayer)
{
CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iPlayer);
if (kPlayer.isAlive())
{
TeamTypes kTeam = kPlayer.getTeam();
if(kTeam != NO_TEAM && btradeNetChanged[kTeam]){
kPlayer.updatePlotGroups();
}
}
}
}
}
Code:
void CvPlot::changeBlockadedCount(TeamTypes eTeam, int iChange)
{
FAssertMsg(eTeam >= 0, "eTeam is expected to be non-negative (invalid Index)");
FAssertMsg(eTeam < MAX_TEAMS, "eTeam is expected to be within maximum bounds (invalid Index)");
if (iChange != 0)
{
if (NULL == m_aiBlockadedCount)
{
m_aiBlockadedCount = new short[MAX_TEAMS];
for (int iI = 0; iI < MAX_TEAMS; ++iI)
{
m_aiBlockadedCount[iI] = 0;
}
}
m_aiBlockadedCount[eTeam] += iChange;
FAssert(getBlockadedCount(eTeam) >= 0);
FAssert(getBlockadedCount(eTeam) == 0 || isWater())
CvCity* pWorkingCity = getWorkingCity();
if (NULL != pWorkingCity)
{
pWorkingCity->AI_setAssignWorkDirty(true);
}
}
}
With these modified functions, placing a blockade on my normal sized test-map dropped from 20 secs to less than 1 sec