• 🏆 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!

[Solved] One of these is causing a Desync (GetLocalPlayer)

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

I was testing a map with a friend, and found that an event was doing a desync. I changed three triggers, and the desync was gone, but my friend had to leave, and I don't know which one was messing up the game.

Check for the 'GetLocalPlayer' I disabled all of them in order to remove the desync.


  • Combat Music ON
    • Events
      • Unit - A unit enters Musiquita <gen>
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
      • Sound - Play Doom
      • Custom script: endif
  • Combat Music OFF
    • Events
      • Unit - A unit leaves Musiquita <gen>
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
      • Sound - Stop the currently playing music theme
      • Custom script: endif
The following is the longest. It works perfectly. The only thing I need to check are the 8 GetLocalPlayer to use Fade Filters.

  • Combat System 2
    • Events
      • Time - SpawnTimer expires
    • Conditions
    • Actions
      • -------- Global --------
      • Set UONH = (Units owned by Neutral Hostile)
      • -------- WOOD --------
      • Set CCP[0] = (Center of WoodCombat <gen>)
      • Set Wood[1] = (Units in WoodCombat <gen> matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in UONH) Equal to True)))
      • Set Wood[2] = (Units in WoodCombat <gen> matching (((Matching unit) is A Hero) Equal to True))
      • Set Wood[3] = (Units in WoodEscape <gen> matching (((Matching unit) is A Hero) Equal to True))
      • Set Wood[4] = (Units in WoodCombat <gen> owned by Neutral Hostile)
      • Floating Text - Create floating text that reads (Creeps Left: + (|cfffff700 + ((String((Number of units in Wood[1]))) + |r))) at CCP[0] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.20 seconds
      • Custom script: call RemoveLocation(udg_CCP[0])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to (Random integer number between 5 and 15)
          • (Number of units in Wood[2]) Equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in Wood[0] and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit has buff Safety ) Equal to False
                • Then - Actions
                  • Set Temp_Int = (Player number of (Owner of TempUnit))
                  • Set Temp_HeroPos[Temp_Int] = (Position of TempUnit)
                  • Set Temp_RandomHeroSpawn[Temp_Int] = (Random point in WoodSpawn <gen>)
                  • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
                  • Cinematic - Fade out over 0.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
                  • Custom script: endif
                  • Unit - Move TempUnit instantly to Temp_RandomHeroSpawn[(Player number of (Owner of (Picked unit)))]
                  • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
                  • Cinematic - Fade in over 1.00 seconds using texture White Mask and color ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%) with 0.00% transparency
                  • Custom script: endif
                  • Custom script: call RemoveLocation(udg_Temp_RandomHeroSpawn[udg_Temp_Int])
                  • Unit Group - Add TempUnit to Wood[2]
                  • Unit Group - Remove TempUnit from Wood[0]
                • Else - Actions
          • -------- Spawning the Creeps --------
          • Set Int_WC = ((Number of units in Wood[4]) x 2)
          • Set Int_RWC = (Random integer number between 1 and Int_WC)
          • For each (Integer A) from 1 to Int_RWC, do (Actions)
            • Loop - Actions
              • Set Temp_PointArray[1] = (Random point in WoodSpawn <gen>)
              • Unit - Create 1 WoodCreeps[(Random integer number between 1 and 9)] for Neutral Hostile at Temp_PointArray[1] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Temp_PointArray[1])
        • Else - Actions
      • -------- WOOD CLEANING --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Number of units in Wood[2]) Equal to (Number of units in Wood[3])
              • (Number of units in Wood[2]) Equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in Wood[2] and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • Set Temp_Int = (Player number of (Owner of (Picked unit)))
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
              • Cinematic - Fade out over 0.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
              • Custom script: endif
              • Unit - Move TempUnit instantly to Temp_HeroPos[Temp_Int]
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
              • Cinematic - Fade in over 1.00 seconds using texture White Mask and color ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%) with 0.00% transparency
              • Custom script: endif
              • Unit - Create 1 DummySafetyCaster for Neutral Passive at Temp_HeroPos[Temp_Int] facing Default building facing degrees
              • Unit - Order (Last created unit) to Human Priest - Inner Fire TempUnit
              • Unit - Remove (Last created unit) from the game
              • Custom script: call RemoveLocation(udg_Temp_HeroPos[udg_Temp_Int])
              • Unit Group - Remove TempUnit from Wood[2]
              • Unit Group - Add TempUnit to Wood[0]
          • Unit Group - Pick every unit in Wood[4] and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Item - Pick every item in WoodCombat <gen> and do (Actions)
            • Loop - Actions
              • Item - Remove (Picked item)
          • Destructible - Pick every destructible in WoodCombat <gen> and do (Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Hide birth animation)
        • Else - Actions
      • -------- WOOD LEAKS --------
      • Custom script: call DestroyGroup(udg_Wood[1])
      • Custom script: call DestroyGroup(udg_Wood[2])
      • Custom script: call DestroyGroup(udg_Wood[3])
      • Custom script: call DestroyGroup(udg_Wood[4])
      • -------- BEACH --------
      • Set CCP[1] = (Center of BeachCombat <gen>)
      • Set Beach[1] = (Units in BeachCombat <gen> matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in UONH) Equal to True)))
      • Set Beach[2] = (Units in BeachCombat <gen> matching (((Matching unit) is A Hero) Equal to True))
      • Set Beach[3] = (Units in BeachEscape <gen> matching (((Matching unit) is A Hero) Equal to True))
      • Set Beach[4] = (Units in BeachCombat <gen> owned by Neutral Hostile)
      • Floating Text - Create floating text that reads (Creeps Left: + (|cfffff700 + ((String((Number of units in Beach[1]))) + |r))) at CCP[1] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 1.20 seconds
      • Custom script: call RemoveLocation(udg_CCP[1])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to (Random integer number between 4 and 16)
          • (Number of units in Beach[2]) Equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in Beach[0] and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempUnit has buff Safety ) Equal to False
                • Then - Actions
                  • Set Temp_Int = (Player number of (Owner of TempUnit))
                  • Set Temp_HeroPos[Temp_Int] = (Position of TempUnit)
                  • Set Temp_RandomHeroSpawn[Temp_Int] = (Random point in BeachSpawn <gen>)
                  • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
                  • Cinematic - Fade out over 0.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
                  • Custom script: endif
                  • Unit - Move TempUnit instantly to Temp_RandomHeroSpawn[Temp_Int]
                  • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
                  • Cinematic - Fade in over 1.00 seconds using texture White Mask and color ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%) with 0.00% transparency
                  • Custom script: endif
                  • Custom script: call RemoveLocation(udg_Temp_RandomHeroSpawn[udg_Temp_Int])
                  • Unit Group - Add TempUnit to Beach[2]
                  • Unit Group - Remove TempUnit from Beach[0]
                • Else - Actions
          • -------- Spawning the Creeps --------
          • Set Int_BC = ((Number of units in Beach[4]) x 2)
          • Set Int_RBC = (Random integer number between 1 and Int_BC)
          • For each (Integer A) from 1 to Int_RBC, do (Actions)
            • Loop - Actions
              • Set Temp_PointArray[2] = (Random point in BeachSpawn <gen>)
              • Unit - Create 1 BeachCreeps[(Random integer number between 1 and 7)] for Neutral Hostile at Temp_PointArray[2] facing Default building facing degrees
              • Custom script: call RemoveLocation(udg_Temp_PointArray[2])
        • Else - Actions
      • -------- BEACH CLEANING --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Number of units in Beach[2]) Equal to (Number of units in Beach[3])
              • (Number of units in Beach[2]) Equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in Beach[2] and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • Set Temp_Int = (Player number of (Owner of (Picked unit)))
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
              • Cinematic - Fade out over 0.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
              • Custom script: endif
              • Unit - Move TempUnit instantly to Temp_HeroPos[Temp_Int]
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetEnumUnit()) then
              • Cinematic - Fade in over 1.00 seconds using texture White Mask and color ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%) with 0.00% transparency
              • Custom script: endif
              • Unit - Create 1 DummySafetyCaster for Neutral Passive at Temp_HeroPos[Temp_Int] facing Default building facing degrees
              • Unit - Order (Last created unit) to Human Priest - Inner Fire TempUnit
              • Unit - Remove (Last created unit) from the game
              • Custom script: call RemoveLocation(udg_Temp_HeroPos[udg_Temp_Int])
              • Unit Group - Remove TempUnit from Beach[2]
              • Unit Group - Add TempUnit to Beach[0]
          • Unit Group - Pick every unit in Beach[4] and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Item - Pick every item in BeachCombat <gen> and do (Actions)
            • Loop - Actions
              • Item - Remove (Picked item)
          • Destructible - Pick every destructible in BeachCombat <gen> and do (Destructible - Resurrect (Picked destructible) with (Max life of (Picked destructible)) life and Hide birth animation)
        • Else - Actions
      • -------- BEACH LEAKS --------
      • Custom script: call DestroyGroup(udg_Beach[1])
      • Custom script: call DestroyGroup(udg_Beach[2])
      • Custom script: call DestroyGroup(udg_Beach[3])
      • Custom script: call DestroyGroup(udg_Beach[4])
      • -------- Global --------
      • Custom script: call DestroyGroup(udg_UONH)


