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

Function PPic_FindNext

Descent3/PilotPicsAPI.cpp:320–360  ·  view source on GitHub ↗

---------------------------------------------------------- PPic_FindNext Purpose: Call repeatedly until false is returned to get information about all the pilots that match pilot_name passed into an initial call to PPic_FindFirst(). It returns the pilot id. ----------------------------------------------------------

Source from the content-addressed store, hash-verified

318// pilot id.
319// ----------------------------------------------------------
320bool PPic_FindNext(uint16_t *pilot_id) {
321 if (!PilotPic_init)
322 return false;
323
324 *pilot_id = 65535;
325
326 char name_buffer[PILOT_STRING_SIZE];
327 CFILE *file = PilotPic_database_index_handle;
328
329 cfseek(file, PilotPic_find_offset, SEEK_SET);
330 if (cfeof(file)) {
331 return false;
332 }
333
334 // first read in the pilot name
335 uint8_t name_size;
336 name_size = cf_ReadByte(file);
337 if (cfeof(file)) {
338 return false;
339 }
340 cf_ReadBytes((uint8_t *)name_buffer, name_size, file);
341 name_buffer[name_size] = '\0';
342
343 // next read in pilot_id
344 uint16_t pid;
345 pid = (uint16_t)cf_ReadShort(file);
346
347 // next read past the bitmap name
348 uint8_t bmp_size;
349 bmp_size = cf_ReadByte(file);
350 cfseek(file, bmp_size, SEEK_CUR);
351
352 if (stricmp(name_buffer, PilotPic_find_name)) {
353 return false; // we're done
354 }
355
356 *pilot_id = pid;
357 PilotPic_find_offset = cftell(file);
358
359 return true;
360}
361
362// ----------------------------------------------------------
363// PPic_FindClose

Callers 1

ShowPilotPicDialogFunction · 0.85

Calls 6

cfseekFunction · 0.85
cfeofFunction · 0.85
cf_ReadByteFunction · 0.85
cf_ReadBytesFunction · 0.85
cf_ReadShortFunction · 0.85
cftellFunction · 0.85

Tested by

no test coverage detected