• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Desync when calling Preloader() locally

Level 2
Joined
Apr 19, 2022
Messages
5
I have been sitting in the editor of version 1.26 for a very long time, but now I decided to switch to the functionality of Reforge, but to my surprise, when saving a map in Reforge, a desynchronization occurs in this place, what has changed in the new versions of Warcraft, because when saving a map in 1.26 everything works? Help fix the desynchronization

Code causing desynchronization

JASS:
  if GetLocalPlayer()==p then
          call Preloader("save2\\Multiplayer\\DungeonRunners\\"+udg_Name[GetPlayerId(p)+1]+".pld")
        endif


JASS:
function Trig_InitialPlayersLoad_Actions takes nothing returns nothing
    local integer i=0
    local player p
    loop
      exitwhen i>15
      set udg_Player[i]=Player(i)
      set i=i+1
    endloop
    set udg_ColoredName[1] = ( ( "|c00FF0000" + GetPlayerName(Player(0)) ) + "|r" )
    set udg_ColoredName[2] = ( ( "|c000000FF" + GetPlayerName(Player(1)) ) + "|r" )
    set udg_ColoredName[3] = ( ( "|c0000FFC2" + GetPlayerName(Player(2)) ) + "|r" )
    set udg_ColoredName[4] = ( ( "|c004B005D" + GetPlayerName(Player(3)) ) + "|r" )
    set udg_ColoredName[5] = ( ( "|c00FFFF00" + GetPlayerName(Player(4)) ) + "|r" )
    set udg_ColoredName[6] = ( ( "|c00FF8B00" + GetPlayerName(Player(5)) ) + "|r" )
    set udg_ColoredName[7] = ( ( "|c0000C800" + GetPlayerName(Player(6)) ) + "|r" )
    set udg_ColoredName[8] = ( ( "|c00FF52AE" + GetPlayerName(Player(7)) ) + "|r" )
    set udg_ColoredName[9] = ( ( "|c00888888" + GetPlayerName(Player(8)) ) + "|r" )
    set udg_ColoredName[10] = ( ( "|c009FC4FF" + GetPlayerName(Player(9)) ) + "|r" )
    set udg_ColoredName[11] = ( ( "|c00004400" + GetPlayerName(Player(10)) ) + "|r" )
    set udg_ColoredName[12] = ( ( "|c00543200" + GetPlayerName(Player(11)) ) + "|r" )
    set i=1
    loop
        exitwhen i>12
        set udg_Name[i] = GetPlayerName(udg_Player[i-1])
        set i=i+1
    endloop
    set i=0
    loop
      exitwhen i>11
      set p=udg_Player[i]
     // call NameLoad(p)
      if GetPlayerController(p)==MAP_CONTROL_USER and GetPlayerSlotState(p)==PLAYER_SLOT_STATE_PLAYING then
        if GetLocalPlayer()==p then
          call Preloader("save2\\Multiplayer\\DungeonRunners\\"+udg_Name[GetPlayerId(p)+1]+".pld")
        endif
      endif
      set i=i+1
    endloop
endfunction

//===========================================================================
function InitTrig_InitialPlayersLoad takes nothing returns nothing
    set gg_trg_InitialPlayersLoad = CreateTrigger()
    call TriggerAddAction( gg_trg_InitialPlayersLoad, function Trig_InitialPlayersLoad_Actions )
endfunction
 
Two things to watch out for:
  1. This thread (Known causes of desync) seems to suggest that certain player controller/player slot-state checks can cause desyncs (I haven't personally verified this, but it may be worth testing to see if that is related since you have GetPlayerController() and GetPlayerSlotState()).
  2. Could you give an example of the file you're preloading? jassdoc says that Preloader returns asynchronous values, so depending on what it contains and how you use those results, you can end up disconnecting players:
Code:
@note If you use `Preloader` to load some values into your map, these values
are very likely to be different for each player (since the player might not 
even have local files enabled), so treat them as async values.

I assume you're using a save/load system, so if you're loading a string that you'll then decode into data, you'll want to make sure you synchronize that whole string across all players before handling it.
 
Top