-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
game: auto-save pc-settings to user's home directory as well as memcard files #1233
Conversation
In the stacktrace, we can see R8 is zero. R8 is loaded with the value of |
So that explains the problem, but how does it make sense that And inside I am fairly certain this is the entrypoint of the crash, but ill have to triple check something else isn't happening first... Is there something else im misunderstanding? |
The build order is not the same as the load order. The DGO description files have the list of files in the order they are loaded. |
ah! kk ill look into that, didnt know about those. Thanks |
4aecd77
to
0cdb0b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just a few questions (nothing that needs changing if you don't want). It's probably a good idea to have @ManDude look over some of the pckernel/memory card saving stuff, but it all looks good to me.
// the project path should be explicitly provided by whatever if needed | ||
// TEMP HACK | ||
// - if the provided path is absolute, don't add the project path | ||
if (input.size() == 1 && std::filesystem::path(input.at(0)).is_absolute()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make this a different function, instead of having it do different things with absolute and relative paths?
I'm not opposed to this (it makes sense to let absolute paths be absolute paths), but I'm just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the main reason I had to make this change is this method is used by the file-stream stuff:
jak-project/game/sce/sif_ee.cpp
Lines 100 to 102 in da00b1f
s32 sceOpen(const char* filename, s32 flag) { | |
FILE* fp = nullptr; | |
auto name = file_util::get_file_path({filename}); |
I think long-term yeah we probably want a more explicit function like get_project_file_path
and that function linked above should not be assuming everything is within the project directory. I think we can do a lot of cleanup / simplification, but im not sure how much we want to do immediately.
"/BASCUS-97124AYBABTU!", "/BASCUS-97124AYBABTU!/icon.sys", | ||
"/BASCUS-97124AYBABTU!/icon.ico", "/BASCUS-97124AYBABTU!/BASCUS-97124AYBABTU!", | ||
"/BASCUS-97124AYBABTU!/bank0.bin", "/BASCUS-97124AYBABTU!/bank1.bin", | ||
"/BASCUS-97124AYBABTU!/bank2.bin", "/BASCUS-97124AYBABTU!/bank3.bin", | ||
"/BASCUS-97124AYBABTU!/bank4.bin", "/BASCUS-97124AYBABTU!/bank5.bin", | ||
"/BASCUS-97124AYBABTU!/bank6.bin", "/BASCUS-97124AYBABTU!/bank7.bin"}; | ||
"BASCUS-97124AYBABTU!", "BASCUS-97124AYBABTU!/icon.sys", | ||
"BASCUS-97124AYBABTU!/icon.ico", "BASCUS-97124AYBABTU!/BASCUS-97124AYBABTU!", | ||
"BASCUS-97124AYBABTU!/bank0.bin", "BASCUS-97124AYBABTU!/bank1.bin", | ||
"BASCUS-97124AYBABTU!/bank2.bin", "BASCUS-97124AYBABTU!/bank3.bin", | ||
"BASCUS-97124AYBABTU!/bank4.bin", "BASCUS-97124AYBABTU!/bank5.bin", | ||
"BASCUS-97124AYBABTU!/bank6.bin", "BASCUS-97124AYBABTU!/bank7.bin"}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the leading backslash cause issues? Don't really think it's a big deal to change these strings, but it would be nice if our filepath stuff could handle redundant slashes properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When being combined with std::filesystem
it's a problem because you end up with a path with two slashes. String concatenation of course avoids this (i think that's how the old code worked). We could add extra code and steps to handle duplicate slashes but, we should probably just be constructing paths correctly and not have to go through another abstraction layer.
(define *pc-temp-string-1* (new 'global 'string 2048 (the-as string #f))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't use the other *pc-temp-string*
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I use it to construct a string that is passed to a function that then uses *pc-temp-string*
(i make the filepath that is passed to the read/write function). I could be wrong and there is a better way? but, one of the problems with depending on these global variables to do things :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, it's fine then
goal_src/pc/pckernel.gc
Outdated
(clear *pc-temp-string-1*) | ||
(format *pc-temp-string-1* "~S/pc-settings.gc" *pc-settings-folder*) | ||
(write-to-file obj *pc-temp-string-1*) | ||
(clear *pc-temp-string-1*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at the string-format
macro in gstring.gc
, it simplifies doing this. You can make an alternate version of it that uses that string instead of the usual *temp-string*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell it only really saves on the calls to clear
? I'd rather just keeps things explicit, it's not obvious that macro uses a particular global (from the caller) and the pattern seems unsustainable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would have to just write (write-to-file obj (pc-string-format "~S/pc-settings.gc" *pc-settings-folder*))
instead of those 4 lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that it saves lines, that isn't what I'm opinionated against.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the global only exists to be used a temporary string in the first place, so I don't think there's an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone could get into the same issue I did and it wouldn't be obvious -- they call a function using the output of pc-string-format
and within the function it also uses pc-string-format
. It's not obvious what's going on unless you expand the macro. I just prefer to be more explicit.
(return obj) | ||
(begin | ||
(format 0 "[PC] PC Settings found at '~S' but could not be loaded, re-creating with defaults!~%" *pc-temp-string-1*) | ||
(reset obj)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm yes that function should probably be altered to not overwrite the settings in case an error occurred, I'll have to fix that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think resetting the settings back to defaults when they are not valid is sensible -- we aren't wiping save-file data or something important. It's better imo than crashing.
goal_src/pc/pckernel.gc
Outdated
;; persist reset / new settings if we made it this far | ||
(pc-mkdir-path *pc-temp-string-1*) | ||
(commit-to-file obj) | ||
(clear *pc-temp-string-1*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this - is it just writing the settings after they've been reset? Probably not super useful (reading the default file and not reading a file at all is the exact same thing), and personally I'd rather it not write things at start-up in case things go wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
This will automatically load the user's pc-settings if it is available from
$HOME/OpenGOAL/jak1/settings/pc-settings.gc
. If it's not there or it cannot be loaded, the defaults will be saved and used instead.This also saves memcard files to
$HOME/OpenGOAL/jak1/saves/*
Fixed this issue, leaving the write up here
There's one remaining issue here that im aware of:
If i set the game's aspect-ratio during boot as part of the pc-setting's load routine, i get a crash. If i run the same code later when the game is fully running, it's fine and works as expected. The current code sets it as part of the
setting-control
defaults, but these two files are tightly coupled when trying to load thepc-settings
at boot as well, one has to come before the other:*setting-control*
to be initialized so it can fix the hud layout (atleast for now)This is how the original game changes the aspect ratio in the progress menu -
jak-project/goal_src/engine/ui/progress/progress.gc
Lines 1643 to 1645 in b2131d4
For clarification, im talking about running just this line at boot time, you can even add them to the bottom of
settings.gc
to reproduce:I can think of hack workarounds to skip things during the setup of the
pc-settings
global, but it feels like the better solution is to figure out why its crashing only at boot time.The current stacktrace isnt very good since this is all triggered from top-level code