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

Function _ReadOldPilotFile

Descent3/pilot.cpp:3921–4088  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

3919
3920/////////////////////////////////////////////////////////////////////
3921void _ReadOldPilotFile(pilot *Pilot, bool keyconfig, bool missiondata) {
3922 char filename[_MAX_PATH];
3923 char pfilename[_MAX_FNAME];
3924 char buffer[256];
3925 uint8_t temp_b;
3926 uint16_t temp_s;
3927 int temp_i;
3928 int filever, i, nctlfuncs;
3929
3930 Pilot->get_filename(pfilename);
3931
3932 // open and process file
3933 ddio_MakePath(filename, Base_directory, pfilename, NULL);
3934 CFILE *file = cfopen(filename, "rb");
3935 if (!file)
3936 return;
3937
3938 filever = cf_ReadInt(file);
3939
3940 if (filever < 0x12) {
3941 cfclose(file);
3942 Error(TXT_PLTTOOOLD);
3943 return;
3944 }
3945
3946 if (filever > PLTFILEVERSION) {
3947 // we're reading in a version that's newer than we have
3948 cfclose(file);
3949 Error(TXT_PLTTOONEW, pfilename);
3950 return;
3951 }
3952
3953 Pilot->clean(true);
3954 Pilot->set_filename(pfilename);
3955
3956 cf_ReadString(buffer, PILOT_STRING_SIZE + 1, file);
3957 Pilot->set_name(buffer);
3958
3959 cf_ReadInt(file);
3960 cf_ReadInt(file);
3961
3962 cf_ReadString(buffer, PAGENAME_LEN + 1, file);
3963 Pilot->set_ship(buffer);
3964
3965 cf_ReadString(buffer, PAGENAME_LEN + 1, file);
3966 Pilot->set_multiplayer_data(buffer);
3967
3968 temp_b = cf_ReadByte(file);
3969 Pilot->set_difficulty(temp_b);
3970
3971 // load hud info
3972 temp_b = cf_ReadByte(file);
3973 Pilot->set_hud_data(&temp_b);
3974
3975 temp_s = cf_ReadShort(file);
3976 Pilot->set_hud_data(NULL, &temp_s);
3977
3978 temp_s = cf_ReadShort(file);

Callers 1

PltReadFileFunction · 0.85

Calls 15

cfopenFunction · 0.85
cf_ReadIntFunction · 0.85
cfcloseFunction · 0.85
ErrorFunction · 0.85
cf_ReadStringFunction · 0.85
cf_ReadByteFunction · 0.85
cf_ReadShortFunction · 0.85
cf_ReadFloatFunction · 0.85
cf_ReadBytesFunction · 0.85
get_filenameMethod · 0.80

Tested by

no test coverage detected