Here is a tool which regulars of our IRC channel might already have heard about;
a tool to check jass snippets for potential desync causing programming constructs.
And i mean snippets as unfortunately this tool is quite slow. So it doesn't work on
your whole war3map.j. I would recommend to not feed it more than ~1000 SLOC.
Sadly i have not enough time (=money) to make this faster, even though the
usefullness of this is greatly dimished by not being able to be run over the whole map.
Still i think it's better to release this as is instead of sitting on it without any use.
Togehter with the executable are three text files named "async.txt",
"unsafe.txt" and "paramsafe.txt".
Each file contains a list of natives/functions which have special properties.
These lists are very likely to not be exhaustive, so feel free to expand them.
While we know that
we have found this way to do it:
In contrast this will throw an error
And while all the snippets i've shown here are all bound to one function body
this tool will work over multiple function calls.
On another note while this only works for JASS the general ideas can be very well
ported to Lua if one had the time.
a tool to check jass snippets for potential desync causing programming constructs.
And i mean snippets as unfortunately this tool is quite slow. So it doesn't work on
your whole war3map.j. I would recommend to not feed it more than ~1000 SLOC.
Sadly i have not enough time (=money) to make this faster, even though the
usefullness of this is greatly dimished by not being able to be run over the whole map.
Still i think it's better to release this as is instead of sitting on it without any use.
Demo
JASS:
// Snippet from Blizzard.j prior to 1.31. Fixed in latest patch
function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing
local real dist
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
set dist = DistanceBetweenPoints(loc, GetCameraTargetPositionLoc())
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
// If the user is too far away, snap the camera.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0)
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
// If the user is moderately close, pan the camera.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
else
// User is close enough, so don't touch the camera.
endif
endif
endfunction
Code:
$ desync-check snippet-bj.j
Unsafe usage in line 9
set dist = DistanceBetweenPoints(loc,GetCameraTargetPositionLoc()) //4
Togehter with the executable are three text files named "async.txt",
"unsafe.txt" and "paramsafe.txt".
Each file contains a list of natives/functions which have special properties.
- async.txt: natives/functions which may return different values for different players
- unsafe.txt: natives/functions which should never be called in an async context
- paramsafe.txt: natives/functions which can under certain circumstances be called in an async context (see below)
These lists are very likely to not be exhaustive, so feel free to expand them.
Demo for paramsafe functions
While we know that
AddSpecialEffect
cannot be blindly used to create an effect locallywe have found this way to do it:
JASS:
function CreateLocalEffect takes player p, string path, real x, real y returns nothing
if p != GetLocalPlayer() then
set path = ""
endif
call AddSpecialEffect(path, x, y)
endfunction
Code:
$ ./desync-check snippet-sfx-fixed.j
In contrast this will throw an error
JASS:
function CreateLocalEffect takes player p, string path, real x, real y returns nothing
if p == GetLocalPlayer() then
call AddSpecialEffect(path, x, y)
endif
endfunction
Code:
$ ./desync-check snippet-sfx.j
Unsafe usage in line 4
call AddSpecialEffect(path,x,y) //4
And while all the snippets i've shown here are all bound to one function body
this tool will work over multiple function calls.
On another note while this only works for JASS the general ideas can be very well
ported to Lua if one had the time.
Attachments
Last edited: