lud99 / botw-unexplored

Easily view the unexplored korok seeds and locations in your BotW savefile on your Switch
102 stars 2 forks source link

Fails to load save file if game is running #4

Closed lud99 closed 3 years ago

lud99 commented 3 years ago

Haven’t experienced it myself, but someone else has. I believe it works if the game is running, but not if a save file has been loaded.

lud99 commented 3 years ago

Sadly it's impossible for homebrew to read saves from a game while it is running. I have however found a solution that works in this case. Whenever the app successfully load a save, it copies it to a folder on the sd card. The next time the app is opened, if BotW is running it instead loads the 'backup' save. This means it's now possible to look at the app while you play the game!

d4mation commented 3 years ago

So, I haven't tried this/looked into this much myself. However, maybe this could be remediated by using fsdevMountSaveDataReadOnly instead of fsdevMountSaveData?

It may be due to you asking for write access to the file by not mounting it as read-only.

https://github.com/switchbrew/libnx/blob/076657fd31862170d98d198f657cecc935ecec90/nx/source/runtime/devices/fs_dev.c#L458-L482

Edit: Using that function means only supporting Horizon 2.0.0+. But I'm not sure how important supporting 1.x is to you.

lud99 commented 3 years ago

I just went ahead and tried it but it unfortunately still won't mount. But thanks for the suggestion, I really appreciate it! Other apps that access game saves, like Checkpoint and EdiZon, also fails to read saves if a game is running, so I'm afraid the fix I've implemented is the best we're going to get.

d4mation commented 3 years ago

Other apps that access game saves, like Checkpoint and EdiZon, also fails to read saves if a game is running,

Bummer. I tried looking at the source of Checkpoint specifically for this yesterday to see if they were somehow managing it, but I couldn't figure out where it actually loaded the saves 🤐

It looks like Edizon is directly calling fopen() as read-only on the save files rather than using libnx, but it sounds like that doesn't work with games that are currently running anyway.

Thanks for trying anyway! The only other thing I can think of is somehow reusing the file handle that the game is currently using, but that could cause its own slew of problems lol.

lud99 commented 3 years ago

reusing the file handle that the game is currently using 👀 sounds like it could be worth a shot! But how would something like that even work. Do you know any other apps that have done this or know what part of the libnx docs to look at?

d4mation commented 3 years ago

I'm not aware of any apps that do this or what docs to look at to accomplish this :/

It may be something someone in the ReSwitched Discord could know about, but it may not be normally possible without a sysmodule in place to MITM the save file or something.

lud99 commented 3 years ago

Aww that's a bummer, then that's way out of scope for this app.

On an unrelated note, would you mind testing out the next release of the app so I can make sure it works for other people? I have added a lot of new features, like a lot, and I'd really appriciate it if you could test it and just tell me if something feels off. I can send an .nro here if you're interested!

d4mation commented 3 years ago

Yeah, I've been checking out the commits and you've added a lot!

If you're cool with providing me a pre-compiled .nro I'll try to find some time to try it out this weekend.

lud99 commented 3 years ago

Here you go! Some quick notes:

d4mation commented 3 years ago

Everything seems to work great! I was really surprised by how fluid switching between Normal and Master Mode was. I figured that'd be buried under a menu or something.

My only nitpicks are:

  1. The text doesn't wrap very cleanly in the Korok descriptions. If it broke at word boundaries that'd be nicer.
  2. The "Korok Paths" where you follow a trail of flowers have choppy looking lines. Mine were like this originally too until I changed how I was drawing them.

2020120508141600-DB1426D1DFD034027CECDE9C2DD914B8

lud99 commented 3 years ago

I first had a dialog popup asking you if you'd like to load your master mode save, but it was super obnoxious and inconvinient so I made less intrusive .

The word wrapping is something I planned on adding, but I hade some difficulties, but I do agree it's kinda hard to read. Regarding the lines, how did you go about making them more connected? It's sadly not as easy as using svg tags for me as I'm using OpenGL. I actually had to take out a pen and paper and do some trigonometry to be able to figure out how to draw them. I just made a change to reduce the line width so it's not as visible anymore, but It's not really fixed. Unless you know a easy fix, then I probably won't bother to make it nicer as I believe it would be too difficult.

d4mation commented 3 years ago

Unfortunately, I don't know a fix in OpenGL :/ SVG is certainly easier in this case, lol.

It seems that this is a well known issue in OpenGL and people say to either ignore it or jump through some hoops by either drawing the lines as triangles arranged so that they look like a line or to write your own shader.

https://stackoverflow.com/questions/60440682/drawing-a-line-in-modern-opengl https://blog.mapbox.com/drawing-antialiased-lines-with-opengl-8766f34192dc https://gamedev.stackexchange.com/a/177615