View Single Post
04-04-13, 07:18 PM   #20
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Rainrider View Post
I asume the Blizzard event dispatcher is C coded, but they set an OnUpdate script for the stock frames instead of registering UNIT_HEALTH_FREQUENT. Why would they do that? The only reason I could think of would be that UNIT_HEALTH_FREQUENT does not work like other events and simply sets an OnUpdate script on the frame it gets registered to.
It doesn't, as you can set your own OnUpdate script without preventing UNIT_HEALTH_FREQUENT from working. The only difference between UNIT_HEALTH and UNIT_HEALTH_FREQUENT is that the former only fires every 0.2 seconds, while the latter fires more often (I'm not sure exactly how often). There's just a bug in Blizzard's code right now that prevents UNIT_HEALTH from firing for boss units. It's not because the event itself is mysteriously "different" from other events; it's just a coincidence that the two events are so closely related. It could just as easily be UNIT_POWER that was bugged, or UNIT_NAME_UPDATE, or UNIT_AURA, or anything else.

As for Blizzard's code using OnUpdate scripts instead of UNIT_HEALTH_FREQUENT, there are two equally likely reasons for that:

1) They actually want to use UNIT_HEALTH, but the UI coders know it's bugged, and are using an OnUpdate script as a temporary workaround until the C coders fix the bug.

2) The code was written before UNIT_HEALTH_FREQUENT existed, and the UI coders have just not bothered updating it. You can see lots of examples of this throughout the Blizzard UI code.

Originally Posted by Rainrider View Post
OnUpdate is also a kind of event handler reacting to the event of refreshing the screen, isn't it?
You could think of it that way, but that's not really accurate. In layman's terms, redrawing the screen is an "event", but in WoW API terms, it's not, as that term is reserved for the specific meaning as relates to RegisterEvent etc.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote