Quantcast

Overhead reduction

Erik L. Vonderscheer [09-25-10 - 05:00]
Overhead reduction
Docs update
4.0.1 compatibility
Filename
.docmeta
Docs/default-filters.txt
Docs/default-lists.txt
Docs/main.txt
TradeFilter3.lua
TradeFilter3.toc
TradeFilter3Options.lua
diff --git a/.docmeta b/.docmeta
index 1ebd7f5..519bb45 100644
--- a/.docmeta
+++ b/.docmeta
@@ -10,3 +10,11 @@
   type: creole
   input-file: Docs/flow.txt
   output-page: "Flow"
+-
+  type: creole
+  input-file: Docs/default-filters.txt
+  output-page: "default-filters"
+-
+  type: creole
+  input-file: Docs/defualt-lists.txt
+  output-page: "defualt-lists"
diff --git a/Docs/default-filters.txt b/Docs/default-filters.txt
new file mode 100644
index 0000000..9f510bf
--- /dev/null
+++ b/Docs/default-filters.txt
@@ -0,0 +1,61 @@
+TradeFilters default channel filters:
+
+##Trade Filters##:
+<<code php>>
+TRADE = {
+  FILTER1 = "[bB][uU][yY][iI][nN][gG]",
+  FILTER10 = "[lL][fF] [pP][oO][rR][tT]",
+  FILTER2 = "[wW][tT][bBsStT]",
+  FILTER3 = "[lL][fF][wWeE]",
+  FILTER4 = "[lL][fF] [eE][nN][cC][hH][aA][nN][tT]",
+  FILTER5 = "[lL][fF] [jJ][cC]",
+  FILTER6 = "AH",
+  FILTER7 = "looking for work",
+  FILTER8 = "lockpick",
+  FILTER9 = "[sS][eE][lL][lL][iI][nN][gG]",
+}<</code>>
+
+##Base Channel Filters##:
+<<code php>>
+BASE = {
+  FILTER1 = "[lL][fF]%d[mM]?",
+  FILTER2 = "[lL][fF][mM]?",
+  FILTER3 = "[lL][fF][gG]",
+  FILTER4 = "2[vV]2",
+  FILTER5 = "3[vV]3",
+  FILTER6 = "5[vV]5",
+  FILTER7 = "[lL][fF] [dD][pP][sS]",
+  FILTER8 = "[lL][fF] [tT][aA][nN][kK]",
+  FILTER9 = "[lL][fF] [hH][eE][aA][lL][eE][rR]",
+}<</code>>
+
+##Battleground Channel Filters##:
+<<code php>>
+BG = {
+  FILTER1 = "^[iI][nN][cC]$",
+  FILTER10 = "[pP][uU][rR][pP][lL][eE]",
+  FILTER11 = "[fF][aA][rR][mM]",
+  FILTER12 = "^[gG][mM]$",
+  FILTER13 = "[mM][iI][nN][eE]",
+  FILTER14 = "[mM][iI][lL][lL]",
+  FILTER15 = "^[lL][mM]$",
+  FILTER16 = "^[bB][sS]$",
+  FILTER17 = "[bB][lL][aA][cC][kK][sS][mM][iT][hH]",
+  FILTER18 = "^[sS][tT]$",
+  FILTER19 = "[sS][tT][aA][bB][lL][eE][sS]",
+  FILTER2 = "^[fF][cC]$",
+  FILTER20 = "[dD][rR][eE][kK]",
+  FILTER21 = "[bB][lL][uU][eE]",
+  FILTER22 = "[rR][eE][dD]",
+  FILTER3 = "^[gG][yY]$",
+  FILTER4 = "^[fF][rR]$",
+  FILTER5 = "^[fF][rR][rR]$",
+  FILTER6 = "^[mM][tT]$",
+  FILTER7 = "^[dD][rR]$",
+  FILTER8 = "[gG][oO][lL][dD]",
+  FILTER9 = "[gG][rR][eE][eE][nN]",
+}
+<</code>>
+
+Note: Adding a set, e.g. [xXyY], will attempt to find a match for any character given in a set. Example: lf[wWeEmM] will match for lfw, lfe and lfm.
+  e.g. http://www.wowwiki.com/Pattern_matching
diff --git a/Docs/default-lists.txt b/Docs/default-lists.txt
new file mode 100644
index 0000000..5a31725
--- /dev/null
+++ b/Docs/default-lists.txt
@@ -0,0 +1,33 @@
+TradeFilters default Black/White lists:
+
+##White List##:
+<<code php>>
+TRADE = {
+  FILTER1 = "[bB][uU][yY][iI][nN][gG]",
+  FILTER10 = "[lL][fF] [pP][oO][rR][tT]",
+  FILTER2 = "[wW][tT][bBsStT]",
+  FILTER3 = "[lL][fF][wWeE]",
+  FILTER4 = "[lL][fF] [eE][nN][cC][hH][aA][nN][tT]",
+  FILTER5 = "[lL][fF] [jJ][cC]",
+  FILTER6 = "AH",
+  FILTER7 = "looking for work",
+  FILTER8 = "lockpick",
+  FILTER9 = "[sS][eE][lL][lL][iI][nN][gG]",
+}<</code>>
+
+##Black List##:
+<<code php>>
+BASE = {
+  FILTER1 = "[lL][fF]%d[mM]?",
+  FILTER2 = "[lL][fF][mM]?",
+  FILTER3 = "[lL][fF][gG]",
+  FILTER4 = "2[vV]2",
+  FILTER5 = "3[vV]3",
+  FILTER6 = "5[vV]5",
+  FILTER7 = "[lL][fF] [dD][pP][sS]",
+  FILTER8 = "[lL][fF] [tT][aA][nN][kK]",
+  FILTER9 = "[lL][fF] [hH][eE][aA][lL][eE][rR]",
+}<</code>>
+
+Note: Adding a set, e.g. [xXyY], will attempt to find a match for any character given in a set. Example: lf[wWeEmM] will match for lfw, lfe and lfm.
+  e.g. http://www.wowwiki.com/Pattern_matching
diff --git a/Docs/main.txt b/Docs/main.txt
index 9f33e76..0517e4c 100644
--- a/Docs/main.txt
+++ b/Docs/main.txt
@@ -6,37 +6,13 @@ TradeFilter does not only filter trade but has the ability to filter General, Lo
 === Channel Filters
 TradeFilter has a set of patterns for trade channel and separate set of patterns for all other channels, or "base" channels as we will call them. This allows the user to define what patterns may be good for trade but not other channels and vise versa. The user also has the ability to add patterns of their own to be matched against for both trade and "base" channel filters.\\

