Call CheckHogfile() instead of copy pasting code

The main motivation behind this commit is to make it easier to create a
future commit. That future commit will modify code in CheckHogFile(). If
I don’t deduplicate the code now, then I’ll have to edit the same lines
of code in multiple different places.
This commit is contained in:
Jason Yundt 2024-05-18 18:31:52 -04:00
parent 72852bce3d
commit 491af3c469

View File

@ -1628,35 +1628,9 @@ void StartLevel() {
// Loads a level and starts everything up
bool LoadAndStartCurrentLevel() {
char hogpath[_MAX_PATH * 2];
// This is a bit redundant because we just did it in most cases, but we need to be sure that it always happens,
// and this code is here for weird systems, like save/load and demo, etc.
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);
}
} 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
mn3_Close();
ddio_MakePath(hogpath, D3MissionsDir, "d3.mn3", nullptr);
if (cfexist(hogpath)) {
mn3_Open(hogpath);
mem_free(Current_mission.filename);
Current_mission.filename = mem_strdup("d3.mn3");
} else {
SetFunctionMode(MENU_MODE);
}
}
CheckHogfile();
// load the level. if fails, then bail out
// ShowProgressScreen (TXT_LOADINGLEVEL);