本文整理汇总了C++中SString函数的典型用法代码示例。如果您正苦于以下问题:C++ SString函数的具体用法?C++ SString怎么用?C++ SString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: argStream
int CLuaFunctionDefs::TriggerServerEvent ( lua_State* luaVM )
{
// bool triggerServerEvent ( string event, element theElement, [arguments...] )
SString strName; CClientEntity* pCallWithEntity; CLuaArguments Arguments;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strName );
argStream.ReadUserData ( pCallWithEntity );
argStream.ReadLuaArguments ( Arguments );
if ( !argStream.HasErrors () )
{
// Trigger it
if ( CStaticFunctionDefinitions::TriggerServerEvent ( strName, *pCallWithEntity, Arguments ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", "triggerServerEvent", *argStream.GetErrorMessage () ) );
// Failed
lua_pushboolean ( luaVM, false );
return 1;
}
示例2: argStream
int CLuaPointLightDefs::SetLightColor ( lua_State* luaVM )
{
// bool setLightColor ( light theLight, float r, float g, float b )
CClientPointLights* pLight;
float fRed;
float fGreen;
float fBlue;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pLight );
argStream.ReadNumber ( fRed );
argStream.ReadNumber ( fGreen );
argStream.ReadNumber ( fBlue );
if ( !argStream.HasErrors () )
{
SColorRGBA color ( fRed, fGreen, fBlue, 0 );
if ( CStaticFunctionDefinitions::SetLightColor ( pLight, color ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, SString ( "Bad argument @ '%s' [%s]", lua_tostring ( luaVM, lua_upvalueindex ( 1 ) ), *argStream.GetErrorMessage () ) );
lua_pushboolean ( luaVM, false );
return 1;
}
示例3: missing
///////////////////////////////////////////////////////////////
//
// CResourceChecker::CheckMetaSourceForIssues
//
//
//
///////////////////////////////////////////////////////////////
void CResourceChecker::CheckMetaSourceForIssues ( CXMLNode* pRootNode, const string& strFileName, const string& strResourceName, ECheckerModeType checkerMode, bool* pbOutHasChanged )
{
// Check min_mta_version is correct
if ( m_strReqClientVersion > m_strMinClientReqFromMetaXml || m_strReqServerVersion > m_strMinServerReqFromMetaXml )
{
// It's not right. What to do?
if ( checkerMode == ECheckerMode::WARNINGS )
{
SString strTemp = "<min_mta_version> section in the meta.xml is incorrect or missing (expected at least ";
if ( m_strReqClientVersion > m_strMinClientReqFromMetaXml )
strTemp += SString ( "client %s because of '%s')", *m_strReqClientVersion, *m_strReqClientReason );
else
if ( m_strReqServerVersion > m_strMinServerReqFromMetaXml )
strTemp += SString ( "server %s because of '%s')", *m_strReqServerVersion, *m_strReqServerReason );
CLogger::LogPrint ( SString ( "WARNING: %s %s\n", strResourceName.c_str (), *strTemp ) );
}
else
if ( checkerMode == ECheckerMode::UPGRADE )
{
// Create min_mta_version node if required
CXMLNode* pNodeMinMtaVersion = pRootNode->FindSubNode("min_mta_version", 0);
if ( !pNodeMinMtaVersion )
pNodeMinMtaVersion = pRootNode->CreateSubNode ( "min_mta_version" );
CXMLAttributes& attributes = pNodeMinMtaVersion->GetAttributes ();
attributes.Delete ( "server" );
attributes.Delete ( "client" );
attributes.Delete ( "both" );
if ( !m_strReqServerVersion.empty () )
{
CXMLAttribute* pAttr = attributes.Create ( "server" );
pAttr->SetValue ( m_strReqServerVersion );
}
if ( !m_strReqClientVersion.empty () )
{
CXMLAttribute* pAttr = attributes.Create ( "client" );
pAttr->SetValue ( m_strReqClientVersion );
}
if ( pbOutHasChanged )
*pbOutHasChanged = true;
}
}
}
示例4: SString
std::string ASE::QueryLight ( void )
{
std::stringstream reply;
int iJoinedPlayers = m_pPlayerManager->CountJoined ();
int iMaxPlayers = m_pMainConfig->GetMaxPlayers ();
SString strPlayerCount = SString ( "%d/%d", iJoinedPlayers, iMaxPlayers );
reply << "EYE2";
// game
reply << ( unsigned char ) 4;
reply << "mta";
// port
reply << ( unsigned char ) ( m_strPort.length() + 1 );
reply << m_strPort;
// server name
reply << ( unsigned char ) ( m_pMainConfig->GetServerName ().length() + 1 );
reply << m_pMainConfig->GetServerName ();
// game type
reply << ( unsigned char ) ( m_strGameType.length() + 1 );
reply << m_strGameType;
// map name with backwardly compatible large player count
reply << ( unsigned char ) ( m_strMapName.length() + 1 + strPlayerCount.length () + 1 );
reply << m_strMapName;
reply << ( unsigned char ) 0;
reply << strPlayerCount;
// version
std::string temp = MTA_DM_ASE_VERSION;
reply << ( unsigned char ) ( temp.length() + 1 );
reply << temp;
// passworded
reply << ( unsigned char ) ( ( m_pMainConfig->HasPassword () ) ? 1 : 0 );
// serial verification?
reply << ( unsigned char ) ( ( m_pMainConfig->GetSerialVerificationEnabled() ) ? 1 : 0 );
// players count
reply << ( unsigned char ) Min ( iJoinedPlayers, 255 );
// players max
reply << ( unsigned char ) Min ( iMaxPlayers, 255 );
// players
CPlayer* pPlayer = NULL;
list < CPlayer* > ::const_iterator pIter = m_pPlayerManager->IterBegin ();
for ( ; pIter != m_pPlayerManager->IterEnd (); pIter++ )
{
pPlayer = *pIter;
if ( pPlayer->IsJoined () )
{
// nick
std::string strPlayerName = RemoveColorCode ( pPlayer->GetNick () );
if ( strPlayerName.length () == 0 )
strPlayerName = pPlayer->GetNick ();
reply << ( unsigned char ) ( strPlayerName.length () + 1 );
reply << strPlayerName.c_str ();
}
}
return reply.str();
}
示例5: strMessage
///////////////////////////////////////////////////////////////
//
// CResourceChecker::CheckLuaDeobfuscateRequirements
//
// Updates version requirements and returns true if obfuscated
//
///////////////////////////////////////////////////////////////
bool CResourceChecker::CheckLuaDeobfuscateRequirements ( const string& strFileContents, const string& strFileName, const string& strResourceName, bool bClientScript )
{
// Get embedded version requirements
SScriptInfo scriptInfo;
if ( !g_pRealNetServer->GetScriptInfo( strFileContents.c_str(), strFileContents.length(), &scriptInfo ) )
{
if ( bClientScript && IsLuaCompiledScript( strFileContents.c_str(), strFileContents.length() ) )
{
// Compiled client script with no version info
#if MTA_DM_VERSION < 0x135
SString strMessage( "%s is invalid and will not work in future versions. Please re-compile at http://luac.mtasa.com/", strFileName.c_str() );
CLogger::LogPrint ( SString ( "WARNING: %s %s\n", strResourceName.c_str (), *strMessage ) );
#else
SString strMessage( "%s is invalid. Please re-compile at http://luac.mtasa.com/", strFileName.c_str() );
CLogger::LogPrint ( SString ( "ERROR: %s %s\n", strResourceName.c_str (), *strMessage ) );
#endif
}
return false;
}
SString strMinServerHostVer = scriptInfo.szMinServerHostVer;
SString strMinServerRunVer = scriptInfo.szMinServerRunVer;
SString strMinClientRunVer = scriptInfo.szMinClientRunVer;
// Check server host requirements
if ( strMinServerHostVer > m_strReqServerVersion )
{
m_strReqServerVersion = strMinServerHostVer;
m_strReqServerReason = strFileName;
}
// Check run requirements
if ( bClientScript && strMinClientRunVer > m_strReqClientVersion )
{
m_strReqClientVersion = strMinClientRunVer;
m_strReqClientReason = strFileName;
}
else
if ( !bClientScript && strMinServerRunVer > m_strReqServerVersion )
{
m_strReqServerVersion = strMinServerRunVer;
m_strReqServerReason = strFileName;
}
return IsLuaObfuscatedScript( strFileContents.c_str(), strFileContents.length() );
}
示例6: AddReportLog
///////////////////////////////////////////////////////////////
//
// CCrashDumpWriter::UpdateCounters
//
// Static function. Called every so often, you know
//
///////////////////////////////////////////////////////////////
void CCrashDumpWriter::UpdateCounters( void )
{
if ( ms_uiInvalidParameterCount > ms_uiInvalidParameterCountLogged && ms_uiInvalidParameterCountLogged < 10 )
{
AddReportLog( 9206, SString( "InvalidParameterCount changed from %d to %d", ms_uiInvalidParameterCountLogged, ms_uiInvalidParameterCount ) );
ms_uiInvalidParameterCountLogged = ms_uiInvalidParameterCount;
}
}
示例7: where
SString SPackage::Data::LoadString(const SString& key, const SString& locale)
{
SString result;
char* buf = NULL;
if (locale == SString::EmptyString())
{
// FIX ME! need to get the system locale
//berr << "FIX ME! SPackage::LoadString() defaulting to enUS" << endl;
SString where("enUS");
buf = get_buffer_for(where);
}
else
{
buf = get_buffer_for(locale);
}
if (buf != NULL)
{
const uint32_t COUNT = *((uint32_t*)buf);
char* it = buf + sizeof(uint32_t);
uint32_t* indices = (uint32_t*)it;
char* keys = it + (sizeof(uint32_t) * COUNT * 2);
bool found = false;
int32_t low = 0;
int32_t high = COUNT - 1;
int32_t mid;
while (low <= high)
{
mid = (low + high) / 2;
char* tmp = buf + indices[mid];
int cmp = strcmp(tmp, key.String());
if (cmp > 0)
{
high = mid - 1;
}
else if (cmp < 0)
{
low = mid + 1;
}
else
{
found = true;
break;
}
}
if (found)
{
result = SString(buf + indices[mid + COUNT]);
}
}
return result;
}
示例8: time
bool CWebCore::UpdateListsFromMaster ()
{
if ( !m_pXmlConfig )
return false;
CXMLNode* pRootNode = m_pXmlConfig->GetRootNode ();
if ( !pRootNode || !MakeSureXMLNodesExist () )
return false;
// Fetch white- and blacklist revision from config
CXMLNode* pWhiteRevNode = pRootNode->FindSubNode ( "whitelistrev" );
if ( !pWhiteRevNode || !pWhiteRevNode->GetTagContent ( m_iWhitelistRevision ) )
{
m_iWhitelistRevision = 0;
}
CXMLNode* pBlackRevNode = pRootNode->FindSubNode ( "blacklistrev" );
if ( !pBlackRevNode || !pBlackRevNode->GetTagContent ( m_iBlacklistRevision ) )
{
m_iBlacklistRevision = 0;
}
// Get last update timestamp and compare with current time
CXMLNode* pLastUpdateNode = pRootNode->FindSubNode ( "lastupdate" );
if ( pLastUpdateNode )
{
SString lastUpdateTime = pLastUpdateNode->GetTagContent ();
time_t currentTime;
time ( ¤tTime );
if ( lastUpdateTime < SString ( "%d", (long long)currentTime - BROWSER_LIST_UPDATE_INTERVAL ) )
{
#ifdef MTA_DEBUG
OutputDebugLine ( "Updating white- and blacklist..." );
#endif
g_pCore->GetNetwork ()->GetHTTPDownloadManager ( EDownloadModeType::WEBBROWSER_LISTS )->QueueFile ( SString("%s?type=getrev", BROWSER_UPDATE_URL),
NULL, 0, NULL, 0, false, this, &CWebCore::StaticFetchRevisionProgress, false, 3 );
pLastUpdateNode->SetTagContent ( SString ( "%d", (long long)currentTime ) );
m_pXmlConfig->Write ();
}
}
return true;
}
示例9: ComposeErrorMessage
void CScriptDebugging::LogString ( const char* szPrePend, const SLuaDebugInfo& luaDebugInfo, const char* szMessage, unsigned int uiMinimumDebugLevel, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue )
{
SString strText = ComposeErrorMessage( szPrePend, luaDebugInfo, szMessage );
// Create a different message if type is "INFO"
if ( uiMinimumDebugLevel > 2 )
strText = SString ( "%s%s", szPrePend, szMessage );
if ( !m_bTriggeringOnClientDebugMessage )
{
m_bTriggeringOnClientDebugMessage = true;
// Prepare onClientDebugMessage
CLuaArguments Arguments;
Arguments.PushString ( szMessage );
Arguments.PushNumber ( uiMinimumDebugLevel );
// Push the file name (if any)
if ( !luaDebugInfo.strFile.empty() )
Arguments.PushString ( luaDebugInfo.strFile );
else
Arguments.PushNil ( );
// Push the line (if any)
if ( luaDebugInfo.iLine != INVALID_LINE_NUMBER )
Arguments.PushNumber ( luaDebugInfo.iLine );
else
Arguments.PushNil ( );
// Call onClientDebugMessage
g_pClientGame->GetRootEntity ( )->CallEvent ( "onClientDebugMessage", Arguments, false );
m_bTriggeringOnClientDebugMessage = false;
}
// Log it to the file if enough level
if ( m_uiLogFileLevel >= uiMinimumDebugLevel )
{
PrintLog ( strText );
}
switch ( uiMinimumDebugLevel )
{
case 1:
ucRed = 255, ucGreen = 0, ucBlue = 0;
break;
case 2:
ucRed = 255, ucGreen = 128, ucBlue = 0;
break;
case 3:
ucRed = 0, ucGreen = 255, ucBlue = 0;
break;
}
#ifdef MTA_DEBUG
if ( !g_pCore->IsDebugVisible () ) return;
#endif
g_pCore->DebugEchoColor ( strText, ucRed, ucGreen, ucBlue );
}
示例10: CheckOnRestartCommand
//////////////////////////////////////////////////////////
//
// CheckOnRestartCommand
//
// Changes current directory if required
//
//////////////////////////////////////////////////////////
SString CheckOnRestartCommand ( void )
{
const SString strMTASAPath = GetMTASAPath ();
SetCurrentDirectory ( strMTASAPath );
SetDllDirectory( strMTASAPath );
SString strOperation, strFile, strParameters, strDirectory, strShowCmd;
if ( GetOnRestartCommand ( strOperation, strFile, strParameters, strDirectory, strShowCmd ) )
{
if ( strOperation == "files" || strOperation == "silent" )
{
//
// Update
//
// Make temp path name and go there
SString strArchivePath, strArchiveName;
strFile.Split ( "\\", &strArchivePath, &strArchiveName, -1 );
SString strTempPath = MakeUniquePath ( strArchivePath + "\\_" + strArchiveName + "_tmp_" );
if ( !MkDir ( strTempPath ) )
return "FileError1";
if ( !SetCurrentDirectory ( strTempPath ) )
return "FileError2";
// Start progress bar
if ( !strParameters.Contains( "hideprogress" ) )
StartPseudoProgress( g_hInstance, "MTA: San Andreas", _("Extracting files...") );
// Try to extract the files
if ( !ExtractFiles ( strFile ) )
{
// If extract failed and update file is an exe, try to run it
if ( ExtractExtension ( strFile ).CompareI ( "exe" ) )
ShellExecuteBlocking ( "open", strFile, "-s" );
}
// Stop progress bar
StopPseudoProgress();
// If a new "Multi Theft Auto.exe" exists, let that complete the install
if ( FileExists ( MTA_EXE_NAME_RELEASE ) )
return "install from far " + strOperation + " " + strParameters;
// Otherwise use the current exe to install
return "install from near " + strOperation + " " + strParameters;
}
else
{
AddReportLog ( 5052, SString ( "CheckOnRestartCommand: Unknown restart command %s", strOperation.c_str () ) );
}
}
return "no update";
}
示例11: OutputDebugLine
void CPlayer::MovePlayerToNearList ( CPlayer* pOther )
{
OutputDebugLine ( SString ( "[Sync] ++ %s: Move %s to nearlist", GetNick (), pOther->GetNick () ) );
dassert ( !MapContains ( m_NearPlayerList, pOther ) && MapContains ( m_FarPlayerList, pOther ) );
SViewerInfo* pInfo = MapFind ( m_FarPlayerList, pOther );
MapSet ( m_NearPlayerList, pOther, *pInfo );
MapRemove ( m_FarPlayerList, pOther );
}
示例12: CreateDeviceSecondCallCheck
////////////////////////////////////////////////
//
// CreateDeviceSecondCallCheck
//
// Check for, and handle subsequent calls to create device
// Know to occur with RTSSHooks.dll (EVGA Precision X on screen display)
//
////////////////////////////////////////////////
bool CreateDeviceSecondCallCheck( HRESULT& hOutResult, IDirect3D9* pDirect3D, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DDevice9** ppReturnedDeviceInterface )
{
static uint uiCreateCount = 0;
if ( ++uiCreateCount == 1 )
return false;
WriteDebugEvent ( SString ( " Passing through call #%d to CreateDevice", uiCreateCount ) );
hOutResult = pDirect3D->CreateDevice ( Adapter, DeviceType, hFocusWindow, BehaviorFlags, pPresentationParameters, ppReturnedDeviceInterface );
return true;
}
示例13: WriteDebugEvent
// Proxy constructor and destructor.
CProxyDirect3DDevice9::CProxyDirect3DDevice9(IDirect3DDevice9* pDevice)
{
WriteDebugEvent(SString("CProxyDirect3DDevice9::CProxyDirect3DDevice9 %08x", this));
// Set our wrapped device.
m_pDevice = pDevice;
// Get CDirect3DData pointer.
m_pData = CDirect3DData::GetSingletonPtr();
g_pProxyDevice = this;
g_pDeviceState = &DeviceState;
pDevice->GetDeviceCaps(&g_pDeviceState->DeviceCaps);
//
// Get video card installed memory
//
D3DDEVICE_CREATION_PARAMETERS creationParameters;
m_pDevice->GetCreationParameters(&creationParameters);
int iAdapter = creationParameters.AdapterOrdinal;
IDirect3D9* pD3D9 = CProxyDirect3D9::StaticGetDirect3D();
if (!pD3D9)
m_pDevice->GetDirect3D(&pD3D9);
D3DADAPTER_IDENTIFIER9 adaptIdent;
ZeroMemory(&adaptIdent, sizeof(D3DADAPTER_IDENTIFIER9));
pD3D9->GetAdapterIdentifier(iAdapter, 0, &adaptIdent);
int iVideoCardMemoryKBTotal = GetWMIVideoAdapterMemorySize(adaptIdent.DeviceName) / 1024;
// Just incase, fallback to using texture memory stats
if (iVideoCardMemoryKBTotal < 16)
iVideoCardMemoryKBTotal = m_pDevice->GetAvailableTextureMem() / 1024;
g_pDeviceState->AdapterState.InstalledMemoryKB = iVideoCardMemoryKBTotal;
//
// Get video card name
//
g_pDeviceState->AdapterState.Name = adaptIdent.Description;
//
// Get max anisotropic setting
//
g_pDeviceState->AdapterState.MaxAnisotropicSetting = 0;
// Make sure device can do anisotropic minification and trilinear filtering
if ((g_pDeviceState->DeviceCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) &&
(g_pDeviceState->DeviceCaps.TextureFilterCaps & D3DPTFILTERCAPS_MIPFLINEAR))
{
int iLevel = std::max<int>(1, g_pDeviceState->DeviceCaps.MaxAnisotropy);
// Convert level 1/2/4/8/16 into setting 0/1/2/3/4
while (iLevel >>= 1)
g_pDeviceState->AdapterState.MaxAnisotropicSetting++;
}
示例14: MapFindRef
///////////////////////////////////////////////////////////////
//
// CGameEntityXRefManagerImpl::OnGameEntityDestruct
//
// Called when GTA is destroying a game entity
//
///////////////////////////////////////////////////////////////
void CGameEntityXRefManagerImpl::OnGameEntityDestruct ( CEntitySAInterface* pEntitySAInterface )
{
if ( MapContains ( m_InterfaceToClientMap, pEntitySAInterface ) )
{
BYTE* pInterface = (BYTE*)pEntitySAInterface;
DWORD InterfaceVtbl = *(DWORD*)pInterface;
ushort InterfaceModelId = *(ushort*)(pInterface + 34);
CClientEntity* pClientEntity = MapFindRef ( m_InterfaceToClientMap, pEntitySAInterface );
bool bClientEntityValid = MapContains ( m_ValidClientEntityMap, pClientEntity );
SString strClientEntityInfo;
if ( bClientEntityValid )
{
CEntity* pGameEntity = NULL;
if ( CClientPed* pPed = DynamicCast < CClientPed > ( pClientEntity ) )
pGameEntity = pPed->GetGameEntity ();
if ( CClientVehicle* pVehicle = DynamicCast < CClientVehicle > ( pClientEntity ) )
pGameEntity = pVehicle->GetGameEntity ();
if ( CClientObject* pObject = DynamicCast < CClientObject > ( pClientEntity ) )
pGameEntity = pObject->GetGameEntity ();
if ( CClientProjectile* pProjectile = DynamicCast < CClientProjectile > ( pClientEntity ) )
pGameEntity = pProjectile->GetGameEntity ();
if ( CClientPickup* pPickup = DynamicCast < CClientPickup > ( pClientEntity ) )
pGameEntity = pPickup->GetGameObject ();
CEntity* pMappedGameEntity = MapFindRef ( m_ClientToGameMap, pClientEntity );
CClientEntity* pMappedClientEntity = MapFindRef ( m_GameToClientMap, pGameEntity );
strClientEntityInfo = SString ( "%s Id:%x GameEntity:%08x MappedGameEntity:%08x MappedClientEntity:%08x"
, pClientEntity->GetClassName ()
, pClientEntity->GetID ()
, (int)pGameEntity
, (int)pMappedGameEntity
, (int)pMappedClientEntity
);
}
SString strMessage ( "EntitySAInterface:%08x Vtbl:%08x ModelId:%d ClientEntity:%08x [%s]"
, (int)pEntitySAInterface
, InterfaceVtbl
, InterfaceModelId
, (int)pClientEntity
, *strClientEntityInfo
);
g_pCore->LogEvent ( 8542, "XRefManager", "GameEntity Mismatch", strMessage );
AddReportLog ( 8542, strMessage );
dassert ( 0 );
}
}
示例15: DebugCreateCount
void DebugCreateCount ( const SString& strName )
{
SDebugCountInfo& info = MapGet ( ms_DebugCountMap, strName );
info.iCount++;
if ( info.iCount > info.iHigh )
{
info.iHigh = info.iCount;
OutputDebugLine ( SString ( "[InstanceCount] New high of %d for %s", info.iCount, *strName ) );
}
}