Game_load, slowly increasing nexus usage

Posted By: jumpman

Game_load, slowly increasing nexus usage - 10/11/17 02:52

Hello!

Im playing around with game_save and game_load. Everytime I save the game with:

game_save("test_save",1,SV_FUNCTIONS+SV_LEVEL);

and load the game with:

game_load("test_save",1);

My nexus usage goes up every load, and eventually I get the "nexus too small" error. What could cause nexus memory to increase every load??
Posted By: jumpman

Re: Game_load, slowly increasing nexus usage - 10/11/17 03:07

the SV_LEVEL is increasing my nexus usage each load. Why do you think that is?
Posted By: MasterQ32

Re: Game_load, slowly increasing nexus usage - 10/11/17 06:33

are you creating/deleting a lot of entities?
Posted By: jumpman

Re: Game_load, slowly increasing nexus usage - 10/11/17 16:14

I was creating alot of entities, throwing them up in the air, saving, and reloading. The game would load correctly, and the objects would load in the air and drop, but the nexus would slightly increase on every load.

I have then tried loading a NULL level then game_load the save file, which kind of helped, but loading the save file increased the nexus usage anyway.

After some testing, I have found 1 culprit, which was PSSM shadows. When i pssm_run(0); correctly, and waited 1 frame before reactivating them, the nexus nor the sys_memory increased. Nothing was being incremented laugh

However, my next questions pertain to what are good practices concerning where to perform game_save and game_load. Currently, I am doing game_save and load through panel buttons! Its not advised in the manual, without a wait before hand. Do you do game_save and load through startup_ loops?

SV_VARS seems to balloon my sav file from just a couple kilobytes to 20 megs! What does SV_VARS save exactly?
Posted By: Kartoffel

Re: Game_load, slowly increasing nexus usage - 10/11/17 16:21

I think it's a good idea to write your own loading / saving function. That way you have more control over what's being stored and how it should be saved or loaded. This can be a bit tricky and time consuming, though smirk
Posted By: jumpman

Re: Game_load, slowly increasing nexus usage - 10/11/17 18:10

How do you do your saving and loading kartoffel?

In the manual it says: A single var is 4 bytes. So if i did this:

var Max_Nodes[999999];

Its 4 bytes multiplied by 999999, which gives me 3999996 bytes, which equates to 3.999996 megs. So this single array currently would take up 4 megs of space/memory.

So if I use SV_VARS, it will save every array, and I have multiples of these huge arrays. Is this the reason why my .sav file is 20 megs?

I have 60 of these huge empty arrays. If each of them is 4 megs, the total should be 244 megs. Why isnt the .sav file over 244 megs?
Posted By: Kartoffel

Re: Game_load, slowly increasing nexus usage - 10/12/17 13:55

I don't know how the engine decides what to save, so I can't help you with that. If I had to write my own function I'd start by deciding what data I want to save, in what order and so on. Storing it in a file is basically just binary writing / reading. You could add some level of encryption & file integrity checking to prevent people from easily fiddling around with savegames aswell.
Posted By: jumpman

Re: Game_load, slowly increasing nexus usage - 10/12/17 14:43

Hi Kartoffel!

Do you write them into txt files? I was able to do that once.

Currently, I have the save and load working so far, but as you know, once you declare something working, it will crash soon after laugh If you'd like to know how I got it working so far, I can let you know if you'd like, incase you want to use the native save/load system.
Posted By: Dooley

Re: Game_load, slowly increasing nexus usage - 10/13/17 03:38

I am using file_var_write and file_var_read to save, then load data from a .txt file. You will also need file_open_write, file_open_append and file_open_read to get these things working.

It is complex and tricky to set up, but I was unable to get around the problems caused by Game_save and Game_load ... well worth the trouble.
Posted By: jumpman

Re: Game_load, slowly increasing nexus usage - 10/13/17 19:04

what problems did you run into using game_save and game_load dooley? Im assuming your txt file load system wont save the actual game state, but it will save the relevant information at certain checkpoints?
© 2024 lite-C Forums