MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadAndStartCurrentLevel

Function LoadAndStartCurrentLevel

Descent3/gamesequence.cpp:1636–1679  ·  view source on GitHub ↗

Loads a level and starts everything up

Source from the content-addressed store, hash-verified

1634
1635// Loads a level and starts everything up
1636bool LoadAndStartCurrentLevel() {
1637 char hogpath[_MAX_PATH * 2];
1638 // This is a bit redundant because we just did it in most cases, but we need to be sure that it always happens,
1639 // and this code is here for weird systems, like save/load and demo, etc.
1640 if (Current_mission.filename && (stricmp(Current_mission.filename, "d3.mn3") == 0) &&
1641 (Current_mission.cur_level > 4)) {
1642 // close the mission hog file and open d3_2.mn3
1643 mn3_Close();
1644 ddio_MakePath(hogpath, D3MissionsDir, "d3_2.mn3", nullptr);
1645 if (cfexist(hogpath)) {
1646 mn3_Open(hogpath);
1647 mem_free(Current_mission.filename);
1648 Current_mission.filename = mem_strdup("d3_2.mn3");
1649 } else {
1650 SetFunctionMode(MENU_MODE);
1651 }
1652 } else if (Current_mission.filename && (stricmp(Current_mission.filename, "d3_2.mn3") == 0) &&
1653 (Current_mission.cur_level <= 4)) {
1654 // Part 2 of the mission is d3_2.mn3
1655 // close the mission hog file and open d3.mn3
1656 mn3_Close();
1657 ddio_MakePath(hogpath, D3MissionsDir, "d3.mn3", nullptr);
1658 if (cfexist(hogpath)) {
1659 mn3_Open(hogpath);
1660 mem_free(Current_mission.filename);
1661 Current_mission.filename = mem_strdup("d3.mn3");
1662 } else {
1663 SetFunctionMode(MENU_MODE);
1664 }
1665 }
1666
1667 // load the level. if fails, then bail out
1668 // ShowProgressScreen (TXT_LOADINGLEVEL);
1669 if (!LoadMissionLevel(Current_mission.cur_level))
1670 return false;
1671
1672 AutomapClearVisMap();
1673
1674 // Now start the level
1675 StartLevel();
1676
1677 // Done!
1678 return true;
1679}
1680
1681#ifdef EDITOR
1682// Called to do game initialization stuff when playing from the editor

Callers 4

GameSequencerFunction · 0.85
ProcessTestKeysFunction · 0.85
LGSMissionFunction · 0.85
DemoReadHeaderFunction · 0.85

Calls 8

mn3_CloseFunction · 0.85
cfexistFunction · 0.85
mn3_OpenFunction · 0.85
SetFunctionModeFunction · 0.85
LoadMissionLevelFunction · 0.85
AutomapClearVisMapFunction · 0.85
StartLevelFunction · 0.85
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected