changeset 440:a4256abd13b7

Added a conditional check to protect against collecting instance information when not in an instance.
author MMOSimca <MMOSimca@gmail.com>
date Sat, 28 Feb 2015 05:01:29 -0500
parents 2baf8d90d8a8
children 7e0ef2127b49
files Main.lua
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Main.lua	Fri Feb 27 07:40:07 2015 -0500
+++ b/Main.lua	Sat Feb 28 05:01:29 2015 -0500
@@ -350,12 +350,16 @@
 
 
 local function InstanceDifficultyToken()
-    local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo()
-
-    if not instance_type or instance_type == "" then
-        instance_type = "NONE"
+    -- Sometimes, instance information is returned when not in an instance. This check protects against that.
+    if _G.IsInInstance() then
+        local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo()
+
+        if not instance_type or instance_type == "" then
+            instance_type = "NONE"
+        end
+        return ("%s:%d:%s"):format(instance_type:upper(), instance_difficulty, tostring(is_dynamic))
     end
-    return ("%s:%d:%s"):format(instance_type:upper(), instance_difficulty, tostring(is_dynamic))
+    return "NONE:0:false"
 end