Moktah Posted August 5, 2018 Share Posted August 5, 2018 if your quest no longer needs to point to a string,you use the command sv_destruct myStringVariable when you no longer need a variableyou can.... let myVariable := 0 and to remove an array you canlet myArray := ar_null SO........what do you do when you no longer want to keep a ref? scn TestCase ref myRef begin gamemode let myRef := player.GetPlayersLastRiddenHorse do some stuff with myRef...now no longer need to keep up with myRefand I want it destroyed/removed/zero'd out so its not in the savegame datacausing extra fluff we don't need I'm thinking I just need to set it to zerolet myRef := 0 but I'm not sure Link to comment Share on other sites More sharing options...
QQuix Posted August 5, 2018 Share Posted August 5, 2018 The answer requires some clarifications: All variable in your script are 4 bytes long. All are saved in the savegame, whether they contain a meaninfull value, zero or some garbage. Some, like ints and floats, contains the value (number) itself (e.g. a conter may contain 0,1,2,3...) Setting them to zero does not reduce savegame size. A string_var contains a pointer to the actual string stored elsewhere in memory. sv_destruct tells the engine (OBSE, in this case) that you dont need that string anymore, therefore the engine will free the memory and will not save that string in the savegame. The 4-byte string_var itself will be saved. An array_var also contains a pointer to the actual array stored elsewhere in memory, but it has a more elaborated internal engine. Arrays are designed/optimized to be used by multiple scripts. In other words, multiple scripts my have string_vars pointing to the same array. It would not be wise for a script to destroy an array, since other scripts may still need it, so there is no ar_destruct. Instead, OBSE keeps track of how may array_vars are pointing to the array. When the count reaches zero, the array data is automatically 'destructed' (memory freed, no savegame space). "let myArray := ..." adds to that count. "let myArray := ar_null" reduces the count. Ref vars contains the FormID of the reference. Like other vars, this 4-byte var is saved in the savegame, whether it contains a FormID or zero. As you see, regarding savegame space, you only have to worry about strings and arrays. Zeroing the other types is pretty much a matter of coding style. (btw, savegame bloating caused by irresponsible use of PlaceAtMe ia a completey different matter). Link to comment Share on other sites More sharing options...
Moktah Posted August 6, 2018 Author Share Posted August 6, 2018 Thanks Q That does indeed clear things up.Much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts