mirror of https://github.com/sm64pc/sm64pc.git
add sanity checks in save_file.c
though it would be a better idea to solve the problem that leads to -1 being passed to these instead
This commit is contained in:
parent
97be18f11d
commit
fde15809b7
|
@ -342,6 +342,9 @@ static void save_file_bswap(struct SaveBuffer *buf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_file_do_save(s32 fileIndex) {
|
void save_file_do_save(s32 fileIndex) {
|
||||||
|
if (fileIndex < 0 || fileIndex >= NUM_SAVE_FILES)
|
||||||
|
return;
|
||||||
|
|
||||||
if (gSaveFileModified)
|
if (gSaveFileModified)
|
||||||
#ifdef TEXTSAVES
|
#ifdef TEXTSAVES
|
||||||
{
|
{
|
||||||
|
@ -370,6 +373,9 @@ void save_file_do_save(s32 fileIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_file_erase(s32 fileIndex) {
|
void save_file_erase(s32 fileIndex) {
|
||||||
|
if (fileIndex < 0 || fileIndex >= NUM_SAVE_FILES)
|
||||||
|
return;
|
||||||
|
|
||||||
touch_high_score_ages(fileIndex);
|
touch_high_score_ages(fileIndex);
|
||||||
bzero(&gSaveBuffer.files[fileIndex][0], sizeof(gSaveBuffer.files[fileIndex][0]));
|
bzero(&gSaveBuffer.files[fileIndex][0], sizeof(gSaveBuffer.files[fileIndex][0]));
|
||||||
|
|
||||||
|
@ -379,7 +385,8 @@ void save_file_erase(s32 fileIndex) {
|
||||||
|
|
||||||
//! Needs to be s32 to match on -O2, despite no return value.
|
//! Needs to be s32 to match on -O2, despite no return value.
|
||||||
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
|
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
|
||||||
UNUSED s32 pad;
|
if (srcFileIndex < 0 || srcFileIndex >= NUM_SAVE_FILES || destFileIndex < 0 || destFileIndex >= NUM_SAVE_FILES)
|
||||||
|
return;
|
||||||
|
|
||||||
touch_high_score_ages(destFileIndex);
|
touch_high_score_ages(destFileIndex);
|
||||||
bcopy(&gSaveBuffer.files[srcFileIndex][0], &gSaveBuffer.files[destFileIndex][0],
|
bcopy(&gSaveBuffer.files[srcFileIndex][0], &gSaveBuffer.files[destFileIndex][0],
|
||||||
|
|
Loading…
Reference in New Issue