Advertisement
Guest User

Auc-Advanced/CoreConst.lua

a guest
Jul 20th, 2016
2,898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.67 KB | None | 0 0
  1. --[[
  2.     Auctioneer
  3.     Version: 5.21f.5579 (SanctimoniousSwamprat)
  4.     Revision: $Id: CoreConst.lua 5574 2015-09-23 17:42:30Z brykrys $
  5.     URL: http://auctioneeraddon.com/
  6.  
  7.     This is an addon for World of Warcraft that adds statistical history to the auction data that is collected
  8.     when the auction is scanned, so that you can easily determine what price
  9.     you will be able to sell an item for at auction or at a vendor whenever you
  10.     mouse-over an item in the game
  11.  
  12.     License:
  13.         This program is free software; you can redistribute it and/or
  14.         modify it under the terms of the GNU General Public License
  15.         as published by the Free Software Foundation; either version 2
  16.         of the License, or (at your option) any later version.
  17.  
  18.         This program is distributed in the hope that it will be useful,
  19.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.         GNU General Public License for more details.
  22.  
  23.         You should have received a copy of the GNU General Public License
  24.         along with this program(see GPL.txt); if not, write to the Free Software
  25.         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  26.  
  27.     Note:
  28.         This AddOn's source code is specifically designed to work with
  29.         World of Warcraft's interpreted AddOn system.
  30.         You have an implicit license to use this AddOn with these facilities
  31.         since that is its designated purpose as per:
  32.         http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat
  33. ]]
  34. if not AucAdvanced then return end
  35.  
  36. local lib = {
  37.     PlayerName = UnitName("player"),
  38.     PlayerRealm = GetRealmName(),
  39.  
  40.     AucMinTimes = {
  41.         0,
  42.         1800, -- 30 mins
  43.         7200, -- 2 hours
  44.         43200, -- 12 hours
  45.     },
  46.     AucMaxTimes = {
  47.         1800,  -- 30 mins
  48.         7200,  -- 2 hours
  49.         43200, -- 12 hours
  50.         172800 -- 48 hours
  51.     },
  52.     AucTimes = {
  53.         0,
  54.         1800, -- 30 mins
  55.         7200, -- 2 hours
  56.         43200, -- 12 hours
  57.         172800 -- 48 hours
  58.     },
  59.  
  60.     EquipEncode = { -- Converts "INVTYPE_*" strings to an internal number code; stored in scandata and used by Stat-iLevel
  61.         INVTYPE_HEAD = 1,
  62.         INVTYPE_NECK = 2,
  63.         INVTYPE_SHOULDER = 3,
  64.         INVTYPE_BODY = 4,
  65.         INVTYPE_CHEST = 5,
  66.         INVTYPE_WAIST = 6,
  67.         INVTYPE_LEGS = 7,
  68.         INVTYPE_FEET = 8,
  69.         INVTYPE_WRIST = 9,
  70.         INVTYPE_HAND = 10,
  71.         INVTYPE_FINGER = 11,
  72.         INVTYPE_TRINKET = 12,
  73.         INVTYPE_WEAPON = 13,
  74.         INVTYPE_SHIELD = 14,
  75.         INVTYPE_RANGEDRIGHT = 15,
  76.         INVTYPE_CLOAK = 16,
  77.         INVTYPE_2HWEAPON = 17,
  78.         INVTYPE_BAG = 18,
  79.         INVTYPE_TABARD = 19,
  80.         INVTYPE_ROBE = 20,
  81.         INVTYPE_WEAPONMAINHAND = 21,
  82.         INVTYPE_WEAPONOFFHAND = 22,
  83.         INVTYPE_HOLDABLE = 23,
  84.         INVTYPE_AMMO = 24,
  85.         INVTYPE_THROWN = 25,
  86.         INVTYPE_RANGED = 26,
  87.     },
  88.     -- EquipDecode = <add a reverse lookup table here if we need it>
  89.  
  90.     EquipLocToInvIndex = {}, -- converts "INVTYPE_*" strings to invTypeIndex for scan queries - only valid for Armour types
  91.     EquipCodeToInvIndex = {}, -- as above, but converts the EquipEncode'd number to invTypeIndex
  92.     -- InvIndexToEquipLoc = <add a reverse lookup table here if we need it>
  93.  
  94.     LINK = 1,
  95.     ILEVEL = 2,
  96.     ITYPE = 3,
  97.     ISUB = 4,
  98.     IEQUIP = 5,
  99.     PRICE = 6,
  100.     TLEFT = 7,
  101.     TIME = 8,
  102.     NAME = 9,
  103.     DEP2 = 10,
  104.     COUNT = 11,
  105.     QUALITY = 12,
  106.     CANUSE = 13,
  107.     ULEVEL = 14,
  108.     MINBID = 15,
  109.     MININC = 16,
  110.     BUYOUT = 17,
  111.     CURBID = 18,
  112.     AMHIGH = 19,
  113.     SELLER = 20,
  114.     FLAG = 21,
  115.     BONUSES = 22,
  116.     ITEMID = 23,
  117.     SUFFIX = 24,
  118.     FACTOR = 25,
  119.     ENCHANT = 26,
  120.     SEED = 27,
  121.     LASTENTRY = 27, -- Used to determine how many entries the table has when copying (some entries can be nil so # won't work)
  122.  
  123.     ScanPosLabels = {"LINK", "ILEVEL", "ITYPE", "ISUB", "IEQUIP", "PRICE", "TLEFT", "TIME", "NAME", "DEP2", "COUNT", "QUALITY", "CANUSE", "ULEVEL", "MINBID", "MININC",
  124.         "BUYOUT", "CURBID", "AMHIGH", "SELLER", "FLAG", "BONUSES", "ITEMID", "SUFFIX", "FACTOR", "ENCHANT", "SEED" },
  125.  
  126.     -- Permanent flags (stored in save file)
  127.     FLAG_UNSEEN = 2,
  128.     FLAG_FILTER = 4,
  129.     -- Temporary flags (only used during processing - higher values to leave lower ones free for permanent flags)
  130.     FLAG_DIRTY = 64,
  131.     FLAG_EXPIRED = 128,
  132.     FLAG_CORRUPT = 256,
  133.  
  134.     ALEVEL_OFF = 0,
  135.     ALEVEL_MIN = 1,
  136.     ALEVEL_LOW = 2,
  137.     ALEVEL_MED = 3,
  138.     ALEVEL_HI = 4,
  139.     ALEVEL_MAX = 5,
  140.  
  141.     -- CLASSES = { GetAuctionItemClasses() }, -- removed in 7.0.x
  142.     CLASSES = {
  143.         AUCTION_CATEGORY_WEAPONS,
  144.         AUCTION_CATEGORY_ARMOR,
  145.         AUCTION_CATEGORY_CONTAINERS,
  146.         AUCTION_CATEGORY_GEMS,
  147.         AUCTION_CATEGORY_ITEM_ENHANCEMENT,
  148.         AUCTION_CATEGORY_CONSUMABLES,
  149.         AUCTION_CATEGORY_GLYPHS,
  150.         AUCTION_CATEGORY_TRADE_GOODS,
  151.         AUCTION_CATEGORY_RECIPES,
  152.         AUCTION_CATEGORY_BATTLE_PETS,
  153.         AUCTION_CATEGORY_QUEST_ITEMS,
  154.         AUCTION_CATEGORY_MISCELLANEOUS
  155.         -- TOKEN_FILTER_LABEL
  156.     },
  157.        
  158.     SUBCLASSES = { },
  159.     CLASSESREV = { }, -- Table mapping names to index in CLASSES table
  160.     SUBCLASSESREV = { }, -- Table mapping from CLASS and SUBCLASSES names to index number in SUBCLASSES
  161.  
  162.     MAXSKILLLEVEL = 700, -- 7.x Note: Legion increases to 800
  163.     MAXUSERLEVEL = 100, -- 7.x Note: Legion increases to 110
  164.    
  165.     MAXITEMLEVEL = 750, -- 7.x Note: Reports that Legion goes up as high as 950
  166.     MAXBIDPRICE = 9999999999, -- copy from Blizzard_AuctionUI.lua, so it is available before AH loads
  167. }
  168.  
  169. lib.CompactRealm = lib.PlayerRealm:gsub(" ", "") -- CompactRealm is realm name with spaces removed
  170.  
  171. for i = 1, #lib.CLASSES do
  172.     lib.CLASSESREV[lib.CLASSES[i]] = i
  173.     lib.SUBCLASSESREV[lib.CLASSES[i]] = {}
  174.     lib.SUBCLASSES[i] = { GetAuctionItemSubClasses(i) }
  175.     for j = 1, #lib.SUBCLASSES[i] do
  176.         lib.SUBCLASSESREV[lib.CLASSES[i]][lib.SUBCLASSES[i][j]] = j
  177.     end
  178. end
  179.  
  180. --[[
  181. local function CompileInvTypes(...)
  182.     for i=1, select("#", ...), 2 do
  183.         -- each type has 2 args: token name(i), display in list(i+1)
  184.         local equipLoc = select(i, ...)
  185.         local invTypeIndex = (i+1)/2
  186.         local equipCode = lib.EquipEncode[equipLoc]
  187.  
  188.         lib.EquipLocToInvIndex[equipLoc] = invTypeIndex
  189.         if equipCode then
  190.             lib.EquipCodeToInvIndex[equipCode] = invTypeIndex
  191.         else
  192.             -- All possible entries should exist in the table - warn if a missing entry is detected
  193.             print("AucAdvanced CoreConst error: missing EquipCode for Equip Location "..equipLoc)
  194.         end
  195.     end
  196. end
  197.  
  198. CompileInvTypes(GetAuctionInvTypes(2, 1))
  199. --]]
  200. -- 7.x removed GetAuctionInvTypes() and now uses hardcoded globals
  201. local function CompileInvTypes()
  202.     local invtype_strformat = "INVTYPE_%s"
  203.     local le_invtype_strformat = "LE_INVENTORY_TYPE_%s_TYPE"
  204.     local invtype_strings = {
  205.         "HEAD",
  206.         "NECK",
  207.         "SHOULDER",
  208.         "BODY",
  209.         "CHEST",
  210.         "WAIST",
  211.         "LEGS",
  212.         "FEET",
  213.         "WRIST",
  214.         "HAND",
  215.         "FINGER",
  216.         "TRINKET",
  217.         "WEAPON",
  218.         "SHIELD",
  219.         "RANGEDRIGHT",
  220.         "CLOAK",
  221.         "2HWEAPON",
  222.         "BAG",
  223.         "TABARD",
  224.         "ROBE",
  225.         "WEAPONMAINHAND",
  226.         "WEAPONOFFHAND",
  227.         "HOLDABLE",
  228.         "AMMO",
  229.         "THROWN",
  230.         "RANGED"
  231.     }
  232.     local invstr
  233.     for _,invstr in ipairs(invtype_strings) do
  234.         -- each type has 2 args: token name(i), display in list(i+1)
  235.         -- However 7.x has removed GetAuctionInvTypes() so we need to be creative
  236.         local equipLoc = string.format(invtype_strformat, invstr)
  237.         local invTypeIndex = _G[string.format(le_invtype_strformat, invstr)]
  238.         local equipCode = lib.EquipEncode[equipLoc]
  239.        
  240.         if not invTypeIndex == nil then
  241.             lib.EquipLocToInvIndex[equipLoc] = invTypeIndex
  242.             if equipCode then
  243.                 lib.EquipCodeToInvIndex[equipCode] = invTypeIndex
  244.             else
  245.                 -- All possible entries should exist in the table - warn if a missing entry is detected
  246.                 print("AucAdvanced CoreConst error: missing EquipCode for Equip Location "..equipLoc)
  247.             end
  248.         else
  249.             print("AucAdvanced CoreConst error: missing invTypeIndex for Inventory Type "..invstr)
  250.         end
  251.     end
  252. end
  253. CompileInvTypes()
  254.  
  255. AucAdvanced.Const = lib
  256.  
  257. AucAdvanced.RegisterRevision("$URL: http://svn.norganna.org/auctioneer/branches/5.21f/Auc-Advanced/CoreConst.lua $", "$Rev: 5574 $")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement