Skip to content

Commit

Permalink
Added missing pairs(...) to "for ... in table"
Browse files Browse the repository at this point in the history
  • Loading branch information
DeTosc committed Sep 2, 2019
1 parent 87a6a49 commit e0f251d
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 131 deletions.
16 changes: 7 additions & 9 deletions GFW_HuntersHelper/GFWTable.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
------------------------------------------------------
-- GFWTable.lua
-- Utilities for manipulating tables
-- Utilities for manipulating tables
------------------------------------------------------

GFWTABLE_THIS_VERSION = 5;
Expand Down Expand Up @@ -31,8 +31,8 @@ end

-- Median: returns the median value (most useful in a table of numbers, but usable in any sorted table)
function GFWTable_temp_Median(aTable)
if (aTable == nil or table.getn(aTable) == 0) then
return nil;
if (aTable == nil or table.getn(aTable) == 0) then
return nil;
end
if (table.getn(aTable) == 1) then
return aTable[1];
Expand Down Expand Up @@ -115,15 +115,15 @@ function GFWTable_temp_KeyOf(aTable, item)
if (aTable == nil or type(aTable) ~= "table") then
return nil; -- caller probably won't expect this, causing traceable error in their code
end
for key, value in aTable do
for key, value in pairs(aTable) do
if (item == value) then
return key;
end
end
return nil;
end

-- Copy: copies one table's elements into a new table (useful if you want to change them while preserving the first table).
-- Copy: copies one table's elements into a new table (useful if you want to change them while preserving the first table).
-- Not a deep copy.
function GFWTable_temp_Copy(aTable)
local newTable = { };
Expand All @@ -139,7 +139,7 @@ function GFWTable_temp_Count(aTable)
return nil; -- caller probably won't expect this, causing traceable error in their code
end
local count = 0;
for key, value in aTable do
for key, value in pairs(aTable) do
count = count + 1;
end
return count;
Expand All @@ -166,9 +166,7 @@ if (G.Version == nil or (tonumber(G.Version) ~= nil and G.Version < GFWTABLE_THI
G.KeyOf = GFWTable_temp_KeyOf;
G.Copy = GFWTable_temp_Copy;
G.Count = GFWTable_temp_Count;

-- Set version number
G.Version = GFWTABLE_THIS_VERSION;
end


26 changes: 13 additions & 13 deletions GFW_HuntersHelper/GFWZones.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
------------------------------------------------------
-- GFWZones.lua
-- Utilities for working with geographic data
-- Utilities for working with geographic data
------------------------------------------------------

GFWZONES_THIS_VERSION = 6;
Expand All @@ -17,13 +17,13 @@ function GFWZones_temp_LocalizedZone(aZone)
return localized;
else
return aZone;
end
end
end

function GFWZones_temp_UnlocalizedZone(aZone)
local key = GFWTable.KeyOf(GFWZones.Localized, aZone);
if (key) then
return key;
return key;
else
return aZone;
end
Expand All @@ -33,19 +33,19 @@ function GFWZones_temp_ConnectionsForZone(aZone)

local G = GFWZones;
aZone = G.UnlocalizedZone(aZone);

local zoneConnections = { };
local _, myFaction = UnitFactionGroup("player");

if not (G.AdjacentZones[aZone] or G.FlightZones[myFaction][aZone]) then return nil; end

-- find zones one step away (adjacent to this zone or one flight/boat/zeppelin away)
zoneConnections[1] = GFWTable.Merge(G.AdjacentZones[aZone], G.FlightZones[myFaction][aZone]);
zoneConnections[1] = GFWTable.Subtract(zoneConnections[1], {aZone});

-- then iterate to find zones more than one step away
numSteps = 2;
repeat
repeat
zoneConnections[numSteps] = { };
for i=1, table.getn(zoneConnections[numSteps-1]) do
zoneConnections[numSteps] = GFWTable.Merge(zoneConnections[numSteps], G.FlightZones[myFaction][zoneConnections[numSteps-1][i]]);
Expand Down Expand Up @@ -153,7 +153,7 @@ local tempAdjacentZones = {

local tempFlightZones = {
[FACTION_ALLIANCE] = {
-- Deeprun Tram is in here even though it's not a "flight" per se because Horde can't easily travel through it.
-- Deeprun Tram is in here even though it's not a "flight" per se because Horde can't easily travel through it.
["Arathi Highlands"] = {"Hillsbrad Foothills", "Ironforge", "The Hinterlands", "Loch Modan", "Wetlands", "Arathi Basin"},
["Ashenvale"] = {"Darkshore"},
["Azshara"] = {"Felwood", "Darkshore"},
Expand Down Expand Up @@ -232,7 +232,7 @@ if (G.Version == nil or (tonumber(G.Version) ~= nil and G.Version < GFWZONES_THI
if (G.AdjacentZones == nil) then
G.AdjacentZones = {};
end
for aZone, adjacentZones in tempAdjacentZones do
for aZone, adjacentZones in pairs(tempAdjacentZones) do
if (G.AdjacentZones[aZone] == nil) then
G.AdjacentZones[aZone] = {};
end
Expand All @@ -241,11 +241,11 @@ if (G.Version == nil or (tonumber(G.Version) ~= nil and G.Version < GFWZONES_THI
if (G.FlightZones == nil) then
G.FlightZones = {};
end
for _, faction in {FACTION_ALLIANCE, FACTION_HORDE} do
for _, faction in pairs({FACTION_ALLIANCE, FACTION_HORDE}) do
if (G.FlightZones[faction] == nil) then
G.FlightZones[faction] = {};
end
for aZone, flightZones in tempFlightZones[faction] do
for aZone, flightZones in pairs(tempFlightZones[faction]) do
if (G.FlightZones[faction][aZone] == nil) then
G.FlightZones[faction][aZone] = {};
end
Expand All @@ -257,7 +257,7 @@ if (G.Version == nil or (tonumber(G.Version) ~= nil and G.Version < GFWZONES_THI
G.LocalizedZone = GFWZones_temp_LocalizedZone;
G.UnlocalizedZone = GFWZones_temp_UnlocalizedZone;
G.ConnectionsForZone = GFWZones_temp_ConnectionsForZone;

-- Set version number
G.Version = GFWZONES_THIS_VERSION;
end
Expand Down
2 changes: 1 addition & 1 deletion GFW_HuntersHelper/GFW_HuntersHelper.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 11302
## Version: 11302
## Version: 11302.1
## Title: Fizzwidget Hunter's Helper
## Author: Gazmik Fizzwidget
## Notes: Helps you find tameable beasts to learn pet skills from.
Expand Down
Loading

0 comments on commit e0f251d

Please sign in to comment.