So first of all I am wondering if this bit of code is the right bit of code to fiddle with, and second what should I fiddle with.
I can sort understand it a little bit but then brain starts dripping from my ear...
So the final goal here is to change it so that each faction starts about 7-8 tiles from at least 2 other factions (what i really want is for all the factions to start 'clustered together' so that very quickly borders are pressing against borders and everyone is looking for a way out to expand, and also generally causing mayhem in each others lands.
I can sort understand it a little bit but then brain starts dripping from my ear...
Spoiler :
Code:
void CvGame::normalizeStartingPlotLocations()
{
CvPlot* apNewStartPlots[MAX_CIV_PLAYERS];
int* aaiDistances[MAX_CIV_PLAYERS];
int aiStartingLocs[MAX_CIV_PLAYERS];
int iI, iJ;
// Precalculate distances between all starting positions:
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
gDLL->callUpdater(); // allow window to update during launch
aaiDistances[iI] = new int[iI];
for (iJ = 0; iJ < iI; iJ++)
{
aaiDistances[iI][iJ] = 0;
}
CvPlot *pPlotI = GET_PLAYER((PlayerTypes)iI).getStartingPlot();
if (pPlotI != NULL)
{
for (iJ = 0; iJ < iI; iJ++)
{
if (GET_PLAYER((PlayerTypes)iJ).isAlive())
{
CvPlot *pPlotJ = GET_PLAYER((PlayerTypes)iJ).getStartingPlot();
if (pPlotJ != NULL)
{
int iDist = GC.getMapINLINE().calculatePathDistance(pPlotI, pPlotJ);
if (iDist == -1)
{
// 5x penalty for not being on the same area, or having no passable route
iDist = 5*plotDistance(pPlotI->getX_INLINE(), pPlotI->getY_INLINE(), pPlotJ->getX_INLINE(), pPlotJ->getY_INLINE());
}
aaiDistances[iI][iJ] = iDist;
}
}
}
}
}
else
{
aaiDistances[iI] = NULL;
}
}
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
aiStartingLocs[iI] = iI; // each player starting in own location
}
int iBestScore = getTeamClosenessScore(aaiDistances, aiStartingLocs);
bool bFoundSwap = true;
while (bFoundSwap)
{
bFoundSwap = false;
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
for (iJ = 0; iJ < iI; iJ++)
{
if (GET_PLAYER((PlayerTypes)iJ).isAlive())
{
int iTemp = aiStartingLocs[iI];
aiStartingLocs[iI] = aiStartingLocs[iJ];
aiStartingLocs[iJ] = iTemp;
int iScore = getTeamClosenessScore(aaiDistances, aiStartingLocs);
if (iScore < iBestScore)
{
iBestScore = iScore;
bFoundSwap = true;
}
else
{
// Swap them back:
iTemp = aiStartingLocs[iI];
aiStartingLocs[iI] = aiStartingLocs[iJ];
aiStartingLocs[iJ] = iTemp;
}
}
}
}
}
}
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
apNewStartPlots[iI] = NULL;
}
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
if (aiStartingLocs[iI] != iI)
{
apNewStartPlots[iI] = GET_PLAYER((PlayerTypes)aiStartingLocs[iI]).getStartingPlot();
}
}
}
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
if (apNewStartPlots[iI] != NULL)
{
GET_PLAYER((PlayerTypes)iI).setStartingPlot(apNewStartPlots[iI], false);
}
}
}
for (iI = 0; iI < MAX_CIV_PLAYERS; iI++)
{
SAFE_DELETE_ARRAY(aaiDistances[iI]);
}
}
So the final goal here is to change it so that each faction starts about 7-8 tiles from at least 2 other factions (what i really want is for all the factions to start 'clustered together' so that very quickly borders are pressing against borders and everyone is looking for a way out to expand, and also generally causing mayhem in each others lands.