From b0efbc84241170b619d6cae34be74c315cc5f4ce Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sat, 16 Mar 2013 08:03:48 +0000 Subject: [PATCH] Code cleanup. * Functions should start with a capital letter. * Lua coding style nit: use ``tinsert'' instead of ``a[#a+1] = ...''. * Remove unnecesary bookkeeping in OvaleCompile that was only used in a rare debugging event. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@778 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- Ovale.lua | 2 +- OvaleActionBar.lua | 4 ++-- OvaleAura.lua | 4 ++-- OvaleBestAction.lua | 2 +- OvaleCompile.lua | 17 ++++------------- OvaleEnemies.lua | 6 +++--- OvaleFuture.lua | 3 ++- OvaleGUID.lua | 2 +- 8 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Ovale.lua b/Ovale.lua index f00b233..4937234 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -57,7 +57,7 @@ BINDING_NAME_OVALE_CHECKBOX3 = L["Inverser la boîte à cocher "].."(4)" BINDING_NAME_OVALE_CHECKBOX4 = L["Inverser la boîte à cocher "].."(5)" -- -function Ovale:debugPrint(flag, ...) +function Ovale:DebugPrint(flag, ...) local profile = OvaleOptions:GetProfile() if profile and profile.debug and profile.debug[flag] then self:Print("[" .. flag .. "]", ...) diff --git a/OvaleActionBar.lua b/OvaleActionBar.lua index 13d658f..b52a77a 100644 --- a/OvaleActionBar.lua +++ b/OvaleActionBar.lua @@ -48,12 +48,12 @@ function OvaleActionBar:ACTIONBAR_SLOT_CHANGED(event, slot, unknown) elseif (slot) then -- on reçoit aussi si c'est une macro avec mouseover à chaque fois que la souris passe sur une cible! self:FillActionIndex(tonumber(slot)) - Ovale:debugPrint("action_bar", "Mapping button " ..tonumber(slot).." to spell/macro") + Ovale:DebugPrint("action_bar", "Mapping button " ..tonumber(slot).." to spell/macro") end end function OvaleActionBar:FillActionIndexes(event) - Ovale:debugPrint("action_bar", "Mapping buttons to spells/macros for " ..event) + Ovale:DebugPrint("action_bar", "Mapping buttons to spells/macros for " ..event) wipe(actionSpell) wipe(actionMacro) wipe(actionItem) diff --git a/OvaleAura.lua b/OvaleAura.lua index e1b8042..e4db07f 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -208,13 +208,13 @@ function OvaleAura:UpdateAuras(unitId, unitGUID) for spellId,whoseTable in pairs(auraList) do for whose,aura in pairs(whoseTable) do if aura.serial ~= self.serial then - Ovale:debugPrint("aura", "Removing "..aura.name.." from "..whose .. " self.serial = " ..self.serial .. " aura.serial = " ..aura.serial) + Ovale:DebugPrint("aura", "Removing "..aura.name.." from "..whose .. " self.serial = " ..self.serial .. " aura.serial = " ..aura.serial) whoseTable[whose] = nil auraPool:Release(aura) end end if not next(whoseTable) then - Ovale:debugPrint("aura", "Removing "..spellId) + Ovale:DebugPrint("aura", "Removing "..spellId) auraList[spellId] = nil end end diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index afe85df..d39e320 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -104,7 +104,7 @@ function OvaleBestAction:GetActionInfo(element) actionCooldownStart, actionCooldownDuration, actionEnable = OvaleState:GetComputedSpellCD(spellId) if not actionCooldownStart or not actionCooldownDuration then - Ovale:debugPrint("unknown_spells", "No cooldown data for spell "..spellId) + Ovale:DebugPrint("unknown_spells", "No cooldown data for spell "..spellId) end local si = OvaleData:GetSpellInfo(spellId) diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 45d7e93..198eb0f 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -18,7 +18,6 @@ local node = {} local nodePool = OvalePool:NewPool("OvaleCompile_nodePool") local defines = {} local customFunctions = {} -local unknownSpellNodes = {} local missingSpellList = {} -- Whether to trigger a script compilation if items or stances change. @@ -40,8 +39,7 @@ OvaleCompile.masterNodes = {} -- local function AddNode(newNode) tinsert(node, newNode) - newNode.nodeId = #node - return "node" .. newNode.nodeId + return "node" .. #node end local function ParseParameters(params) @@ -207,13 +205,11 @@ local function ParseFunction(prefix, func, params) end if spellName then if spellName == GetSpellInfo(spellName) then - Ovale:debugPrint("missing_spells", "Learning spell "..tostring(spellName).." with ID "..spellId) + Ovale:DebugPrint("missing_spells", "Learning spell "..tostring(spellName).." with ID "..spellId) missingSpellList[spellId] = spellName - else - unknownSpellNodes[newNode.nodeId] = spellId end else - Ovale:debugPrint("unknown_spells", "Unknown spell with ID "..spellId) + Ovale:DebugPrint("unknown_spells", "Unknown spell with ID "..spellId) end end end @@ -654,7 +650,6 @@ local function CompileScript(text) Ovale.bug = false wipe(defines) - wipe(unknownSpellNodes) wipe(missingSpellList) -- Return all existing nodes to the node pool. @@ -727,7 +722,7 @@ function OvaleCompile:OnDisable() end function OvaleCompile:EventHandler(event) - Ovale:debugPrint("compile", event) + Ovale:DebugPrint("compile", event) self:Compile() end @@ -772,11 +767,7 @@ function OvaleCompile:DebugNode(node) text = text .. "}\n" elseif (node.type == "function") then text = node.func.."(" - local spellId = unknownSpellNodes[node.nodeId] for k,p in pairs(node.params) do - if spellId and p == spellId then - p = p .. ":unknown" - end text = text .. k.."=" .. p .. " " end text = text .. ")" diff --git a/OvaleEnemies.lua b/OvaleEnemies.lua index 8ac6eca..4874079 100644 --- a/OvaleEnemies.lua +++ b/OvaleEnemies.lua @@ -43,21 +43,21 @@ function OvaleEnemies:COMBAT_LOG_EVENT_UNFILTERED(event, ...) enemies[v] = nil numberOfEnemies = numberOfEnemies - 1 Ovale.refreshNeeded["player"] = true - Ovale:debugPrint("enemy", "enemy die") + Ovale:DebugPrint("enemy", "enemy die") end end elseif sourceFlags and not enemies[sourceGUID] and bit_band(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE)>0 and bit_band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) > 0 and destFlags and bit_band(destFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == 0 then enemies[sourceGUID] = true - Ovale:debugPrint("enemy", "new enemy source=" .. tostring(sourceName)) + Ovale:DebugPrint("enemy", "new enemy source=" .. tostring(sourceName)) numberOfEnemies = numberOfEnemies + 1 Ovale.refreshNeeded["player"] = true elseif destGUID and not enemies[destGUID] and bit_band(destFlags, COMBATLOG_OBJECT_REACTION_HOSTILE)>0 and bit_band(destFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) > 0 and sourceFlags and bit_band(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_OUTSIDER) == 0 then enemies[destGUID] = true - Ovale:debugPrint("enemy", "new enemy dest=".. tostring(destName)) + Ovale:DebugPrint("enemy", "new enemy dest=".. tostring(destName)) numberOfEnemies = numberOfEnemies + 1 Ovale.refreshNeeded["player"] = true end diff --git a/OvaleFuture.lua b/OvaleFuture.lua index 3c9753d..9647b6d 100644 --- a/OvaleFuture.lua +++ b/OvaleFuture.lua @@ -17,6 +17,7 @@ local ipairs = ipairs local pairs = pairs local select = select local strfind = string.find +local tinsert = table.insert local tremove = table.remove local GetSpellInfo = GetSpellInfo @@ -274,7 +275,7 @@ function OvaleFuture:AddSpellToList(spellId, lineId, startTime, endTime, channel self.lastSpellSP[spellId] = OvalePaperDoll.spellBonusDamage self.lastSpellDM[spellId] = OvaleAura:GetDamageMultiplier(spellId) self.lastSpellMastery[spellId] = OvalePaperDoll.masteryEffect - lastSpell[#lastSpell+1] = newSpell + tinsert(lastSpell, newSpell) local si = OvaleData.spellInfo[spellId] if si then diff --git a/OvaleGUID.lua b/OvaleGUID.lua index d5e2aa5..0a96e82 100644 --- a/OvaleGUID.lua +++ b/OvaleGUID.lua @@ -69,7 +69,7 @@ function OvaleGUID:Update(unitId) if not self.unitId[guid] then self.unitId[guid] = {} end - Ovale:debugPrint("guid", "GUID "..guid.." is ".. unitId) + Ovale:DebugPrint("guid", "GUID "..guid.." is ".. unitId) self.unitId[guid][unitId] = true end end -- 1.7.9.5