• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Am I doing this codeless loading wrong?

Status
Not open for further replies.
I've been trying to solve the desyncs in my map for almost a month now. I've looked through every trigger and script and I can't find anything suspect but my save/load system and I'm wondering if I'm doing things wrong. I got inspired by TriggerHappy's Codeless save/load system and since I'm writing in Lua I can't import his library (JASS) into my map, so I decided to just look at the code, try to understand it and make my own.

Lua:
function InitLoad()
    local trig = CreateTrigger()
    TriggerAddAction(trig, SyncData)
    for i = 0, bj_MAX_PLAYER_SLOTS do
        BlzTriggerRegisterPlayerSyncEvent(trig, Player(i), "LoadData", false)
    end

    -- Load all player saves
    ForForce(GetPlayersAll(), LoadStrings)
end

function LoadStrings()
    local player = GetConvertedPlayerId(GetEnumPlayer())
    -- increase when more character slots are created
    for i = 1, 3 do
        if (player < 24) then
            local data = ""
            Preloader("\\AzerothRPG\\Hero" .. i .. ".txt")
            data = BlzGetAbilityTooltip(1097690227, 0)
            BlzSetAbilityTooltip(1097690227, originalTooltip, 0) -- Reset tooltip
            if (GetLocalPlayer() == GetEnumPlayer()) then
                BlzSendSyncData("LoadData", data)
            end
        end
    end
end

function SyncData()
    local player = GetConvertedPlayerId(GetTriggerPlayer())

    if (characterNext[player] == nil) then
        characterNext[player] = 1
    else
        characterNext[player] = characterNext[player] + 1
    end

    characterLoadStrings[player][characterNext[player]] = BlzGetTriggerSyncData()

    LoadCharacterForPlayer(player, characterNext[player])
end

For context, the preloader loads a file that injects code that changes an ability tooltip for the players (locally) but sends the data for the current player in the loop to a synced event so everyone is in sync... is the idea at least. It works, except I think it's causing a desync and I'm sort of blaming the fact that I'm doing this inside a loop, but I'm just not sure.
 
Last edited:
Level 14
Joined
Feb 7, 2020
Messages
388
I've been going through the Codeless system to get a better grasp of it. Based on my understanding, looks pretty congruent with the ordering of things.
Lua:
    Preloader("\\AzerothRPG\\Hero" .. i .. ".txt")
    data = BlzGetAbilityTooltip(1097690227, 0)
    BlzSetAbilityTooltip(1097690227, originalTooltip, 0) -- Reset tooltip
    if (GetLocalPlayer() == GetEnumPlayer()) then
        BlzSendSyncData("LoadData", data)
    end
I'm wondering if this needs to be altered.

From the Codeless system, any client updates seem to be limited to after BlzGetTriggerSyncData() using the data fetched i.e. the tooltip changes might need to pushed into LoadCharacterForPlayer after being read from characterLoadStrings. I also wonder if empty strings do weird things for sync updates. Maybe want to also add a check for empty strings before calling BlzSendSyncData for that player.

I'd also suspect a loop might cause issues if there's a data sync timeout since all of the calls are happening together with mixed player ping, but not an expert here. edit2: what I said here doesn't hold true as the engine utilizes networking where ping is always a problem; maybe that's different for manual sync natives.

edit: nevermind this previous comment, I don't think tooltips would be effected
 
Last edited:
Linksys Customer Support
lul

Sry, didn't follow up on this, but I think I know what causes the desyncs now. I'm using Bribe's Damage Engine and his engine uses 'GetHandleId' to register and store attack types and stuff, and since Lua by nature generates different handles per client, the handles the Damage Engine uses will be different on each client and desync the game. I haven't tested it, but that's most likely the cause.
 
Status
Not open for further replies.
Top