MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / HasD3XP

Method HasD3XP

neo/framework/FileSystem.cpp:3718–3781  ·  view source on GitHub ↗

=============== idFileSystemLocal::HasD3XP =============== */

Source from the content-addressed store, hash-verified

3716===============
3717*/
3718bool idFileSystemLocal::HasD3XP( void ) {
3719 int i;
3720 idStrList dirs, pk4s;
3721 idStr gamepath;
3722
3723 if ( d3xp == -1 ) {
3724 return false;
3725 } else if ( d3xp == 1 ) {
3726 return true;
3727 }
3728
3729#if 0
3730 // check for a d3xp directory with a pk4 file
3731 // copied over from ListMods - only looks in basepath
3732 ListOSFiles( fs_basepath.GetString(), "/", dirs );
3733 for ( i = 0; i < dirs.Num(); i++ ) {
3734 if ( dirs[i].Icmp( "d3xp" ) == 0 ) {
3735 gamepath = BuildOSPath( fs_basepath.GetString(), dirs[ i ], "" );
3736 ListOSFiles( gamepath, ".pk4", pk4s );
3737 if ( pk4s.Num() ) {
3738 d3xp = 1;
3739 return true;
3740 }
3741 }
3742 }
3743#else
3744 // check for d3xp's d3xp/pak000.pk4 in any search path
3745 // checking wether the pak is loaded by checksum wouldn't be enough:
3746 // we may have a different fs_game right now but still need to reply that it's installed
3747 const char *search[4];
3748 idFile *pakfile;
3749 search[0] = fs_savepath.GetString();
3750 search[1] = fs_devpath.GetString();
3751 search[2] = fs_basepath.GetString();
3752 search[3] = fs_cdpath.GetString();
3753 for ( i = 0; i < 4; i++ ) {
3754 pakfile = OpenExplicitFileRead( BuildOSPath( search[ i ], "d3xp", "pak000.pk4" ) );
3755 if ( pakfile ) {
3756 CloseFile( pakfile );
3757 d3xp = 1;
3758 return true;
3759 }
3760 }
3761#endif
3762
3763 // if we didn't find a pk4 file then the user might have unpacked so look for default.cfg file
3764 // that's the old way mostly used during developement. don't think it hurts to leave it there
3765 ListOSFiles( fs_basepath.GetString(), "/", dirs );
3766 for ( i = 0; i < dirs.Num(); i++ ) {
3767 if ( dirs[i].Icmp( "d3xp" ) == 0 ) {
3768
3769 gamepath = BuildOSPath( fs_configpath.GetString(), dirs[ i ], "default.cfg" );
3770 idFile* cfg = OpenExplicitFileRead(gamepath);
3771 if(cfg) {
3772 CloseFile(cfg);
3773 d3xp = 1;
3774 return true;
3775 }

Callers 8

CheckKeyMethod · 0.80
CDKeysAreValidMethod · 0.80
StartMenuMethod · 0.80
SetMainMenuGuiVarsMethod · 0.80
MessageBoxMethod · 0.80
IsFilteredMethod · 0.80
BuildInvalidKeyMsgMethod · 0.80

Calls 3

IcmpMethod · 0.60
GetStringMethod · 0.45
NumMethod · 0.45

Tested by

no test coverage detected