Simplify CheckHogfile()

The main motivation behind this commit is to make it easier to create a
future commit. That future commit will change how CheckHogFile() finds
the path for d3.mn3 and d3_2.mn3. Simplifying CheckHogFile() now
decreases the amount of code that needs to be changed in that future
commit.
This commit is contained in:
Jason Yundt 2024-05-17 19:35:30 -04:00
parent 491af3c469
commit 3a21380f9b

View File

@ -1295,31 +1295,28 @@ bool GameSequencer() {
// Make sure we have the correct hogfile
void CheckHogfile() {
char hogpath[_MAX_PATH * 2];
const char *new_mn3;
LOG_DEBUG << "Checking to see if we need to open another hog off of disk or CDROM";
if (Current_mission.filename && (stricmp(Current_mission.filename, "d3.mn3") == 0) &&
(Current_mission.cur_level > 4)) {
// close the mission hog file and open d3_2.mn3
mn3_Close();
ddio_MakePath(hogpath, D3MissionsDir, "d3_2.mn3", nullptr);
if (cfexist(hogpath)) {
mn3_Open(hogpath);
mem_free(Current_mission.filename);
Current_mission.filename = mem_strdup("d3_2.mn3");
} else {
SetFunctionMode(MENU_MODE);
}
new_mn3 = "d3_2.mn3";
} else if (Current_mission.filename && (stricmp(Current_mission.filename, "d3_2.mn3") == 0) &&
(Current_mission.cur_level <= 4)) {
// Part 2 of the mission is d3_2.mn3
// close the mission hog file and open d3.mn3
new_mn3 = "d3.mn3";
} else {
new_mn3 = NULL;
}
if (new_mn3) {
// close the mission hog file and open the new one
mn3_Close();
ddio_MakePath(hogpath, D3MissionsDir, "d3.mn3", nullptr);
char hogpath[_MAX_PATH * 2];
ddio_MakePath(hogpath, D3MissionsDir, new_mn3, nullptr);
if (cfexist(hogpath)) {
mn3_Open(hogpath);
mem_free(Current_mission.filename);
Current_mission.filename = mem_strdup("d3.mn3");
Current_mission.filename = mem_strdup(new_mn3);
} else {
SetFunctionMode(MENU_MODE);
}