• 🏆 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] Fixing a LocalPlayer desync

Status
Not open for further replies.
Level 7
Joined
Dec 9, 2014
Messages
89
Hi, need some help with fixing this trigger (not made by me.) It is definetly causing desyncs, and I assume it's related to the last part of the trigger which uses Localplayer relating to Multiboards. How do I make this trigger safe while still using Localplayer?

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Cond_New_Leaver takes nothing returns boolean
    return IsPlayerObserver(GetTriggerPlayer()) == false and udg_GameOver == false
endfunction

function Act_New_Leaver takes nothing returns nothing
    local player leaver = GetTriggerPlayer()

    call DisplayTextToForce(GetPlayersAll(), GetPlayerName(leaver) + " has left the game.")
    call FlagPlayer(leaver,FLAG_LEAVER)
    call ShareEverythingWithTeam(leaver)
    if GetPlayerId(leaver) < 3 then
        set udg_LeaverBoard[0] = bj_lastCreatedMultiboard
        if IsUserNotThere(Player(0)) == true and IsUserNotThere(Player(1)) == true and IsUserNotThere(Player(2)) == true then
            set udg_Defeated[0] = true
            set udg_Defeated[1] = true
            set udg_Defeated[2] = true
        endif
    else
        set udg_LeaverBoard[1] = bj_lastCreatedMultiboard
        if IsUserNotThere(Player(3)) == true and IsUserNotThere(Player(4)) == true and IsUserNotThere(Player(5)) == true then
            set udg_Defeated[3] = true
            set udg_Defeated[4] = true
            set udg_Defeated[5] = true
        endif
    endif
    call MultiboardDisplay(bj_lastCreatedMultiboard,false)
   if IsPlayerAlly((GetLocalPlayer()), Player(10)) == true then
        call MultiboardDisplay(udg_LeftBoard,true)
    elseif IsPlayerAlly((GetLocalPlayer()), Player(11)) == true then
        call MultiboardDisplay(udg_RightBoard,true)
    else
        call MultiboardDisplay(udg_OtherBoard,true)
    endif
    set leaver = null
endfunction

//===========================================================================
function InitTrig_New_Leaver takes nothing returns nothing
    local integer i = 0
    set gg_trg_New_Leaver = CreateTrigger()
    loop
        exitwhen i > 5
        call TriggerRegisterPlayerEvent(gg_trg_New_Leaver,Player(i),EVENT_PLAYER_LEAVE)
        set i = i + 1
    endloop
    call TriggerAddCondition(gg_trg_New_Leaver,Condition(function Cond_New_Leaver))
    call TriggerAddAction(gg_trg_New_Leaver,function Act_New_Leaver)
endfunction
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I dont really see the problem with it, but for safety measures, you can comment the lines that you find suspicious and run the script again.
(Commenting out lines can be done by adding a double forward slash before the code in that line.)

Commenting out the entire if statement of "IsPlayerAlly()" (including the actions) and testing again would be useful.
If the game still desyncs, there is another problem, in which case we would need the implementations of the custom functions in that script.
If the game doesnt desync, I might still have an idea, but in that case, I am also really interested what the actual cause is.
 
Level 7
Joined
Dec 9, 2014
Messages
89
if IsPlayerAlly((GetLocalPlayer()), Player(10)) == true then
call MultiboardDisplay(udg_LeftBoard,true)
elseif IsPlayerAlly((GetLocalPlayer()), Player(11)) == true then
call MultiboardDisplay(udg_RightBoard,true)
else
call MultiboardDisplay(udg_OtherBoard,true)
endif
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Calling MultiboardDisplay locally should not be a problem. Two guesses:

  • You check for IsMultiboardMinimized or similar somewhere else.
  • The function Player could be initialized on first call per index. In that case, the elseif could be run only for some and then construct the player object individually.
 
Status
Not open for further replies.
Top