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


C++ idStr::c_str方法代码示例

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


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

示例1: AnimIsApplicable

bool IdleAnimationTask::AnimIsApplicable(idAI* owner, const idStr& animName)
{
	int torsoAnimNum = owner->GetAnim(ANIMCHANNEL_TORSO, animName);

	if (torsoAnimNum == 0)
	{
		gameLocal.Warning("Could not find anim %s on entity %s", animName.c_str(), owner->name.c_str());
		DM_LOG(LC_AI, LT_ERROR)LOGSTRING("Could not find anim %s on entity %s\r", animName.c_str(), owner->name.c_str());

		return false;
	}

	// Check if this anim interferes with random head turning
	if ( owner->GetMemory().currentlyHeadTurning && AnimHasNoHeadTurnFlag(owner, torsoAnimNum) )
	{
//		gameLocal.Printf("Inhibited idle animation %s, since random head turning is active.\n", animName.c_str());

		// Cannot play this one at this point
		return false;
	}

	// grayman #3182 - Check if this anim plays a voice bark, which would interfere with ongoing voice barks
	if ( owner->GetMemory().currentlyBarking && AnimHasVoiceFlag(owner, animName) )
	{
//		gameLocal.Printf("Inhibited idle animation %s, since barking is active.\n", animName.c_str());

		// Cannot play this one at this point
		return false;
	}

	// OK
	return true; 
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:33,代码来源:IdleAnimationTask.cpp

示例2: OpenFile

CZipFilePtr CZipLoader::OpenFile(const idStr& fullOSPath)
{
	DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Attempting to open file as ZIP: %s.\r", fullOSPath.c_str());
	unzFile handle = unzOpen(fullOSPath.c_str());

	return (handle != NULL) ? CZipFilePtr(new CZipFile(handle)) : CZipFilePtr();
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:7,代码来源:ZipLoader.cpp

示例3:

/*
================
Sys_DefaultBasePath

Get the default base path
- binary image path
- current directory
- hardcoded
Try to be intelligent: if there is no BASE_GAMEDIR, try the next path
================
*/
const char *Sys_DefaultBasePath( void ) {
	struct stat st;
	idStr testbase;
	basepath = Sys_EXEPath();
	if( basepath.Length() ) {
		basepath.StripFilename();
		testbase = basepath;
		testbase += "/";
		testbase += BASE_GAMEDIR;
		if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) ) {
			return basepath.c_str();
		} else {
			common->Printf( "no '%s' directory in exe path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
		}
	}
	if( basepath != Posix_Cwd() ) {
		basepath = Posix_Cwd();
		testbase = basepath;
		testbase += "/";
		testbase += BASE_GAMEDIR;
		if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) ) {
			return basepath.c_str();
		} else {
			common->Printf( "no '%s' directory in cwd path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
		}
	}
	common->Printf( "WARNING: using hardcoded default base path\n" );
	return LINUX_DEFAULT_PATH;
}
开发者ID:revelator,项目名称:Revelation,代码行数:40,代码来源:main.cpp

示例4: Set

/*
============
idInternalCVar::Set
============
*/
void idInternalCVar::Set( const char *newValue, bool force, bool fromServer )
{
    if ( session && session->IsMultiplayer() && !fromServer )
    {
#ifndef ID_TYPEINFO
        if ( ( flags & CVAR_NETWORKSYNC ) && idAsyncNetwork::client.IsActive() )
        {
            common->Printf( "%s is a synced over the network and cannot be changed on a multiplayer client.\n", nameString.c_str() );
#if ID_ALLOW_CHEATS
            common->Printf( "ID_ALLOW_CHEATS override!\n" );
#else
            return;
#endif
        }
#endif
        if ( ( flags & CVAR_CHEAT ) && !cvarSystem->GetCVarBool( "net_allowCheats" ) )
        {
            common->Printf( "%s cannot be changed in multiplayer.\n", nameString.c_str() );
#if ID_ALLOW_CHEATS
            common->Printf( "ID_ALLOW_CHEATS override!\n" );
#else
            return;
#endif
        }
    }

    if ( !newValue )
    {
        newValue = resetString.c_str();
    }

    if ( !force )
    {
        if ( flags & CVAR_ROM )
        {
            common->Printf( "%s is read only.\n", nameString.c_str() );
            return;
        }

        if ( flags & CVAR_INIT )
        {
            common->Printf( "%s is write protected.\n", nameString.c_str() );
            return;
        }
    }

    if ( valueString.Icmp( newValue ) == 0 )
    {
        return;
    }

    valueString = newValue;
    value = valueString.c_str();
    UpdateValue();

    SetModified();
    cvarSystem->SetModifiedFlags( flags );
}
开发者ID:revelator,项目名称:Revelator-Doom3,代码行数:63,代码来源:CVarSystem.cpp

