gdquest-demos / godot-demos-2022

Free and open-source Godot demos for learning, with guides and tutorials: 2022 edition.
Other
409 stars 41 forks source link

Load Save workaround: Read as bytes instead of text #13

Closed DeeJayLSP closed 2 years ago

DeeJayLSP commented 2 years ago

If the save file is stored as a binary .res instead of a text .tres, file.get_as_text() will fail and a broken temporary file will be generated.

Reading and storing as a byte array works with both text resources and binary resources.

Please check if the PR fulfills these requirements:

What kind of change does this PR introduce?

It changes the workaround in the load_savegame() function. Instead of reading the file as text, it reads as a byte array.

Does this PR introduce a breaking change?

It only changes the way the temporary save file is read and stored, so no.

New feature or change

What is the current behavior?

Read save file as string, temporarily store it as string.

What is the new behavior?

Read save file as binary, temporarily store it as binary.

Other information:

Since a whole text file is copied and stored as a binary, it will still work as an usual text file.

NathanLovato commented 2 years ago

Thank you very much for the contribution, and please excuse the review delay. I had lost track of the PR. Don't hesitate to ping us if we're that slow to review and merge again in the future.