diff options
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); |