本文整理汇总了C++中CvAssert函数的典型用法代码示例。如果您正苦于以下问题:C++ CvAssert函数的具体用法?C++ CvAssert怎么用?C++ CvAssert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CvAssert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CvAssert
/// Value of this site for a settler
int CvSiteEvaluatorForSettler::PlotFoundValue(CvPlot* pPlot, CvPlayer* pPlayer, YieldTypes eYield, bool bCoastOnly)
{
CvAssert(pPlot);
if(!pPlot) return 0;
if(!CanFound(pPlot, pPlayer, true))
{
return 0;
}
// Is there any reason this site doesn't work for a settler?
//
// First must be on coast if settling a new continent
bool bIsCoastal = pPlot->isCoastalLand(GC.getMIN_WATER_SIZE_FOR_OCEAN());
CvArea* pArea = pPlot->area();
CvAssert(pArea);
if(!pArea) return 0;
int iNumAreaCities = pArea->getCitiesPerPlayer(pPlayer->GetID());
if(bCoastOnly && !bIsCoastal && iNumAreaCities == 0)
{
return 0;
}
// Seems okay for a settler, use base class to determine exact value
else
{
return CvCitySiteEvaluator::PlotFoundValue(pPlot, pPlayer, eYield);
}
}
示例2: log10
/// Make some adjustments to flavors based on the map we're on
void CvFlavorManager::AdjustWeightsForMap()
{
int iTotalLandTiles;
int iNumPlayers;
double iTilesPerPlayer;
double fAdjust;
int iAdjust;
iTotalLandTiles = GC.getMap().getLandPlots();
iNumPlayers = GC.getGame().countMajorCivsAlive();
if(iNumPlayers > 0)
{
int iNumFlavorTypes = GC.getNumFlavorTypes();
// Find tiles per player
iTilesPerPlayer = (double)iTotalLandTiles / (double)iNumPlayers;
// Compute +/- addition
//
// We want this to be logarithmic, since that is the curve between lots of players on a duel map
// and a few player on a huge map. "FLAVOR_STANDARD_LOG10_TILES_PER_PLAYER" is the typical log10 of
// tiles per player. We go up and down from this point (multiplying by a coefficient) from here
fAdjust = log10(iTilesPerPlayer) - GC.getFLAVOR_STANDARD_LOG10_TILES_PER_PLAYER();
fAdjust *= (double)GC.getFLAVOR_EXPANDGROW_COEFFICIENT();
iAdjust = (int)fAdjust;
int iFlavorMaxValue = /*20*/ GC.getPERSONALITY_FLAVOR_MAX_VALUE();
int iFlavorMinValue = /*0*/ GC.getPERSONALITY_FLAVOR_MIN_VALUE();
int iExpansionIndex = GC.getInfoTypeForString("FLAVOR_EXPANSION");
int iGrowthIndex = GC.getInfoTypeForString("FLAVOR_GROWTH");
// Boost expansion
CvAssert(iExpansionIndex >= 0 && iExpansionIndex < iNumFlavorTypes);
if (iExpansionIndex >= 0 && iExpansionIndex < iNumFlavorTypes)
{
m_piPersonalityFlavor[iExpansionIndex] += iAdjust;
if(m_piPersonalityFlavor[iExpansionIndex] > iFlavorMaxValue)
{
m_piPersonalityFlavor[iExpansionIndex] = iFlavorMaxValue;
}
}
// Reduce growth
CvAssert(iGrowthIndex >= 0 && iGrowthIndex < iNumFlavorTypes);
if (iGrowthIndex >= 0 && iGrowthIndex < iNumFlavorTypes)
{
m_piPersonalityFlavor[iGrowthIndex] -= iAdjust;
if(m_piPersonalityFlavor[iGrowthIndex] < iFlavorMinValue)
{
m_piPersonalityFlavor[iGrowthIndex] = iFlavorMinValue;
}
}
// Save these off as our core personality and broadcast updates
ResetToBasePersonality();
}
}
示例3: atWar
bool atWar(TeamTypes eTeamA, TeamTypes eTeamB)
{
if((eTeamA == NO_TEAM) || (eTeamB == NO_TEAM))
{
return false;
}
CvAssert(GET_TEAM(eTeamA).isAtWar(eTeamB) == GET_TEAM(eTeamB).isAtWar(eTeamA));
CvAssert((eTeamA != eTeamB) || !(GET_TEAM(eTeamA).isAtWar(eTeamB)));
return GET_TEAM(eTeamA).isAtWar(eTeamB);
}
示例4: CvAssert
void CvLoggerCSV::DeleteCSV(const char* strLogName)
{
CvAssert(strLogName != NULL);
FILogFile *pLog;
pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);
CvAssert(pLog != NULL);
LOGFILEMGR.DeleteLog(pLog);
}
示例5: isBeforeUnitCycle
bool isBeforeUnitCycle(const CvUnit* pFirstUnit, const CvUnit* pSecondUnit)
{
CvAssert(pFirstUnit != NULL);
CvAssert(pSecondUnit != NULL);
CvAssert(pFirstUnit != pSecondUnit);
if(!pFirstUnit || !pSecondUnit)
return false;
if(pFirstUnit->getOwner() != pSecondUnit->getOwner())
{
return (pFirstUnit->getOwner() < pSecondUnit->getOwner());
}
if(pFirstUnit->getDomainType() != pSecondUnit->getDomainType())
{
return (pFirstUnit->getDomainType() < pSecondUnit->getDomainType());
}
if(pFirstUnit->GetBaseCombatStrength() != pSecondUnit->GetBaseCombatStrength())
{
return (pFirstUnit->GetBaseCombatStrength() > pSecondUnit->GetBaseCombatStrength());
}
if(pFirstUnit->getUnitType() != pSecondUnit->getUnitType())
{
return (pFirstUnit->getUnitType() > pSecondUnit->getUnitType());
}
if(pFirstUnit->getLevel() != pSecondUnit->getLevel())
{
return (pFirstUnit->getLevel() > pSecondUnit->getLevel());
}
#if defined(MOD_UNITS_XP_TIMES_100)
if (pFirstUnit->getExperienceTimes100() != pSecondUnit->getExperienceTimes100())
{
return (pFirstUnit->getExperienceTimes100() > pSecondUnit->getExperienceTimes100());
}
#else
if (pFirstUnit->getExperience() != pSecondUnit->getExperience())
{
return (pFirstUnit->getExperience() > pSecondUnit->getExperience());
}
#endif
return (pFirstUnit->GetID() < pSecondUnit->GetID());
}
示例6: CvAssert
/// Delete the army
void CvArmyAI::Kill()
{
CvAssert(GetOwner() != NO_PLAYER);
CvAssertMsg(GetID() != -1, "GetID() is not expected to be equal with -1");
int iUnitID;
iUnitID = GetFirstUnitID();
while(iUnitID != ARMYSLOT_NO_UNIT)
{
UnitHandle pThisUnit = GET_PLAYER(GetOwner()).getUnit(iUnitID);
if(pThisUnit)
{
pThisUnit->setArmyID(-1);
#if defined(MOD_BALANCE_CORE)
pThisUnit->AI_setUnitAIType(pThisUnit->getUnitInfo().GetDefaultUnitAIType());
#endif
}
iUnitID = GetNextUnitID();
}
m_FormationEntries.clear();
CvAIOperation* pOperation = GET_PLAYER(GetOwner()).getAIOperation(m_iOperationID);
if (pOperation)
pOperation->DeleteArmyAI(m_iID);
GET_PLAYER(GetOwner()).deleteArmyAI(m_iID);
}
示例7: CvAssert
/// Value of plot for providing tradeable resources
int CvCitySiteEvaluator::ComputeTradeableResourceValue(CvPlot* pPlot, const CvPlayer* pPlayer)
{
int rtnValue = 0;
CvAssert(pPlot);
if(!pPlot) return rtnValue;
// If we already own this Tile then we already have access to the Strategic Resource
if(pPlot->isOwned())
{
return rtnValue;
}
TeamTypes eTeam = NO_TEAM;
if(pPlayer != NULL)
{
eTeam = pPlayer->getTeam();
}
ResourceTypes eResource;
eResource = pPlot->getResourceType(eTeam);
if(eResource != NO_RESOURCE)
{
ResourceUsageTypes eResourceUsage = GC.getResourceInfo(eResource)->getResourceUsage();
// Multiply number of tradeable resources by flavor value
if(eResourceUsage == RESOURCEUSAGE_LUXURY || eResourceUsage == RESOURCEUSAGE_STRATEGIC)
{
rtnValue += pPlot->getNumResource() * m_iFlavorMultiplier[SITE_EVALUATION_RESOURCES];
if(pPlayer)
{
// If we don't have this resource yet, increase it's value
if(pPlayer->getNumResourceTotal(eResource) == 0)
rtnValue *= 3;
#if defined(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES)
if(MOD_BALANCE_CORE_RESOURCE_MONOPOLIES && (GC.getMap().getNumResources(eResource) > 0))
{
//Will this get us closer to a monopoly?
if((((pPlot->getNumResource() + pPlayer->getNumResourceTotal(eResource, false) + pPlayer->getResourceExport(eResource)) * 100) / GC.getMap().getNumResources(eResource)) >= 30)
{
rtnValue *= 2;
}
else if((((pPlot->getNumResource() + pPlayer->getNumResourceTotal(eResource, false)) * 100) / GC.getMap().getNumResources(eResource)) >= 50)
{
rtnValue *= 10;
}
}
#endif
}
}
}
return rtnValue;
}
示例8: isBeforeUnitCycle
bool isBeforeUnitCycle(const CvUnit* pFirstUnit, const CvUnit* pSecondUnit)
{
CvAssert(pFirstUnit != NULL);
CvAssert(pSecondUnit != NULL);
CvAssert(pFirstUnit != pSecondUnit);
if(!pFirstUnit || !pSecondUnit)
return false;
if(pFirstUnit->getOwner() != pSecondUnit->getOwner())
{
return (pFirstUnit->getOwner() < pSecondUnit->getOwner());
}
if(pFirstUnit->getDomainType() != pSecondUnit->getDomainType())
{
return (pFirstUnit->getDomainType() < pSecondUnit->getDomainType());
}
if(pFirstUnit->GetBaseCombatStrength() != pSecondUnit->GetBaseCombatStrength())
{
return (pFirstUnit->GetBaseCombatStrength() > pSecondUnit->GetBaseCombatStrength());
}
if(pFirstUnit->getUnitType() != pSecondUnit->getUnitType())
{
return (pFirstUnit->getUnitType() > pSecondUnit->getUnitType());
}
if(pFirstUnit->getLevel() != pSecondUnit->getLevel())
{
return (pFirstUnit->getLevel() > pSecondUnit->getLevel());
}
if(pFirstUnit->getExperience() != pSecondUnit->getExperience())
{
return (pFirstUnit->getExperience() > pSecondUnit->getExperience());
}
return (pFirstUnit->GetID() < pSecondUnit->GetID());
}
示例9: CvAssert
/// Log all potential builds
void CvProjectProductionAI::LogPossibleBuilds()
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strOutBuf;
CvString strBaseString;
CvString strTemp;
CvString playerName;
CvString cityName;
CvString strDesc;
CvString strLogName;
CvAssert(m_pCity);
if(!m_pCity) return;
// Find the name of this civ and city
playerName = GET_PLAYER(m_pCity->getOwner()).getCivilizationShortDescription();
cityName = m_pCity->getName();
// Open the log file
FILogFile* pLog;
pLog = LOGFILEMGR.GetLog(m_pCity->GetCityStrategyAI()->GetLogFileName(playerName, cityName), FILogFile::kDontTimeStamp);
CvAssert(pLog);
if(!pLog) return;
// Get the leading info for this line
strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
strBaseString += playerName + ", " + cityName + ", ";
// Dump out the weight of each buildable item
for(int iI = 0; iI < m_Buildables.size(); iI++)
{
CvProjectEntry* pProjectEntry = GC.GetGameProjects()->GetEntry(m_Buildables.GetElement(iI));
strDesc = (pProjectEntry != NULL)? pProjectEntry->GetDescription() : "Unknown";
strTemp.Format("Project, %s, %d", strDesc.GetCString(), m_Buildables.GetWeight(iI));
strOutBuf = strBaseString + strTemp;
pLog->Msg(strOutBuf);
}
}
}
示例10: CvAssert
/// Value of this site for a settler
int CvSiteEvaluatorForSettler::PlotFoundValue(CvPlot* pPlot, CvPlayer* pPlayer, YieldTypes eYield, bool bCoastOnly)
{
CvAssert(pPlot);
if(!pPlot) return 0;
if(!CanFound(pPlot, pPlayer, true))
{
return 0;
}
// Is there any reason this site doesn't work for a settler?
//
// First must be on coast if settling a new continent
bool bIsCoastal = pPlot->isCoastalLand(GC.getMIN_WATER_SIZE_FOR_OCEAN());
CvArea* pArea = pPlot->area();
CvAssert(pArea);
if(!pArea) return 0;
int iNumAreaCities = pArea->getCitiesPerPlayer(pPlayer->GetID());
if(bCoastOnly && !bIsCoastal && iNumAreaCities == 0)
{
return 0;
}
// Seems okay for a settler, use base class to determine exact value
else
{
// if the civ gets a benefit from settling on a new continent (ie: Indonesia)
// double the fertility of that plot
int iLuxuryModifier = 0;
if (pPlayer->GetPlayerTraits()->WillGetUniqueLuxury(pArea))
{
iLuxuryModifier = CvCitySiteEvaluator::PlotFoundValue(pPlot, pPlayer, eYield) * 2;
return iLuxuryModifier;
}
else
{
return CvCitySiteEvaluator::PlotFoundValue(pPlot, pPlayer, eYield);
}
}
}
示例11: CvAssert
void CvPlayerAI::ProcessGreatPeople(void)
{
SpecialUnitTypes eSpecialUnitGreatPerson = (SpecialUnitTypes) GC.getInfoTypeForString("SPECIALUNIT_PEOPLE");
CvAssert(isAlive());
if(!isAlive())
return;
int iLoop;
for(CvUnit* pLoopUnit = firstUnit(&iLoop); pLoopUnit; pLoopUnit = nextUnit(&iLoop))
{
if(pLoopUnit->getSpecialUnitType() != eSpecialUnitGreatPerson)
{
continue;
}
GreatPeopleDirectiveTypes eDirective = NO_GREAT_PEOPLE_DIRECTIVE_TYPE;
switch(pLoopUnit->AI_getUnitAIType())
{
case UNITAI_WRITER:
eDirective = GetDirectiveWriter(pLoopUnit);
break;
case UNITAI_ARTIST:
eDirective = GetDirectiveArtist(pLoopUnit);
break;
case UNITAI_MUSICIAN:
eDirective = GetDirectiveMusician(pLoopUnit);
break;
case UNITAI_ENGINEER:
eDirective = GetDirectiveEngineer(pLoopUnit);
break;
case UNITAI_MERCHANT:
eDirective = GetDirectiveMerchant(pLoopUnit);
break;
case UNITAI_SCIENTIST:
eDirective = GetDirectiveScientist(pLoopUnit);
break;
case UNITAI_GENERAL:
eDirective = GetDirectiveGeneral(pLoopUnit);
break;
case UNITAI_PROPHET:
eDirective = GetDirectiveProphet(pLoopUnit);
break;
case UNITAI_ADMIRAL:
eDirective = GetDirectiveAdmiral(pLoopUnit);
break;
}
pLoopUnit->SetGreatPeopleDirective(eDirective);
}
}
示例12: CvAssert
/// Delete the army
void CvArmyAI::Kill()
{
CvAssert(GetOwner() != NO_PLAYER);
CvAssertMsg(GetID() != -1, "GetID() is not expected to be equal with -1");
ReleaseUnits();
CvAIOperation* pOperation = GET_PLAYER(GetOwner()).getAIOperation(m_iOperationID);
if (pOperation)
pOperation->DeleteArmyAI(m_iID);
GET_PLAYER(GetOwner()).deleteArmyAI(m_iID);
}
示例13: float
/// Compute unit supply for the turn (returns component info)
int CvTreasury::CalculateUnitSupply(int& iPaidUnits, int& iBaseSupplyCost)
{
int iSupply;
iPaidUnits = std::max(0, (m_pPlayer->getNumOutsideUnits() - /*3*/ GC.getINITIAL_FREE_OUTSIDE_UNITS()));
// JON: This is set to 0 right now, which pretty much means it's disabled
iBaseSupplyCost = iPaidUnits* /*0*/ GC.getINITIAL_OUTSIDE_UNIT_GOLD_PERCENT();
iBaseSupplyCost /= 100;
iSupply = iBaseSupplyCost;
CvHandicapInfo& playerHandicap = m_pPlayer->getHandicapInfo();
iSupply *= playerHandicap.getUnitCostPercent();
iSupply /= 100;
if(!m_pPlayer->isHuman() && !m_pPlayer->IsAITeammateOfHuman() && !m_pPlayer->isBarbarian())
{
//iSupply *= gameHandicap->getAIUnitSupplyPercent(); // This is no longer valid
//iSupply /= 100;
iSupply *= std::max(0, ((GC.getGame().getHandicapInfo().getAIPerEraModifier() * m_pPlayer->GetCurrentEra()) + 100));
iSupply /= 100;
}
// Game progress factor ranges from 0.0 to 1.0 based on how far into the game we are
double fGameProgressFactor = float(GC.getGame().getElapsedGameTurns()) / GC.getGame().getEstimateEndTurn();
// Multiplicative increase - helps scale costs as game goes on - the HIGHER this number the more is paid
double fMultiplyFactor = 1.0 + (fGameProgressFactor* /*8*/ GC.getUNIT_MAINTENANCE_GAME_MULTIPLIER());
// Exponential increase - this one really punishes those with a HUGE military - the LOWER this number the more is paid
double fExponentialFactor = 1.0 + (fGameProgressFactor / /*7*/ GC.getUNIT_MAINTENANCE_GAME_EXPONENT_DIVISOR());
double fTempCost = fMultiplyFactor * iSupply;
int iFinalCost = (int) pow(fTempCost, fExponentialFactor);
// A mod at the player level? (Policies, etc.)
if(m_pPlayer->GetUnitSupplyMod() != 0)
{
iFinalCost *= (100 + m_pPlayer->GetUnitSupplyMod());
iFinalCost /= 100;
}
CvAssert(iFinalCost >= 0);
return iFinalCost;
}
示例14: CvAssert
/// Compute inflation for this part of the game
int CvTreasury::CalculateInflationRate()
{
CvGame& kGame = GC.getGame();
CvHandicapInfo& playerHandicap = m_pPlayer->getHandicapInfo();
CvHandicapInfo& gameHandicap = kGame.getHandicapInfo();
CvGameSpeedInfo& gameSpeedInfo = kGame.getGameSpeedInfo();
int iTurns = ((kGame.getGameTurn() + kGame.getElapsedGameTurns()) / 2);
iTurns += gameSpeedInfo.getInflationOffset();
if(iTurns <= 0)
{
return 0;
}
int iInflationPerTurnTimes10000 = gameSpeedInfo.getInflationPercent();
iInflationPerTurnTimes10000 *= playerHandicap.getInflationPercent();
iInflationPerTurnTimes10000 /= 100;
int iModifier = 0;
if(!m_pPlayer->isHuman() && !m_pPlayer->isBarbarian())
{
int iAIModifier = gameHandicap.getAIInflationPercent();
iAIModifier *= std::max(0, ((gameHandicap.getAIPerEraModifier() * m_pPlayer->GetCurrentEra()) + 100));
iAIModifier /= 100;
iModifier += iAIModifier - 100;
}
iInflationPerTurnTimes10000 *= std::max(0, 100 + iModifier);
iInflationPerTurnTimes10000 /= 100;
// Keep up to second order terms in binomial series
int iRatePercent = (iTurns * iInflationPerTurnTimes10000) / 100;
iRatePercent += (iTurns * (iTurns - 1) * iInflationPerTurnTimes10000 * iInflationPerTurnTimes10000) / 2000000;
CvAssert(iRatePercent >= 0);
return iRatePercent;
}
示例15: CvAssert
/// Delete the army
void CvArmyAI::Kill()
{
CvAssert(GetOwner() != NO_PLAYER);
CvAssertMsg(GetID() != FFreeList::INVALID_INDEX, "GetID() is not expected to be equal with FFreeList::INVALID_INDEX");
int iUnitID;
iUnitID = GetFirstUnitID();
while(iUnitID != ARMY_NO_UNIT)
{
UnitHandle pThisUnit = GET_PLAYER(GetOwner()).getUnit(iUnitID);
if(pThisUnit)
{
pThisUnit->setArmyID(FFreeList::INVALID_INDEX);
}
iUnitID = GetNextUnitID();
}
m_FormationEntries.clear();
}