Merge branch 'master' of git://cams.pavlovian.net/questhelper
[QuestHelper.git] / cartographer_is_terrible.lua
bloba47a3d2fe3e7b8e29bab4c2ff57ba3861e92830b
1 QuestHelper_File["cartographer_is_terrible.lua"] = "Development Version"
2 QuestHelper_Loadtime["cartographer_is_terrible.lua"] = GetTime()
4 -- http://gunnerkrigg.wikia.com/wiki/Category:Terrible
6 if Cartographer and Cartographer.SetCurrentInstance and Cartographer_InstanceMaps and Cartographer_InstanceMaps.OnEnable and not Cartographer.TheInstanceBugIsFixedAlready_YouCanStopHackingIt then
7 local nop = function () end
9 function hookitsbrainsout(name)
10 local oldfunc = _G[name]
11 _G[name] = function(...)
12 local temp = WorldMapLevelDropDown_Update
13 WorldMapLevelDropDown_Update = nop -- YOINK
14 oldfunc(...)
15 WorldMapLevelDropDown_Update = temp -- KNIOY
16 end
17 end
19 local oldenable = Cartographer_InstanceMaps.OnEnable
20 function Cartographer_InstanceMaps:OnEnable(...)
21 oldenable(self, ...)
23 hookitsbrainsout("SetMapZoom")
24 hookitsbrainsout("SetMapToCurrentZone")
25 end
27 -- BEHOLD, MY MADNESS! BEHOLD AND SUFFER
29 -- BEHOOOOOOLD
30 end
34 -- okay okay I guess I'll explain
36 -- There's a bug in Cartographer where SetMapZoom() or SetMapToCurrentZone(), called in an instance, causes any open menus to instantly close. Questhelper (and in general, anything that uses Astrolabe, and other UI mods as well) call those function every frame if the map is closed. This isn't a performance problem or anything, but it happens to trigger the Cartographer bug.
38 -- The top two bugs on the Cartographer tracker are both this one, as well as a third bug listed later down. I've talked to both of the possibly-main Cartographer maintainers about fixing it, neither are interested. It's pretty clearly not going to be fixed.
40 -- So here's a hack. The problem is the WorldMapLevelDropDown_Update call which, after a few nested calls, is eventually called. Why's it there? I dunno. What will removing it break? Not a clue. This cute little hook automatically disables it during the call of the important functions. Will this be a problem for Cartographer? Damned if I know. Will it be *my* problem? No! No it will not.
42 -- If the Cartographer crew ever fixes it properly, this hook can be disabled by simply doing Cartographer.TheInstanceBugIsFixedAlready_YouCanStopHackingIt = true. And it will go away. Until then, the bug will go away.
44 -- LOOK HOW MUCH MY PROBLEM THIS ISN'T ANYMORE