HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What functions using local player don't desync?

04-27-2008, 10:13 PM#1
EnderA
What functions can be used in local player code without risking desyncs? Is there a list somewhere? For example, I know DisplayTextToPlayer works locally, as is shown in DisplayTextToForce:

Collapse JASS:
function DisplayTextToForce takes force toForce, string message returns nothing
    if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, message)
    endif
endfunction
04-27-2008, 10:34 PM#2
Toadcop
one which don't do global actions ? for example displaying message isn't global.
texttags self are not global so you can create texttags local. (same for lightning,ubersplats,images but i am not 100% ure but i guess it's so.)
04-27-2008, 11:54 PM#3
Zandose
You can display anything locally as long as it doesn't effect the gameplay (or data between players; desync). I suggest whatever you do create for all players then make a local block/trigger to display it to only one player.

game-text, special effects, camera, text-tags, lightning, ubersplats, images, ?buffs?, ?trackables?, ?timers?,

Animation: ?all?
Camera: all
Cinematic: ?all?
Enviroment:
Weather
water color
sky
?fog?
Floating Text: all

Too many to say. Basicly anything you can do which will not cause any problems for other computers (data/syncing). For example: creating a local unit has collision and effects others (thats a no no), or creating a special effect locally will desync (you need to create the effect data for everyone then display is locally to the player. All data must be the same.)
04-28-2008, 04:53 AM#4
EnderA
Quote:
Originally Posted by Zandose
You can display anything locally as long as it doesn't effect the gameplay (or data between players; desync). I suggest whatever you do create for all players then make a local block/trigger to display it to only one player.

game-text, special effects, camera, text-tags, lightning, ubersplats, images, ?buffs?, ?trackables?, ?timers?,

Animation: ?all?
Camera: all
Cinematic: ?all?
Enviroment:
Weather
water color
sky
?fog?
Floating Text: all

Too many to say. Basicly anything you can do which will not cause any problems for other computers (data/syncing). For example: creating a local unit has collision and effects others (thats a no no), or creating a special effect locally will desync (you need to create the effect data for everyone then display is locally to the player. All data must be the same.)

So... what would I need to change if my code is:

Collapse JASS:
if (GetLocalPlayer() == lPlayer) then
    set lEffect = AddSpecialEffectTarget(<Special Effect Model>, lUnit, <Attach Point>)
    call DestroyEffect(lEffect)
    set lEffect = null
endif
04-28-2008, 05:31 AM#5
Deaod
someone once said to me you have to null the path for every player you dont want to display the model to and then create the model for every player (the only difference is the path).
04-28-2008, 05:31 AM#6
Pyrogasm
You'd write this instead:
Collapse JASS:
local string ModelFile = ""

if (GetLocalPlayer() == lPlayer) then
    set ModelFile = <Special Effect Model>
endif
call DestroyEffect(AddSpecialEffectTarget(ModelFile, lUnit, <Attach Point>)
04-28-2008, 05:59 AM#7
Strilanc
Quote:
Originally Posted by Toadcop
one which don't do global actions ? for example displaying message isn't global.
texttags self are not global so you can create texttags local. (same for lightning,ubersplats,images but i am not 100% ure but i guess it's so.)

Small point: you can display a text tag to only one player, but you still have to _create_ it for every player. If you only create a text tag for one player, their handle ids will go out of sync.
04-28-2008, 06:16 AM#8
Ammorth
Quote:
Originally Posted by Pyrogasm
You'd write this instead:
Collapse JASS:
local string ModelFile = ""

if (GetLocalPlayer() == lPlayer) then
    set ModelFile = <Special Effect Model>
endif
call DestroyEffect(AddSpecialEffectTarget(ModelFile, lUnit, <Attach Point>)

Actually, its safer to do:

Collapse JASS:
local string ModelFile = <Special Effect Model>

if (GetLocalPlayer() != lPlayer) then
    set ModelFile = ""
endif
call DestroyEffect(AddSpecialEffectTarget(ModelFile, lUnit, <Attach Point>)
as it keeps the string table synced, where the other one has a chance of not doing it (depending when strings are declared).
04-28-2008, 01:44 PM#9
Toadcop
Quote:
Small point: you can display a text tag to only one player, but you still have to _create_ it for every player. If you only create a text tag for one player, their handle ids will go out of sync.
lol o rly ? xD i don't write such stuff if i am not sure. YOU CAN. thats why TT's have custom handle index space.
// and it will not desync.


string table don't need to be synced in truth. only if you use string indexes to attaching data you need.
04-28-2008, 04:20 PM#10
Strilanc
Quote:
Originally Posted by Toadcop
lol o rly ? xD i don't write such stuff if i am not sure. YOU CAN. thats why TT's have custom handle index space.
// and it will not desync.


string table don't need to be synced in truth. only if you use string indexes to attaching data you need.

Is that so? I've never tried it, I just assumed it would cause problems. I especially expected consequences with H2I.
04-29-2008, 07:22 AM#11
Pyrogasm
orly, Ammorth? I didn't really know it made a difference. In fact, it still doesn't seem like it would matter, because either way the string tables will be "unsynced".

If I did it my way:
Example String Table:
For Player(0)For All Other Players
"MyModel.mdl"""
Say if it was done backwards (displaying for everyone but Player 0)
Example String Table:
For Player(0)For All Other Players
"""MyModel.mdl"

I'd say each are equally "unsynced"... if it was simply no string instead of a null string (""), then it wouldn't be the same, but the way I see it neither way is better nor worse.
04-29-2008, 10:35 AM#12
TheDamien
Quote:
Originally Posted by Pyrogasm
orly, Ammorth? I didn't really know it made a difference. In fact, it still doesn't seem like it would matter, because either way the string tables will be "unsynced".

If I did it my way:
Example String Table:
For Player(0)For All Other Players
"MyModel.mdl"""
Say if it was done backwards (displaying for everyone but Player 0)
Example String Table:
For Player(0)For All Other Players
"""MyModel.mdl"

I'd say each are equally "unsynced"... if it was simply no string instead of a null string (""), then it wouldn't be the same, but the way I see it neither way is better nor worse.

"" already exists at position 1 in the string table [for every player], so it remains synced.
04-30-2008, 06:52 AM#13
Pyrogasm
Oh.
05-01-2008, 12:59 AM#14
PurgeandFire111
Don't create handles using GetLocalPlayer(). There are only certain exceptions where the handle isn't normally allocated as regular handles are.

Texttags, lightning, etc.

You can use H2I and see if they are less than 0x100000... Stay away from creating handles for local players in general if you are not sure. Displaying it for players is probably the way to go unless someone performs an action on the object or whatever the case may be. (Which is why you don't create/show units locally unless they are stationary and don't do anything at all, but it is still kind of dangerous)

Um... You get the point/jist of it at least.