You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been having problems saving and loading data on Android. All of the methods that can be used on PC (Export/Exec, TAMLWrite/TAMLRead, OpenForWrite/OpenForRead) fail on Android. The first one I used, which I use in the PC version of my app, was to export the data I want to save, in this case a High Score, as a pref in a cs file, and then execute this file, if found, the next time the game is run. The file seems to be created just fine, but when the game is run the second time and the file is read, it crashes. It was suggested on the forums that I try creating and exporting a file object using TAMLWrite and TAMLRead. This didn't crash the game, but threw errors to the console and didn't give me my high score data. I then tried using the basic functions for saving and loading data, OpenForWrite, and OpenForRead. It was these functions I chose to focus on when I sought help on the irc. A user named "az" walked me through debugging these functions which is where we found the break. The following are the script functions I'm currently trying to use to save data on Android. Note that I still use a pref internally to track the score, all I've changed are the methods that save and retrieve that information:
This is part of the AppCore::create function run at the start of the game.The first echo reports if the OpenForRead function was called successfully, while the second reports the data that was read.
This is what I use to save the score. This appears to be working correctly (I have verified with a rooted file browser that the file is being created and contains exactly what it's supposed to), but I will include it anyway:
As you can see, the only change is the addition of single line that reports the contents and size of the file buffer. Earlier I had one reporting the path, but this appeared to be correct, so I left it out.
The following is a record of LogCat for two consecutive runs of the game, after an initial run to create the high score file. The first score that was read was 4 digits long, the second was 3 digits:
As you can see, the data in the FileBuffer is incorrect. I did a few more runs reading the same text file and got a different set of seemingly random characters in the FileBuffer each time. az suggested this meant sections of RAM were being read instead of my data.
I am not a programmer, this guided debug was literally the first time I ever touched C++ code, so I can't go any farther with this. I'm hoping someone here who's more experienced with Android and the i/o functions will be able to track this down with the information I've provided.
The text was updated successfully, but these errors were encountered:
I've been having problems saving and loading data on Android. All of the methods that can be used on PC (Export/Exec, TAMLWrite/TAMLRead, OpenForWrite/OpenForRead) fail on Android. The first one I used, which I use in the PC version of my app, was to export the data I want to save, in this case a High Score, as a pref in a cs file, and then execute this file, if found, the next time the game is run. The file seems to be created just fine, but when the game is run the second time and the file is read, it crashes. It was suggested on the forums that I try creating and exporting a file object using TAMLWrite and TAMLRead. This didn't crash the game, but threw errors to the console and didn't give me my high score data. I then tried using the basic functions for saving and loading data, OpenForWrite, and OpenForRead. It was these functions I chose to focus on when I sought help on the irc. A user named "az" walked me through debugging these functions which is where we found the break. The following are the script functions I'm currently trying to use to save data on Android. Note that I still use a pref internally to track the score, all I've changed are the methods that save and retrieve that information:
This is part of the AppCore::create function run at the start of the game.The first echo reports if the OpenForRead function was called successfully, while the second reports the data that was read.
This is what I use to save the score. This appears to be working correctly (I have verified with a rooted file browser that the file is being created and contains exactly what it's supposed to), but I will include it anyway:
All I'm writing is a number.
This is the function in fileObject.cc that I modified at az's suggestion:
As you can see, the only change is the addition of single line that reports the contents and size of the file buffer. Earlier I had one reporting the path, but this appeared to be correct, so I left it out.
The following is a record of LogCat for two consecutive runs of the game, after an initial run to create the high score file. The first score that was read was 4 digits long, the second was 3 digits:
As you can see, the data in the FileBuffer is incorrect. I did a few more runs reading the same text file and got a different set of seemingly random characters in the FileBuffer each time. az suggested this meant sections of RAM were being read instead of my data.
I am not a programmer, this guided debug was literally the first time I ever touched C++ code, so I can't go any farther with this. I'm hoping someone here who's more experienced with Android and the i/o functions will be able to track this down with the information I've provided.
The text was updated successfully, but these errors were encountered: