View Single Post
Old 05-13-11, 10:29 PM   #5
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 170
I use this for pre-4.1, 4.1 and 4.2 compat:

lua Code:
  1. local TOC -- Pre-4.1 CLEU compat
  2. local dummyTable = {}
  3. local recurse = true
  4. do
  5.     -- Because GetBuildInfo() still returns 40000 on the PTR
  6.     local major, minor, rev = strsplit(".", (GetBuildInfo()))
  7.     TOC = major*10000 + minor*100
  8. end
  9. function Omen:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventtype, hideCaster, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  10.     -- Pre-4.1 CLEU compat
  11.     if TOC < 40100 and hideCaster ~= dummyTable then
  12.         -- Insert a dummy for the new argument introduced in 4.1 and perform a tail call
  13.         return self:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventtype, dummyTable, hideCaster, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...)
  14.     elseif TOC >= 40200 and recurse then
  15.         local arg1 = ...
  16.         recurse = false
  17.         return self:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventtype, hideCaster, srcGUID, srcName, srcFlags, dstName, dstFlags, arg1, select(3, ...))
  18.     end
  19.     recurse = true
  20.  
  21.     -- Rest of Omen code
  22. 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.
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
Xinhuan is offline   Reply With Quote