Page 1 of 1

Confused about what will / won't break sync

Posted: Sat Jan 18, 2014 8:37 am
by t3hplayer
So I'm confused about what will / won't break multiplayer sync. In particular, there's a warning about the GetCVar function on the ZDoom Wiki:
Warning: This feature has at least one use case where the outcome is indeterminate. This feature can break demo and multiplayer sync if an indeterminate result is used to modify the playsim (anything that uses the random number generator, modify level geometry, spawn obstacles, monsters, or powerups, and so on). Usage of the feature in conjunction with non-playsim related features, such as displaying a HudMessage, is safe.

Using non-playsim CVARs such as screenblocks or invertmouse will cause indeterminate behavior. Using Server or User variables, either internal or defined via CVARINFO, is however perfectly safe.
So, I've got some code which alters some game state stuff based on CVars. I'm just setting these CVars on the server by doing (for example):

Code: Select all

set sf_percentspeed 10
Then I've got a bit of ACS code that reads in this CVar, checks it against a random number, and if the CVar is greater than the random number, we modify the speed of the monster for which the code is being run.

So, I've got a few questions:

1. Do I need to define this CVar some other way? Right now, sf_percentspeed isn't even defined on clients which connect to the server, but is instead only defined on the server.
2. Is this something that will cause sync problems? Is all ACS run both locally (on the client) and remotely (on the server), and the results have to match? Or is that bit of ACS I described only run on the server, and so it won't be a problem?

Thanks!

Edit: As far as I can tell, I should be in the clear, but I wanted a second opinion

RE: Confused about what will / won't break sync

Posted: Sat Jan 18, 2014 9:30 am
by StrikerMan780
If this is for Zandronum, you won't have to worry about Sync.

RE: Confused about what will / won't break sync

Posted: Sat Jan 18, 2014 2:50 pm
by Klofkac
Your sync will break if you call gameplay altering function in clientside script.
About setting CVars, I'd set the CVar to defined value ACS wise if the CVAR does not exist (which is actually hard to check out because undefined CVAR throws 0 in GetCVAR...).
Clients should not need the CVar to be set, because it is currently used by ACS which is by default running serverside.

Uh, I hope you understand what I mean...

RE: Confused about what will / won't break sync

Posted: Sat Jan 18, 2014 7:45 pm
by Ænima
Klofkac wrote: Your sync will break if you call gameplay altering function in clientside script.
About setting CVars, I'd set the CVar to defined value ACS wise if the CVAR does not exist (which is actually hard to check out because undefined CVAR throws 0 in GetCVAR...).
Clients should not need the CVar to be set, because it is currently used by ACS which is by default running serverside.

Uh, I hope you understand what I mean...
Yeah but what are you gonna do when they take our ConsoleCommand() away?

RE: Confused about what will / won't break sync

Posted: Sat Jan 18, 2014 8:08 pm
by Ijon Tichy
t3hplayer wrote: 1. Do I need to define this CVar some other way? Right now, sf_percentspeed isn't even defined on clients which connect to the server, but is instead only defined on the server.
no, and that's normal; serverside cvars shouldn't need to be on the clients, and clientside cvars, unless explicitly coded otherwise, should not affect the server
2. Is this something that will cause sync problems? Is all ACS run both locally (on the client) and remotely (on the server), and the results have to match? Or is that bit of ACS I described only run on the server, and so it won't be a problem?
unless specified otherwise, acs runs on the server
scripts called from clientside scripts will be clientside
using acs_executewithresult to run a clientside script will still have the script be serverside

RE: Confused about what will / won't break sync

Posted: Sun Jan 19, 2014 12:23 am
by t3hplayer
Thanks for the input guys. I had suspected that probably generally the model was that the ACS runs on the server. The part that confused is that Zandronum doesn't have any support for server-side only mods (i.e., just modified ACS that only the server needs a copy of -- any client can connect without a copy). I figured that since clients have to have a copy of the ACS, even if there's no client-side ACS, it was being run on clients as well.

So, is it possible to have a server-side only mod in Zandronum, by modifying only server-side ACS? I think the answer is no, right, since files have to match?

RE: Confused about what will / won't break sync

Posted: Sun Jan 19, 2014 5:54 am
by Ijon Tichy
t3hplayer wrote: The part that confused is that Zandronum doesn't have any support for server-side only mods (i.e., just modified ACS that only the server needs a copy of -- any client can connect without a copy).
there actually is a way to run mods that are only on the server, but the problem is it requires sv_pure to be off, which brings in a whole host of problems, so no one does it

RE: Confused about what will / won't break sync

Posted: Sun Jan 19, 2014 7:34 am
by ZzZombo
Or modified servers.