/*

*
* AUTHOR: paradox
*
* PURPOSE: Handling including all the sub-modules for
* detours.
*

*/

//-/~ Detour Table
detour = {
    Function_Enviroments = {  },
    ObjectMetatables = {  }, -- Used by debug.setmetatable/debug.getmetatable
    ObjectMetatablesFunc = {  }, -- Used by setmetatable/getmetatable
    SetHook_Returns = {
        Func = nil,
        Mask = "",
        Count = 0
    }
}

//-/~ Detour Function
function majestic.Detour( VirtualFunction, NewVirtualFunction )
    -- Override our Virtual Function via detouring through GLOBAL table.
    _G[ VirtualFunction ] = function( ... )
        return NewVirtualFunction( ... )
    end -- For some reason this doesn't override the base enviroment even if we do getfenv( ) instead of _G.

    -- Print our debug text.
    majestic.Print( 'Detoured function at ' .. tostring( VirtualFunction ) .. ' with function at ' .. tostring( NewVirtualFunction ) .. '.' )

    -- Set our callback for refrence later.
    majestic.Detours[ NewVirtualFunction ] = VirtualFunction

    return NewVirtualFunction
end

//-/~ Includes
majestic.loadFile( 'majestic/modules/detours/debug.lua' )

//-/~ Client Message
majestic.Print( 'Initialized all detours.' )