Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
2.2.5 release
Browse files Browse the repository at this point in the history
see changelog for details
  • Loading branch information
Metric committed Mar 16, 2021
1 parent b7d69e4 commit 1c092bd
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 506 deletions.
437 changes: 0 additions & 437 deletions AnS/AnS.lua.bak

This file was deleted.

2 changes: 1 addition & 1 deletion AnS/AnS.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 90005
## Title: AnS
## Version: 2.2.4
## Version: 2.2.5
## Notes: Core library for Auction Snipe etc.
## License: MIT
## SavedVariables: ANS_FILTERS, ANS_CONFIG, ANS_CUSTOM_VARS, ANS_GLOBAL_SETTINGS, ANS_ANALYTICS_DATA
Expand Down
16 changes: 16 additions & 0 deletions AnS/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## AnS Changes 2.2.5

- Fixed an issue in Sniper where results would disappear from the list on retail when it shouldn't or not be added at all on retail. This one was a tricky one to figure out how to fix. It was several problems combined causing this issue. First, known items / groups was being cleared too early. Second, the hashing method was not taking into account the retail itemKey.itemSuffix properly. Thus, things were being overwritten in the known lookup table, because it was only looking at the itemLevel and itemID for the general grouping. Hence, items disappearing from the list for no reason, or not being included at all. It now takes into account the proper itemSuffix for general grouping.

- Fixed an issue where if Skip Lowest Seen Group was checked for Sniping settings, it would miss groups for items that share a common itemLevel and itemID but differing itemSuffix. It now takes into account the itemSuffix as well.

- Fixed an issue in retail for Sniper, where scanning for battle pets could cause an nil exception to be thrown.

- Fixed an issue where there was still a memory leak on both classic and retail in Sniper. Should see a pretty big decrease in memory gain rate on both. As well as the memory properly clearing after a bit of closing the AH.

- Fixed the issue where bonus() formula function would not ignore browse query groups on retail.

- Fixed an issue from last build where bonus(), startswith(), and contains() formula functions would not return true or false if only the first argument was provided.

- Added a new formula variable called: isgroup. isgroup = true if it is a browse group query calling the formula on retail. Otherwise it is false.

## AnS Changes 2.2.4

- Updated TOC number for latest Retail patch
Expand Down
52 changes: 27 additions & 25 deletions AnS/Core/Auction/Auction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,37 @@ function Auction:Acquire(o)
a.auctionId = nil;
a.avg = 1;
a.op = nil;
a.suffix = 0;
return a;
end

function Auction:Clone()
return Auction:New({
id = self.id;
itemKey = self.itemKey;
name = self.name;
hash = self.hash;
texture = self.texture;
quality = self.quality;
count = self.count;
level = self.level;
ppu = self.ppu;
buyoutPrice = self.buyoutPrice;
owner = self.owner;
link = self.link;
sniped = self.sniped;
tsmId = self.tsmId;
percent = self.percent;
iLevel = self.iLevel;
vendorsell = self.vendorsell;
isCommodity = self.isCommodity;
isPet = self.isPet;
auctionId = self.auctionId;
itemIndex = self.itemIndex;
avg = self.avg;
auctions = self.auctions;
op = self.op;
isEquipment = self.isEquipment;
id = self.id,
itemKey = self.itemKey,
name = self.name,
hash = self.hash,
texture = self.texture,
quality = self.quality,
count = self.count,
level = self.level,
ppu = self.ppu,
buyoutPrice = self.buyoutPrice,
owner = self.owner,
link = self.link,
sniped = self.sniped,
tsmId = self.tsmId,
percent = self.percent,
iLevel = self.iLevel,
vendorsell = self.vendorsell,
isCommodity = self.isCommodity,
isPet = self.isPet,
auctionId = self.auctionId,
itemIndex = self.itemIndex,
avg = self.avg,
auctions = self.auctions,
op = self.op,
isEquipment = self.isEquipment,
suffix = self.suffix
});
end
10 changes: 7 additions & 3 deletions AnS/Core/Auction/Query.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function Query:IsFiltered(auction)
end

if (auction.buyoutPrice > 0) then
local avg = Sources:Query(Config.Sniper().source, auction);
local avg = Sources:Query(Config.Sniper().source, auction, false);
if (not avg or avg <= 0) then avg = auction.vendorsell or 1; end;

