• 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.

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.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
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:
Level 11
Joined
Oct 11, 2012
Messages
711
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?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
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.
Top