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

Function PltReadFile

Descent3/pilot.cpp:1769–1820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1767void _ReadOldPilotFile(pilot *Pilot, bool keyconfig, bool missiondata);
1768
1769void PltReadFile(pilot *Pilot, bool keyconfig, bool missiondata) {
1770 if (Dedicated_server) {
1771 PltCreateDedicatedServerPilot(Pilot);
1772 return;
1773 }
1774
1775 char filename[_MAX_PATH];
1776 char pfilename[_MAX_FNAME];
1777 CFILE *file;
1778 int filever;
1779
1780 Pilot->get_filename(pfilename);
1781 if (pfilename[0] == 0)
1782 return;
1783
1784 // open and process file
1785 ddio_MakePath(filename, Base_directory, pfilename, NULL);
1786 try {
1787 file = cfopen(filename, "rb");
1788 if (!file)
1789 return;
1790
1791 filever = cf_ReadInt(file);
1792 cfclose(file);
1793 } catch (...) {
1794 mprintf(0, "File exception has occured\n");
1795 Int3();
1796 Error(TXT_MAJORPLTERROR);
1797 return;
1798 }
1799
1800 if (filever >= 0x20) {
1801 // new pilot files!
1802 int ret = Pilot->read(!keyconfig, !missiondata);
1803 switch (ret) {
1804 case PLTR_TOO_NEW:
1805 Error(TXT_PLTFILETOONEW, pfilename);
1806 break;
1807 }
1808
1809 return;
1810 } else {
1811 try {
1812 _ReadOldPilotFile(Pilot, keyconfig, missiondata);
1813 } catch (...) {
1814 mprintf(0, "File exception has occured\n");
1815 Int3();
1816 Error(TXT_MAJORPLTERROR);
1817 return;
1818 }
1819 }
1820}
1821
1822//////////////////////////////////////////////////////////////
1823// returns the filelist of pilots available

Callers 6

InitEditGameSystemsFunction · 0.85
PilotSelectFunction · 0.85
PilotChooseFunction · 0.85
NewPltUpdateFunction · 0.85
MainMenuFunction · 0.85

Calls 9

cfopenFunction · 0.85
cf_ReadIntFunction · 0.85
cfcloseFunction · 0.85
ErrorFunction · 0.85
_ReadOldPilotFileFunction · 0.85
get_filenameMethod · 0.80
ddio_MakePathFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected