I find sometimes that I have to write something down, even if the information can be readily looked up somewhere, in order for it to be fixed in my mind. While trying to debug a problem with the interactions between WoWPro, TomTom and Astrolabe, I quickly realized I needed a referesher on events.
Astonishingly enough, the whole UI is single threaded. The game engine fires off events in response to messages from the server or various timers going off or other nonsense. But once a handler for an event starts running, it controls the processor until it is done. That is why doing too much work in a function can grind everything to a halt. The game engine meanwhile queues up all the pending events and then blasts them out after that greedy function returns.
But what I wanted to write down was the startup sequence and the sequence of events around cinematic scenes and around zone changes.
The first thing that happens is that when the client starts, it looks through the Interface\Addons directory and loads all the .TOC files and any .XML files that referenced. This is used to build the list of files which will be loaded. Any changes to .TOC or .XML files will not take effect until the client is restarted. Each .TOC file may include dependency information, which will cause that addon to be loaded before it gets loaded.
The client then presents the user with the menu of realms and characters and lets the user select/create/delete them. After a one is selected, the load process starts. Addons are loaded mostly alphabetically, unless a dependency alters the order. The files for a given addon are then loaded in the order specified in the .TOC and .XML files and and then any saved variables specified in the .TOC then our first event fires off, ADDON_LOADED. So this event goes off for every addon that is going to be loaded, and then we are done with the addons. If any addon was marked for load on demand, then the loading is postponed till after PLAYER_ALIVE.
Now we get into the actual login process.
- SPELLS_CHANGED: Basic character information is availible. May fire more than once. You may see Blizzard ADDON_LOADED components.
- PLAYER_LOGIN: All UI Sizing and Position is done, one-time initialization for Addons should be done now.
- PLAYER_ENTERING_WORLD: Fires at the end of the load screen.
- PLAYER_ALIVE: Quest and Talent information is now availible. (Also fires when you become alive after dying)
- VARIABLES_LOADED: Fires when all the Bilzzard initialization is done. Could happen anytime from the first ADDON_LOADED till after PLAYER_ENTERING_WORLD.
- Load on Demand Addons are loaded.
Mixed in are some PLAYER_TALENT_UPDATE events, which cause you to unlearn everything before PLAYER_LEAVING_WORLDand then relearn after PLAYER_ENTERING_WORLD.