I use this for pre-4.1, 4.1 and 4.2 compat:
lua Code:
local TOC -- Pre-4.1 CLEU compat
local dummyTable = {}
local recurse = true
do
-- Because GetBuildInfo() still returns 40000 on the PTR
local major, minor, rev = strsplit(".", (GetBuildInfo()))
TOC = major*10000 + minor*100
end
function Omen:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventtype, hideCaster, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
-- Pre-4.1 CLEU compat
if TOC < 40100 and hideCaster ~= dummyTable then
-- Insert a dummy for the new argument introduced in 4.1 and perform a tail call
return self:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventtype, dummyTable, hideCaster, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
elseif TOC >= 40200 and recurse then
local arg1 = ...
recurse = false
return self:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventtype, hideCaster, srcGUID, srcName, srcFlags, dstName, dstFlags, arg1, select(3, ...))
end
recurse = true
-- Rest of Omen code
end
It only uses tailcalls if the version is NOT 4.1, so for standard users suffer no performance penalties. Omegal's solution is essentially the same thing, just that he created a second function to call the original, and I instead made the function call itself.
Note the unorthodox way of calculating the TOC only because for most of the 4.1 PTR testing, the 4th return of GetBuildInfo() returned 40000 rather than 40100.