当前位置: 首页>>代码示例>>C++>>正文


C++ CvString::Format方法代码示例

本文整理汇总了C++中CvString::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ CvString::Format方法的具体用法?C++ CvString::Format怎么用?C++ CvString::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CvString的用法示例。


在下文中一共展示了CvString::Format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LogPolicyChoice

/// Log chosen policy
void CvPolicyAI::LogPolicyChoice(PolicyTypes ePolicy)
{
    if(GC.getLogging() && GC.getAILogging())
    {
        CvString strOutBuf;
        CvString strBaseString;
        CvString strTemp;
        CvString playerName;
        CvString strDesc;

        // Find the name of this civ and city
        playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();

        FILogFile* pLog;
        pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);

        // Get the leading info for this line
        strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
        strBaseString += playerName + ", ";

        CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy);
        const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown";
        strTemp.Format("CHOSEN, %s", szPolicyType);

        strOutBuf = strBaseString + strTemp;
        pLog->Msg(strOutBuf);
    }
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:29,代码来源:CvPolicyAI.cpp

示例2: LogBranchChoice

/// Log chosen policy
void CvPolicyAI::LogBranchChoice(PolicyBranchTypes eBranch)
{
    if(GC.getLogging() && GC.getAILogging())
    {
        CvString strOutBuf;
        CvString strBaseString;
        CvString strTemp;
        CvString playerName;
        CvString strDesc;

        // Find the name of this civ and city
        playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();

        FILogFile* pLog;
        pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);

        // Get the leading info for this line
        strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
        strBaseString += playerName + ", ";

        strTemp.Format("CHOSEN, Branch %d", eBranch);

        strOutBuf = strBaseString + strTemp;
        pLog->Msg(strOutBuf);
    }
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:27,代码来源:CvPolicyAI.cpp

示例3: LogIdeologyChoice

/// Logging function to write out info on Ideology choices
void CvPolicyAI::LogIdeologyChoice(CvString &decisionState, int iWeightFreedom, int iWeightAutocracy, int iWeightOrder)
{
    if(GC.getLogging() && GC.getAILogging())
    {
        CvString strOutBuf;
        CvString strBaseString;
        CvString strTemp;
        CvString playerName;

        // Find the name of this civ
        playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();

        FILogFile* pLog;
        pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);

        // Get the leading info for this line
        strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
        strBaseString += playerName + ", ";

        strTemp.Format("%s, Freedom: %d, Order: %d, Autocracy: %d", decisionState.c_str(), iWeightFreedom, iWeightOrder, iWeightAutocracy);

        strOutBuf = strBaseString + strTemp;
        pLog->Msg(strOutBuf);
    }
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:26,代码来源:CvPolicyAI.cpp

示例4: LogPossibleResearch

/// Log all possible tech choices
void CvTechAI::LogPossibleResearch()
{
	if(GC.getLogging() && GC.getAILogging())
	{
		CvString strOutBuf;
		CvString strBaseString;
		CvString strTemp;
		CvString playerName;
		CvString strDesc;

		// Find the name of this civ
		playerName = m_pCurrentTechs->GetPlayer()->getCivilizationShortDescription();

		FILogFile* pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);

		// Get the leading info for this line
		strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
		strBaseString += playerName + ", ";

		// Dump out the weight of each Researchable Tech
		for(int iI = 0; iI < m_ResearchableTechs.size(); iI++)
		{
			TechTypes eTech = (TechTypes) m_ResearchableTechs.GetElement(iI);
			int iWeight = m_ResearchableTechs.GetWeight(iI);

			CvTechEntry* pTechEntry = GC.getTechInfo(eTech);
			const char* szTechType = (pTechEntry != NULL)? pTechEntry->GetType() : "Unknown Tech";

			strTemp.Format("%s, %d", szTechType, iWeight);

			strOutBuf = strBaseString + strTemp;
			pLog->Msg(strOutBuf);
		}
	}
}
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:36,代码来源:CvTechAI.cpp

示例5: LogGrandStrategies

/// Log GrandStrategy state: what are the Priorities and who is Active?
void CvGrandStrategyAI::LogGrandStrategies(const FStaticVector< int, 5, true, c_eCiv5GameplayDLL >& vModifiedGrandStrategyPriorities)
{
	if(GC.getLogging() && GC.getAILogging())
	{
		CvString strOutBuf;
		CvString strBaseString;
		CvString strTemp;
		CvString playerName;
		CvString strDesc;
		CvString strLogName;

		// Find the name of this civ and city
		playerName = GetPlayer()->getCivilizationShortDescription();

		// Open the log file
		if(GC.getPlayerAndCityAILogSplit())
		{
			strLogName = "GrandStrategyAI_Log_" + playerName + ".csv";
		}
		else
		{
			strLogName = "GrandStrategyAI_Log.csv";
		}

		FILogFile* pLog;
		pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);

		AIGrandStrategyTypes eGrandStrategy;

		// Loop through Grand Strategies
		for(int iGrandStrategyLoop = 0; iGrandStrategyLoop < GC.getNumAIGrandStrategyInfos(); iGrandStrategyLoop++)
		{
			// Get the leading info for this line
			strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
			strBaseString += playerName + ", ";

			eGrandStrategy = (AIGrandStrategyTypes) iGrandStrategyLoop;

			// GrandStrategy Info
			CvAIGrandStrategyXMLEntry* pEntry = GC.getAIGrandStrategyInfo(eGrandStrategy);
			const char* szAIGrandStrategyType = (pEntry != NULL)? pEntry->GetType() : "Unknown Type";

			if(GetActiveGrandStrategy() == eGrandStrategy)
			{
				strTemp.Format("*** %s, %d, %d", szAIGrandStrategyType, GetGrandStrategyPriority(eGrandStrategy), vModifiedGrandStrategyPriorities[eGrandStrategy]);
			}
			else
			{
				strTemp.Format("%s, %d, %d", szAIGrandStrategyType, GetGrandStrategyPriority(eGrandStrategy), vModifiedGrandStrategyPriorities[eGrandStrategy]);
			}
			strOutBuf = strBaseString + strTemp;
			pLog->Msg(strOutBuf);
		}
	}
}
开发者ID:Jheral,项目名称:Civ5Comps,代码行数:56,代码来源:CvGrandStrategyAI.cpp

示例6: LogFlavors

void CvFlavorManager::LogFlavors(FlavorTypes eFlavor)
{
    CvString strOutBuf;
    CvString strBaseString;
    CvString strTemp;
    CvString playerName;
    CvString strDesc;
    CvString strLogName;

    if(GC.getLogging() && GC.getAILogging())
    {
        // Find the name of this civ
        playerName = m_pPlayer->getCivilizationShortDescription();

        // Open the log file
        if(GC.getPlayerAndCityAILogSplit())
        {
            strLogName = "FlavorAILog_" + playerName + ".csv";
        }
        else
        {
            strLogName = "FlavorAILog.csv";
        }

        FILogFile* pLog;
        pLog = LOGFILEMGR.GetLog(strLogName, FILogFile::kDontTimeStamp);

        // Get the leading info for this line
        strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
        strBaseString += playerName + ", ";

        // Dump out the setting for each flavor
        if(eFlavor == NO_FLAVOR)
        {
            for(int iI = 0; iI < GC.getNumFlavorTypes(); iI++)
            {
                // Only dump if non-zero
                //		if (m_piLatestFlavorValues[iI] > 0)
                {
                    strTemp.Format("Flavor, %s, %d", GC.getFlavorTypes((FlavorTypes)iI).GetCString(), GetIndividualFlavor((FlavorTypes) iI));
                    strOutBuf = strBaseString + strTemp;
                    pLog->Msg(strOutBuf);
                }
            }
        }
        else
        {
            strTemp.Format("Flavor, %s, %d", GC.getFlavorTypes(eFlavor).GetCString(), GetIndividualFlavor(eFlavor));
            strOutBuf = strBaseString + strTemp;
            pLog->Msg(strOutBuf);
        }
    }
}
开发者ID:GravitasShortfall,项目名称:Community-Patch-DLL,代码行数:53,代码来源:CvFlavorManager.cpp

示例7: DetectNearbyEnemy

