This function reads in the data from file (from the filename associated) into the pilot data.
| 507 | // This function reads in the data from file (from the filename associated) |
| 508 | // into the pilot data. |
| 509 | int pilot::read(bool skip_config, bool skip_mission_data) { |
| 510 | if (!filename) { |
| 511 | Int3(); |
| 512 | return PLTR_NO_FILENAME; // no filename was given |
| 513 | } |
| 514 | |
| 515 | CFILE *file; |
| 516 | char real_filename[_MAX_PATH]; |
| 517 | |
| 518 | // open and process file |
| 519 | ddio_MakePath(real_filename, Base_directory, filename, NULL); |
| 520 | |
| 521 | if (!cfexist(real_filename)) { |
| 522 | // the file already exists, we can't write out |
| 523 | mprintf(0, "PLTR: File (%s) does not exist\n", real_filename); |
| 524 | return PLTR_FILE_NOEXIST; |
| 525 | } |
| 526 | |
| 527 | try { |
| 528 | file = cfopen(real_filename, "rb"); |
| 529 | if (!file) { |
| 530 | mprintf(0, "PLTR: File (%s) can't be opened\n", real_filename); |
| 531 | return PLTR_FILE_CANTOPEN; |
| 532 | } |
| 533 | |
| 534 | // Write out our fileversion |
| 535 | file_version = cf_ReadInt(file); |
| 536 | |
| 537 | if (file_version > PLT_FILE_VERSION) { |
| 538 | // too new!! |
| 539 | cfclose(file); |
| 540 | return PLTR_TOO_NEW; |
| 541 | } |
| 542 | |
| 543 | ////////////////////////////////////////////// |
| 544 | read_name(file, false); |
| 545 | read_ship_info(file, false); |
| 546 | read_custom_multiplayer_data(file, false); |
| 547 | read_difficulty(file, false); |
| 548 | if (file_version >= PFV_PROFANITY) { |
| 549 | read_profanity_filter(file, false); |
| 550 | } |
| 551 | if (file_version >= PFV_AUDIOTAUNTS) { |
| 552 | read_audiotaunts(file, false); |
| 553 | } |
| 554 | |
| 555 | read_hud_data(file, false); |
| 556 | read_mission_data(file, skip_mission_data); |
| 557 | read_taunts(file, false); |
| 558 | |
| 559 | if (file_version >= PFV_WEAPONSELECT) { |
| 560 | read_weapon_select(file); |
| 561 | } |
| 562 | |
| 563 | if (file_version >= PFV_GAMETOGGLES) { |
| 564 | read_gameplay_toggles(file, false); |
| 565 | } |
| 566 |
no test coverage detected