WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   Tutorials & Other Helpful Info. (http://www.wowinterface.com/forums/forumdisplay.php?f=12)
-   -   4.2 COMBAT_LOG_EVENT_UNFILTERED changed (again) (http://www.wowinterface.com/forums/showthread.php?t=40010)

Ketho 05-05-11 07:52 AM

4.2 COMBAT_LOG_EVENT_UNFILTERED changed (again)
 
Quote:

  • 4.1: timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags
  • 4.2: timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags

It seems that Blizzard has run out of space on the original UnitFlags, so they had to add another pair of UnitFlags parameters, and for now at least, moved the Raid Target Icon Flags into there
  • FrameXML
    Blizzard_CombatLog.lua L2180 CombatLog_OnEvent
    Blizzard_CombatLog.lua L2037 CombatLog_String_GetIcon
-- credits to the wowace.com, us.battle.net threads

Rilgamon 05-05-11 11:38 AM

hehe, we're not even trough with the first change ;)

Ketho 05-12-11 12:31 PM

This time Blizzard wasn't so lazy and properly updated the TOC on the PTRs to 40200 which is less of a hassle :)
I'm interested in the solutions for forwards compatibility, and I want to share some myself
  • Quoting the forwards compatible fix of Omegal:
    Code:

    -- fix for 4.2 which introduces some new argument
    -- this is a temporary work-around which just drops the new argument for a quick and easy fix that is compatible with 4.2

    if tonumber((select(4, GetBuildInfo()))) >= 40200 then
            local oldHandler = mod.COMBAT_LOG_EVENT_UNFILTERED
            function mod:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, mysteryArgument, destGUID, destName, destFlags, anotherMysteryArgument, ...)
                    return oldHandler(self, timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...)
            end
    end

  • Here is my own (Ace3) fowards compatible fix:
    Lua Code:
    1. local toc = select(4, GetBuildInfo())
    2.  
    3. function MyAddOn:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
    4.     local timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags
    5.     local spellID, spellName, spellSchool
    6.     local SuffixParam1, SuffixParam2, SuffixParam3, SuffixParam4, SuffixParam5, SuffixParam6, SuffixParam7, SuffixParam8, SuffixParam9
    7.  
    8.     local suffixPos
    9.     if toc >= 40200 then
    10.         timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
    11.         suffixPos = 12
    12.     else
    13.         timestamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = ...
    14.         suffixPos = 10
    15.     end
    16.  
    17.     local prefix = strsub(subevent, 1, 5)
    18.     if prefix == "SWING" then
    19.         SuffixParam1, SuffixParam2, SuffixParam3, SuffixParam4, SuffixParam5, SuffixParam6, SuffixParam7, SuffixParam8, SuffixParam9 = select(suffixPos, ...)
    20.     elseif prefix == "SPELL" or prefix == "RANGE" then
    21.         spellID, spellName, spellSchool, SuffixParam1, SuffixParam2, SuffixParam3, SuffixParam4, SuffixParam5, SuffixParam6, SuffixParam7, SuffixParam8, SuffixParam9 = select(suffixPos, ...)
    22.     end
    23.  
    24.     -- do stuff
    25. end
I've also seen some addons use a "tail call" solution for patch 4.1.0,
but I'm not sure how it would be done now for patch 4.2.0

Edit:
Myself I still don't really understand the mod stuff/solution though, but somehow it looks like a way better solution .. (><)

Ailae 05-12-11 01:00 PM

It saves a reference to the old handler for CLEU and then declares a new one. The new one then has the new parameters in the function-call (so things line up correctly) and then just passes the all parameters besides the new ones to the old handler.

Xinhuan 05-13-11 10:29 PM

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.


All times are GMT -6. The time now is 07:23 AM.

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC