Afforess
The White Wizard
I created (borrowed, really) a loop that checks to make sure a city is near water, and the water is not a lake. (Basically, the city needs to be on the coast.)
It works. Kinda. If the city isn't on any water at all, it gets ignored. But if a city is next to a 1 tile lake, but still inland, the loop works, when it shouldn't. I'm sure this is some stupid oversight on my part.
It works. Kinda. If the city isn't on any water at all, it gets ignored. But if a city is next to a 1 tile lake, but still inland, the loop works, when it shouldn't. I'm sure this is some stupid oversight on my part.
Code:
void CvUnit::tradeUnit(PlayerTypes eReceivingPlayer)
{
CvUnit* pTradeUnit;
CvWString szBuffer;
CvCity* pCapitalCity;
CvArea* pWaterArea = NULL;
PlayerTypes eOwner;
int iLoop;
eOwner = getOwnerINLINE();
if (eReceivingPlayer != NO_PLAYER)
{
pCapitalCity = GET_PLAYER(eReceivingPlayer).getCapitalCity();
pTradeUnit = GET_PLAYER(eReceivingPlayer).initUnit(getUnitType(), pCapitalCity->getX_INLINE(), pCapitalCity->getY_INLINE(), AI_getUnitAIType());
[COLOR="Blue"] if (pTradeUnit->getDomainType() == DOMAIN_SEA)
//Find the first coastal city, and put the ship there
{
for (CvCity* pLoopCity = GET_PLAYER(eReceivingPlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(eReceivingPlayer).nextCity(&iLoop))
{
if (((pWaterArea = pLoopCity->waterArea()) != NULL && !pWaterArea->isLake()))
{
pTradeUnit = GET_PLAYER(eReceivingPlayer).initUnit(getUnitType(), pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE(), AI_getUnitAIType());
break;
}
}
}
[/COLOR]
pTradeUnit->convert(this);
szBuffer = gDLL->getText("TXT_KEY_MISC_TRADED_UNIT_TO_YOU", GET_PLAYER(eOwner).getNameKey(), pTradeUnit->getNameKey());
gDLL->getInterfaceIFace()->addMessage(pTradeUnit->getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNITGIFTED", MESSAGE_TYPE_INFO, pTradeUnit->getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_WHITE"), pTradeUnit->getX_INLINE(), pTradeUnit->getY_INLINE(), true, true);
}
}