ZDaemon Forum Index ZDaemon
Client/Server DOOM
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[ACS]Global variable/array lose data in some cases

 
Post new topic   Reply to topic    ZDaemon Forum Index -> Implemented Requests
View previous topic :: View next topic  
Author Message
Miami_vice
has entered the game!


Joined: 06 Sep 2008
Location: Lithuania, Vilnius

PostPosted: Thu Sep 17, 2015 9:02 pm    Post subject: [ACS]Global variable/array lose data in some cases Reply with quote

Hello. I'm working on a LOADACS scripts. I'm saving some data into global array like global int 1:list[]; It works fine when players exit maps by a button. But in this case maps are very hard to exit and people die and just vote for another map or by rcon change map. I successfully save data into the array and retrieve data from it, also delete.
But here comes very unexpected thing - data is saved to global array. People vote and change another map. After a load global array doesn't have already written data. It's reset. But it is really needed that an array would hold it.

Can you implement some cvar "sv_globalvars"or smth that upon TRUE would not reset global/world variables/arrays when changing map by a vote or rcon? " a cvar sets global to 0=hexen/zdoom behaviour 1=keep value as long as the server is running"

An example:
Lets say I save troll players nicknames (would be also good IPs) into an array so the script everytime automatically would check all alive players nicknames and if it matches to the ones in the blacklist that player is killed. This works ok with global array, but once the map is reset via console or vote then the global array is reset and doesn't hold anything.
Back to top
View user's profile Send private message
rhinoduck
Potatoes


Joined: 22 Oct 2012

PostPosted: Mon Nov 21, 2016 11:53 pm    Post subject: Reply with quote

Having ACS-accessible storage that would keep its values at least for the life of the server would be invaluable for many reasons; own statistics, rewards, and generally mods that spawn the whole of TNS session for example being several of them. As of now, values in global arrays are lost on any map/round start except when map was successfully exited.

The suggested CVAR that would toggle whether ACS global arrays get erased under certain circumstances (as they were until now) or never seems to be the simplest idea to implement and should be free of side effects.

The only place where the global ACS vars get cleared is in G_InitNew() in g_level.cpp in both current tip of the ZDoom master branch and in ZDaemon 1.06. ZDoom handles this by calling P_ClearACSVars() with a bool flag which signifies if global data should die; ZDaemon 1.06 does not have global arrays so I can't comment on that, but it clears ordinary global variables in the same place.

I did not or cannot check if simply adding a condition based on the CVAR here would affect save games (it doesn't seem like it would in ZDoom; does ZDaemon even care save games?) or demos in any way (should not unless you save and load the data based on a different condition than simply its existence), but I don't think it will or that it will be hard to fix that.
Back to top
View user's profile Send private message
rhinoduck
Potatoes


Joined: 22 Oct 2012

PostPosted: Sun Oct 04, 2020 7:13 pm    Post subject: Reply with quote

The acs_always_preserve_globals CVAR was added in ZDaemon 1.10.14; check the changelog for more information.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ZDaemon Forum Index -> Implemented Requests All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group