Dale
Mohawk Games Developer
- Joined
- Mar 14, 2002
- Messages
- 7,601
Well, this is an error that makes self-made maps unplayable unless you play the AoD mod, and I enjoy the game both ways - pure and modded, yet I can't play it unmodded, cause I don't know how to cope with the issue :-( (though I tried but without success). Would be very grateful for your help .
I think this is all that's needed:
Code:
void CvPlayer::doTurnUnits()
{
PROFILE_FUNC();
CvSelectionGroup* pLoopSelectionGroup;
int iLoop;
AI_doTurnUnitsPre();
for (pLoopSelectionGroup = firstSelectionGroup(&iLoop); pLoopSelectionGroup != NULL; pLoopSelectionGroup = nextSelectionGroup(&iLoop))
{
pLoopSelectionGroup->doDelayedDeath();
}
for (pLoopSelectionGroup = firstSelectionGroup(&iLoop); pLoopSelectionGroup != NULL; pLoopSelectionGroup = nextSelectionGroup(&iLoop))
{
pLoopSelectionGroup->doTurn();
}
if (getParent() != NO_PLAYER)
{
CvPlayer& kEurope = GET_PLAYER(getParent());
if (kEurope.isAlive() && kEurope.isEurope() && !::atWar(getTeam(), kEurope.getTeam()))
{
int iLowestCost = MAX_INT;
UnitTypes eCheapestShip = NO_UNIT;
for (int iUnitClass = 0; iUnitClass < GC.getNumUnitClassInfos(); ++iUnitClass)
{
UnitTypes eLoopUnit = (UnitTypes) GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(iUnitClass);
if (eLoopUnit != NO_UNIT)
{
if (GC.getUnitInfo(eLoopUnit).getDomainType() == DOMAIN_SEA)
{
int iCost = getEuropeUnitBuyPrice(eLoopUnit);
if (iCost < iLowestCost && iCost >= 0)
{
iLowestCost = iCost;
eCheapestShip = eLoopUnit;
}
}
}
}
if (eCheapestShip != NO_UNIT && getGold() < getEuropeUnitBuyPrice(eCheapestShip))
{
[b] // PatchMod: Randomise spawn spot START
CvPlot* pBestPlot = getStartingPlot();
CvPlot* pLoopPlot = NULL;
int iBestPlotRand = 0;
int iPlotRand = 0;
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
gDLL->callUpdater();
pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
if (pLoopPlot->isRevealed(getTeam(), false) && pBestPlot->getEurope() == pLoopPlot->getEurope())
{
if (pLoopPlot->getX_INLINE() > (GC.getMapINLINE().getGridWidthINLINE() / 2) && pLoopPlot->isEurope())
{
iPlotRand = (1 + GC.getGameINLINE().getSorenRandNum(1000, "Starting Plot"));
if (iPlotRand > iBestPlotRand)
{
iBestPlotRand = iPlotRand;
pBestPlot = pLoopPlot;
}
}
}
}
setStartingPlot(pBestPlot, true);
// PatchMod: Randomise spawn spot END[/b]
bool bHasShip = false;
int iLoop;
for (CvUnit* pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
{
if (pLoopUnit->getDomainType() == DOMAIN_SEA)
{
bHasShip = true;
break;
}
}
if (!bHasShip)
{
for (uint i = 0; i < m_aEuropeUnits.size(); ++i)
{
CvUnit* pLoopUnit = m_aEuropeUnits[i];
if (pLoopUnit->getDomainType() == DOMAIN_SEA)
{
bHasShip = true;
break;
}
}
}
if (!bHasShip)
{
buyEuropeUnit(eCheapestShip, 0);
//change taxrate
int iOldTaxRate = getTaxRate();
int iNewTaxRate = std::min(99, iOldTaxRate + 1 + GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("TAX_RATE_MAX_INCREASE"), "Tax Rate Increase for ship"));
int iChange = iNewTaxRate - iOldTaxRate;
changeTaxRate(iChange);
if (isHuman())
{
CvDiploParameters* pDiplo = new CvDiploParameters(kEurope.getID());
pDiplo->setDiploComment((DiploCommentTypes)GC.getInfoTypeForString("AI_DIPLOCOMMENT_KING_GIFT_SHIP"));
pDiplo->addDiploCommentVariable(iNewTaxRate);
pDiplo->setAIContact(true);
gDLL->beginDiplomacy(pDiplo, getID());
}
}
}
}
}
if (getID() == GC.getGameINLINE().getActivePlayer())
{
gDLL->getFAStarIFace()->ForceReset(&GC.getInterfacePathFinder());
gDLL->getInterfaceIFace()->setDirty(Waypoints_DIRTY_BIT, true);
gDLL->getInterfaceIFace()->setDirty(SelectionButtons_DIRTY_BIT, true);
}
gDLL->getInterfaceIFace()->setDirty(UnitInfo_DIRTY_BIT, true);
AI_doTurnUnitsPost();
}