Ryan Scorpion
Member
Recently I've been trying to port my game to Xbox One though the UWP export and part of that is saving asynchronously which I've wanted to do anyways.
I followed this article whilst doing this to try and get it to work since I've never done it before and can't find anything else on it when searching:
This mostly works in the fact that it saves & loaded the file fine but for whatever reason in the Asynchronous Event, when loading it will load fine but the Event triggers another two times. To prevent a memory leak, I deleted the buffer used in this scenario meaning that when it tries again, it cannot find the buffer end crashes. Is there away to make it so that the Event only triggers once each time instead of 3 times?
This is my code in the Asynchronous Load/Save Event in a persistent object:
So the first time it runs through, it reads fine but then in the second and third, it will try to access a buffer that was deleted the first time causing the crash. I just don't get why it's running the event that only triggers when the game has finished loading 3 times
I'm probably missing something small but I can't figure it out for the life of me. If any other code is required please let me know. Thanks for reading!
I followed this article whilst doing this to try and get it to work since I've never done it before and can't find anything else on it when searching:
UWP: Asynchronous Saving And Loading When Targeting Xbox One Devices
A number of long-time GML function for saving files work in a synchronous manner, which means they make the game wait while the load or save operation is performed. Therefore, if you use these func...
help.yoyogames.com
This mostly works in the fact that it saves & loaded the file fine but for whatever reason in the Asynchronous Event, when loading it will load fine but the Event triggers another two times. To prevent a memory leak, I deleted the buffer used in this scenario meaning that when it tries again, it cannot find the buffer end crashes. Is there away to make it so that the Event only triggers once each time instead of 3 times?
This is my code in the Asynchronous Load/Save Event in a persistent object:
Code:
var ident = async_load[? "id" ];
var status = async_load[? "status"];
var error = async_load[? "error"];
if (ident == global.saveid)
{
buffer_delete(global.savebuff);
show_debug_message("saved data status " + string(status) + " error " + string(error));
}
else if (ident == global.loadid)
{
var buffstring = buffer_read(global.loadbuff,buffer_string);
ini_open_from_string(buffstring);
show_message("Score: " + string(ini_read_real("Stats", "HighScore", 0)));
ini_close();
buffer_delete(global.loadbuff);
}
I'm probably missing something small but I can't figure it out for the life of me. If any other code is required please let me know. Thanks for reading!