[ACS] Best way to sync global variables with server and client?
[ACS] Best way to sync global variables with server and client?
I'm having trouble finding an efficient and fool-proof way of syncing the global variables of my mod from server to client. These variables are dynamic, and can change at item pickup, or depending on user action on certain scenarios.
Also, I think we should have a modifier to variables to ensure they get auto-synced to clients. Honestly it confuses me why global variables wouldn't be synced automatically anyway.
Also, I think we should have a modifier to variables to ensure they get auto-synced to clients. Honestly it confuses me why global variables wouldn't be synced automatically anyway.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
- Combinebobnt
- Retired Staff / Community Team Member
- Posts: 1893
- Joined: Mon Jun 04, 2012 3:37 am
- Location: Erth
- Contact:
[ACS] Re: Best way to sync global variables with server and client?
ask the player to say the variable in chat and hire someone who idles on irc all day to type it into the server
SUPERFAST: DUEL DM CTF DOM
Zdoomwars Kosher Maps
Naturemod LMS
[ACS] Re: Best way to sync global variables with server and client?
Idk if i would rely that heavily on clients to tell you the exact values of their variables. Because if they get desync'd, wouldn't that then mess the globals up?
I guess it depends exactly what you're using these variables for.
I guess it depends exactly what you're using these variables for.
Doom64: Unabsolved: New weapons, monsters, and gameplay features for coop !
ZandroSkins: a pack made by our community
Doom64: Unabsolved: New weapons, monsters, and gameplay features for coop !
ZandroSkins: a pack made by our community
[ACS] Re: Best way to sync global variables with server and client?
I'm afraid there's no good solution. If you don't have too many of such variables, you could create a setter function that calls ACS_Execute on a clientside script to sync these variables to clients.
I tried to do that at some point, but it requires a lot of effort. Especially since acc needs to be changed accordingly. Unless we'd only do it on the ACS VM side and let more advanced ACS compilers implement such a keyword.Ivan wrote:Also, I think we should have a modifier to variables to ensure they get auto-synced to clients.
Because that would break existing mods.Ivan wrote:Honestly it confuses me why global variables wouldn't be synced automatically anyway.
[ACS] Re: Best way to sync global variables with server and client?
Dusk wrote:I'm afraid there's no good solution. If you don't have too many of such variables, you could create a setter function that calls ACS_Execute on a clientside script to sync these variables to clients.
I tried to do that at some point, but it requires a lot of effort. Especially since acc needs to be changed accordingly. Unless we'd only do it on the ACS VM side and let more advanced ACS compilers implement such a keyword.Ivan wrote:Also, I think we should have a modifier to variables to ensure they get auto-synced to clients.
Because that would break existing mods.Ivan wrote:Honestly it confuses me why global variables wouldn't be synced automatically anyway.
Code: Select all
typedef struct {
int prosperity_orb_bonus;
int fortitude_orb_bonus;
int hp_flat_bonus;
int armor_flat_bonus;
int hp_percent_bonus;
int armor_percent_bonus;
int greed_percent_bonus;
int wisdom_percent_bonus;
int damage_type_bonus[MAX_TALENTS];
} pstat_T;
global pstat_T 4: Player_Bonuses[MAXPLAYERS];
The reason I need the syncing is because I'm relying on a shit-ton of inventory items to do the syncing right now and it's getting tedious. Also, there are some requirements that force me to not use inventories for syncing anymore. (Using a MaxHealthBonus increase item to increase health capacity of player for example, I can't rely on this anymore because I'll have some things actually reduce the health capacity and I can't take these items away to do that...)
I guess I'll do a huge ass syncing function and hope it works right on clients' end...
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
-
- Retired Staff / Community Team Member
- Posts: 2558
- Joined: Sat Jun 02, 2012 2:44 am
[ACS] Re: Best way to sync global variables with server and client?
If you want a reliable way to guarantee syncing, spawn a dummy server-side actor and set its angle and pitch to the variables you wanna save. Everyone on the player will have to spawn that actor with the correct angle and pitch as well.
So for example, if you wanna store a players "credit", spawn a dummy actor with a TID relative to the player, set its angle = credits, and then it'll be updated for everyone since it's angles and pitches.
So for example, if you wanna store a players "credit", spawn a dummy actor with a TID relative to the player, set its angle = credits, and then it'll be updated for everyone since it's angles and pitches.
[ACS] Re: Best way to sync global variables with server and client?
That's an interesting idea, never thought of that and it makes sense as I used similar things. Damn.Catastrophe wrote:If you want a reliable way to guarantee syncing, spawn a dummy server-side actor and set its angle and pitch to the variables you wanna save. Everyone on the player will have to spawn that actor with the correct angle and pitch as well.
So for example, if you wanna store a players "credit", spawn a dummy actor with a TID relative to the player, set its angle = credits, and then it'll be updated for everyone since it's angles and pitches.
Unfortunately though I just ended up doing what Dusk said and it'll take a lot of time to redo it, but that's good to keep in mind.
=== RAGNAROK DM ON ... uh... dead forever? ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===
=== ALWAYS BET ON ... uh... dead forever? ===
=== Who wanta sum wang? ===
=== Death and Decay - A new Monster/Weapon replacer ===