| 727 | } |
| 728 | |
| 729 | S32 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 | } |
no test coverage detected