Skip to content

Commit

Permalink
Merge crc fix and small fix
Browse files Browse the repository at this point in the history
upstream into a topic branch.
  • Loading branch information
3096 committed Oct 14, 2018
2 parents 638ec5f + 5fba8f5 commit 75c09d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif

TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules

Expand Down
8 changes: 8 additions & 0 deletions source/SaveDataFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ SaveDataFactory::SaveDataFactory(const std::string save_inPath) {
this->~SaveDataFactory();
throw e;
}

// in case crc is not fixed
updateCRC();
}

SaveDataFactory::~SaveDataFactory() {
Expand Down Expand Up @@ -237,6 +240,11 @@ void SaveDataFactory::decode() {
}
}

void SaveDataFactory::updateCRC() {
*(uint32_t*)&m_saveData[0x8] =
crc32(0L, &m_saveData[HEADER_SIZE], m_bodySize);
}

void SaveDataFactory::shuffle() {
uint8_t* tmpBodyUnshuffled = new uint8_t[m_bodySize];
std::memcpy(tmpBodyUnshuffled, m_saveBody_encoded, m_bodySize);
Expand Down
1 change: 1 addition & 0 deletions source/SaveDataFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SaveDataFactory {
void encode();
void decode();
int randBytes(uint8_t* output, const size_t output_len);
void updateCRC();

// save shuffle
typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ int main(int argc, char const* argv[]) {
#endif

return ret;
}
}

0 comments on commit 75c09d6

Please sign in to comment.