CvPlot* CvArmyAI::DetectNearbyEnemy(PlayerTypes eEnemy, bool bNaval)
{
	UnitHandle pUnit = GetFirstUnit();
	while(pUnit)
	{
		for(int iDirectionLoop = 0; iDirectionLoop < NUM_DIRECTION_TYPES; ++iDirectionLoop)
		{
			CvPlot* pAdjacentPlot = plotDirection(pUnit->getX(), pUnit->getY(), ((DirectionTypes)iDirectionLoop));
			if(pAdjacentPlot != NULL && pAdjacentPlot->isWater()==bNaval && pAdjacentPlot->getOwner() == eEnemy)
			{
				UnitHandle pOtherUnit = pAdjacentPlot->getBestDefender(eEnemy);
				if(pOtherUnit)
				{
					if(GC.getLogging() && GC.getAILogging())
					{
						CvString strMsg;
						strMsg.Format("Ran into enemy unit during attack (x=%d y=%d). Need to declare war to continue!", pAdjacentPlot->getX(), pAdjacentPlot->getY());
						GET_PLAYER(m_eOwner).getAIOperation(m_iOperationID)->LogOperationSpecialMessage(strMsg);
					}

					return pAdjacentPlot;
				}
			}
		}
		pUnit = GetNextUnit();
	}

	return NULL;
}
开发者ID:steemroller,项目名称:Community-Patch-DLL,代码行数:29,代码来源:CvArmyAI.cpp

示例8: ReadDBLookup

/// Helper function to read a single type (as a string) and find its ID in a database table.
/// Assumes the type is in the table's field "Type"
int ReadDBLookup(FDataStream& kStream, const char* szTable, bool* bValid /*= NULL*/)
{
	FStringFixedBuffer(sTemp, 256);
	kStream >> sTemp;
	if (bValid) *bValid = true;
	if(sTemp.GetLength() > 0 && sTemp != "NO_TYPE")
	{
		Database::Connection* pDB = GC.GetGameDatabase();
		if(pDB)
		{
			Database::Results kResults;
			CvString szCommand;
			szCommand.Format("SELECT ID from %s where Type = ? LIMIT 1", szTable);
			if(pDB->Execute(kResults, szCommand.c_str()))
			{
				kResults.Bind(1, sTemp.c_str());
				if(kResults.Step())
				{
					return kResults.GetInt(0);
				}
				else
					if (bValid) *bValid = false;
			}
		}
		else
			if (bValid) *bValid = false;
	}
	
	return -1;
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:32,代码来源:CvInfosSerializationHelper.cpp

示例9: AppendToLog

void TreasuryHelpers::AppendToLog(CvString& strHeader, CvString& strLog, CvString strHeaderValue, float fValue)
{
	strHeader += strHeaderValue;
	strHeader += ",";
	CvString str;
	str.Format("%.2f,", fValue);
	strLog += str;
}
开发者ID:J-d-H,项目名称:Community-Patch-DLL,代码行数:8,代码来源:CvTreasury.cpp

示例10: Read

/// Serialization read
void CvUnitProductionAI::Read(FDataStream& kStream)
{
	// Version number to maintain backwards compatibility
	uint uiVersion;
	kStream >> uiVersion;

	int iWeight;

	// Reset vector
	m_UnitAIWeights.clear();

	// Loop through reading each one and adding it to our vector
	if(m_pUnits)
	{
#ifdef AUI_WARNING_FIXES
		for (uint i = 0; i < m_pUnits->GetNumUnits(); i++)
#else
		for(int i = 0; i < m_pUnits->GetNumUnits(); i++)
#endif
		{
			m_UnitAIWeights.push_back(i, 0);
		}

#ifdef AUI_WARNING_FIXES
		uint iNumEntries;
		int iType;

		kStream >> iNumEntries;

		for (uint iI = 0; iI < iNumEntries; iI++)
#else
		int iNumEntries;
		int iType;

		kStream >> iNumEntries;

		for(int iI = 0; iI < iNumEntries; iI++)
#endif
		{
			bool bValid = true;
			iType = CvInfosSerializationHelper::ReadHashed(kStream, &bValid);
			if(iType != -1 || !bValid)
			{
				kStream >> iWeight;
				if(iType != -1)
				{
					m_UnitAIWeights.IncreaseWeight(iType, iWeight);
				}
				else
				{
					CvString szError;
					szError.Format("LOAD ERROR: Unit Type not found");
					GC.LogMessage(szError.GetCString());
					CvAssertMsg(false, szError);
				}
			}
		}
	}
开发者ID:gskleres,项目名称:nqmod-vs2008,代码行数:59,代码来源:CvUnitProductionAI.cpp

示例11: LogZones

/// Log dominance zone data
void CvTacticalAnalysisMap::LogZones()
{
	if(GC.getLogging() && GC.getAILogging())
	{
		CvString szLogMsg;
		CvTacticalDominanceZone* pZone;

		for(unsigned int iI = 0; iI < m_DominanceZones.size(); iI++)
		{
			pZone = &m_DominanceZones[iI];

			szLogMsg.Format("Zone ID: %d, Area ID: %d, Value: %d, FRIENDLY Str: %d (%d), Ranged: %d (%d), ENEMY Str: %d (%d), Ranged: %d (%d), Closest Enemy: %d",
			                pZone->GetDominanceZoneID(), pZone->GetAreaID(), pZone->GetDominanceZoneValue(),
			                pZone->GetFriendlyStrength(), pZone->GetFriendlyUnitCount(), pZone->GetFriendlyRangedStrength(), pZone->GetFriendlyRangedUnitCount(),
			                pZone->GetEnemyStrength(), pZone->GetEnemyUnitCount(), pZone->GetEnemyRangedStrength(), pZone->GetEnemyRangedUnitCount(), pZone->GetRangeClosestEnemyUnit());
			if(pZone->GetDominanceFlag() == TACTICAL_DOMINANCE_FRIENDLY)
			{
				szLogMsg += ", Friendly";
			}
			else if(pZone->GetDominanceFlag() == TACTICAL_DOMINANCE_ENEMY)
			{
				szLogMsg += ", Enemy";
			}
			else if(pZone->GetDominanceFlag() == TACTICAL_DOMINANCE_EVEN)
			{
				szLogMsg += ", Even";
			}
			else if(pZone->GetDominanceFlag() == TACTICAL_DOMINANCE_NO_UNITS_VISIBLE)
			{
				szLogMsg += ", No Units Visible";
			}

			if(pZone->IsWater())
			{
				szLogMsg += ", Water";
			}
			else
			{
				szLogMsg += ", Land";
			}

			if(pZone->GetTerritoryType() == TACTICAL_TERRITORY_TEMP_ZONE)
			{
				szLogMsg += ", Temporary Zone";
			}
			else if(pZone->GetClosestCity())
			{
				szLogMsg += ", " + pZone->GetClosestCity()->getName();
				if (m_pPlayer->GetTacticalAI()->IsTemporaryZoneCity(pZone->GetClosestCity()))
				{
					szLogMsg += " (Temp)";
				}
			}

			m_pPlayer->GetTacticalAI()->LogTacticalMessage(szLogMsg, true /*bSkipLogDominanceZone*/);
		}
	}
}
开发者ID:gskleres,项目名称:nqmod-vs2008,代码行数:59,代码来源:CvTacticalAnalysisMap.cpp

示例12: LogPossiblePolicies

/// Log all possible policy choices
void CvPolicyAI::LogPossiblePolicies()
{
    if(GC.getLogging() && GC.getAILogging())
    {
        CvString strOutBuf;
        CvString strBaseString;
        CvString strTemp;
        CvString playerName;
        CvString strDesc;

        // Find the name of this civ and city
        playerName = m_pCurrentPolicies->GetPlayer()->getCivilizationShortDescription();

        FILogFile* pLog;
        pLog = LOGFILEMGR.GetLog(GetLogFileName(playerName), FILogFile::kDontTimeStamp);

        // Get the leading info for this line
        strBaseString.Format("%03d, ", GC.getGame().getElapsedGameTurns());
        strBaseString += playerName + ", ";

        int iNumBranches = GC.getNumPolicyBranchInfos();

        // Dump out the weight of each possible policy
        for(int iI = 0; iI < m_AdoptablePolicies.size(); iI++)
        {
            int iWeight = m_AdoptablePolicies.GetWeight(iI);

            if(m_AdoptablePolicies.GetElement(iI) < iNumBranches)
            {
                strTemp.Format("Branch %d, %d", m_AdoptablePolicies.GetElement(iI), iWeight);
            }
            else
            {

                PolicyTypes ePolicy = (PolicyTypes)(m_AdoptablePolicies.GetElement(iI) - iNumBranches);
                CvPolicyEntry* pPolicyEntry = GC.getPolicyInfo(ePolicy);
                const char* szPolicyType = (pPolicyEntry != NULL)? pPolicyEntry->GetType() : "Unknown";
                strTemp.Format("%s, %d", szPolicyType, iWeight);
            }
            strOutBuf = strBaseString + strTemp;
            pLog->Msg(strOutBuf);
        }
    }
}
开发者ID:Yonyonnisan,项目名称:Civ5-UAM-Mod,代码行数:45,代码来源:CvPolicyAI.cpp

示例13: LogPossibleBuilds

/// 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);
		}
	}
}
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:42,代码来源:CvProjectProductionAI.cpp