-##Trade Filters##:
-<<code php>>
-lf port,
-buying,
-wt[bBsStT],
-lf[wWeE],
-lf enchant,
-lf jc,
-AH,
-looking for work,
-lockpick,
-selling,
-buying,
-<</code>>
-##Base Channel Filters##:
-<<code php>>
-lf dps,
-lf tank,
-lf healer,
-lf#m?,
-lfm?,
-lfg,
-2v2,
-3v3,
-5v5
-<</code>>
-Adding a set, e.g. [xXyY], will attempt to find a match for any character given in a set. Example: lf[wWeEmM] will match for lfw, lfe and lfm.
+[[http://www.wowace.com/projects/trade-filter/default-filters/|Default Channel Filters]]\\

 === Black and White Lists
 TradeFilter also has a built in Black and White list. Refer to the [[http://www.wowace.com/addons/trade-filter/pages/flow/|flowchart]] for how Black and White lists are checked.

+[[http://www.wowace.com/projects/trade-filter/default-lists/|Default Black/White Lists]]\\
+
 === Configuration
 <<code php>>/tf or /filter<</code>>

diff --git a/TradeFilter3.lua b/TradeFilter3.lua
index b88bfc6..0ba386c 100644
--- a/TradeFilter3.lua
+++ b/TradeFilter3.lua
@@ -67,7 +67,7 @@ repeatdata = {}

 local PROJECT_VERSION = "@project-version@"
 local PROJECT_REVISION = 000 + tonumber(("$Revision: @project-revision@ $"):match("%d+"))
-TF3.date = sub("$Date: @file-date-iso@ $", 8, 17)
+TF3.date = sub("$Date: @project-date-iso@ $", 8, 17)
 TF3.version = gsub(PROJECT_VERSION, "-release", "")

 --[[ Database Defaults ]]--
@@ -236,6 +236,16 @@ function TF3:GetNumElements(t)
  return count
 end

+function TF3:getnHash(t)
+   local count = 0;
+   if not t then return 0; end
+   if (type(t)) ~= "table" then return 0; end
+   for i,_ in pairs(t) do
+      count = count + 1;
+   end
+   return count;
+end
+
 function TF3:RecycleTables(t, state)
 	local gtime = floor(GetTime()*power(10,0)+0.5) / power(10,0)
 	if (t ~= nil and type(t) == "table" and TF3:GetNumElements(t) >= tonumber(TF3.db.profile.repeat_recycle_size)) then
@@ -333,6 +343,7 @@ function TF3:IsFriend(userID)
 	return false
 end

+--[[ Duel Spam Functions ]]--
 function TF3:DuelFilter()
 	if (TF3.db.profile.filterDuelSpam) then
 		DUEL_WINNER_KNOCKOUT, DUEL_WINNER_RETREAT = "", ""
@@ -497,7 +508,7 @@ local function PreFilterFunc_Addon(self, event, ...)
 	local msgID = arg11 or select(11, ...)
 	local cName = arg12 or select(12, ...)
 	local coloredName = TF3:GetColoredName(userID, cName)
-	if not (repeatdata[userID]) then
+	if (repeatdata[userID] ~= type(table) and TF3.db.profile.repeat_enable) then
 		repeatdata[userID] = {}
 		repeatdata[userID].lastmsg = msg
 		repeatdata[userID].lastmsgID = msgID
@@ -538,7 +549,7 @@ local function PreFilterFunc_Say(self, event, ...)
 	local msgID = arg11 or select(11, ...)
 	local cName = arg12 or select(12, ...)
 	local coloredName = TF3:GetColoredName(userID, cName)
-	if not (repeatdata[userID]) then
+	if (repeatdata[userID] ~= type(table) and TF3.db.profile.repeat_enable) then
 		repeatdata[userID] = {}
 		repeatdata[userID].lastmsg = msg
 		repeatdata[userID].lastmsgID = msgID
@@ -578,7 +589,7 @@ local function PreFilterFunc_Yell(self, event, ...)
 	local msgID = arg11 or select(11, ...)
 	local cName = arg12 or select(12, ...)
 	local coloredName = TF3:GetColoredName(userID, cName)
-	if not (repeatdata[userID]) then
+	if (repeatdata[userID] ~= type(table) and TF3.db.profile.repeat_enable) then
 		repeatdata[userID] = {}
 		repeatdata[userID].lastmsg = msg
 		repeatdata[userID].lastmsgID = msgID
@@ -618,7 +629,7 @@ local function PreFilterFunc_BG(self, event, ...)
 	local msgID = arg11 or select(11, ...)
 	local cName = arg12 or select(12, ...)
 	local coloredName = TF3:GetColoredName(userID, cName)
-	if not (repeatdata[userID]) then
+	if (repeatdata[userID] ~= type(table) and TF3.db.profile.repeat_enable) then
 		repeatdata[userID] = {}
 		repeatdata[userID].lastmsg = msg
 		repeatdata[userID].lastmsgID = msgID
@@ -661,7 +672,7 @@ local function PreFilterFunc(self, event, ...)
 	local msgID = arg11 or select(11, ...)
 	local cName = arg12 or select(12, ...)
 	local coloredName = TF3:GetColoredName(userID, cName)
-	if not (repeatdata[userID]) then
+	if (repeatdata[userID] ~= type(table) and TF3.db.profile.repeat_enable) then
 		repeatdata[userID] = {}
 		repeatdata[userID].lastmsg = msg
 		repeatdata[userID].lastmsgID = msgID
@@ -670,8 +681,8 @@ local function PreFilterFunc(self, event, ...)
 		rptdone = msgID
 	end
 	--[[ Check for Trade Channel and User setting ]]--
-	if (TF3.db.profile.filtertrade) then
-		if (zoneID == 2) then
+	if (zoneID == 2) then
+		if (TF3.db.profile.filtertrade) then
 			if (TF3:IsFriend(userID) == false) then
 				if (userID == UnitName("Player") and TF3.db.profile.filterSELF == false or TF3:WhiteList(msg, userID, msgID, coloredName) == true) then
 					filtered = false
@@ -690,10 +701,10 @@ local function PreFilterFunc(self, event, ...)
 				filtered = false
 			end
 		end
-	end
+--~ 	end
 	--[[ Check for General Channel and User setting ]]--
-	if (TF3.db.profile.filtergeneral) then
-		if (chanID == 1) then
+	elseif (chanID == 1) then
+		if (TF3.db.profile.filtergeneral) then
 			if (TF3:IsFriend(userID) == false) then
 				if (userID == UnitName("Player") and TF3.db.profile.filterSELF == false or TF3:WhiteList(msg, userID, msgID, coloredName) == true) then
 					filtered = false
@@ -712,10 +723,10 @@ local function PreFilterFunc(self, event, ...)
 				filtered = false
 			end
 		end
-	end
+--~ 	end
 	--[[ Check for LFG Channel and User setting ]]--
-	if (TF3.db.profile.filterLFG) then
-		if (zoneID == 26) then
+	elseif (zoneID == 26) then
+		if (TF3.db.profile.filterLFG) then
 			if (TF3:IsFriend(userID) == false) then
 				if (userID == UnitName("Player") and TF3.db.profile.filterSELF == false or TF3:WhiteList(msg, userID, msgID, coloredName) == true) then
 					filtered = false
@@ -734,10 +745,10 @@ local function PreFilterFunc(self, event, ...)
 				filtered = false
 			end
 		end
-	end
+--~ 	end
 	--[[ Check for Special Channel and User setting ]]--
-	if (TF3.db.profile.special_enable) then
-		if (TF3:SpecialChans(chanName) == true) then
+	elseif (TF3:SpecialChans(chanName) == true) then
+		if (TF3.db.profile.special_enable) then
 			if (TF3:IsFriend(userID) == false) then
 				if (userID == UnitName("Player") and TF3.db.profile.filterSELF == false or TF3:WhiteList(msg, userID, msgID, coloredName) == true) then
 					filtered = false
diff --git a/TradeFilter3.toc b/TradeFilter3.toc
index 18fb4c0..6790515 100644
--- a/TradeFilter3.toc
+++ b/TradeFilter3.toc
@@ -1,4 +1,5 @@
 ## Interface: 30300
+## X-Compatible-With: 40000
 #@alpha@
 ## Title: @localization(locale="enUS", key="Title", namespace="ToC")@ SVN: @project-revision@
 #@end-alpha@
diff --git a/TradeFilter3Options.lua b/TradeFilter3Options.lua
index f973e69..9978fa9 100644
--- a/TradeFilter3Options.lua
+++ b/TradeFilter3Options.lua
@@ -15,16 +15,6 @@ local format = string.format
 local insert = table.insert
 local sort = table.sort

-function getnHash(t)
-   local count = 0;
-   if not t then return 0; end
-   if (type(t)) ~= "table" then return 0; end
-   for i,_ in pairs(t) do
-      count = count + 1;
-   end
-   return count;
-end
-
 --[[ Options Table ]]--
 options = {
 	type="group",
@@ -517,6 +507,9 @@ options = {
 								editblacklist = {
 									type = 'toggle',
 									order = 3,
+									disabled = function()
+										return not TF3.db.profile.blacklist_enable
+									end,
 									width = "double",
 									name = L["EBL"],
 									desc = L["EBL"],
@@ -600,6 +593,9 @@ options = {
 								editwhitelist = {
 									type = 'toggle',
 									order = 3,
+									disabled = function()
+										return not TF3.db.profile.whitelist_enable
+									end,
 									width = "double",
 									name = L["EWL"],
 									desc = L["EWL"],
@@ -609,6 +605,9 @@ options = {
 								whitelist_repeat_bypass = {
 									type = 'toggle',
 									order = 4,
+									disabled = function()
+										return not TF3.db.profile.whitelist_enable
+									end,
 									width = "double",
 									name = L["RPTBYPASS"],
 									desc = L["RPTBYPASSD"],
@@ -618,6 +617,9 @@ options = {
 								whitelist_blacklist_bypass = {
 									type = 'toggle',
 									order = 5,
+									disabled = function()
+										return not TF3.db.profile.whitelist_enable
+									end,
 									width = "double",
 									name = L["BLBYPASS"],
 									desc = L["BLBYPASSD"],
@@ -780,7 +782,7 @@ options = {
 									get = function(info) return TF3.db.profile.repeat_recycle_time end,
 									set = function(info, value)
 										TF3.db.profile.repeat_recycle_time = value
-										TF3:ScheduleRepeatingTimer(TF3:RecycleTables(), tonumber(TF3.db.profile.repeat_recycle_time), repeatdata)
+										TF3:ScheduleRepeatingTimer("RecycleTables", tonumber(TF3.db.profile.repeat_recycle_time), repeatdata)
 									end,
 								},
 								repeat_recycle_size = {
@@ -801,7 +803,7 @@ options = {
 									disabled = true,
 									order = 3,
 									name = L["RPTTS"],
-									get = function() return format("%d",getnHash(repeatdata)) end,
+									get = function() return format("%d",TF3:getnHash(repeatdata)) end,
 								},
 								blank_space1 = {
 									type = 'description',