• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] What does SyncSelections() do?

Status
Not open for further replies.

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I encountered a strange behaviour when I made a trigger in my map. When I use call SyncSelections() in this trigger I get weird results. SyncSelections() is part of the action
  • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Actions)
    • Loop - Actions
My question is: What does SyncSelections() do and how can it screw up a trigger that has nothing to do with selections?


Here are debug messages that show the different results with and without SyncSelections().
Normal intended result:

Code:
Wait: 1 TimeLine:1 Time:1.000
Wait: 1 TimeLine:1 Time:0.500

Result with call SyncSelections():

Code:
Wait: 1 TimeLine:1 Time:1.000
Wait: 1 TimeLine:2 Time:1.000
Wait: 1 TimeLine:3 Time:0.500
Wait: 1 TimeLine:4 Time:1.000
Wait: 1 TimeLine:5 Time:1.000
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
It hangs the thread until all players in the game have the same selection data.

Nice to know, so this function should be avoided?
I used units matching (units selected by player1) instead, which does not call the function.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
It is needed to get correct player unit selection results as selection results are asynchronous and local to each client.

In StarCraft II engine they made it automatic, along with camera tracking, as part of their anti-cheat measures. However in Warcraft III player selections and camera are not really tracked at all, replays instead guess them based on how the orders are being issued to units. StarCraft II's camera tracking replay is near perfectly accurate, however in Warcraft III it can sometimes do stupid stuff like hold the camera over the middle of nowhere due to a very bad guess as to where the camera should be and in any case does not reflect the player's camera at all.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Why does the function IsUnitSelected not use this function? (IsUnitSelected(u,p) returns if unit u is selected by player p)
 
Status
Not open for further replies.
Top