• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Quick Jass question about SyncSelections()

Status
Not open for further replies.
I haven't tested it out yet, but this is my guess:

The native to select a unit is:
JASS:
native          SelectUnit          takes unit whichUnit, boolean flag returns nothing
Note that it doesn't have a player field.
JASS:
function SelectUnitAddForPlayer takes unit whichUnit, player whichPlayer returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call SelectUnit(whichUnit, true)
    endif
endfunction
Note that the SelectUnit() is within a GetLocalPlayer() block. That means that IsUnitSelected() will likely return true for one player, but will return false for others. That may cause things to go out of sync. e.g. if you group the units selected, the group will contain different units for each player.

I'm guessing SyncSelections() makes it so that those functions will work properly (IsUnitSelected and GroupEnumUnitsSelected).

EDIT: Moved to T&S.
 
That doesn't make sense, by nature, even without any trigger, selections are already local stuff.

EDIT : But meh maybe you're right after all, but then i think it would be better to use a "system" which would use the unit event selected/deselected instead.
 
Last edited:
I haven't tested it out yet, but this is my guess:

The native to select a unit is:
JASS:
native          SelectUnit          takes unit whichUnit, boolean flag returns nothing
Note that it doesn't have a player field.
JASS:
function SelectUnitAddForPlayer takes unit whichUnit, player whichPlayer returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call SelectUnit(whichUnit, true)
    endif
endfunction
Note that the SelectUnit() is within a GetLocalPlayer() block. That means that IsUnitSelected() will likely return true for one player, but will return false for others. That may cause things to go out of sync. e.g. if you group the units selected, the group will contain different units for each player.

I'm guessing SyncSelections() makes it so that those functions will work properly (IsUnitSelected and GroupEnumUnitsSelected).

EDIT: Moved to T&S.

Thanks for the explanation. +Rep

That doesn't make sense, by nature, even without any trigger, selections are already local stuff.

EDIT : But meh maybe you're right after all, but then i think it would be better to use a "system" which would use the unit event selected/deselected instead.

Thanks. What do you mean by using a "system"? Is there such a system?
 
By "system" i mean a code which use the select/deselect events and then have custom functions instead of the native ones (IsUnitSelected, GroupEnumUnitsSelected).
Because if what PurgeandFire said is true, then SyncSelections would work like a wait.
Now it's just a theory, and a such code wouldn't be hard to make.
 
Status
Not open for further replies.
Back
Top