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

Function GetGameStateInfo

Descent3/loadstate.cpp:419–447  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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
419bool 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
444savesg_error:
445 cfclose(fp);
446 return false;
447}
448
449//////////////////////////////////////////////////////////////////////////////
450#define BUILD_XLATE_TABLE(_table, _maxtable, _fn) \

Callers 4

QuickSaveGameFunction · 0.85
SaveGameDialogFunction · 0.85
LoadGameDialogCBFunction · 0.85
LoadGameDialogFunction · 0.85

Calls 5

cfopenFunction · 0.85
cf_ReadBytesFunction · 0.85
cf_ReadShortFunction · 0.85
LGSSnapshotFunction · 0.85
cfcloseFunction · 0.85

Tested by

no test coverage detected