if (avg <= 1) then
Expand Down Expand Up @@ -268,6 +268,7 @@ function Query:GetAuctionData(group)
auction.iLevel = group.itemKey.itemLevel or 0;
auction.id = group.itemKey.itemID;
auction.count = group.totalQuantity;
auction.suffix = group.itemKey.itemSuffix or 0;

auction.ppu = group.minPrice;
auction.buyoutPrice = auction.ppu;
Expand Down Expand Up @@ -312,6 +313,10 @@ function Query:GetAuctionData(group)
end

function Query:IsFilteredGroup(auction)
if (not auction) then
return nil, false;
end

local ignoreMaxPercent = Config.Sniper().ignoreGroupMaxPercent;

if (auction.buyoutPrice > 0) then
Expand All @@ -334,7 +339,7 @@ function Query:IsFilteredGroup(auction)
if (#self.ops == 0) then
local allowed = 0;

allowed = Sources:Query(Config.Sniper().pricing, auction);
allowed = Sources:Query(Config.Sniper().pricing, auction, true);

if (type(allowed) == "boolean" or type(allowed) == "number") then
if (type(allowed) == "number") then
Expand Down Expand Up @@ -586,7 +591,6 @@ function Query.OnListUpdate()
local item = Query:Next();
if (item) then
EventManager:Emit("QUERY_SEARCH_RESULT", item);
Recycler:Recycle(item);
end
end

Expand Down
4 changes: 4 additions & 0 deletions AnS/Core/Auction/Recycler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function Recycler:Recycle(auction)
end

function Recycler:Get()
-- free up a memory at this point
if (#self.auctions > 800) then
wipe(self.auctions);
end
if (#self.auctions > 0) then
return Auction:Acquire(tremove(self.auctions, 1));
end
Expand Down
4 changes: 2 additions & 2 deletions AnS/Core/Operations/Sniping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function Sniping:IsValid(item, exact, isGroup)
local price = self.price;
local presult = nil;
if (price ~= nil and #price > 0) then
presult = Sources:Query(price, item);
presult = Sources:Query(price, item, isGroup);
if ((type(presult) == "boolean" and presult == false) or (type(presult) == "number" and item.ppu > presult)) then
return false;
end
Expand Down Expand Up @@ -159,7 +159,7 @@ function Sniping:IsValid(item, exact, isGroup)

if (self:HasIds()) then
local t,id = strsplit(":", item.tsmId);
return self.ids[item.tsmId] == 1 or (not isExact and self.ids[t..":"..id] == 1);
return self.ids[item.tsmId] == 1 or ((not isExact or isGroup) and self.ids[t..":"..id] == 1);
end

return (price ~= nil and #price > 0 and not self:HasIds())
Expand Down
59 changes: 55 additions & 4 deletions AnS/Core/Sources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function OpCodes:Acquire()
op.maxbuy = 0;
op.destroy = 0;
op.numinventory = 0;
op.isgroup = false;
return op;
end

Expand All @@ -76,8 +77,16 @@ local TEMPLATE = [[
abs, ceil, floor, random, log,
log10, exp, sqrt = sources.ifgte, sources.iflte, sources.iflt, sources.ifgt, sources.ifeq, sources.ifneq, sources.check, sources.avg, sources.first, sources.round, sources.min, sources.max, math.fmod, math.abs, math.ceil, math.floor, math.random, math.log, math.log10, math.exp, math.sqrt;
local isgroup = ops.isgroup;
local eq, neq, startswith, contains = sources.eq, sources.neq, sources.startswith, sources.contains;
local bonus = function(v1,v2,v3)
local noArgs = v2 == nil and v3 == nil;
if (isgroup) then
if (noArgs) then
return true;
end
return v2 or 0;
end
return sources.bonus(ops.tsmId, v1, v2, v3);
end
Expand Down Expand Up @@ -387,7 +396,7 @@ Sources.ifneq = function(v1, v2, v3, v4)
return v4 or 0;
end

Sources.neq = function(v1,v2,v3,v4)
Sources.neq = function(v1,v2,v3,v4)
if (v1 ~= v2) then
return v3 or 0;
end
Expand All @@ -404,51 +413,90 @@ Sources.eq = function(v1,v2,v3,v4)
end

Sources.startswith = function(v1, v2, v3, v4)
local noArgs = v3 == nil and v4 == nil;

if (not v1 or type(v1) ~= "string") then
if (noArgs) then
return false;
end
return v4 or 0;
end

if (not v2 or type(v2) ~= "string") then
return v3 or 0;
if (noArgs) then
return false;
end
return v4 or 0;
end

if (strsub(v1, 1, #v2) == v2) then
if (noArgs) then
return true;
end
return v3 or 0;
end

if (noArgs) then
return false;
end
return v4 or 0;
end

Sources.contains = function(v1, v2, v3, v4)
local noArgs = v3 == nil and v4 == nil;

if (not v1 or type(v1) ~= "string") then
if (noArgs) then
return false;
end
return v4 or 0;
end

if (not v2 or type(v2) ~= "string") then
if (noArgs) then
return true;
end
return v3 or 0;
end

if (strfind(v1, v2)) then
if (noArgs) then
return true;
end
return v3 or 0;
end

if (noArgs) then
return false;
end
return v4 or 0;
end

Sources.bonus = function(v1,v2,v3,v4)
local noArgs = v3 == nil and v4 == nil;

if (not v1) then
if (noArgs) then
return false;
end
return v4 or 0;
end

local s,e = strfind(v1, ":"..v2..":");
if (not s) then
s,e = strfind(v1, ":"..v2.."$");
end

if (s) then
if (noArgs) then
return true;
end
return v3 or 0;
end

if (noArgs) then
return false;
end
return v4 or 0;
end

Expand Down Expand Up @@ -513,6 +561,7 @@ function Sources:QueryID(q, itemId)
codes.ilevel = 0;
codes.vendorsell = 0;
codes.tsmId = Utils.GetID(itemId);
codes.isgroup = false;

local idBonusOnly = Utils.BonusID(codes.tsmId);

Expand Down Expand Up @@ -605,6 +654,7 @@ function Sources:Validate(q)
codes.tsmId = itemId;
codes.vendorbuy = 0;
codes.id = 2589;
codes.isgroup = false;

local _, fn, err = false, nil, nil;
local oq = q;
Expand Down Expand Up @@ -653,7 +703,7 @@ function Sources:Validate(q)
return true;
end

function Sources:Query(q, item)
function Sources:Query(q, item, isGroup)
local itemId = item.link or item.id;
local buyout = item.buyoutPrice;
local stackSize = item.count;
Expand Down Expand Up @@ -701,6 +751,7 @@ function Sources:Query(q, item)
codes.tsmId = item.tsmId;
codes.id = item.id;
codes.vendorbuy = Config.Vendor()[idBonusOnly] or VendorData[idBonusOnly] or 0;
codes.isgroup = isGroup;

local _, fn, err = false, nil, nil;
local oq = q;
Expand Down
10 changes: 10 additions & 0 deletions AnS/Core/Utils/TempTable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ local Ans = select(2, ...);
local TempTable = Ans.Object.Register("TempTable");
local tbls = {};

function TempTable.Reset()
wipe(tbls);
end

function TempTable:Acquire(...)
local t = nil;

-- free up memory
if (#tbls > 800) then
wipe(tbls);
end

if (#tbls == 0) then
t = TempTable:New({});
else
Expand Down
4 changes: 4 additions & 0 deletions AnS/UI/Auctioning/Posting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,10 @@ end
function PostingView.OnSearchResult(item)
if (PostingFSM) then
PostingFSM:Process('ITEM_RESULT', item);

if (Utils.IsClassic()) then
Recycler:Recycle(item);
end
end
end

Expand Down
8 changes: 8 additions & 0 deletions AnS/UI/Hooks/AuctionHook.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local Ans = select(2, ...);
local Sources = Ans.Sources;
local TempTable = Ans.TempTable;
local Recycler = Ans.Auctions.Recycler;
local Config = Ans.Config;
local Utils = Ans.Utils;
local Draggable = Utils.Draggable;
Expand Down Expand Up @@ -42,9 +44,15 @@ EventManager:On("AUCTION_HOUSE_SHOW",

EventManager:On("AUCTION_HOUSE_CLOSED",
function()

-- clear sources cache on AH close
Sources:Clear();

-- clear these on AH close to free up memory
-- faster
TempTable.Reset();
Recycler:Reset();

AuctionHook.shown = false;
end
);
2 changes: 1 addition & 1 deletion AnsAuctionSnipe/AnsAuctionSnipe.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 90005
## Title: AnS [Auction Sniper]
## Version: 2.2.4
## Version: 2.2.5
## Notes: A lightweight addon for auction sniping; Relies on Undermine Journal or TSM for pricing.
## License: MIT
## Dependencies: AnS
Expand Down
Loading

0 comments on commit 1c092bd

Please sign in to comment.