示例5: PushState

void Mind::PushState( const idStr &stateName ) {
	// Get a new state with the given name
	StatePtr newState = StateLibrary::Instance().CreateInstance( stateName.c_str() );
	if( newState != NULL ) {
		PushState( newState );
	} else {
		gameLocal.Error( "Mind: Could not push state %s", stateName.c_str() );
	}
}
开发者ID:SL987654,项目名称:The-Darkmod-Experimental,代码行数:9,代码来源:Mind.cpp

示例6: Update

/*
============
idInternalCVar::Update
============
*/
void idInternalCVar::Update( const idCVar *cvar )
{

    // if this is a statically declared variable
    if ( cvar->GetFlags() & CVAR_STATIC )
    {

        if ( flags & CVAR_STATIC )
        {

            // the code has more than one static declaration of the same variable, make sure they have the same properties
            if ( resetString.Icmp( cvar->GetString() ) != 0 )
            {
                common->Warning( "CVar '%s' declared multiple times with different initial value", nameString.c_str() );
            }
            if ( ( flags & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) != ( cvar->GetFlags() & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) )
            {
                common->Warning( "CVar '%s' declared multiple times with different type", nameString.c_str() );
            }
            if ( valueMin != cvar->GetMinValue() || valueMax != cvar->GetMaxValue() )
            {
                common->Warning( "CVar '%s' declared multiple times with different minimum/maximum", nameString.c_str() );
            }

        }

        // the code is now specifying a variable that the user already set a value for, take the new value as the reset value
        resetString = cvar->GetString();
        descriptionString = cvar->GetDescription();
        description = descriptionString.c_str();
        valueMin = cvar->GetMinValue();
        valueMax = cvar->GetMaxValue();
        Mem_Free( valueStrings );
        valueStrings = CopyValueStrings( cvar->GetValueStrings() );
        valueCompletion = cvar->GetValueCompletion();
        UpdateValue();
        cvarSystem->SetModifiedFlags( cvar->GetFlags() );
    }

    flags |= cvar->GetFlags();

    UpdateCheat();

    // only allow one non-empty reset string without a warning
    if ( resetString.Length() == 0 )
    {
        resetString = cvar->GetString();
    }
    else if ( cvar->GetString()[0] && resetString.Cmp( cvar->GetString() ) != 0 )
    {
        common->Warning( "cvar \"%s\" given initial values: \"%s\" and \"%s\"\n", nameString.c_str(), resetString.c_str(), cvar->GetString() );
    }
}
开发者ID:revelator,项目名称:Revelator-Doom3,代码行数:58,代码来源:CVarSystem.cpp

示例7: TriggerHitTarget

/*
========================
idMenuScreen_HUD::TriggerHitTarget
========================
*/
void idMenuScreen_HUD::TriggerHitTarget( bool show, const idStr & target, int color ) {

	if ( !mpHitInfo ) {
		return;
	}

	if ( show ) {

		mpHitInfo->SetVisible( true );
		mpHitInfo->PlayFrame( "rollOn" );

		if ( menuGUI ) {
			menuGUI->SetGlobal( "hitTargetName", target.c_str() );
		}

		idSWFSpriteInstance * backing = mpHitInfo->GetScriptObject()->GetNestedSprite( "bgColor" );
		if ( backing ) {
			if ( color <= 0 || !gameLocal.mpGame.IsGametypeTeamBased() ) {
				color = 1;
			}
			backing->StopFrame( color );
		}

	} else {
		mpHitInfo->PlayFrame( "rollOff" );
	}

}
开发者ID:M-Code,项目名称:DOOM-3-BFG,代码行数:33,代码来源:MenuScreen_HUD.cpp

示例8: LoadTextFile

idStr CZipFile::LoadTextFile(const idStr& fileName)
{
	int result = unzLocateFile(_handle, fileName.c_str(), 0);

	if (result != UNZ_OK) return "";

	unz_file_info info;
	unzGetCurrentFileInfo(_handle, &info, NULL, 0, NULL, 0, NULL, 0);

	unsigned long fileSize = info.uncompressed_size;

	int openResult = unzOpenCurrentFile(_handle);

	idStr returnValue;

	if (openResult == UNZ_OK)
	{
		char* buffer = new char[fileSize + 1];

		// Read and null-terminate the string
		unzReadCurrentFile(_handle, buffer, fileSize);
		buffer[fileSize] = '\0';

		returnValue = buffer;
		
		delete[] buffer;
	}

	unzCloseCurrentFile(_handle);

	return returnValue;
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:32,代码来源:ZipLoader.cpp

示例9: parseToken

/*
================
idCameraPosition::parseToken
================
*/
bool idCameraPosition::parseToken( const idStr &key, idParser *src ) {
	idToken token;

	if ( !key.Icmp( "time" ) ) {
		time = src->ParseInt();
		return true;
	}
	else if ( !key.Icmp( "type" ) ) {
		type = static_cast<idCameraPosition::positionType> ( src->ParseInt() );
		return true;
	}
	else if ( !key.Icmp( "velocity" ) ) {
		long t = atol(token);
		long d = src->ParseInt();
		float s = src->ParseFloat();
		addVelocity(t, d, s);
		return true;
	}
	else if ( !key.Icmp( "baseVelocity" ) ) {
		baseVelocity = src->ParseFloat();
		return true;
	}
	else if ( !key.Icmp( "name" ) ) {
		src->ReadToken( &token );
		name = token;
		return true;
	}
	else {
		src->Error( "unknown camera position key: %s", key.c_str() );
		return false;
	}
}
开发者ID:BielBdeLuna,项目名称:dhewm3,代码行数:37,代码来源:splines.cpp

示例10: Sys_SaveGameCheck

/*
========================
Sys_SaveGameCheck
========================
*/
void Sys_SaveGameCheck( bool & exists, bool & autosaveExists ) {
	exists = false;
	autosaveExists = false;

	const idStr autosaveFolderStr = AddSaveFolderPrefix( SAVEGAME_AUTOSAVE_FOLDER, idSaveGameManager::PACKAGE_GAME );
	const char * autosaveFolder = autosaveFolderStr.c_str();
	const char * saveFolder = "savegame";

	if ( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES ) {
		idFileList * files = fileSystem->ListFiles( saveFolder, "/" );
		const idStrList & fileList = files->GetList();

		idLib::PrintfIf( saveGame_verbose.GetBool(), "found %d savegames\n", fileList.Num() );

		for ( int i = 0; i < fileList.Num(); i++ ) {
			const char * directory = va( "%s/%s", saveFolder, fileList[i].c_str() );

			if ( fileSystem->IsFolder( directory, "fs_savePath" ) == FOLDER_YES ) {
				exists = true;
				
				idLib::PrintfIf( saveGame_verbose.GetBool(), "found savegame: %s\n", fileList[i].c_str() );

				if ( idStr::Icmp( fileList[i].c_str(), autosaveFolder ) == 0 ) {
					autosaveExists = true;
					break;
				}
			}
		}

		fileSystem->FreeFileList( files );
	}
}
开发者ID:469486139,项目名称:DOOM-3-BFG,代码行数:37,代码来源:win_savegame.cpp

示例11: ExportModel

/*
====================
idModelExport::ExportModel
====================
*/
bool idModelExport::ExportModel( const char *model ) {

// RAVEN BEGIN
// scork:
	MayaConversionCleaner _any_old_name;
// RAVEN END

	const char *game = cvarSystem->GetCVarString( "fs_game" );

	if ( strlen(game) == 0 ) {
		game = BASE_GAMEDIR;
	}

	Reset();
	src  = model;
	dest = model;
	dest.SetFileExtension( MD5_MESH_EXT );

	sprintf( commandLine, "mesh %s -dest %s -game %s", src.c_str(), dest.c_str(), game );
	if ( !ConvertMayaToMD5() ) {
		gameLocal.Printf( "Failed to export '%s' : %s", src.c_str(), Maya_Error.c_str() );
		return false;
	}

	return true;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:31,代码来源:Anim_Import.cpp

示例12: Init

/*
============
idAASLocal::Init
============
*/
bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
	if ( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
		gameLocal.Printf( "Keeping %s\n", file->GetName() );
		RemoveAllObstacles();
	}
	else {
		Shutdown();

		file = AASFileManager->LoadAAS( mapName, mapFileCRC );
		if ( !file ) {
			common->DWarning( "Couldn't load AAS file: '%s'", mapName.c_str() );
			return false;
		}
// RAVEN BEGIN
// rhummer: Check if this is a dummy file, since it really has no valid data dump it.
		else if ( file->IsDummyFile( mapFileCRC ) ) {
			AASFileManager->FreeAAS( file );
			file = NULL;
			return false;
		}
// RAVEN END
		SetupRouting();
	}
	return true;
}
开发者ID:AliKalkandelen,项目名称:quake4,代码行数:30,代码来源:AAS.cpp

示例13: defined

/*
 ==============
 Sys_DefaultSavePath
 ==============
 */
const char *Sys_DefaultSavePath( void ) {
#if defined( ID_DEMO_BUILD )
	sprintf( savepath, "%s/.doom3-demo", getenv( "HOME" ) );
#else
	sprintf( savepath, "%s/.doom3", getenv( "HOME" ) );
#endif
	return savepath.c_str();
}
开发者ID:revelator,项目名称:Revelation,代码行数:13,代码来源:main.cpp

示例14: ExtractFileTo

bool CZipFile::ExtractFileTo(const idStr& fileName, const idStr& destPath)
{
	bool returnValue = true;

	int result = unzLocateFile(_handle, fileName.c_str(), 0);

	if (result != UNZ_OK) return false;

	// Try to open the destination path before uncompressing the file
	FILE* outFile = fopen(destPath.c_str(), "wb");

	if (outFile == NULL) 
	{
		// couldn't open file for writing
		DM_LOG(LC_MAINMENU, LT_ERROR)LOGSTRING("Couldn't extract %s file to %s.\r", fileName.c_str(), destPath.c_str());
		return false; 
	}

	unz_file_info info;
	unzGetCurrentFileInfo(_handle, &info, NULL, 0, NULL, 0, NULL, 0);

	unsigned long fileSize = info.uncompressed_size;

	int openResult = unzOpenCurrentFile(_handle);

	if (openResult == UNZ_OK)
	{
		unsigned char* buffer = new unsigned char[fileSize];

		// Read and null-terminate the string
		unzReadCurrentFile(_handle, buffer, fileSize);

		fwrite(buffer, 1, fileSize, outFile);
				
		delete[] buffer;
	}
	else
	{
		returnValue = false; // fopen failed
	}

	fclose(outFile);
	unzCloseCurrentFile(_handle);

	return returnValue;
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:46,代码来源:ZipLoader.cpp

示例15: GetDemoNameInfo

/*
============
sdGameRulesStopWatch::GetDemoNameInfo
============
*/
const char* sdGameRulesStopWatch::GetDemoNameInfo( void ) {
	static idStr demoNameBuffer;
	if ( progression == GP_FIRST_MATCH ) {
		demoNameBuffer = va( "stopwatch_first" );
	} else {
		demoNameBuffer = va( "stopwatch_second" );
	}
	return demoNameBuffer.c_str();
}
开发者ID:,项目名称:,代码行数:14,代码来源:


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