Skip to content

Commit

Permalink
Move SS4 save writing to writeSS4Save
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed May 23, 2020
1 parent 5357940 commit 594797b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions source/savedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static bool ss4SaveRead = false;

static bool ss2SaveModified = false;
static bool ss3SaveModified = false;
static bool ss4SaveModified = false;
//static bool ss4SaveModified = false;

Handle handle4;
FS_Archive archive4;
Expand All @@ -43,12 +43,6 @@ void commitSaveData(void) {
if (ss3SaveModified) {
archiveCommitSaveData("ss3");
}
if (ss4SaveModified) {
u32 bytesWritten = 0;
FSUSER_OpenFile(&handle4, archive4, fsMakePath(PATH_UTF16, (const void*)UTF8toUTF16(ss4SavePath).data()), FS_OPEN_WRITE, FS_WRITE_FLUSH);
FSFILE_Write(handle4, &bytesWritten, 0, ss4Save, (u32)sizeof(ss4Save), 0);
FSFILE_Close(handle4);
}
}

/*
Expand Down Expand Up @@ -396,12 +390,11 @@ bool foundSS4Save(void) {
void readSS4Save(void) {
if (ss4SaveRead) return;

std::u16string savePath = UTF8toUTF16(ss4SavePath);
u32 bytesRead = 0;

/*FILE* saveData = fopen(ss4SavePath, "rb");
fread(ss4Save, (int)sizeof(ss4Save), 1, saveData);
fclose(saveData);*/

u32 bytesRead = 0;
FSUSER_OpenFile(&handle4, archive4, fsMakePath(PATH_UTF16, (const void*)UTF8toUTF16(ss4SavePath).data()), FS_OPEN_READ, 0);
FSFILE_Read(handle4, &bytesRead, 0, ss4Save, (u32)sizeof(ss4Save));
FSFILE_Close(handle4);
Expand All @@ -419,7 +412,12 @@ void writeSS4Save(void) {
fwrite(ss4Save, (int)sizeof(ss4Save), 1, saveData);
fclose(saveData);*/

ss4SaveModified = true;
u32 bytesWritten = 0;
FSUSER_OpenFile(&handle4, archive4, fsMakePath(PATH_UTF16, (const void*)UTF8toUTF16(ss4SavePath).data()), FS_OPEN_WRITE, FS_WRITE_FLUSH);
FSFILE_Write(handle4, &bytesWritten, 0, ss4Save, (u32)sizeof(ss4Save), 0);
FSFILE_Close(handle4);

//ss4SaveModified = true;
}

void readSS4Character(u16 id) {
Expand Down

0 comments on commit 594797b

Please sign in to comment.