Also (a bit offtopic) I was testing with version 1.26a and the other players (with same version) were kicked, but works with 1.24e :S. What could be the cause?
 
Level 8
Joined
Apr 26, 2011
Messages
403
when you use GetLocalPlayer(), try make sure:

Use only local code (no net traffic) within this block to avoid desyncs., mean you should never use global variable inside the block (eg, within "endif" block)

for your code
  • Cinematic - Fade out over 0.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
It will look like this after convert to JASS :

JASS:
function CinematicFadeBJ takes integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing
    if (fadetype == bj_CINEFADETYPE_FADEOUT) then
        // Fade out to the requested color.
        call AbortCinematicFadeBJ()
        call CinematicFadeCommonBJ(red, green, blue, duration, tex, 100, trans)
    elseif (fadetype == bj_CINEFADETYPE_FADEIN) then
        // Fade in from the requested color.
        call AbortCinematicFadeBJ()
        call CinematicFadeCommonBJ(red, green, blue, duration, tex, trans, 100)
        call FinishCinematicFadeAfterBJ(duration)
    elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then
        // Fade out to the requested color, and then fade back in from it.
        if (duration > 0) then
            call AbortCinematicFadeBJ()
            call CinematicFadeCommonBJ(red, green, blue, duration * 0.5, tex, 100, trans)
            call ContinueCinematicFadeAfterBJ(duration * 0.5, red, green, blue, trans, tex)
            call FinishCinematicFadeAfterBJ(duration)
        endif
    else
        // Unrecognized fadetype - ignore the request.
    endif
endfunction

as you can see, bj_CINEFADETYPE_FADEOUT is global variable.


that is why you get desync from all of "Cinematic" code.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Of course you can read a global variable in local blocks, even write if you use it for async purposes.

JASS:
function AbortCinematicFadeBJ takes nothing returns nothing
    if (bj_cineFadeContinueTimer != null) then
        call DestroyTimer(bj_cineFadeContinueTimer)
    endif

    if (bj_cineFadeFinishTimer != null) then
        call DestroyTimer(bj_cineFadeFinishTimer)
    endif
endfunction

JASS:
function FinishCinematicFadeAfterBJ takes real duration returns nothing
    // Create a timer to end the cinematic fade.
    set bj_cineFadeFinishTimer = CreateTimer()
    call TimerStart(bj_cineFadeFinishTimer, duration, false, function FinishCinematicFadeBJ)
endfunction

JASS:
function ContinueCinematicFadeAfterBJ takes real duration, real red, real green, real blue, real trans, string tex returns nothing
    set bj_cineFadeContinueRed = red
    set bj_cineFadeContinueGreen = green
    set bj_cineFadeContinueBlue = blue
    set bj_cineFadeContinueTrans = trans
    set bj_cineFadeContinueDuration = duration
    set bj_cineFadeContinueTex = tex

    // Create a timer to continue the cinematic fade.
    set bj_cineFadeContinueTimer = CreateTimer()
    call TimerStart(bj_cineFadeContinueTimer, duration, false, function ContinueCinematicFadeBJ)
endfunction

It fiddles with timers, shifting the synced handle stack, creating different amounts of thread executions etc. Those are the problems.

For the GUI-User: Cinematic - Fade Filter is not localblock-proof.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Oooooooh... so that was it. Somehow, I felt sure about it.

Uh, ok, I don't know that much JASS as to convert the trigger to custom text, edit, and then not knowing how to work with it, so I'll remove these untill I learn how to handle situations like these in JASS.

Anway, a bit off/in/topic... I'm trying to resemble the 'Combat engaging' in SNES, where hero in the world map is paused, and the screen comes blurry and zoomed in and suddenly the units appear in combat.

Since it's another subject, I created a different thread for that. This is solved :) Thanks.

http://www.hiveworkshop.com/forums/.../fast-short-cinematic-camera-question-204111/
 
Status
Not open for further replies.
Top