Skip to content

Commit c5d5037

Browse files
authored
Merge pull request #455 from winterheart/remove-getmultcdpath
Remove redundant GetMultiCDPath()
2 parents ed79350 + c76612e commit c5d5037

6 files changed

Lines changed: 24 additions & 121 deletions

File tree

Descent3/Mission.cpp

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -919,18 +919,7 @@ bool LoadMission(const char *mssn) {
919919
ResetMission(); // Reset everything.
920920
// open MN3 if filename passed was an mn3 file.
921921

922-
// Correct for mission split hack
923-
924-
if (stricmp(mssn, "d3_2.mn3") == 0) {
925-
strcpy(mission, "d3_2.mn3");
926-
strcpy(pathname, "d3_2.mn3");
927-
928-
} else if (stricmp(mssn, "d3.mn3") == 0) {
929-
strcpy(mission, "d3.mn3");
930-
strcpy(pathname, "d3.mn3");
931-
932-
}
933-
else if (IS_MN3_FILE(mssn)) {
922+
if (IS_MN3_FILE(mssn)) {
934923
strcpy(mission, mssn);
935924
ddio_MakePath(pathname, D3MissionsDir, mission, NULL);
936925
} else {
@@ -1837,13 +1826,9 @@ bool mn3_Open(const char *mn3file) {
18371826
mn3file = tempMn3File;
18381827
}
18391828

1840-
const char *p = GetMultiCDPath((char *)mn3file);
1841-
// ddio_MakePath(pathname, D3MissionsDir, mn3file, NULL);
1842-
if (!p)
1843-
return false;
1844-
strcpy(pathname, p);
1829+
ddio_MakePath(pathname, D3MissionsDir, mn3file, NULL);
18451830
// open MN3 HOG.
1846-
mn3_handle = cf_OpenLibrary(pathname);
1831+
mn3_handle = cf_OpenLibrary(mn3file);
18471832
if (mn3_handle == 0) {
18481833
return false;
18491834
} else {
@@ -1852,42 +1837,30 @@ bool mn3_Open(const char *mn3file) {
18521837
// do table file stuff.
18531838
ddio_SplitPath(mn3file, NULL, filename, ext);
18541839

1855-
// char voice_hog[_MAX_PATH*2];
1840+
char voice_hog[_MAX_PATH*2];
18561841
if ((stricmp(filename, "d3") == 0) || (stricmp(filename, "training") == 0)) {
18571842
// Open audio hog file
1858-
// ddio_MakePath(voice_hog, D3MissionsDir, "d3voice1.hog", NULL);//Audio for levels 1-4
1859-
const char *v = GetMultiCDPath("d3voice1.hog");
1860-
if (!v)
1861-
return false;
1862-
Mission_voice_hog_handle = cf_OpenLibrary(v);
1843+
ddio_MakePath(voice_hog, D3MissionsDir, "d3voice1.hog", nullptr); // Audio for levels 1-4
1844+
Mission_voice_hog_handle = cf_OpenLibrary(voice_hog);
18631845
} else if (stricmp(filename, "d3_2") == 0) {
18641846
// Open audio hog file
1865-
// ddio_MakePath(voice_hog, D3MissionsDir, "d3voice2.hog", NULL);//Audio for levels 5-17
1866-
const char *v = GetMultiCDPath("d3voice2.hog");
1867-
if (!v)
1868-
return false;
1869-
Mission_voice_hog_handle = cf_OpenLibrary(v);
1847+
ddio_MakePath(voice_hog, D3MissionsDir, "d3voice2.hog", nullptr); // Audio for levels 5-17
1848+
Mission_voice_hog_handle = cf_OpenLibrary(voice_hog);
18701849
}
18711850
strcat(filename, ".gam");
18721851
mng_SetAddonTable(filename);
18731852
Current_mission.mn3_handle = mn3_handle;
18741853
return true;
18751854
}
1855+
18761856
// returns mission information given the mn3 file.
18771857
bool mn3_GetInfo(const char *mn3file, tMissionInfo *msn) {
18781858
int handle;
18791859
bool retval;
18801860
char pathname[_MAX_PATH];
18811861
char filename[PSFILENAME_LEN + 1];
18821862

1883-
if (stricmp(mn3file, "d3.mn3") == 0) {
1884-
const char *p = GetMultiCDPath((char *)mn3file);
1885-
if (!p)
1886-
return false;
1887-
strcpy(pathname, p);
1888-
} else {
1889-
ddio_MakePath(pathname, D3MissionsDir, mn3file, NULL);
1890-
}
1863+
ddio_MakePath(pathname, D3MissionsDir, mn3file, nullptr);
18911864
handle = cf_OpenLibrary(pathname);
18921865
if (handle == 0) {
18931866
mprintf(0, "MISSION: MN3 failed to open.\n");

Descent3/descent.cpp

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,7 @@ void Descent3() {
493493
for (auto const &intro : intros) {
494494
ddio_MakePath(intropath, Base_directory, "movies", intro, nullptr);
495495
if (cfexist(intropath)) {
496-
const char *t = GetMultiCDPath(intro);
497-
if (t)
498-
PlayMovie(t);
496+
PlayMovie(intropath);
499497
}
500498
}
501499
}
@@ -715,55 +713,3 @@ void D3DebugResumeHandler() {
715713
#endif
716714

717715
void RenderBlankScreen();
718-
719-
struct file_vols {
720-
char file[_MAX_PATH];
721-
char localpath[_MAX_PATH * 2];
722-
int volume;
723-
bool localized;
724-
};
725-
726-
// This function figures out whether or not a file needs to be loaded off of
727-
// CD or off of the local drive. If it needs to come from a CD, it figures out
728-
// which CD and prompts the user to enter that CD. If they hit cancel, it
729-
// returns NULL.
730-
const char *GetMultiCDPath(const char *file) {
731-
// Filename, directory it might be installed on the hard drive, CD number to look for it
732-
const std::vector<file_vols> file_volumes = {
733-
// file, localpath, volume, localized
734-
{"d3.mn3", "missions", 1, false},
735-
{"d3_2.mn3", "missions", 2, false},
736-
{"level1.mve", "movies", 1, true},
737-
{"level5.mve", "movies", 2, true},
738-
{"end.mve", "movies", 2, true},
739-
{"intro.mve", "movies", 1, true},
740-
{"dolby1.mv8", "movies", 1, true},
741-
{"d3voice1.hog", "missions", 1, true},
742-
{"d3voice2.hog", "missions", 2, true},
743-
};
744-
745-
static char fullpath[_MAX_PATH * 2];
746-
747-
if ((file == nullptr) || (*file == '\0'))
748-
return nullptr;
749-
750-
auto it = std::find_if(
751-
file_volumes.begin(), file_volumes.end(),
752-
[&file](const file_vols& file_volume) {
753-
return (stricmp(file_volume.file, file) == 0);
754-
}
755-
);
756-
757-
// This is a file we don't know about
758-
if (it == file_volumes.end()) {
759-
return file;
760-
}
761-
762-
ddio_MakePath(fullpath, LocalD3Dir, it->localpath, file, nullptr);
763-
// See if the file is in the local dir already.
764-
if (cfexist(fullpath)) {
765-
return fullpath;
766-
}
767-
768-
return nullptr;
769-
}

Descent3/descent.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ function_mode GetFunctionMode();
213213
void CreateGameViewport(grViewport **vp);
214214
void DestroyGameViewport(grViewport *vp);
215215

216-
// This function figures out whether or not a file needs to be loaded off of
217-
// CD or off of the local drive. If it needs to come from a CD, it figures out
218-
// which CD and prompts the user to enter that CD. If they hit cancel, it
219-
// returns NULL.
220-
const char *GetMultiCDPath(const char *file);
221-
222216
inline void CREATE_VIEWPORT(grViewport **vp) { CreateGameViewport(vp); }
223217

224218
inline void DESTROY_VIEWPORT(grViewport *vp) { DestroyGameViewport(vp); }

Descent3/gamesequence.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,8 @@ void CheckHogfile() {
13081308
(Current_mission.cur_level > 4)) {
13091309
// close the mission hog file and open d3_2.mn3
13101310
mn3_Close();
1311-
const char *hogp = GetMultiCDPath("d3_2.mn3");
1312-
if (hogp) {
1313-
strcpy(hogpath, hogp);
1311+
ddio_MakePath(hogpath, D3MissionsDir, "d3_2.mn3", nullptr);
1312+
if (cfexist(hogpath)) {
13141313
mn3_Open(hogpath);
13151314
mem_free(Current_mission.filename);
13161315
Current_mission.filename = mem_strdup("d3_2.mn3");
@@ -1322,9 +1321,8 @@ void CheckHogfile() {
13221321
// Part 2 of the mission is d3_2.mn3
13231322
// close the mission hog file and open d3.mn3
13241323
mn3_Close();
1325-
const char *hogp = GetMultiCDPath("d3.mn3");
1326-
if (hogp) {
1327-
strcpy(hogpath, hogp);
1324+
ddio_MakePath(hogpath, D3MissionsDir, "d3.mn3", nullptr);
1325+
if (cfexist(hogpath)) {
13281326
mn3_Open(hogpath);
13291327
mem_free(Current_mission.filename);
13301328
Current_mission.filename = mem_strdup("d3.mn3");
@@ -1643,9 +1641,8 @@ bool LoadAndStartCurrentLevel() {
16431641
(Current_mission.cur_level > 4)) {
16441642
// close the mission hog file and open d3_2.mn3
16451643
mn3_Close();
1646-
const char *hogp = GetMultiCDPath("d3_2.mn3");
1647-
if (hogp) {
1648-
strcpy(hogpath, hogp);
1644+
ddio_MakePath(hogpath, D3MissionsDir, "d3_2.mn3", nullptr);
1645+
if (cfexist(hogpath)) {
16491646
mn3_Open(hogpath);
16501647
mem_free(Current_mission.filename);
16511648
Current_mission.filename = mem_strdup("d3_2.mn3");
@@ -1657,9 +1654,8 @@ bool LoadAndStartCurrentLevel() {
16571654
// Part 2 of the mission is d3_2.mn3
16581655
// close the mission hog file and open d3.mn3
16591656
mn3_Close();
1660-
const char *hogp = GetMultiCDPath("d3.mn3");
1661-
if (hogp) {
1662-
strcpy(hogpath, hogp);
1657+
ddio_MakePath(hogpath, D3MissionsDir, "d3.mn3", nullptr);
1658+
if (cfexist(hogpath)) {
16631659
mn3_Open(hogpath);
16641660
mem_free(Current_mission.filename);
16651661
Current_mission.filename = mem_strdup("d3.mn3");

Descent3/menu.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,12 +1155,10 @@ bool MenuNewGame() {
11551155

11561156
FirstGame = true;
11571157

1158-
char temppath[_MAX_PATH];
1159-
const char *moviepath;
1160-
moviepath = GetMultiCDPath("level1.mve");
1161-
if (moviepath) {
1162-
strcpy(temppath, moviepath);
1163-
PlayMovie(temppath);
1158+
char moviepath[_MAX_PATH];
1159+
ddio_MakePath(moviepath, LocalD3Dir, "movies", "level1.mve", nullptr);
1160+
if (cfexist(moviepath)) {
1161+
PlayMovie(moviepath);
11641162
}
11651163
Skip_next_movie = true;
11661164

Descent3/mission_download.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,7 @@ int msn_CheckGetMission(network_address *net_addr, char *filename) {
601601
#ifdef OEM
602602
return 1;
603603
#else
604-
if ((stricmp(filename, "d3_2.mn3") == 0) || (stricmp(filename, "d3.mn3") == 0)) {
605-
const char *p = GetMultiCDPath(filename);
606-
return p ? 1 : 0;
607-
}
608-
604+
// Don't download local missions
609605
char pathname[_MAX_PATH];
610606
ddio_MakePath(pathname, D3MissionsDir, filename, NULL);
611607
if (cfexist(filename) || cfexist(pathname)) {

0 commit comments

Comments
 (0)