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


C++ CvString类代码示例

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


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

示例1: 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

示例2: DecodePublicParams

bool CvSakke::DecodePublicParams( const String& aPublicParams, OUT octet& aPx, OUT octet& aPy )
{
	CvString publicParams = aPublicParams;
	
	vector<CvString> tokens;
	publicParams.Tokenize( "#", tokens );
	
	if ( tokens.size() != 2 )
		return false;
	
	tokens[0].TrimLeft("[");
	tokens[0].TrimRight("]");
	
	vector<CvString> tokensP;
	tokens[0].Tokenize( ",", tokensP );
	
	if ( tokensP.size() != 2 )
		return false;
	
	String decoded;
	CvBase64::Decode( tokensP[0], decoded );
	OCTET_JOIN_BYTES( decoded.data(), (int)decoded.size(), &aPx );

	decoded.clear();
	CvBase64::Decode( tokensP[1], decoded );
	OCTET_JOIN_BYTES( decoded.data(), (int)decoded.size(), &aPy );
	
	return true;
}
开发者ID:apache,项目名称:incubator-milagro-mfa-sdk-core,代码行数:29,代码来源:CvSakke.cpp

示例3: 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

示例4: OCTET_CLEAR

/*
CDpkgConfig* CvSakke::GetSakkeParams() //temporary
{ return CDpkgConfig::Instance(); 
}
*/
bool CvSakke::DecodePublicKey( const String& aPublicKey, OUT octet& aZ_S )
{
	OCTET_CLEAR(&aZ_S);
	
	if ( aPublicKey[0] != '[' || aPublicKey[aPublicKey.length()-1] != ']' )
		return false;
	
	CvString publicKey = aPublicKey;
	
	publicKey.TrimLeft( "[" );
	publicKey.TrimRight( "]" );	
	
	vector<CvString> tokens;
	publicKey.Tokenize( ",", tokens );
	
	if ( tokens.size() != 2 )
		return false;
	
	OCTET_JOIN_BYTE( 4, 1, &aZ_S );
	
	for ( vector<CvString>::const_iterator itr = tokens.begin();
		 itr != tokens.end();
		 ++itr )
	{
		String decoded;

		CvBase64::Decode( *itr, decoded );
		if ( decoded.size() != FS )
			return false;
		OCTET_JOIN_BYTES( decoded.data(), FS, &aZ_S );
	}
	
	return true;
}
开发者ID:apache,项目名称:incubator-milagro-mfa-sdk-core,代码行数:39,代码来源:CvSakke.cpp

示例5: sprintf

//------------------------------------------------------------------------------------------------------
//
//  FUNCTION:   LoadCivXml(FXml* pFXml, TCHAR* szFilename)
//
//  PURPOSE :   Gets the full pathname for the xml file from the FileManager .
//				If it is succesful we return true
//				from the function and a valid FXml pointer to the pFXml parameter.
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::LoadCivXml(FXml* pFXml, const TCHAR* szFilename)
{
	char szLog[256];
	sprintf(szLog, "LoadCivXml (%s)", szFilename);
	PROFILE(szLog);
	OutputDebugString(szLog);
	OutputDebugString("\n");

	CvString szPath = szFilename;
	CvString fsFilename = szFilename;

	if (!gDLL->fileManagerEnabled())
	{
		szPath = "Assets//" + szPath;
	}

	logMsg("Loading XML file %s\n", szPath.c_str());

	if (!gDLL->getXMLIFace()->LoadXml(pFXml, szPath))
	{
		logMsg("Load XML file %s FAILED\n", szPath.c_str());
		return false;
	}

	logMsg("Load XML file %s SUCCEEDED\n", szPath.c_str());
	GC.setCurrentXMLFile(szFilename);
	return true;	// success
}
开发者ID:Nightinggale,项目名称:Religion_and_Revolution_Extended,代码行数:37,代码来源:CvXMLLoadUtility.cpp

示例6: read

//------------------------------------------------------------------------------------------------------
bool CvTerrainPlaneInfo::read(CvXMLLoadUtility* pXML)
{
    CvString  szTextVal;
    if (!CvInfoBase::read(pXML))
        return false;

    pXML->GetChildXmlValByName( &m_bVisible, "bVisible");
    pXML->GetChildXmlValByName( &m_bGroundPlane, "bGroundPlane");
    pXML->GetChildXmlValByName( &m_fMaterialAlpha, "MaterialAlpha");
    pXML->GetChildXmlValByName( &m_fCloseAlpha, "CloseAlpha");

    pXML->GetChildXmlValByName( szTextVal, "TextureFile");
    setBaseTexture(szTextVal);

    pXML->GetChildXmlValByName( &m_BaseTextureScaleU, "TextureScalingU");
    pXML->GetChildXmlValByName( &m_BaseTextureScaleV, "TextureScalingV");
    pXML->GetChildXmlValByName( &m_fURate, "URate");
    pXML->GetChildXmlValByName( &m_fVRate, "VRate");
    pXML->GetChildXmlValByName( &m_fZHeight, "ZHeight");

    pXML->GetChildXmlValByName( szTextVal, "FogType");
    if(szTextVal.CompareNoCase("FOG_TYPE_NONE") == 0)
        m_eFogType = FOG_TYPE_NONE;
    else if(szTextVal.CompareNoCase("FOG_TYPE_PARALLEL") == 0)
        m_eFogType = FOG_TYPE_PARALLEL;
    else if(szTextVal.CompareNoCase("FOG_TYPE_PROJECTED") == 0)
        m_eFogType = FOG_TYPE_PROJECTED;
    else
    {
        FAssertMsg(false, "[Jason] Unknown fog type.");
        m_eFogType = FOG_TYPE_NONE;
    }

    return true;
}
开发者ID:Redirion,项目名称:Dawn-of-Civilization,代码行数:36,代码来源:CvInfoWater.cpp

示例7: 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

示例8: GetFirstUnit

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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: GetInstance

//------------------------------------------------------------------------------
//string GetGreatPersonRateModifierDetails(UnitClassTypes eGreatPersonClass);
int CvLuaLeague::lGetGreatPersonRateModifierDetails(lua_State* L)
{
	CvLeague* pLeague = GetInstance(L);
	const UnitClassTypes eGreatPersonClass = (UnitClassTypes) lua_tointeger(L, 2);

	CvString sValue = pLeague->GetGreatPersonRateModifierDetails(eGreatPersonClass);
	lua_pushstring(L, sValue.c_str());
	return 1;
}
开发者ID:QuinaryLogician,项目名称:DLL-VMC,代码行数:11,代码来源:CvLuaLeague.cpp

示例15: 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


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