示例14: Read

/// Serialization read
void CvUnitProductionAI::Read(FDataStream& kStream)
{
	// Version number to maintain backwards compatibility
	uint uiVersion;
	kStream >> uiVersion;
	// modVersion - v1, Snarko
	// We are using our own value here to keep backwards compatibility.
	// While we could use the Firaxis value that would cause issues when they update it, so we use our own for maximum backward compatibility. 
	// Old firaxis patch and old mod version? No problem! Except if you weren't using our mod before...
	uint modVersion;
	kStream >> modVersion;
	// END modVersion

	int iWeight;

	// Reset vector
	m_UnitAIWeights.clear();

	// Loop through reading each one and adding it to our vector
	if(m_pUnits)
	{
		for(int i = 0; i < m_pUnits->GetNumUnits(); i++)
		{
			m_UnitAIWeights.push_back(i, 0);
		}

		int iNumEntries;
		int iType;

		kStream >> iNumEntries;

		for(int iI = 0; iI < iNumEntries; iI++)
		{
			bool bValid = true;
			iType = CvInfosSerializationHelper::ReadHashed(kStream, &bValid);
			if(iType != -1 || !bValid)
			{
				kStream >> iWeight;
				if(iType != -1)
				{
					m_UnitAIWeights.IncreaseWeight(iType, iWeight);
				}
				else
				{
					CvString szError;
					szError.Format("LOAD ERROR: Unit Type not found");
					GC.LogMessage(szError.GetCString());
					CvAssertMsg(false, szError);
				}
			}
		}
	}
开发者ID:Jheral,项目名称:Civ5Comps,代码行数:53,代码来源:CvUnitProductionAI.cpp

示例15: Read

/// Serialization read
void CvUnitProductionAI::Read(FDataStream& kStream)
{
	// Version number to maintain backwards compatibility
	uint uiVersion;
	kStream >> uiVersion;

	int iWeight;

	// Reset vector
	m_UnitAIWeights.clear();

	// Loop through reading each one and adding it to our vector
	if(m_pUnits)
	{
		if(uiVersion >= 2)
		{
			for(int i = 0; i < m_pUnits->GetNumUnits(); i++)
			{
				m_UnitAIWeights.push_back(i, 0);
			}

			int iNumEntries;
			FStringFixedBuffer(sTemp, 64);
			int iType;

			kStream >> iNumEntries;

			for(int iI = 0; iI < iNumEntries; iI++)
			{
				kStream >> sTemp;
				if(sTemp != "NO_UNIT")
				{
					iType = GC.getInfoTypeForString(sTemp);
					kStream >> iWeight;
					if(iType != -1)
					{
						m_UnitAIWeights.IncreaseWeight(iType, iWeight);
					}
					else
					{
						CvString szError;
						szError.Format("LOAD ERROR: Unit Type not found: %s", sTemp);
						GC.LogMessage(szError.GetCString());
						CvAssertMsg(false, szError);
					}
				}
			}
		}
		else
		{
			for(int i = 0; i < 90 /* Units in gold master */; i++)
开发者ID:Be1eriand,项目名称:Battle-Royale,代码行数:52,代码来源:CvUnitProductionAI.cpp


注:本文中的CvString::Format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。