<commit_before>if _mpPatch and _mpPatch.enabled and _mpPatch.isModding then
    local startLock = false

    local StartCountdownOld = StartCountdown
    function StartCountdown(...)
        if not Matchmaking.IsHost() then
            _mpPatch.overrideModsFromPreGame()
        end
        return StartCountdownOld(...)
    end

    local function cancelOverride()
        if not Matchmaking.IsHost() then
            _mpPatch.debugPrint("Cancelling override.")
            _mpPatch.patch.NetPatch.reset()
        end
    end

    local function OnPreGameDirtyHook(...)
        if not ContextPtr:IsHidden() then
            _mpPatch.debugPrint("cancelOverride from OnPreGameDirty")
            cancelOverride()
        end
        return OnPreGameDirtyOld(...)
    end
    Events.PreGameDirty.Add(OnPreGameDirtyHook)

    local DequeuePopup = UIManager.DequeuePopup
    _mpPatch.patch.globals.rawset(UIManager, "DequeuePopup", function(this, ...)
        local context = ...
        if context == ContextPtr then
            _mpPatch.debugPrint("cancelOverride from DequeuePopup")
            cancelOverride()
        end
        return DequeuePopup(UIManager, ...)
    end)

    -- Disable manual launch, helps with countdown related things.
    Controls.LaunchButton:RegisterCallback(Mouse.eLClick, function() end)
end<commit_msg>Try to fix stagingroom... again.<commit_after>if _mpPatch and _mpPatch.enabled and _mpPatch.isModding then
    local confirmChat = "mppatch:gamelaunchcountdown:WgUUz7wWuxWFmjY02WFS0mka53nFDzJvD00zmuQHKyJT2wNHuWZvrDcejHv5rTyl"

    local gameLaunchSet = false
    local gameLaunchCountdown = 3

    local StartCountdownOld = StartCountdown
    function StartCountdown(...)
        if gameLaunchSet then return end
        return StartCountdownOld(...)
    end

    local StopCountdownOld = StopCountdown
    function StopCountdown(...)
        if gameLaunchSet then return end
        return StopCountdownOld(...)
    end

    local HandleExitRequestOld = HandleExitRequest
    function HandleExitRequest(...)
        if gameLaunchSet then return end
        return HandleExitRequestOld(...)
    end

    local LaunchGameOld = LaunchGame
    local function LaunchGameCountdown(timeDiff)
        gameLaunchCountdown = gameLaunchCountdown - timeDiff
        if gameLaunchCountdown <= 0 then
            LaunchGameOld()
            ContextPtr:ClearUpdate()
        end
    end
    function LaunchGame(...)
        if PreGame.IsHotSeatGame() then
            return LaunchGameOld(...)
        else
            SendChat(confirmChat)
            ContextPtr:ClearUpdate()
            gameLaunchSet = true
            ContextPtr:SetUpdate(LaunchGameCountdown)
        end
    end
    Controls.LaunchButton:RegisterCallback(Mouse.eLClick, LaunchGame)

    local OnChatOld = OnChat
    function OnChat(...)
        local fromPlayer, toPlayer, text = ...
        if not Matchmaking.IsHost() and fromPlayer == m_HostID and text == confirmChat then
            gameLaunchSet = true
            _mpPatch.overrideModsFromPreGame()
            return
        end
        return OnChatOld(...)
    end

    local DequeuePopup = UIManager.DequeuePopup
    _mpPatch.patch.globals.rawset(UIManager, "DequeuePopup", function(this, ...)
        local context = ...
        if context == ContextPtr and not Matchmaking.IsHost() then
            _mpPatch.debugPrint("Cancelling override.")
            _mpPatch.patch.NetPatch.reset()
        end
        return DequeuePopup(UIManager, ...)
    end)
end
{'fraction_non_alphanumeric': 0.0772079772079772, 'fraction_numerical': 0.003418803418803419, 'mean_word_length': 2.462524654832347, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5513445', 'n_tokens_mistral': 1000, 'n_tokens_neox': 967, 'n_words': 226}