retreive gamesave file header info. description must be a buffer of length GAMESAVE_DESCLEN+1 returns true if it's a valid savegame file. false if corrupted somehow
| 417 | // retreive gamesave file header info. description must be a buffer of length GAMESAVE_DESCLEN+1 |
| 418 | // returns true if it's a valid savegame file. false if corrupted somehow |
| 419 | bool GetGameStateInfo(const char *pathname, char *description, int *bm_handle) { |
| 420 | CFILE *fp; |
| 421 | int bitmap; |
| 422 | char desc[GAMESAVE_DESCLEN + 1]; |
| 423 | |
| 424 | fp = cfopen(pathname, "rb"); |
| 425 | if (!fp) |
| 426 | return false; |
| 427 | |
| 428 | if (!cf_ReadBytes((uint8_t *)desc, GAMESAVE_DESCLEN + 1, fp)) { |
| 429 | strcpy(description, TXT_ILLEGALSAVEGAME); |
| 430 | goto savesg_error; |
| 431 | } |
| 432 | |
| 433 | strcpy(description, desc); |
| 434 | |
| 435 | if (bm_handle) { |
| 436 | cf_ReadShort(fp); // skip version. |
| 437 | bitmap = LGSSnapshot(fp); |
| 438 | *bm_handle = bitmap; |
| 439 | } |
| 440 | |
| 441 | cfclose(fp); |
| 442 | return true; |
| 443 | |
| 444 | savesg_error: |
| 445 | cfclose(fp); |
| 446 | return false; |
| 447 | } |
| 448 | |
| 449 | ////////////////////////////////////////////////////////////////////////////// |
| 450 | #define BUILD_XLATE_TABLE(_table, _maxtable, _fn) \ |
no test coverage detected