Quantcast

Adopt to terminally breaking change in the way of getting one's realm.

Coren[m] [12-15-13 - 16:28]
Adopt to terminally breaking change in the way of getting one's realm.
Work around an issue with talent discovery handling while a raid is falling apart.
Filename
Karma/karma.lua
Karma/karmaDB.lua
diff --git a/Karma/karma.lua b/Karma/karma.lua
index bdd68c2..4038ba4 100755
--- a/Karma/karma.lua
+++ b/Karma/karma.lua
@@ -3013,12 +3013,16 @@ function	Karma_AutofetchTalents()
 				if (oMember) then
 					local	oOut = oMember[KARMA_DB_L5_RRFFM_TALENTTREE] or {};
 					local	oIn, k, v = KARMA_TalentInspect.TalentsReadyCallList[1];
-					for k, v in pairs(oIn) do
-						oOut[k] = oIn[k];
+					-- this shouldn't be nil, but when the unit left the raid during the attempt to read back talents, it can be
+					if (oIn) then
+						for k, v in pairs(oIn) do
+							oOut[k] = oIn[k];
+						end
+
+						oMember[KARMA_DB_L5_RRFFM_TALENTTREE] = oOut;
+						KARMA_TalentInspect.TalentsReadyCallList = {};
+						bSuccess = true;
 					end
-					oMember[KARMA_DB_L5_RRFFM_TALENTTREE] = oOut;
-					KARMA_TalentInspect.TalentsReadyCallList = {};
-					bSuccess = true;

 					KARMA_TalentInspect.RequestedUnitInventoryIncomplete = KarmaObj.Events.UNIT_INVENTORY_CHANGED(nil, KARMA_TalentInspect.RequestedUnit, oMember);
 					KarmaChatSecondaryFallbackDefault("Successfully updated talents on " .. KARMA_TalentInspect.RequestedMember .. ".");
diff --git a/Karma/karmaDB.lua b/Karma/karmaDB.lua
index bdff0c7..4966501 100755
--- a/Karma/karmaDB.lua
+++ b/Karma/karmaDB.lua
@@ -626,7 +626,14 @@ function	KarmaObj.DB.ServerCreate(oFactionDB, sRealm, bPartial)
 end

 function	KarmaObj.DB.Create()
-	local	sRealm = GetCVar("realmName");
+	local	sRealm;
+	if (GetRealmName ~= nil) then
+		-- 5.4: realmname is no longer a global variable
+		sRealm = GetRealmName();
+	else
+		sRealm = GetCVar("realmName");
+	end
+
 	local	sPlayerFaction = UnitFactionGroup("player");
 	if ((sRealm == nil) or (sPlayerFaction == nil)) then
 		local	s = "";