| 1767 | void _ReadOldPilotFile(pilot *Pilot, bool keyconfig, bool missiondata); |
| 1768 | |
| 1769 | void 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 |
no test coverage detected