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?)
global property persistence in savegames
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
global property persistence in savegames
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
-
Duha
- Trained

- Posts: 287
- Joined: 25 Mar 2012, 20:05
- Location: SPb, Russia
Re: global property persistence in savegames
Saves is humanreadble text.aubergine wrote: 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?)
http://addons.wz2100.net/ developer
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: global property persistence in savegames
Don't know. There is only one way to find out.
PS Please do not put "@name" in the topic. That is kinda annoying and defeats the purpose of this being a forum, I think.
PS Please do not put "@name" in the topic. That is kinda annoying and defeats the purpose of this being a forum, I think.