| 11-03-2003, 09:54 PM | #1 |
Posting it to make it easier to answer for you: Code:
//===========================================================================
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
endfunctionOk, I was trying to make an SmartCameraPanND that doesn't desync, but unfortunally I can't find the thing that makes it desync. |
| 11-03-2003, 11:21 PM | #2 |
GetCameraTargetPositionLoc() That's what does it. It's a different number for every player. I think the reason it desyncs it is because of the location memory leak... it gets that location but never removes it. It could also be that since location variables are really pointers, it's like accessing a global. Then again accessing a global shouldn't set it off, just changing one... |
| 11-04-2003, 11:39 AM | #3 |
I guess it is the location memory leak, since it is something blizzard didn't know about, also an extra thing in memory for one player will make him desync. |
| 11-04-2003, 06:37 PM | #4 |
I'd bet that it was DistanceBetweenPoints that desynced. DistanceBetweenPoints is a function in Blizzard.j, and according to my experiences any function that isn't a native generates network traffic upon calling. The solution to this problem would be to inline DistanceBetweenPoints. |
| 11-04-2003, 08:05 PM | #5 |
I think Blizzard should fix these issue in a patch. There are way too much leaks in Jass. For their next RTS (SC2 maybe?) they should give us a more advanced language that has all those features we miss in Jass. It should be at us to fix leaks, not at the limitations of the scripting language. |
| 11-05-2003, 01:30 PM | #6 |
Then I suppose this function may fix that: Code:
function SmartCameraPanND takes player whichPlayer, location loc, real duration returns nothing
local real dist
local real x=GetLocationX(loc)
local real y=GetLocationY(loc)
if (GetLocalPlayer() == whichPlayer) then
set dist = SquareRoot(((GetCameraTargetPositionX() - x) * (GetCameraTargetPositionX() - x)) + ((GetCameraTargetPositionY() - y) * (GetCameraTargetPositionY() - y)))
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
call PanCameraToTimed(x, y, 0)
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
call PanCameraToTimed(x, y, duration)
else
endif
endif
endfunction |
| 11-05-2003, 02:42 PM | #7 |
Vex, did you test it? |
| 11-05-2003, 07:53 PM | #8 |
I don't have the resources to test it. That's why I said I suppose this may fix it |
| 11-06-2003, 09:13 PM | #9 |
Eh, I don't think all BJ functions automatically generate network traffic. I remember using them in arrow key movement in RoC without any problems. |
