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

[JASS] Can anyone recognize a desync from these snippets?

Status
Not open for further replies.

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
Hi, does anyone know off the top of their head of any of these desync?

I'm about 80% sure it's occurring from one of them.

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call DisplayTimedTextToPlayer(Players.locl, .1, 0., 3., text)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call DisplayTimedTextToPlayer(Players.locl, .1, 0., 3., text)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call ClearTextMessages()
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call ClearTextMessages()
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call SetCinematicScene(0, PLAYER_COLOR_LIGHT_BLUE, "", text, duration, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCinematicScene(0, PLAYER_COLOR_LIGHT_BLUE, "", text, duration, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call FogEnable(true)
        call FogMaskEnable(true)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call FogEnable(true)
        call FogMaskEnable(true)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call PanCameraToTimed(x, y, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call PanCameraToTimed(x, y, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, dist, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, dist, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, aoa, duration)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call PanCameraToTimed(x, y, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call PanCameraToTimed(x, y, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, aoa, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, aoa, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, d, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, d, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_ROTATION, r, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_ROTATION, r, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, aoa, 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, duration, FILTER_MASK, 0., 0., 0., 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, duration, FILTER_MASK, 0., 0., 0., 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, duration, FILTER_MASK, 0., 0., 0., 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, duration, FILTER_MASK, 0., 0., 0., 0.)
    endif

JASS:
    if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
        call ResetToGameCamera(0.)
    endif

JASS:
    if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
        call ResetToGameCamera(0.)
    endif

Note that Players.locl is a cached player containing GetLocalPlayer()
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
JASS:
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, duration, FILTER_MASK, 0., 0., 0., 0.)
This desync if you do it locally. You can do:

JASS:
local string s

if LocalPlayer == thePlayer then
    set s = FILTER_MASK
else
    set s = "alpha.blp" //an alpha image
endif
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, duration, s, 0., 0., 0., 0.)

About alpha image, maybe you can leave it blank ( "" ), I'm not sure, not tested it yet.
 
I thought that looked bad but wasn't totally sure since I am usually a GUI'er, was looking at it earlier and failed to recognize it.... Yeah you can't apply filters like that locally, got to do it as Dalv says.

You should follow Dalv up to where you declare the string, everything else is fine but that part. You need to identify and set the string for all clients/players otherwise the table should desync. It's safer and better to do it this way I am pretty sure.
[jass=]
local string s

set s = "alpha.blp"
set s = FILTER_MASK
if LocalPlayer == thePlayer then
set s = FILTER_MASK
else
set s = "alpha.blp" //an alpha image
endif
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, duration, s, 0., 0., 0., 0.)[/code]

Have to make sure all new strings are declared/entered into the string table for all clients/players.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I remember purgeandfire created local version of these filter functions which works for different players at the same time.You can find and use them.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
I fixed the desync and verified it with this:


JASS:
private static method endFadeHunter takes nothing returns nothing
			call DestroyTimer(hunterFadeFinishTimer)
			set hunterFadeFinishTimer = null
			if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
				call DisplayCineFilter(false)
				call EnableUserUI(true)
			endif
		endmethod
		
		private static method endFadeBeast takes nothing returns nothing
			call DestroyTimer(beastFadeFinishTimer)
			set beastFadeFinishTimer = null
			if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
				call DisplayCineFilter(false)
				call EnableUserUI(true)
			endif
		endmethod
		
		public static method fadeInHunter takes real duration returns nothing
			// Fade in from the requested color.
			if (hunterFadeContinueTimer != null) then
				call DestroyTimer(hunterFadeContinueTimer)
			endif

			if (hunterFadeFinishTimer != null) then
				call DestroyTimer(hunterFadeFinishTimer)
			endif
			
			if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
				call EnableUserUI(false)
				call SetCineFilterTexture(FILTER_MASK)
				call SetCineFilterBlendMode(BLEND_MODE_BLEND)
				call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
				call SetCineFilterStartUV(0, 0, 1, 1)
				call SetCineFilterEndUV(0, 0, 1, 1)
				call SetCineFilterStartColor(0, 0, 0, 255)
				call SetCineFilterEndColor(0, 0, 0, 0)
				call SetCineFilterDuration(duration)
				call DisplayCineFilter(true)
			endif
			
			// Create a timer to end the cinematic fade.
			set hunterFadeFinishTimer = CreateTimer()
			call TimerStart(hunterFadeFinishTimer, duration, false, function thistype.endFadeHunter)
		endmethod
		
		public static method fadeInBeast takes real duration returns nothing
			// Fade in from the requested color.
			if (beastFadeContinueTimer != null) then
				call DestroyTimer(beastFadeContinueTimer)
			endif

			if (beastFadeFinishTimer != null) then
				call DestroyTimer(beastFadeFinishTimer)
			endif
			
			if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
				call EnableUserUI(false)
				call SetCineFilterTexture(FILTER_MASK)
				call SetCineFilterBlendMode(BLEND_MODE_BLEND)
				call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
				call SetCineFilterStartUV(0, 0, 1, 1)
				call SetCineFilterEndUV(0, 0, 1, 1)
				call SetCineFilterStartColor(0, 0, 0, 255)
				call SetCineFilterEndColor(0, 0, 0, 0)
				call SetCineFilterDuration(duration)
				call DisplayCineFilter(true)
			endif
			
			// Create a timer to end the cinematic fade.
			set beastFadeFinishTimer = CreateTimer()
			call TimerStart(beastFadeFinishTimer, duration, false, function thistype.endFadeBeast)
		endmethod
		
		public static method fadeOutHunter takes real duration returns nothing
			// Fade out to the requested color.
			if (hunterFadeContinueTimer != null) then
				call DestroyTimer(hunterFadeContinueTimer)
			endif

			if (hunterFadeFinishTimer != null) then
				call DestroyTimer(hunterFadeFinishTimer)
			endif
			
			if GetPlayerId(Players.locl) < Players.FIRST_BEAST then
				call EnableUserUI(false)
				call SetCineFilterTexture(FILTER_MASK)
				call SetCineFilterBlendMode(BLEND_MODE_BLEND)
				call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
				call SetCineFilterStartUV(0, 0, 1, 1)
				call SetCineFilterEndUV(0, 0, 1, 1)
				call SetCineFilterStartColor(0, 0, 0, 0)
				call SetCineFilterEndColor(0, 0, 0, 255)
				call SetCineFilterDuration(duration)
				call DisplayCineFilter(true)
			endif
		endmethod
		
		public static method fadeOutBeast takes real duration returns nothing
			// Fade out to the requested color.
			if (beastFadeContinueTimer != null) then
				call DestroyTimer(beastFadeContinueTimer)
			endif

			if (beastFadeFinishTimer != null) then
				call DestroyTimer(beastFadeFinishTimer)
			endif
			
			if GetPlayerId(Players.locl) >= Players.FIRST_BEAST then
				call EnableUserUI(false)
				call SetCineFilterTexture(FILTER_MASK)
				call SetCineFilterBlendMode(BLEND_MODE_BLEND)
				call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
				call SetCineFilterStartUV(0, 0, 1, 1)
				call SetCineFilterEndUV(0, 0, 1, 1)
				call SetCineFilterStartColor(0, 0, 0, 0)
				call SetCineFilterEndColor(0, 0, 0, 255)
				call SetCineFilterDuration(duration)
				call DisplayCineFilter(true)
			endif
		endmethod


The only reason fade filters desync is the create/destroy timer. You are free to apply the texture (among other things) to all players.
 
Oh, you were creating and destroying timers locally? That's bad as well, didn't see that.... My bad, lol. Yeah you have to create and destroy them normally/globally however you can hide/show them locally. Same with leader and multi boards as well strings. Text tags are the only ones I remember that can be created and destroyed locally.

Glad you fixed it, I don't see where/how me and Dalv made a mistake though.... The timer wasn't being made locally or so it looked like.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
Oh, you were creating and destroying timers locally? That's bad as well, didn't see that.... My bad, lol. Yeah you have to create and destroy them normally/globally however you can hide/show them locally. Same with leader and multi boards as well strings. Text tags are the only ones I remember that can be created and destroyed locally.

Glad you fixed it, I don't see where/how me and Dalv made a mistake though.... The timer wasn't being made locally or so it looked like.

No, you don't understand. The CinematicFadeFilterBJ() function creates and destroys timers.

If you start the filter for a single player it will desync because you can't add/remove objects from the heap.

If you start the filter globally but only load the texture for one player, it wont work because the UI will be hidden for players that arent meant to see the filter, and will cause undefined behavior if you try to show two different players a filer with overlapping durations.

The correct solution is to use separate timers as I've done here.
 
No, you don't understand. The CinematicFadeFilterBJ() function creates and destroys timers.

If you start the filter for a single player it will desync because you can't add/remove objects from the heap.

If you start the filter globally but only load the texture for one player, it wont work because the UI will be hidden for players that arent meant to see the filter, and will cause undefined behavior if you try to show two different players a filer with overlapping durations.

The correct solution is to use separate timers as I've done here.

http://www.hiveworkshop.com/forums/world-editor-help-zone-98/getlocalplayer-faq-224876/ Says otherwise, still you found a solution so. :thumbs_up:

Edit: I realize I offered the wrong answer so my apologies. You can't show alternate texture's for every player however you can "hide" them.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
Look, yes, it doesn't desync :)

But here is the contents of CinematicFadeBJ:

JASS:
function CinematicFadeCommonBJ takes real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing
    if (duration == 0) then
        // If the fade is instant, use the same starting and ending values,
        // so that we effectively do a set rather than a fade.
        set startTrans = endTrans
    endif
    call EnableUserUI(false)
    call SetCineFilterTexture(tex)
    call SetCineFilterBlendMode(BLEND_MODE_BLEND)
    call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
    call SetCineFilterStartUV(0, 0, 1, 1)
    call SetCineFilterEndUV(0, 0, 1, 1)
    call SetCineFilterStartColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100-startTrans))
    call SetCineFilterEndColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100-endTrans))
    call SetCineFilterDuration(duration)
    call DisplayCineFilter(true)
endfunction

Note the call EnableUserUI(false)

Even if the fading doesn't appear, this is still not what you want - it will make weird bugs in your map :)

Thanks anyway to everyone who took a look, though
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
Instead of this:

JASS:
        call FogEnable(true)
        call FogMaskEnable(true)

Why not just create a fog modifier for the player and enable it? I think this should do the same thing.

Indeed that is how you would make it friendly for player-by-player basis.

Why didn't I do it initially? managing objects is a pain in the ass and I didn't think with my head.
 
Status
Not open for further replies.
Top