Пример #1
0
/*
================
idLexer::GetLastWhiteSpace
================
*/
int idLexer::GetLastWhiteSpace( idStr &whiteSpace ) const {
	whiteSpace.Clear();
	for ( const char *p = whiteSpaceStart_p; p < whiteSpaceEnd_p; p++ ) {
		whiteSpace.Append( *p );
	}
	return whiteSpace.Length();
}
Пример #2
0
/*
================
CleanName
================
*/
void CleanName( idStr &name ) {
	name.Replace( "::", "_" );
	name.Replace( " , ", "_" );
	name.Replace( "< ", "_" );
	name.Replace( " >", "_" );
	name.Replace( " ", "_" );
}
Пример #3
0
/*
================
CPathTreeCtrl::FindItem

Find the given path in the tree.
================
*/
HTREEITEM CPathTreeCtrl::FindItem( const idStr &pathName ) {
	int lastSlash;
	idStr path, tmpPath, itemName;
	HTREEITEM item, parentItem;

	parentItem = NULL;
	item = GetRootItem();

	lastSlash = pathName.Last( '/' );

	while( item && lastSlash > path.Length() ) {
		itemName = GetItemText( item );
		tmpPath = path + itemName;
		if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
			parentItem = item;
			item = GetChildItem( item );
			path = tmpPath + "/";
		} else {
			item = GetNextSiblingItem( item );
		}
	}

	for ( item = GetChildItem( parentItem ); item; item = GetNextSiblingItem( item ) ) {
		itemName = GetItemText( item );
		if ( pathName.Icmp( path + itemName ) == 0 ) {
			return item;
		}
	}

	return NULL;
}
Пример #4
0
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();
}
Пример #5
0
/*
========================
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 );
	}
}
Пример #6
0
/*
============
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;
}
Пример #7
0
void DialogEntityDefEditor::BuildDeclText( idStr &declText )
{
	CString declName;
	declNameEdit.GetWindowText(declName);
	CString inherit;
	inheritCombo.GetWindowText(inherit);
	CString spawnclass;
	spawnclassCombo.GetWindowText(spawnclass);

	declText = "entityDef " + declName + "\r{\r";
	declText += "\"inherit\"\t\t\t\"" + inherit + "\"\r";
	declText += "\"spawnclass\"\t\t\t\"" + spawnclass + "\"\r";
	for (int i=0; i<keyValsList.GetCount(); i++) {
		CPropertyItem* pItem = (CPropertyItem*)keyValsList.GetItemDataPtr(i);
		if (pItem) {
			// Items with a * in front are inherited and shouldn't be written out
			if (pItem->m_propName[0] == '*') {
				break;
			}
			declText += "\"" + pItem->m_propName + "\"\t\t\t\"" + pItem->m_curValue + "\"\r";
		}
	}
	declText += "}\r";

	declText.Replace( "\r", "\r\n" );
	declText.Insert( "\r\n\r\n", 0 );
	declText.StripTrailing( "\r\n" );
}
Пример #8
0
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; 
}
Пример #9
0
void CModInfo::GetMissionTitles(idStr missionTitles)
{
	if (modName.IsEmpty())
	{
		return;
	}

	int startIndex = 0;
	idStr start = "Mission 1 Title: ";
	idStr end   = "Mission 2 Title: ";
	int endIndex = missionTitles.Find(end.c_str(), true); // grayman #3733
	bool finished = false;
	for ( int i = 1 ; ; i++ )
	{
		idStr title = idStr(missionTitles, startIndex, endIndex); // grayman #3733
		Strip(start.c_str(), title);
		_missionTitles.Append(title);
		start = end;
		startIndex = endIndex;
		if (finished)
		{
			break;
		}
		end = va("Mission %d Title: ",i+2);
		endIndex = missionTitles.Find(end.c_str(), true, startIndex); // grayman #3733
		if (endIndex < 0)
		{
			endIndex = missionTitles.Length();
			finished = true;
		}
	}
}
Пример #10
0
bool Sys_GetPath(sysPath_t type, idStr &path) {
    char buf[MAX_OSPATH];
    struct _stat st;
    idStr s;

    switch(type) {
    case PATH_BASE:
        // try <path to exe>/base first
        if (Sys_GetPath(PATH_EXE, path)) {
            path.StripFilename();

            s = path;
            s.AppendPath(BASE_GAMEDIR);
            if (_stat(s.c_str(), &st) != -1 && st.st_mode & _S_IFDIR)
                return true;

            common->Warning("base path '%s' does not exits", s.c_str());
        }

        // fallback to vanilla doom3 cd install
        if (GetRegistryPath(buf, sizeof(buf), L"SOFTWARE\\id\\Doom 3", L"InstallPath") > 0) {
            path = buf;
            return true;
        }

        // fallback to steam doom3 install
        if (GetRegistryPath(buf, sizeof(buf), L"SOFTWARE\\Valve\\Steam", L"InstallPath") > 0) {
            path = buf;
            path.AppendPath("steamapps\\common\\doom 3");

            if (_stat(path.c_str(), &st) != -1 && st.st_mode & _S_IFDIR)
                return true;
        }

        common->Warning("vanilla doom3 path not found");

        return false;

    case PATH_CONFIG:
    case PATH_SAVE:
        if (GetHomeDir(buf, sizeof(buf)) < 1) {
            Sys_Error("ERROR: Couldn't get dir to home path");
            return false;
        }

        path = buf;
        return true;

    case PATH_EXE:
        GetModuleFileName(NULL, buf, sizeof(buf) - 1);
        path = buf;
        path.BackSlashesToSlashes();
        return true;
    }

    return false;
}
Пример #11
0
/*
============
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();
}
Пример #12
0
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() );
	}
}
Пример #13
0
/*
============
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() );
    }
}
Пример #14
0
/*
========================
idKeyInput::LocalizedKeyName
========================
*/
const char* idKeyInput::LocalizedKeyName( keyNum_t keynum )
{
	// RB
#if defined(_WIN32)
	// DG TODO: move this into a win32 Sys_GetKeyName()
	if( keynum < K_JOY1 )
	{
		// On the PC, we want to turn the scan code in to a key label that matches the currently selected keyboard layout
		unsigned char keystate[256] = { 0 };
		WCHAR temp[5];
		
		int scancode = ( int )keynum;
		int vkey = MapVirtualKey( keynum, MAPVK_VSC_TO_VK_EX );
		int result = -1;
		while( result < 0 )
		{
			result = ToUnicode( vkey, scancode, keystate, temp, sizeof( temp ) / sizeof( temp[0] ), 0 );
		}
		if( result > 0 && temp[0] > ' ' && iswprint( temp[0] ) )
		{
			static idStr bindStr;
			bindStr.Empty();
			bindStr.AppendUTF8Char( temp[0] );
			return bindStr;
		}
	}
#else // DG: for !Windows I introduced Sys_GetKeyName() to get key label for current keyboard layout
	
	const char* ret = nullptr;
	
	if( keynum < K_JOY1 ) // only for keyboard keys, not joystick or mouse
	{
		ret = Sys_GetKeyName( keynum );
	}
	
	if( ret != NULL )
	{
		return ret;
	}
#endif
	
	// check for a key string
	for( keyname_t* kn = keynames; kn->name; kn++ )
	{
		if( keynum == kn->keynum )
		{
			return idLocalization::GetString( kn->strId );
		}
	}
	return "????";
	// RB/DG end
}
Пример #15
0
/*
================
DialogDeclBrowser::GetDeclName
================
*/
void DialogDeclBrowser::GetDeclName( HTREEITEM item, idStr &typeName, idStr &declName ) const {
	HTREEITEM parent;
	idStr itemName;

	declName.Clear();
	for( parent = declTree.GetParentItem( item ); parent; parent = declTree.GetParentItem( parent ) ) {
		itemName = declTree.GetItemText( item );
		declName = itemName + "/" + declName;
		item = parent;
	}
	declName.Strip( '/' );
	typeName = declTree.GetItemText( item );
}
Пример #16
0
/*
==================
Sym_GetFuncInfo
==================
*/
void Sym_GetFuncInfo( long addr, idStr &module, idStr &funcName )
{
    MEMORY_BASIC_INFORMATION mbi;
    module_t *m;
    symbol_t *s;

    VirtualQuery( (void*)addr, &mbi, sizeof(mbi) );

    for ( m = modules; m != NULL; m = m->next )
    {
        if ( m->address == (int) mbi.AllocationBase )
        {
            break;
        }
    }
    if ( !m )
    {
        Sym_Init( addr );
        m = modules;
    }

    for ( s = m->symbols; s != NULL; s = s->next )
    {
        if ( s->address == addr )
        {

            char undName[MAX_STRING_CHARS];
            if ( UnDecorateSymbolName( s->name, undName, sizeof(undName), UNDECORATE_FLAGS ) )
            {
                funcName = undName;
            }
            else
            {
                funcName = s->name;
            }
            for ( int i = 0; i < funcName.Length(); i++ )
            {
                if ( funcName[i] == '(' )
                {
                    funcName.CapLength( i );
                    break;
                }
            }
            module = m->name;
            return;
        }
    }

    sprintf( funcName, "0x%08x", addr );
    module = "";
}
Пример #17
0
/*
============
idAASLocal::Init
============
*/
bool idAASLocal::Init( const idStr &mapName, unsigned int mapFileCRC ) {
	if( file && mapName.Icmp( file->GetName() ) == 0 && mapFileCRC == file->GetCRC() ) {
		common->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;
		}
		SetupRouting();
	}
	return true;
}
Пример #18
0
/*
================
idTypeInfoTools::ParseTemplateArguments
================
*/
bool idTypeInfoTools::ParseTemplateArguments( idLexer &src, idStr &arguments ) {
	int indent;
	idToken token;

	arguments = "";

	if ( !src.ExpectTokenString( "<" ) ) {
		return false;
	}

	indent = 1;
	while( indent ) {
		if ( !src.ReadToken( &token ) ) {
			break;
		}
		if ( token == "<" ) {
			indent++;
		} else if ( token == ">" ) {
			indent--;
		} else {
			if ( arguments.Length() ) {
				arguments += " ";
			}
			arguments += token;
		}
	}
	return true;
}
/*
================
DialogDeclEditor::TestDecl
================
*/
bool DialogDeclEditor::TestDecl(const idStr &declText)
{
	idLexer src(LEXFL_NOSTRINGCONCAT);
	idToken token;
	int indent;

	src.LoadMemory(declText, declText.Length(), "decl text");

	indent = 0;

	while (src.ReadToken(&token)) {
		if (token == "{") {
			indent++;
		} else if (token == "}") {
			indent--;
		}
	}

	if (indent < 0) {
		MessageBox("Missing opening brace!", va("Error saving %s", decl->GetFileName()), MB_OK | MB_ICONERROR);
		return false;
	}

	if (indent > 0) {
		MessageBox("Missing closing brace!", va("Error saving %s", decl->GetFileName()), MB_OK | MB_ICONERROR);
		return false;
	}

	return true;
}
Пример #20
0
void DialogEntityDefEditor::SetInherit( idStr &inherit ) {
	CWaitCursor wc;
	for( int i = 0; i < keyValsList.GetCount(); i++ ) {
		CPropertyItem *pItem = ( CPropertyItem * )keyValsList.GetItemDataPtr( i );
		if( pItem ) {
			if( pItem->m_propName[0] == '*' ) {
				delete pItem;
				keyValsList.DeleteString( i );
				i--;
			}
		}
	}
	CString spawnclass;
	// Fill up the rest of the box with inherited info
	if( !inherit.IsEmpty() ) {
		const idDecl *temp = declManager->FindType( DECL_ENTITYDEF, inherit, false );
		const idDeclEntityDef *parent = static_cast<const idDeclEntityDef *>( temp );
		if( parent ) {
			size_t numPairs = parent->dict.Size();
			for( unsigned int i = 0; i < numPairs; i++ ) {
				const idKeyValue *keyVal = parent->dict.GetKeyVal( i );
				if( keyVal ) {
					if( spawnclass.IsEmpty() && keyVal->GetKey() == "spawnclass" ) {
						spawnclass = keyVal->GetValue();
					} else {
						CString key = keyVal->GetKey();
						key = "*" + key;
						keyValsList.AddPropItem( new CPropertyItem( key, keyVal->GetValue().c_str(), PIT_EDIT, "" ) );
					}
				}
			}
		}
	}
}
Пример #21
0
/*
========================
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" );
	}

}
Пример #22
0
/*
===============
idCommonLocal::ScrubSaveGameFileName

Turns a bad file name into a good one or your money back
===============
*/
void idCommonLocal::ScrubSaveGameFileName( idStr &saveFileName ) const {
	int i;
	idStr inFileName;

	inFileName = saveFileName;
	inFileName.RemoveColors();
	inFileName.StripFileExtension();

	saveFileName.Clear();

	int len = inFileName.Length();
	for ( i = 0; i < len; i++ ) {
		if ( strchr( "',.~!@#$%^&*()[]{}<>\\|/=?+;:-\'\"", inFileName[i] ) ) {
			// random junk
			saveFileName += '_';
		} else if ( (const unsigned char)inFileName[i] >= 128 ) {
			// high ascii chars
			saveFileName += '_';
		} else if ( inFileName[i] == ' ' ) {
			saveFileName += '_';
		} else {
			saveFileName += inFileName[i];
		}
	}
}
Пример #23
0
CInventoryItemPtr CInventory::GetItemById(const idStr& id, const idStr& categoryName, bool createCategory)
{
	// Do we have a specific category to search in?
	if (!categoryName.IsEmpty())
	{
		// We have a category name, look it up
		CInventoryCategoryPtr category = GetCategory(categoryName);

		if (category == NULL && createCategory)
		{
			// Special case, the caller requested to create this category if not found
			category = CreateCategory(categoryName);
		}

		// Let the category search for the item, may return NULL
		return (category != NULL) ? category->GetItemById(id) : CInventoryItemPtr();
	}

	// No specific category specified, look in all categories
	for (int i = 0; i < m_Category.Num(); i++)
	{
		CInventoryItemPtr foundItem = m_Category[i]->GetItemById(id);

		if (foundItem != NULL)
		{
			// Found the item
			return foundItem;
		}
	}

	return CInventoryItemPtr(); // nothing found
}
Пример #24
0
/*
====================
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;
}
Пример #25
0
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;
}
Пример #26
0
/*
 ==============
 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();
}
Пример #27
0
bool TestMapVal(idStr& str) {
	//Already Localized?
	if(str.Find("#str_") != -1) {
		return false;
	}

	return true;
}
Пример #28
0
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;
}
Пример #29
0
/*
=============
idStr::StripMediaName

  makes the string lower case, replaces backslashes with forward slashes, and removes extension
=============
*/
void idStr::StripMediaName( const char *name, idStr &mediaName ) {
	char c;

	mediaName.Empty();

	for ( c = *name; c; c = *(++name) ) {
		// truncate at an extension
		if ( c == '.' ) {
			break;
		}
		// convert backslashes to forward slashes
		if ( c == '\\' ) {
			mediaName.Append( '/' );
		} else {
			mediaName.Append( idStr::ToLower( c ) );
		}
	}
}
Пример #30
0
/*
================
idRestoreGame::ReadString
================
*/
void idRestoreGame::ReadString( idStr &string ) {
	int len;
	ReadInt( len );
	if( len < 0 ) {
		Error( "idRestoreGame::ReadString: invalid length" );
	}
	string.Fill( ' ', len );
	file->Read( &string[ 0 ], len );
}