---------------------------------------------------------- PPic_GetPilot Purpose: Given a pilot id, it will return the pilot name of the pilot name. Returns false if it's an invalid pilot id. ----------------------------------------------------------
| 376 | // the pilot name. Returns false if it's an invalid pilot id. |
| 377 | // ---------------------------------------------------------- |
| 378 | bool PPic_GetPilot(uint16_t pilot_id, char *pilot_name, int buffersize) { |
| 379 | if (!PilotPic_init) |
| 380 | return false; |
| 381 | |
| 382 | int oldoffset = cftell(PilotPic_database_index_handle); |
| 383 | |
| 384 | int offset = PPic_GetOffsetByID(pilot_id); |
| 385 | if (offset == -1) |
| 386 | return false; |
| 387 | |
| 388 | // jump to the offset |
| 389 | // ------------------ |
| 390 | cfseek(PilotPic_database_index_handle, offset, SEEK_SET); |
| 391 | if (cfeof(PilotPic_database_index_handle)) { |
| 392 | cfseek(PilotPic_database_index_handle, oldoffset, SEEK_SET); |
| 393 | return false; |
| 394 | } |
| 395 | |
| 396 | // read in the pilot name |
| 397 | // ---------------------- |
| 398 | uint8_t name_size; |
| 399 | name_size = cf_ReadByte(PilotPic_database_index_handle); |
| 400 | if (cfeof(PilotPic_database_index_handle)) { |
| 401 | cfseek(PilotPic_database_index_handle, oldoffset, SEEK_SET); |
| 402 | return false; |
| 403 | } |
| 404 | int toread = std::min<int>(name_size, buffersize - 1); |
| 405 | cf_ReadBytes((uint8_t *)pilot_name, toread, PilotPic_database_index_handle); |
| 406 | pilot_name[toread] = '\0'; |
| 407 | |
| 408 | cfseek(PilotPic_database_index_handle, oldoffset, SEEK_SET); |
| 409 | return true; |
| 410 | } |
| 411 | |
| 412 | // ---------------------------------------------------------- |
| 413 | // PPic_GetBitmapHandle |
nothing calls this directly
no test coverage detected