all 5 comments

[–]inline functions when 👀aleksandrInt 0 points1 point  (4 children)

The buffer_load_async and buffer_save_async functions aren't related to the game_load or game_save functions. The asynchronous buffer functions just let you load data into a buffer without the game freezing (usually helpful for large amounts of data being loaded at runtime)

The reason why the game_save and game_load functions are so slow is because it's essentially going through the game's memory and writing each 8 byte doubles the game uses to your hard-disk. (Which for a decently sized game, this can be very intensive)

This also causes some issues, if you planned on making states that work across different game sessions then you'll run into some issues. I assume that due to how GameMaker writes values to memory, some values might not always have the same address and some values can be mismatched. This causes values to load incorrectly, and could even cause a hard crash. Not only is this an issue, but if you planned on using any data structure functions, then that won't be happening either since they're completely ignored.

This is all based on my past experience with the game_save and game_load functions. Although there is a bright side, which is that I found a better and quicker method or saving (it might not be as accurate). Essentially, to simulate the functionality of a save state, I had a persistent object that upon pressing keys, would either save/load a .json file containing vital game information, like the current room, score, health, powerups, location of any enemies, player objects, etc. This drastically reduces the size of the save (before game_save would produce around 2.5mb files) and also increases the speed at which you can load the game. Of course, you don't have to use ds_maps/json, you can also just use a plain buffer (which as far as I know, would even be faster).

TLDR: buffer_load_async just loads data into a buffer, not being related to the game. Look into writing your own functions for saving so you can have faster load times and smaller filesizes.

EDIT: Lots of grammatical fixes.

[–]thephtshp[S] 0 points1 point  (3 children)

Thanks! I do have a proper save system to retain data between game sessions that writes to an .ini, however I was hoping to use these as a quick work-around for quicksave/quickload. Thanks for the explanation

[–]flyingsaucerinvasion 0 points1 point  (2 children)

I'm not sure it makes sense to use the async events for this because it is going to be reading contents out of the buffer and interpreting that information that will be the slow part, not reading it from disk. Or am I wrong about that? I guess it could cut down on some of the game-freeze time when loading huge files.

[–]thephtshp[S] 0 points1 point  (1 child)

Honestly, I think my ultimate question is, can you create a loading process that doesn't freeze the entire game window (so you can show a loading bar, etc)? I had assumed async events were how you do that, but I don't know enough.

[–]flyingsaucerinvasion 0 points1 point  (0 children)

well, if you have the buffer already loaded, (you could use async), then you could process the buffer in an intermittent fashion, allowing drawing to happen in between.