EvilTurtleProductions Posted June 14, 2022 Share Posted June 14, 2022 I noticed something interesting: if our game crashes, after saving the player stats to a file and having finished this, the save file is empty. The bit of code below is the stats saving, wrapping up some gameplay-related things and then clearing the procedurally generated level. Sometimes the game crashes when clearing the level, which is way after the stats file has been saved. Yet the file is empty. Stream* statsfilestream = FileSystem::WriteFile("playerstats.sav"); if (statsfilestream) { System::Print("Saving player stats: " + std::to_string(playerstats_local.XP) + ", " + std::to_string(playerstats_local.level) + ", " + std::to_string(playerstats_local.money)); statsfilestream->WriteInt(playerstats_local.XP); statsfilestream->WriteInt(playerstats_local.level); statsfilestream->WriteInt(playerstats_local.money); statsfilestream->WriteInt(playerstats_local.logs); statsfilestream->Release(); } //SOME EXTRA BITS AND BOBS OF CODE HERE //SUCH AS UPDATING INGAME MISSION SCREENS AND PLAYING VOICE ACTING SOUNDS //clear level ClearLevel(); Quote Link to comment Share on other sites More sharing options...
Josh Posted June 14, 2022 Share Posted June 14, 2022 The OS probably has a memory buffer that writes to the steam when a certain threshold size is reached, or when the file handle is closed. This would allow it to write a big block at once, instead of writing bytes in the same chunks you are writing them in. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted June 14, 2022 Share Posted June 14, 2022 If your game is crashing, you have bigger problems to sort out imo. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
EvilTurtleProductions Posted June 14, 2022 Author Share Posted June 14, 2022 2 hours ago, reepblue said: If your game is crashing, you have bigger problems to sort out imo. Haha, obviously the focus is on those Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.