diff options
author | Simon Howard | 2006-12-23 21:24:56 +0000 |
---|---|---|
committer | Simon Howard | 2006-12-23 21:24:56 +0000 |
commit | 052741d3485780d8e029ada086e330fdd56ee7ac (patch) | |
tree | 439704265dd3cbbe140e5a08538e75129e0a359b /src | |
parent | 8630d0991eb32b3bedecb6655ac9935bd50391df (diff) | |
download | chocolate-doom-052741d3485780d8e029ada086e330fdd56ee7ac.tar.gz chocolate-doom-052741d3485780d8e029ada086e330fdd56ee7ac.tar.bz2 chocolate-doom-052741d3485780d8e029ada086e330fdd56ee7ac.zip |
Add '-findiwads' command line hack so that the setup program can find
out what games are installed. Provide a drop-down list in setup to allow
the game type to be selected.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 803
Diffstat (limited to 'src')
-rw-r--r-- | src/d_iwad.c | 48 | ||||
-rw-r--r-- | src/d_iwad.h | 1 | ||||
-rw-r--r-- | src/d_main.c | 5 |
3 files changed, 41 insertions, 13 deletions
diff --git a/src/d_iwad.c b/src/d_iwad.c index 04774203..612f2434 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -170,12 +170,12 @@ static char *GetRegistryString(registry_value_t *reg_val) // Allocate a buffer for the value and read the value - result = Z_Malloc(len, PU_STATIC, 0); + result = malloc(len); if (RegQueryValueEx(key, reg_val->value, NULL, &valtype, (unsigned char *) result, &len) != ERROR_SUCCESS) { - Z_Free(result); + free(result); return NULL; } @@ -209,7 +209,7 @@ static void CheckUninstallStrings(void) if (unstr == NULL) { - Z_Free(val); + free(val); } else { @@ -238,17 +238,16 @@ static void CheckCollectorsEdition(void) for (i=0; i<sizeof(collectors_edition_subdirs) / sizeof(*collectors_edition_subdirs); ++i) { - subpath = Z_Malloc(strlen(install_path) - + strlen(collectors_edition_subdirs[i]) - + 5, - PU_STATIC, 0); + subpath = malloc(strlen(install_path) + + strlen(collectors_edition_subdirs[i]) + + 5); sprintf(subpath, "%s\\%s", install_path, collectors_edition_subdirs[i]); AddIWADDir(subpath); } - Z_Free(install_path); + free(install_path); } #endif @@ -279,7 +278,7 @@ static char *SearchDirectoryForIWAD(char *dir) iwadname = DEH_String(iwads[i].name); - filename = Z_Malloc(strlen(dir) + strlen(iwadname) + 3, PU_STATIC, 0); + filename = malloc(strlen(dir) + strlen(iwadname) + 3); sprintf(filename, "%s%c%s", dir, DIR_SEPARATOR, iwadname); @@ -289,7 +288,7 @@ static char *SearchDirectoryForIWAD(char *dir) return filename; } - Z_Free(filename); + free(filename); } return NULL; @@ -409,7 +408,6 @@ static void BuildIWADDirList(void) // Searches IWAD search paths for an IWAD with a specific name. // - char *D_FindIWADByName(char *name) { char *buf; @@ -429,7 +427,7 @@ char *D_FindIWADByName(char *name) { // Construct a string for the full path - buf = Z_Malloc(strlen(iwad_dirs[i]) + strlen(name) + 5, PU_STATIC, 0); + buf = malloc(strlen(iwad_dirs[i]) + strlen(name) + 5); sprintf(buf, "%s%c%s", iwad_dirs[i], DIR_SEPARATOR, name); exists = M_FileExists(buf); @@ -439,7 +437,7 @@ char *D_FindIWADByName(char *name) return buf; } - Z_Free(buf); + free(buf); } // File not found @@ -731,3 +729,27 @@ void D_SetGameDescription(void) } } +// Clever hack: Setup can invoke Doom to determine which IWADs are installed. +// Doom searches install paths and exits with the return code being a +// bitmask of the installed IWAD files. + +void D_FindInstalledIWADs(void) +{ + int i; + int result; + + BuildIWADDirList(); + + result = 0; + + for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i) + { + if (D_FindIWADByName(iwads[i].name) != NULL) + { + result |= 1 << i; + } + } + + exit(result); +} + diff --git a/src/d_iwad.h b/src/d_iwad.h index 404d7efb..a0f1a0ba 100644 --- a/src/d_iwad.h +++ b/src/d_iwad.h @@ -31,6 +31,7 @@ char *D_FindIWAD(void); void D_SetSaveGameDir(void); void D_IdentifyVersion(void); void D_SetGameDescription(void); +void D_FindInstalledIWADs(void); #endif diff --git a/src/d_main.c b/src/d_main.c index a8c46a95..af892d30 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -929,6 +929,11 @@ void D_DoomMain (void) FindResponseFile (); + if (M_CheckParm("-findiwads") > 0) + { + D_FindInstalledIWADs(); + } + // print banner PrintBanner(PACKAGE_STRING); |