diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bb98ada --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bin +*.dat \ No newline at end of file diff --git a/README.md b/README.md index 1f0eca2..eaa93e7 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ This is a small tool to import [HoloCure](https://kay-yu.itch.io/holocure) save ## Download -TODO +Grab a release from [Releases](https://github.com/DaniruKun/tasukeru/releases) and save it anywhere on your PC. +Pick the executable matching your architecture (note: HoloCure currently only runs on Windows). ## Usage -1. Build a release by running `make` or download a release for your platform from Releases +1. Build a release by running `make` or download a release for your platform from [Releases](https://github.com/DaniruKun/tasukeru/releases) 2. Get the save file from the source PC at `Users\[your username]\AppData\Local\HoloCure\save.dat` and move it to the target PC 3. Play HoloCure **at least once** one the target PC 4. On the target PC, drag and drop the `save.dat` onto `tasukeru-*.exe` diff --git a/main.go b/main.go index 5cf21e0..c808c4c 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( ) const defaultSaveFileName = "save.dat" -const version = "0.1" +const version = "0.2" func check(e error) { if e != nil { @@ -46,6 +46,8 @@ func holoCureSaveFilePath() string { return filepath.Join(dir, "HoloCure", defaultSaveFileName) } +// generally it seems that the start offset will always be the same +// across machines, but safer to find save block dynamically func getSettingsStartEnd(srcDec *[]byte) (start, end int) { for offset, char := range *srcDec { if char == 0x7B && (*srcDec)[offset+1] == 0x20 { @@ -82,8 +84,8 @@ func main() { start, end = getSettingsStartEnd(&srcDec) - srcSettingsJson := srcDec[start : end+1] - fmt.Println("source save:", string(srcSettingsJson)) + srcSaveBlock := srcDec[start : end+1] + fmt.Println("source save:", string(srcSaveBlock)) var targetFilePath string @@ -100,8 +102,15 @@ func main() { start, _ = getSettingsStartEnd(&targetDec) - for i, char := range srcSettingsJson { - targetDec[start+i] = char + // iterate over the source save block and overwrite the dst save block with its data + for i, char := range srcSaveBlock { + targetOffset := start + i + + if targetOffset >= len(targetDec) { + targetDec = append(targetDec, char) + } else { + targetDec[targetOffset] = char + } } fmt.Println("patched save:", string(targetDec)) @@ -114,6 +123,7 @@ func main() { err = os.WriteFile(holoCureSaveFilePath(), []byte(targetEnc), 0644) check(err) fmt.Println("save file imported succesfully!") + prompter.YN("Press Enter to quit", true) } }