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

Function xSGWriteData

src/SB/Core/x/xsavegame.cpp:729–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727}
728
729S32 xSGWriteData(st_XSAVEGAME_DATA* xsgdata, st_XSAVEGAME_WRITECONTEXT* wctxt, char* data,
730 S32 elesiz, S32 n)
731{
732 S32 cnt;
733 S32 is_ok = 1;
734
735 if (xsgdata->stage & 0x40000000)
736 {
737 return 0;
738 }
739 if (elesiz == 0)
740 {
741 return 0;
742 }
743
744 cnt = n * elesiz;
745 if (cnt == 0)
746 {
747 return cnt;
748 }
749
750 if (xsgdata->upd_tally != 0 && xsgdata->totamt + cnt > xsgdata->memsize)
751 {
752 xsgdata->stage |= 0x40000000;
753 return 0;
754 }
755
756 void* mcprc;
757 mcprc = memcpy(xsgdata->buf_curpos, data, cnt);
758 if (mcprc == NULL)
759 {
760 is_ok = 0;
761 }
762 else
763 {
764 xsgdata->buf_curpos += cnt;
765 }
766
767 // I wonder if this was supposed to be a boolean and
768 if (is_ok & xsgdata->upd_tally)
769 {
770 xsgdata->totamt += cnt;
771 if (wctxt != NULL)
772 {
773 st_XSAVEGAME_CLIENT* clt = (st_XSAVEGAME_CLIENT*)wctxt;
774 clt->realamt += cnt;
775 }
776 }
777
778 if (is_ok == 0)
779 {
780 xsgdata->stage |= 0x40000000;
781 return 0;
782 }
783 else
784 {
785 return cnt / elesiz;
786 }

Callers 11

xSER_xsgclt_svproc_verFunction · 0.70
xSER_xsgclt_svproc_cltFunction · 0.70
xSER_xsgclt_svproc_fillFunction · 0.70
xSG_cb_leader_svprocFunction · 0.70
xSG_sv_flipprocFunction · 0.70
xSG_smem_blkopenFunction · 0.70
xSG_smem_blkcloseFunction · 0.70
xSG_smem_cltopenFunction · 0.70
xSG_smem_cltcloseFunction · 0.70
xSGT_SaveProcCBFunction · 0.50
xSGT_SaveProcPrefsCBFunction · 0.50

Calls 1

memcpyFunction · 0.85

Tested by

no test coverage detected