global property persistence in savegames
Posted: 02 Dec 2012, 02:38
I was looking through the C++ code the other day and from what I can tell, the JS API works out which global object properties not to save as follows:
* During environment initialisation, WZ puts all its functions, constants, etc., on global object
* After environment is initialised, a list is compiled of everything that lives on global object = stuff not to persist
* 'me' global is then added, it will get saved (desired behaviour) because it's not in list mentioned above
* When game is saved, WZ filters out the following:
** Stuff in the list compiled above is not persisted
** Stuff that is of type "function" is not persisted
** Constants in the global scope are not persisted
* All un-filtered vars and properties of the global object and scope are saved?
I was wondering what happens if I add a non-enumerable, non-configurable, non-writable property to the global object (using Object.defineProperty) - will that get persisted to the save game or not? (I hope not... If it does, can it be made not to?)
* During environment initialisation, WZ puts all its functions, constants, etc., on global object
* After environment is initialised, a list is compiled of everything that lives on global object = stuff not to persist
* 'me' global is then added, it will get saved (desired behaviour) because it's not in list mentioned above
* When game is saved, WZ filters out the following:
** Stuff in the list compiled above is not persisted
** Stuff that is of type "function" is not persisted
** Constants in the global scope are not persisted
* All un-filtered vars and properties of the global object and scope are saved?
I was wondering what happens if I add a non-enumerable, non-configurable, non-writable property to the global object (using Object.defineProperty) - will that get persisted to the save game or not? (I hope not... If it does, can it be made not to?)