MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / zSaveLoad_DoAutoSave

Function zSaveLoad_DoAutoSave

src/SB/Game/zSaveLoad.cpp:1718–1830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1716}
1717
1718S32 zSaveLoad_DoAutoSave()
1719{
1720 S32 success = 0;
1721 S32 teststat = 1;
1722 en_XSGASYNC_STATUS asstat = XSG_ASTAT_NOOP;
1723 st_XSAVEGAME_DATA* svinst;
1724
1725 XSGAutoData* autodata = xSGAutoSave_GetCache();
1726 if (autodata == NULL)
1727 {
1728 return -1;
1729 }
1730 if (!autodata->IsValid())
1731 {
1732 return -1;
1733 }
1734
1735 S32 use_tgt = CardtoTgt(autodata->LastTarget());
1736 S32 lastGame = autodata->LastGame();
1737 autodata->Discard();
1738 svinst = xSGInit(XSG_MODE_SAVE);
1739 xSGTgtSelect(svinst, use_tgt);
1740 xSGGameSet(svinst, lastGame);
1741
1742 if (svinst == NULL)
1743 {
1744 teststat = 0;
1745 }
1746
1747 zSceneSave(globals.sceneCur, 0);
1748
1749 xSGAddSaveClient(svinst, 'ROOM', 0, xSGT_SaveInfoCB, xSGT_SaveProcCB);
1750 xSGAddSaveClient(svinst, 'PREF', 0, xSGT_SaveInfoPrefsCB, xSGT_SaveProcPrefsCB);
1751
1752 xSerial_svgame_register(svinst, XSG_MODE_SAVE);
1753 U32 progress = zSceneCalcProgress();
1754
1755 const char* area;
1756 if (globals.sceneCur->sceneID == 'PG12')
1757 {
1758 area = zSceneGetLevelName('HB01');
1759 }
1760 else
1761 {
1762 area = zSceneGetLevelName(globals.sceneCur->sceneID);
1763 }
1764
1765 char label[64];
1766 strncpy(label, area, sizeof(label));
1767 if (!xSGSetup(svinst, lastGame, label, progress, 0, zSceneGetLevelIndex()))
1768 {
1769 teststat = 0;
1770 }
1771
1772 if (teststat != 0)
1773 {
1774 S32 iprocess = xSGProcess(svinst);
1775 if (iprocess != 0)

Callers 2

SpatulaGrabStopCBFunction · 0.70
zGameUpdateModeFunction · 0.70

Calls 15

xSGAutoSave_GetCacheFunction · 0.85
xSGGameSetFunction · 0.85
zSceneCalcProgressFunction · 0.85
strncpyFunction · 0.85
zSceneGetLevelIndexFunction · 0.85
xSGGameIsEmptyFunction · 0.85
xSGTgtPhysSlotIdxFunction · 0.85
IsValidMethod · 0.80
LastTargetMethod · 0.80
LastGameMethod · 0.80
SetCacheMethod · 0.80
CardtoTgtFunction · 0.70

Tested by

no test coverage detected