global property persistence in savegames

For AI and campaign script related discussions and questions
Post Reply
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

global property persistence in savegames

Post by aubergine »

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?)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: global property persistence in savegames

Post by Duha »

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?)
Saves is humanreadble text.
http://addons.wz2100.net/ developer
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: global property persistence in savegames

Post by Per »

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.
Post Reply