//------------------------------------------------------------------------------------------------------ bool CvCameraOverlayInfo::read(CvXMLLoadUtility* pXML) { CvString szTextVal; if (!CvInfoBase::read(pXML)) return false; pXML->GetChildXmlValByName( &m_bVisible, "bVisible"); pXML->GetChildXmlValByName( szTextVal, "TextureFile"); setBaseTexture(szTextVal); pXML->GetChildXmlValByName( szTextVal, "CameraOverlayType"); if(szTextVal.CompareNoCase("CAMERA_OVERLAY_DECAL") == 0) m_eCameraOverlayType = CAMERA_OVERLAY_DECAL; else if(szTextVal.CompareNoCase("CAMERA_OVERLAY_ADDITIVE") == 0) m_eCameraOverlayType = CAMERA_OVERLAY_ADDITIVE; else { FAssertMsg(false, "[Jason] Unknown camera overlay type."); m_eCameraOverlayType = CAMERA_OVERLAY_DECAL; } return true; }
int CvArea::getNumRevealedTiles(TeamTypes eIndex) const { FAssertMsg(eIndex >= 0, "eIndex is expected to be >= 0"); FAssertMsg(eIndex < MAX_PLAYERS, "eIndex is expected to be < MAX_PLAYERS"); return m_aiNumRevealedTiles[eIndex]; }
/// What Flavors will be added by adopting this Grand Strategy? int CvAIGrandStrategyXMLEntry::GetFlavorModValue(int i) const { FAssertMsg(i < GC.getNumFlavorTypes(), "Index out of bounds"); FAssertMsg(i > -1, "Index out of bounds"); return m_piFlavorModValue ? m_piFlavorModValue[i] : 0; }
void CvBattleDefinition::checkBattleRound(int index) const { FAssertMsg((index >= 0) && (index < (int)m_aBattleRounds.size()), "[Jason] Invalid battle round index."); }
void checkBattleUnitType(BattleUnitTypes unitType) { FAssertMsg((unitType >= 0) && (unitType < BATTLE_UNIT_COUNT), "[Jason] Invalid battle unit type."); }
///TKs Med TradeScreens void CvMapGenerator::addEurope() { PROFILE_FUNC(); gDLL->NiTextOut("Adding Europe..."); for (int iEurope = 0; iEurope < GC.getNumEuropeInfos(); ++iEurope) { EuropeTypes eEurope = (EuropeTypes) iEurope; CvEuropeInfo& kEurope = GC.getEuropeInfo(eEurope); int iWidthPercent = kEurope.getWidthPercent(); gDLL->getPythonIFace()->pythonGetEuropeWidthPercent(eEurope, &iWidthPercent); int iMinLandDistance = kEurope.getMinLandDistance(); gDLL->getPythonIFace()->pythonGetEuropeMinLandDistance(eEurope, &iMinLandDistance); //try several times until at least one start europe is found //bool bWaterRoute = (kEurope.getDomainsValid(DOMAIN_SEA)); bool bAnyEuropeFound = false; bool bCheckDirection = true; //int iDomainCount = 0; int iGridWidth = GC.getMapINLINE().getGridWidthINLINE(); int iGridHeight = GC.getMapINLINE().getGridHeightINLINE(); for ( ; iMinLandDistance >= 0 && !bAnyEuropeFound; iMinLandDistance--) { for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); ++i) { CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i); bCheckDirection = true; if (!kEurope.getDomainsValid(DOMAIN_SEA) && pPlot->isWater()) { bCheckDirection = false; } //else if (kEurope.getDomainsValid(DOMAIN_SEA)) //{ //iDomainCount++; //} if (!kEurope.getDomainsValid(DOMAIN_LAND) && !pPlot->isWater()) { bCheckDirection = false; } //else if (kEurope.getDomainsValid(DOMAIN_LAND)) //{ //iDomainCount++; //} if (bCheckDirection && !pPlot->isTradeScreenAccessPlot(eEurope)) { for (int iDir = 0; iDir < NUM_DIRECTION_TYPES; ++iDir) { /*DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_EAST, DIRECTION_SOUTHEAST, DIRECTION_SOUTH, DIRECTION_SOUTHWEST, DIRECTION_WEST, DIRECTION_NORTHWEST,*/ bool bEurope = false; if (kEurope.getDirectionValid(iDir)) { switch ((DirectionTypes)iDir) { case DIRECTION_EAST: bEurope = (pPlot->getX_INLINE() > (100 - iWidthPercent) * iGridWidth / 100 && pPlot->getY_INLINE() <= (100 - iWidthPercent) * iGridHeight / 100 && pPlot->getY_INLINE() >= iWidthPercent * iGridHeight / 100); break; case DIRECTION_NORTHEAST: bEurope = (pPlot->getX_INLINE() > (100 - iWidthPercent) * iGridWidth / 100 && pPlot->getY_INLINE() > (100 - iWidthPercent) * iGridHeight / 100); break; case DIRECTION_SOUTHEAST: bEurope = (pPlot->getX_INLINE() > (100 - iWidthPercent) * iGridWidth / 100 && pPlot->getY_INLINE() < iWidthPercent * iGridHeight / 100); break; case DIRECTION_WEST: bEurope = (pPlot->getX_INLINE() < iWidthPercent * iGridWidth / 100 && pPlot->getY_INLINE() <= (100 - iWidthPercent) * iGridHeight / 100 && pPlot->getY_INLINE() >= iWidthPercent * iGridHeight / 100); break; case DIRECTION_NORTHWEST: bEurope = (pPlot->getX_INLINE() < (100 - iWidthPercent) * iGridWidth / 100 && pPlot->getY_INLINE() > (100 - iWidthPercent) * iGridHeight / 100); break; case DIRECTION_SOUTHWEST: bEurope = (pPlot->getX_INLINE() < (100 - iWidthPercent) * iGridWidth / 100 && pPlot->getY_INLINE() < iWidthPercent * iGridHeight / 100); break; case DIRECTION_NORTH: bEurope = (pPlot->getY_INLINE() > (100 - iWidthPercent) * iGridHeight / 100 && pPlot->getX_INLINE() > iWidthPercent * iGridWidth / 100 && pPlot->getX_INLINE() < (100 - iWidthPercent) * iGridWidth / 100); break; case DIRECTION_SOUTH: bEurope = (pPlot->getY_INLINE() < iWidthPercent * iGridHeight / 100 && pPlot->getX_INLINE() > iWidthPercent * iGridWidth / 100 && pPlot->getX_INLINE() < (100 - iWidthPercent) * iGridWidth / 100); break; default: FAssertMsg(false, "Invalid direction"); break; } } if (bEurope) { if (kEurope.getDomainsValid(DOMAIN_SEA)) { for (int i = -iMinLandDistance; i <= iMinLandDistance && bEurope; i++) { for (int j = -iMinLandDistance; j <= iMinLandDistance && bEurope; j++) { CvPlot* pLoopPlot = ::plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), i, j); if (pLoopPlot != NULL) { if (!pLoopPlot->isWater()) { bEurope = false; } } } } if (bEurope) { if (pPlot->getFeatureType() != NO_FEATURE && GC.getFeatureInfo(pPlot->getFeatureType()).isImpassable()) { pPlot->setFeatureType(NO_FEATURE); } if (pPlot->isImpassable()) { bEurope = false; } } if (bEurope) { if (!pPlot->isEurope()) { pPlot->setEurope(eEurope); } pPlot->setTradeScreenAccess(eEurope); bAnyEuropeFound = true; } bEurope = true; } if (kEurope.getDomainsValid(DOMAIN_LAND)) { switch ((DirectionTypes)iDir) { case DIRECTION_EAST: if (pPlot->getX_INLINE() < (iGridWidth - kEurope.getMaxLandCoverage())) { bEurope = false; } break; case DIRECTION_NORTHEAST: if (pPlot->getX_INLINE() < (iGridWidth - kEurope.getMaxLandCoverage()) && pPlot->getY_INLINE() < (iGridHeight - kEurope.getMaxLandCoverage())) { bEurope = false; } break; case DIRECTION_SOUTHEAST: if (pPlot->getY_INLINE() > kEurope.getMaxLandCoverage() && pPlot->getX_INLINE() < (iGridWidth - kEurope.getMaxLandCoverage())) { bEurope = false; } break; case DIRECTION_WEST: if (pPlot->getX_INLINE() > kEurope.getMaxLandCoverage()) { bEurope = false; } break; case DIRECTION_NORTHWEST: if (pPlot->getX_INLINE() > kEurope.getMaxLandCoverage() && pPlot->getY_INLINE() < (iGridHeight - kEurope.getMaxLandCoverage())) { bEurope = false; } break; case DIRECTION_SOUTHWEST: if (pPlot->getY_INLINE() > kEurope.getMaxLandCoverage() && pPlot->getX_INLINE() > kEurope.getMaxLandCoverage()) { bEurope = false; } break; case DIRECTION_NORTH: if (pPlot->getY_INLINE() < (iGridHeight - kEurope.getMaxLandCoverage())) { bEurope = false; } break; case DIRECTION_SOUTH: if (pPlot->getY_INLINE() > kEurope.getMaxLandCoverage()) { bEurope = false; } break; default: FAssertMsg(false, "Invalid direction"); break; } if (bEurope) { if (pPlot->getFeatureType() != NO_FEATURE && GC.getFeatureInfo(pPlot->getFeatureType()).isImpassable()) { pPlot->setFeatureType(NO_FEATURE); } if (pPlot->isImpassable()) { bEurope = false; } } if (bEurope) { if (!pPlot->isEurope()) { pPlot->setEurope(eEurope); } pPlot->setTradeScreenAccess(eEurope); bAnyEuropeFound = true; } } } /*if (bEurope) { if (pPlot->getFeatureType() != NO_FEATURE && GC.getFeatureInfo(pPlot->getFeatureType()).isImpassable()) { pPlot->setFeatureType(NO_FEATURE); } if (pPlot->isImpassable()) { bEurope = false; } } if (bEurope) { if (!pPlot->isEurope()) { pPlot->setEurope(eEurope); } pPlot->setTradeScreenAccess(eEurope); bAnyEuropeFound = true; }*/ } } } } } }
//Note from Blake: //Iustus wrote this function, it ensures that a new river actually //creates fresh water on the passed plot. Quite useful really //Altouh I veto'd it's use since I like that you don't always //get fresh water starts. // pFreshWaterPlot = the plot we want to give a fresh water river // bool CvMapGenerator::addRiver(CvPlot* pFreshWaterPlot) { FAssertMsg(pFreshWaterPlot != NULL, "NULL plot parameter"); // cannot have a river flow next to water if (pFreshWaterPlot->isWater()) { return false; } // if it already has a fresh water river, then success! we done if (pFreshWaterPlot->isRiver()) { return true; } bool bSuccess = false; // randomize the order of directions std::vector<int> aiShuffle(NUM_CARDINALDIRECTION_TYPES); GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, NULL); // make two passes, once for each flow direction of the river int iNWFlowPass = GC.getGameINLINE().getMapRandNum(2, "addRiver"); for (int iPass = 0; !bSuccess && iPass <= 1; iPass++) { // try placing a river edge in each direction, in random order for (int iI = 0; !bSuccess && iI < NUM_CARDINALDIRECTION_TYPES; iI++) { CardinalDirectionTypes eRiverDirection = NO_CARDINALDIRECTION; CvPlot *pRiverPlot = NULL; switch (aiShuffle[iI]) { case CARDINALDIRECTION_NORTH: if (iPass == iNWFlowPass) { pRiverPlot = plotDirection(pFreshWaterPlot->getX_INLINE(), pFreshWaterPlot->getY_INLINE(), DIRECTION_NORTH); eRiverDirection = CARDINALDIRECTION_WEST; } else { pRiverPlot = plotDirection(pFreshWaterPlot->getX_INLINE(), pFreshWaterPlot->getY_INLINE(), DIRECTION_NORTHWEST); eRiverDirection = CARDINALDIRECTION_EAST; } break; case CARDINALDIRECTION_EAST: if (iPass == iNWFlowPass) { pRiverPlot = pFreshWaterPlot; eRiverDirection = CARDINALDIRECTION_NORTH; } else { pRiverPlot = plotDirection(pFreshWaterPlot->getX_INLINE(), pFreshWaterPlot->getY_INLINE(), DIRECTION_NORTH); eRiverDirection = CARDINALDIRECTION_SOUTH; } break; case CARDINALDIRECTION_SOUTH: if (iPass == iNWFlowPass) { pRiverPlot = pFreshWaterPlot; eRiverDirection = CARDINALDIRECTION_WEST; } else { pRiverPlot = plotDirection(pFreshWaterPlot->getX_INLINE(), pFreshWaterPlot->getY_INLINE(), DIRECTION_WEST); eRiverDirection = CARDINALDIRECTION_EAST; } break; case CARDINALDIRECTION_WEST: if (iPass == iNWFlowPass) { pRiverPlot = plotDirection(pFreshWaterPlot->getX_INLINE(), pFreshWaterPlot->getY_INLINE(), DIRECTION_WEST); eRiverDirection = CARDINALDIRECTION_NORTH; } else { pRiverPlot = plotDirection(pFreshWaterPlot->getX_INLINE(), pFreshWaterPlot->getY_INLINE(), DIRECTION_NORTHWEST); eRiverDirection = CARDINALDIRECTION_SOUTH; } break; default: FAssertMsg(false, "invalid cardinal direction"); } if (pRiverPlot != NULL && !pRiverPlot->hasCoastAtSECorner()) { // try to make the river doRiver(pRiverPlot, eRiverDirection, eRiverDirection, -1); // if it succeeded, then we will be a river now! if (pFreshWaterPlot->isRiver()) { bSuccess = true; } } } } return bSuccess; }
// pStartPlot = the plot at whose SE corner the river is starting // void CvMapGenerator::doRiver(CvPlot *pStartPlot, CardinalDirectionTypes eLastCardinalDirection, CardinalDirectionTypes eOriginalCardinalDirection, int iThisRiverID) { if (iThisRiverID == -1) { iThisRiverID = GC.getMapINLINE().getNextRiverID(); GC.getMapINLINE().incrementNextRiverID(); } int iOtherRiverID = pStartPlot->getRiverID(); if (iOtherRiverID != -1 && iOtherRiverID != iThisRiverID) { return; // Another river already exists here; can't branch off of an existing river! } CvPlot *pRiverPlot = NULL; CvPlot *pAdjacentPlot = NULL; CardinalDirectionTypes eBestCardinalDirection = NO_CARDINALDIRECTION; if (eLastCardinalDirection==CARDINALDIRECTION_NORTH) { pRiverPlot = pStartPlot; if (pRiverPlot == NULL) { return; } pAdjacentPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), CARDINALDIRECTION_EAST); if ((pAdjacentPlot == NULL) || pRiverPlot->isWOfRiver() || pRiverPlot->isWater() || pAdjacentPlot->isWater()) { return; } pStartPlot->setRiverID(iThisRiverID); pRiverPlot->setWOfRiver(true, eLastCardinalDirection); pRiverPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), CARDINALDIRECTION_NORTH); } else if (eLastCardinalDirection==CARDINALDIRECTION_EAST) { pRiverPlot = plotCardinalDirection(pStartPlot->getX_INLINE(), pStartPlot->getY_INLINE(), CARDINALDIRECTION_EAST); if (pRiverPlot == NULL) { return; } pAdjacentPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), CARDINALDIRECTION_SOUTH); if ((pAdjacentPlot == NULL) || pRiverPlot->isNOfRiver() || pRiverPlot->isWater() || pAdjacentPlot->isWater()) { return; } pStartPlot->setRiverID(iThisRiverID); pRiverPlot->setNOfRiver(true, eLastCardinalDirection); } else if (eLastCardinalDirection==CARDINALDIRECTION_SOUTH) { pRiverPlot = plotCardinalDirection(pStartPlot->getX_INLINE(), pStartPlot->getY_INLINE(), CARDINALDIRECTION_SOUTH); if (pRiverPlot == NULL) { return; } pAdjacentPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), CARDINALDIRECTION_EAST); if ((pAdjacentPlot == NULL) || pRiverPlot->isWOfRiver() || pRiverPlot->isWater() || pAdjacentPlot->isWater()) { return; } pStartPlot->setRiverID(iThisRiverID); pRiverPlot->setWOfRiver(true, eLastCardinalDirection); } else if (eLastCardinalDirection==CARDINALDIRECTION_WEST) { pRiverPlot = pStartPlot; if (pRiverPlot == NULL) { return; } pAdjacentPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), CARDINALDIRECTION_SOUTH); if ((pAdjacentPlot == NULL) || pRiverPlot->isNOfRiver() || pRiverPlot->isWater() || pAdjacentPlot->isWater()) { return; } pStartPlot->setRiverID(iThisRiverID); pRiverPlot->setNOfRiver(true, eLastCardinalDirection); pRiverPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), CARDINALDIRECTION_WEST); } else { //FAssertMsg(false, "Illegal direction type"); // River is starting here, set the direction in the next step pRiverPlot = pStartPlot; long result = 0; if (gDLL->getPythonIFace()->pythonGetRiverStartCardinalDirection(pRiverPlot, &result) && !gDLL->getPythonIFace()->pythonUsingDefaultImpl()) // Python override { if (result >= 0) { eBestCardinalDirection = ((CardinalDirectionTypes)result); } else { FAssertMsg(false, "python pythonGetRiverStartCardinalDirection() must return >= 0"); } } } if (pRiverPlot == NULL) { return; // The river has flowed off the edge of the map. All is well. } else if (pRiverPlot->hasCoastAtSECorner()) { return; // The river has flowed into the ocean. All is well. } if (eBestCardinalDirection == NO_CARDINALDIRECTION) { int iBestValue = MAX_INT; for (int iI = 0; iI < NUM_CARDINALDIRECTION_TYPES; iI++) { if (getOppositeCardinalDirection((CardinalDirectionTypes)iI) != eOriginalCardinalDirection) { if (getOppositeCardinalDirection((CardinalDirectionTypes)iI) != eLastCardinalDirection) { CvPlot* pAdjacentPlot; pAdjacentPlot = plotCardinalDirection(pRiverPlot->getX_INLINE(), pRiverPlot->getY_INLINE(), ((CardinalDirectionTypes)iI)); if (pAdjacentPlot != NULL) { int iValue = getRiverValueAtPlot(pAdjacentPlot); if (iValue < iBestValue) { iBestValue = iValue; eBestCardinalDirection = (CardinalDirectionTypes)iI; } } } } } } if (eBestCardinalDirection != NO_CARDINALDIRECTION) { if (eOriginalCardinalDirection == NO_CARDINALDIRECTION) { eOriginalCardinalDirection = eBestCardinalDirection; } doRiver(pRiverPlot, eBestCardinalDirection, eOriginalCardinalDirection, iThisRiverID); } }
///Tks Med CvPlot* CvMap::syncRandPlot(int iFlags, int iArea, int iMinUnitDistance, int iTimeout, bool bIgnoreNativeTeams) { ///TKe CvPlot* pPlot = NULL; int iCount = 0; while (iCount < iTimeout) { CvPlot* pTestPlot = plotSorenINLINE(GC.getGameINLINE().getSorenRandNum(getGridWidthINLINE(), "Rand Plot Width"), GC.getGameINLINE().getSorenRandNum(getGridHeightINLINE(), "Rand Plot Height")); FAssertMsg(pTestPlot != NULL, "TestPlot is not assigned a valid value"); if ((iArea == -1) || (pTestPlot->getArea() == iArea)) { bool bValid = true; if (bValid) { if (iMinUnitDistance != -1) { for (int iDX = -(iMinUnitDistance); iDX <= iMinUnitDistance; iDX++) { for (int iDY = -(iMinUnitDistance); iDY <= iMinUnitDistance; iDY++) { CvPlot* pLoopPlot = plotXY(pTestPlot->getX_INLINE(), pTestPlot->getY_INLINE(), iDX, iDY); if (pLoopPlot != NULL) { if (pLoopPlot->isUnit()) { bValid = false; } } } } } } if (bValid) { if (iFlags & RANDPLOT_LAND) { if (pTestPlot->isWater()) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_UNOWNED) { if (pTestPlot->isOwned()) { ///Tks Med if (bIgnoreNativeTeams) { if (!GET_PLAYER(pTestPlot->getOwnerINLINE()).isNative()) { bValid = false; } } else { bValid = false; } ///TKe } } } if (bValid) { if (iFlags & RANDPLOT_ADJACENT_UNOWNED) { if (pTestPlot->isAdjacentOwned()) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_ADJACENT_LAND) { if (!(pTestPlot->isAdjacentToLand())) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_PASSIBLE) { if (pTestPlot->isImpassable()) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_NOT_VISIBLE_TO_CIV) { ///TKs Med if (pTestPlot->isVisibleToCivTeam(bIgnoreNativeTeams)) { bValid = false; } ///TKe } } ///TKs Med if (bValid) { if (bIgnoreNativeTeams) { if (pTestPlot->isVisibleToWatchingHuman()) { bValid = false; } } } ///TKe if (bValid) { if (iFlags & RANDPLOT_NOT_CITY) { if (pTestPlot->isCity()) { bValid = false; } } } if (bValid) { pPlot = pTestPlot; break; } } iCount++; } return pPlot; }
CvDllHandicapInfo::CvDllHandicapInfo(CvHandicapInfo* pHandicapInfo) : m_pHandicapInfo(pHandicapInfo) , m_uiRefCount(1) { FAssertMsg(pHandicapInfo != NULL, "SHOULD NOT HAPPEN"); }
int CvArea::getNumImprovements(ImprovementTypes eImprovement) const { FAssertMsg(eImprovement >= 0, "eImprovement expected to be >= 0"); FAssertMsg(eImprovement < GC.getNumImprovementInfos(), "eImprovement expected to be < GC.getNumImprovementInfos"); return m_paiNumImprovements[eImprovement]; }
int CvArea::getNumBonuses(BonusTypes eBonus) const { FAssertMsg(eBonus >= 0, "eBonus expected to be >= 0"); FAssertMsg(eBonus < GC.getNumBonusInfos(), "eBonus expected to be < GC.getNumBonusInfos"); return m_paiNumBonuses[eBonus]; }
CvCity* CvArea::getTargetCity(PlayerTypes eIndex) const { FAssertMsg(eIndex >= 0, "eIndex is expected to be >= 0"); FAssertMsg(eIndex < MAX_PLAYERS, "eIndex is expected to be < MAX_PLAYERS"); return getCity(m_aTargetCities[eIndex]); }
void CvArea::setAreaAIType(TeamTypes eIndex, AreaAITypes eNewValue) { FAssertMsg(eIndex >= 0, "eIndex is expected to be >= 0"); FAssertMsg(eIndex < MAX_TEAMS, "eIndex is expected to be < MAX_TEAMS"); m_aeAreaAIType[eIndex] = eNewValue; }
AreaAITypes CvArea::getAreaAIType(TeamTypes eIndex) const { FAssertMsg(eIndex >= 0, "eIndex is expected to be >= 0"); FAssertMsg(eIndex < MAX_TEAMS, "eIndex is expected to be < MAX_TEAMS"); return m_aeAreaAIType[eIndex]; }
bool CvMapGenerator::canPlaceGoodyAt(ImprovementTypes eImprovement, int iX, int iY) { PROFILE_FUNC(); CvPlot* pPlot; FAssertMsg(eImprovement != NO_IMPROVEMENT, "Improvement is not assigned a valid value"); FAssertMsg(GC.getImprovementInfo(eImprovement).isGoody(), "ImprovementType eImprovement is expected to be a goody"); if (GC.getGameINLINE().isOption(GAMEOPTION_NO_GOODY_HUTS)) { return false; } pPlot = GC.getMapINLINE().plotINLINE(iX, iY); if (!(pPlot->canHaveImprovement(eImprovement, NO_TEAM))) { return false; } long result = 0; if (gDLL->getPythonIFace()->pythonCanPlaceGoodyAt(pPlot, &result) && !gDLL->getPythonIFace()->pythonUsingDefaultImpl()) // Python override { if (result >= 0) { return result; } else { FAssertMsg(false, "pythonGetRiverAltitude() must return >= 0"); } } if (pPlot->getImprovementType() != NO_IMPROVEMENT) { return false; } if (pPlot->getBonusType() != NO_BONUS) { return false; } if (pPlot->isImpassable()) { return false; } int iUniqueRange = GC.getImprovementInfo(eImprovement).getGoodyUniqueRange(); for (int iDX = -iUniqueRange; iDX <= iUniqueRange; iDX++) { for (int iDY = -iUniqueRange; iDY <= iUniqueRange; iDY++) { CvPlot *pLoopPlot = plotXY(iX, iY, iDX, iDY); if (pLoopPlot != NULL && pLoopPlot->getImprovementType() == eImprovement) { return false; } } } return true; }
void CvMapGenerator::addRivers() { PROFILE_FUNC(); if (gDLL->getPythonIFace()->pythonAddRivers() && !gDLL->getPythonIFace()->pythonUsingDefaultImpl()) { return; // Python override } gDLL->NiTextOut("Adding Rivers..."); CvPlot* pLoopPlot; CvPlot* pStartPlot; int iPass; int iRiverSourceRange; int iSeaWaterRange; int iI; for (iPass = 0; iPass < 4; iPass++) { if (iPass <= 1) { iRiverSourceRange = GC.getXMLval(XML_RIVER_SOURCE_MIN_RIVER_RANGE); } else { iRiverSourceRange = (GC.getXMLval(XML_RIVER_SOURCE_MIN_RIVER_RANGE) / 2); } if (iPass <= 1) { iSeaWaterRange = GC.getXMLval(XML_RIVER_SOURCE_MIN_SEAWATER_RANGE); } else { iSeaWaterRange = (GC.getXMLval(XML_RIVER_SOURCE_MIN_SEAWATER_RANGE) / 2); } for (iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++) { gDLL->callUpdater(); pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI); FAssertMsg(pLoopPlot != NULL, "LoopPlot is not assigned a valid value"); if (!(pLoopPlot->isWater())) { if (((iPass == 0) && (pLoopPlot->isHills() || pLoopPlot->isPeak())) || ((iPass == 1) && !(pLoopPlot->isCoastalLand()) && (GC.getGameINLINE().getMapRandNum(8, "addRivers") == 0)) || ((iPass == 2) && (pLoopPlot->isHills() || pLoopPlot->isPeak()) && (pLoopPlot->area()->getNumRiverEdges() < ((pLoopPlot->area()->getNumTiles() / GC.getXMLval(XML_PLOTS_PER_RIVER_EDGE)) + 1))) || ((iPass == 3) && (pLoopPlot->area()->getNumRiverEdges() < ((pLoopPlot->area()->getNumTiles() / GC.getXMLval(XML_PLOTS_PER_RIVER_EDGE)) + 1)))) { if (!(GC.getMapINLINE().findWater(pLoopPlot, iRiverSourceRange, true))) { if (!(GC.getMapINLINE().findWater(pLoopPlot, iSeaWaterRange, false))) { pStartPlot = pLoopPlot->getInlandCorner(); if (pStartPlot != NULL) { doRiver(pStartPlot); } } } } } } } }
CvMessageData* CvMessageData::createMessage(GameMessageTypes eType) { switch (eType) { case GAMEMESSAGE_EXTENDED_GAME: return new CvNetExtendedGame(); case GAMEMESSAGE_AUTO_MOVES: return new CvNetAutoMoves(); case GAMEMESSAGE_TURN_COMPLETE: return new CvNetTurnComplete(); case GAMEMESSAGE_PUSH_ORDER: return new CvNetPushOrder(); case GAMEMESSAGE_POP_ORDER: return new CvNetPopOrder(); case GAMEMESSAGE_DO_TASK: return new CvNetDoTask(); case GAMEMESSAGE_UPDATE_CIVICS: return new CvNetUpdateCivics(); case GAMEMESSAGE_RESEARCH: return new CvNetResearch(); case GAMEMESSAGE_ESPIONAGE_CHANGE: return new CvNetEspionageChange(); case GAMEMESSAGE_ADVANCED_START_ACTION: return new CvNetAdvancedStartAction(); case GAMEMESSAGE_MOD_NET_MESSAGE: return new CvNetModNetMessage(); case GAMEMESSAGE_CONVERT: return new CvNetConvert(); case GAMEMESSAGE_EMPIRE_SPLIT: return new CvNetEmpireSplit(); case GAMEMESSAGE_FOUND_RELIGION: return new CvNetFoundReligion(); case GAMEMESSAGE_LAUNCH_SPACESHIP: return new CvNetLaunchSpaceship(); case GAMEMESSAGE_EVENT_TRIGGERED: return new CvNetEventTriggered(); case GAMEMESSAGE_JOIN_GROUP: return new CvNetJoinGroup(); case GAMEMESSAGE_PUSH_MISSION: return new CvNetPushMission(); case GAMEMESSAGE_AUTO_MISSION: return new CvNetAutoMission(); case GAMEMESSAGE_DO_COMMAND: return new CvNetDoCommand(); case GAMEMESSAGE_PERCENT_CHANGE: return new CvNetPercentChange(); case GAMEMESSAGE_CHANGE_VASSAL: return new CvNetChangeVassal(); case GAMEMESSAGE_CHOOSE_ELECTION: return new CvNetChooseElection(); case GAMEMESSAGE_DIPLO_VOTE: return new CvNetDiploVote(); case GAMEMESSAGE_CHANGE_WAR: return new CvNetChangeWar(); case GAMEMESSAGE_PING: return new CvNetPing(); // BUG - Reminder Mod - start case GAMEMESSAGE_ADD_REMINDER: return new CvNetAddReminder(); // BUG - Reminder Mod - end default: FAssertMsg(false, "Unknown message type"); } return NULL; }
bool CvMapGenerator::canPlaceBonusAt(BonusTypes eBonus, int iX, int iY, bool bIgnoreLatitude) { PROFILE_FUNC(); CvArea* pArea; CvPlot* pPlot; CvPlot* pLoopPlot; int iRange; int iDX, iDY; int iI; pPlot = GC.getMapINLINE().plotINLINE(iX, iY); pArea = pPlot->area(); if (!(pPlot->canHaveBonus(eBonus, bIgnoreLatitude))) { return false; } long result = 0; if (gDLL->getPythonIFace()->pythonCanPlaceBonusAt(pPlot, &result) && !gDLL->getPythonIFace()->pythonUsingDefaultImpl()) // Python override { if (result >= 0) { return result; } else { FAssertMsg(false, "canPlaceBonusAt() must return >= 0"); } } for (iI = 0; iI < NUM_DIRECTION_TYPES; iI++) { pLoopPlot = plotDirection(iX, iY, ((DirectionTypes)iI)); if (pLoopPlot != NULL) { if ((pLoopPlot->getBonusType() != NO_BONUS) && (pLoopPlot->getBonusType() != eBonus)) { return false; } } } CvBonusInfo& pInfo = GC.getBonusInfo(eBonus); if (pPlot->isWater()) { if (((GC.getMapINLINE().getNumBonusesOnLand(eBonus) * 100) / (GC.getMapINLINE().getNumBonuses(eBonus) + 1)) < pInfo.getMinLandPercent()) { return false; } } // Make sure there are none of the same bonus nearby: iRange = pInfo.getUniqueRange(); for (iDX = -(iRange); iDX <= iRange; iDX++) { for (iDY = -(iRange); iDY <= iRange; iDY++) { pLoopPlot = plotXY(iX, iY, iDX, iDY); if (pLoopPlot != NULL) { if (pLoopPlot->area() == pArea) { if (plotDistance(iX, iY, pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE()) <= iRange) { if (pLoopPlot->getBonusType() == eBonus) { return false; } } } } } } return true; }
CvDllUnit::CvDllUnit(CvUnit* pUnit) : m_pUnit(pUnit) , m_uiRefCount(1) { FAssertMsg(pUnit != NULL, "SHOULD NOT HAPPEN"); }
void CvMapGenerator::addUniqueBonusType(BonusTypes eBonusType) { int* piAreaTried = new int[GC.getMapINLINE().getNumAreas()]; for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++) { piAreaTried[iI] = FFreeList::INVALID_INDEX; } CvBonusInfo& pBonusInfo = GC.getBonusInfo(eBonusType); int iBonusCount = calculateNumBonusesToAdd(eBonusType); bool bIgnoreLatitude = false; gDLL->getPythonIFace()->pythonIsBonusIgnoreLatitudes(&bIgnoreLatitude); FAssertMsg(pBonusInfo.isOneArea(), "addUniqueBonusType called with non-unique bonus type"); while (true) { int iBestValue = 0; int iLoop = 0; CvArea *pBestArea = NULL; CvArea *pLoopArea = NULL; for(pLoopArea = GC.getMapINLINE().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoop)) { bool bTried = false; for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++) { if (pLoopArea->getID() == piAreaTried[iI]) { bTried = true; break; } } if (!bTried) { int iNumUniqueBonusesOnArea = pLoopArea->countNumUniqueBonusTypes() + 1; // number of unique bonuses starting on the area, plus this one int iNumTiles = pLoopArea->getNumTiles(); int iValue = iNumTiles / iNumUniqueBonusesOnArea; if (iValue > iBestValue) { iBestValue = iValue; pBestArea = pLoopArea; } } } if (pBestArea == NULL) { break; // can't place bonus on any area } for (int iI = 0; iI < GC.getMapINLINE().getNumAreas(); iI++) { if (piAreaTried[iI] == FFreeList::INVALID_INDEX) { piAreaTried[iI] = pBestArea->getID(); break; } } // Place the bonuses: std::vector<int> aiShuffle(GC.getMapINLINE().numPlotsINLINE()); GC.getGameINLINE().getMapRand().shuffleSequence(aiShuffle, "addUniqueBonusType shuffle"); for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++) { CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(aiShuffle[iI]); FAssertMsg(pPlot != NULL, "addUniqueBonusType(): pPlot is null"); if (GC.getMapINLINE().getNumBonuses(eBonusType) >= iBonusCount) { break; // We already have enough } if (pBestArea == pPlot->area()) { if (canPlaceBonusAt(eBonusType, pPlot->getX_INLINE(), pPlot->getY_INLINE(), bIgnoreLatitude)) { pPlot->setBonusType(eBonusType); for (int iDX = -(pBonusInfo.getGroupRange()); iDX <= pBonusInfo.getGroupRange(); iDX++) { for (int iDY = -(pBonusInfo.getGroupRange()); iDY <= pBonusInfo.getGroupRange(); iDY++) { if (GC.getMapINLINE().getNumBonuses(eBonusType) < iBonusCount) { CvPlot* pLoopPlot = plotXY(pPlot->getX_INLINE(), pPlot->getY_INLINE(), iDX, iDY); if (pLoopPlot != NULL && (pLoopPlot->area() == pBestArea)) { if (canPlaceBonusAt(eBonusType, pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), bIgnoreLatitude)) { if (GC.getGameINLINE().getMapRandNum(100, "addUniqueBonusType") < pBonusInfo.getGroupRand()) { pLoopPlot->setBonusType(eBonusType); } } } } } } } } } } SAFE_DELETE_ARRAY(piAreaTried); }
void BaseCheckYieldGroup::build() { FAssertMsg(false, "The base function shouldn't call this virtual function"); }
CvDllTerrainInfo::CvDllTerrainInfo(CvTerrainInfo* pTerrainInfo) : m_pTerrainInfo(pTerrainInfo) , m_uiRefCount(1) { FAssertMsg(pTerrainInfo != NULL, "SHOULD NOT HAPPEN"); }
bool BaseCheckYieldGroup::function(YieldTypes eYield) { FAssertMsg(false, "The base function shouldn't call this virtual function"); return false; }
void CvBattleDefinition::checkBattleTimeType(BattleTimeTypes timeType) const { FAssertMsg((timeType >= 0) && (timeType < BATTLE_TIME_COUNT), "[Jason] Invalid battle time type."); }
void BaseCheckYieldGroup::checkSingleXMLType(YieldTypes eYield, const char* XMLname) { FAssert(eYield >= 0 && eYield < NUM_YIELD_TYPES); XMLnameChecked[eYield] = true; FAssertMsg(!strcmp(GC.getYieldInfo(eYield).getType(), XMLname), CvString::format("XML error. Found %s instead of %s at index %d", GC.getYieldInfo(eYield).getType(), XMLname, eYield).c_str()); }
/// What Flavors will be added by adopting this Grand Strategy? int CvAIGrandStrategyXMLEntry::GetSpecializationBoost(YieldTypes eYield) const { FAssertMsg(eYield < NUM_YIELD_TYPES, "Index out of bounds"); FAssertMsg(eYield > -1, "Index out of bounds"); return m_piSpecializationBoost ? m_piSpecializationBoost[(int)eYield] : 0; }
void CvGlobals::CheckEnumYieldTypes() const { #ifdef FASSERT_ENABLE BaseCheckYieldGroup BaseGroup; for (int iYield = 0; iYield < NUM_YIELD_TYPES; iYield++) { BaseGroup.XMLnameChecked[iYield] = false; } BaseGroup.checkXML(); FAssertMsg(GC.getYieldInfo().size() == NUM_YIELD_TYPES, CvString::format("XML error. Expected %d types, but found %d", NUM_YIELD_TYPES, GC.getYieldInfo().size())); for (int iYield = 0; iYield < NUM_YIELD_TYPES; iYield++) { YieldTypes eYield = (YieldTypes)iYield; FAssertMsg(BaseGroup.XMLnameChecked[iYield], CvString::format("Yield %s not checked for consistency between enum and XML", GC.getYieldInfo(eYield).getType()).c_str()); if (YieldGroup_Virtual(eYield)) { FAssertMsg(!GC.getYieldInfo(eYield).isCargo(), CvString::format("Virtual yield %s has bCargo set in XML", GC.getYieldInfo(eYield).getType()).c_str()); } else { FAssertMsg(GC.getYieldInfo(eYield).isCargo(), CvString::format("Non-virtual yield %s has bCargo unset in XML", GC.getYieldInfo(eYield).getType()).c_str()); } } Check_YieldGroup_AI_Sell AI_Sell; AI_Sell.check(); Check_YieldGroup_AI_Sell_To_Europe AI_Sell_To_Europe; AI_Sell_To_Europe.check(); Check_YieldGroup_AI_Buy_From_Natives AI_Buy_From_Natives; AI_Buy_From_Natives.check(); Check_YieldGroup_AI_Buy_From_Europe AI_Buy_From_Europe; AI_Buy_From_Europe.check(); Check_YieldGroup_AI_Raw_Material AI_Raw_Material; AI_Raw_Material.check(); Check_YieldGroup_AI_Native_Product AI_Native_Product; AI_Native_Product.check(); Check_YieldGroup_City_Billboard City_Billboard; City_Billboard.check(); Check_YieldGroup_City_Billboard_Offset_Fix City_Billboard_Offset_Fix; City_Billboard_Offset_Fix.check(); Check_YieldGroup_Armor Armor; Armor.check(); Check_YieldGroup_Light_Armor Light_Armor; Light_Armor.check(); Check_YieldGroup_Heavy_Armor Heavy_Armor; Heavy_Armor.check(); // check armor groups for (int iYield = 0; iYield < NUM_YIELD_TYPES; iYield++) { YieldTypes eYield = (YieldTypes)iYield; if (YieldGroup_Armor(eYield)) { FAssertMsg(YieldGroup_Light_Armor(eYield) || YieldGroup_Heavy_Armor(eYield), CvString::format("%s is armor, but neither light or heavy armor", GC.getYieldInfo(eYield).getType()).c_str()); FAssertMsg(!(YieldGroup_Light_Armor(eYield) && YieldGroup_Heavy_Armor(eYield)), CvString::format("%s is both light and heavy armor", GC.getYieldInfo(eYield).getType()).c_str()); } else { FAssertMsg(!YieldGroup_Light_Armor(eYield), CvString::format("%s is light armor, but not armor", GC.getYieldInfo(eYield).getType()).c_str()); FAssertMsg(!YieldGroup_Heavy_Armor(eYield), CvString::format("%s is heavy armor, but not armor", GC.getYieldInfo(eYield).getType()).c_str()); } } #endif }
CvDllPlayerOptionInfo::CvDllPlayerOptionInfo(CvPlayerOptionInfo* pPlayerOptionInfo) : m_pPlayerOptionInfo(pPlayerOptionInfo) , m_uiRefCount(1) { FAssertMsg(pPlayerOptionInfo != NULL, "SHOULD NOT HAPPEN"); }
CvDllPromotionInfo::CvDllPromotionInfo(CvPromotionEntry* pPromotionInfo) : m_pPromotionInfo(pPromotionInfo) , m_uiRefCount(1) { FAssertMsg(pPromotionInfo != NULL, "SHOULD NOT HAPPEN"); }