vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Auctioneer Addon for World of Warcraft(tm).
3 Version: 3.9.0.1000 (Kangaroo)
4 Revision: $Id: AucConvert.lua 996 2006-09-12 02:06:36Z mentalpower $
5  
6 Auctioneer intra-version conversion.
7 Functions that allow auctioneer to upgrade the data formats when necessary.
8  
9 License:
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14  
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19  
20 You should have received a copy of the GNU General Public License
21 along with this program(see GPL.txt); if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ]]
24  
25 --Local Function Prototypes
26 local backup, convert
27  
28 -- helperfunction to backup data, which can't be converted atm
29 function backup(auctKey, sig, data) --Local
30 if (not AuctionBackup[auctKey]) then
31 AuctionBackup[auctKey] = {}
32 end
33  
34 AuctionBackup[auctKey][sig] = data
35 end
36  
37 function convert()
38 if (not AuctionConfig.version) then AuctionConfig.version = 30000; end
39 if (AuctionConfig.version < 30200) then
40 AuctionConfig.data = {};
41 AuctionConfig.info = {};
42 AuctionConfig.snap = {};
43 AuctionConfig.sbuy = {};
44 if (AHSnapshot) then
45 for auctKey, sData in pairs(AHSnapshot) do
46 local colon = string.find(auctKey, ":");
47 local hyphen = string.find(auctKey, "-");
48 if (hyphen and not colon) then
49 if (not AuctionConfig.snap[auctKey]) then
50 AuctionConfig.snap[auctKey] = {};
51 end
52 for sig, iData in pairs(sData) do
53 local catName = Auctioneer.Util.GetCatName(tonumber(iData.category));
54 if (not catName) then iData.category = Auctioneer.Util.GetCatNumberByName(iData.category) end
55 local cat = iData.category;
56 Auctioneer.Core.SaveSnapshot(auctKey, cat, sig, iData);
57 end
58 end
59 end
60 end
61  
62 if (AHSnapshotItemPrices) then
63 for auctKey, sData in pairs(AHSnapshotItemPrices) do
64 local colon = string.find(auctKey, ":");
65 local hyphen = string.find(auctKey, "-");
66 if (hyphen and not colon) and (sData.buyoutPrices == nil) then
67 if (not AuctionConfig.sbuy[auctKey]) then
68 AuctionConfig.sbuy[auctKey] = {};
69 end
70 for itemKey, iData in pairs(sData) do
71 Auctioneer.Core.SaveSnapshotInfo(auctKey, itemKey, iData);
72 end
73 end
74 end
75 end
76  
77 if (AuctionPrices) then
78 for auctKey, sData in pairs(AuctionPrices) do
79 local colon = string.find(auctKey, ":");
80 local hyphen = string.find(auctKey, "-");
81 if (hyphen and not colon) then
82 AuctionConfig.data[auctKey] = {};
83 for sig, iData in pairs(sData) do
84 local catName
85 local cat
86 local data
87 local name = nil
88 local hist = ""
89 local newsig = sig
90 if type(iData) == "string" then
91 -- 2.x -> 3.1
92 local oldData = iData
93 local s1, s2, s3, s4, s5, s6, s7, sname
94  
95 -- category
96 name, _, _, _, catName = GetItemInfo(sig)
97 if catName == nil then
98 -- !!!item not seen since serverrestart!!!
99 cat = 0 -- mark as unknown
100 else
101 cat = Auctioneer.Util.GetCatNumberByName(catName)
102 end
103  
104 -- signatue
105 newsig = newsig..':0:0'
106  
107 -- data/name
108 _, _, s1, s2, s3, s4, s5, s6, s7, sname = string.find(iData, "(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(.+)")
109 if s1 == nil then
110 _, _, s1, s2, s3, s4, s5, s6, s7 = string.find(iData, "(%d+):(%d+):(%d+):(%d+):(%d+):(%d+):(%d+)")
111 end
112 if s1 == nil then
113 -- unsuported, likely corrupt format (for example: s7 = -727389968)
114  
115 -- set name = '' to name = nil
116 name = nil
117  
118 -- backing it up so we might convert it later
119 backup(auctKey, sig, iData)
120 else
121 if (name == nil) or (name == '') then
122 name = sname
123 end
124 if (name == nil) or (name == '') then
125 -- ouch ! can't convert the old data atm since no valid itemname can be found
126  
127 -- set name = '' to name = nil
128 name = nil
129  
130 -- backing it up so we might convert it later
131 backup(auctKey, sig, iData)
132 else
133 -- only set the data, if the name has successfully been identified
134 data = s1..":"..s2..":"..s3..":"..s4..":"..s5..":"..s6..":"..s7
135 end
136 end
137 elseif iData.category == nil then
138 -- unknown dataformat
139 -- ouch ! strange dataformat, can't convert atm since there is no way to get the itemid right now
140 -- backing it up so we might convert it later
141 backup(auctKey, sig, iData)
142 else
143 -- 3.0 -> 3.1
144 catName = Auctioneer.Util.GetCatName(tonumber(iData.category));
145 if (not catName) then iData.category = Auctioneer.Util.GetCatNumberByName(iData.category) end
146 cat = iData.category;
147 data = iData.data;
148 name = iData.name;
149 if (iData.buyoutPricesHistoryList) then
150 --[[
151 Check history list for corrupted data that several people seem to have.
152 Looks like some other item's "data" string. Example:
153 ["9778:1182:0"] = {
154 ["playerMade"] = false,
155 ["name"] = "Bandit Buckler of the Bear",
156 ["category"] = 2,
157 ["data"] = "4:4:8230:0:0:3:11500",
158 ["buyoutPricesHistoryList"] = {
159 [1] = 2500,
160 [2] = 3000,
161 [3] = "16:16:12756:0:0:9:23888",
162 },
163 },
164 ]]
165 for pos, hPrice in pairs(iData.buyoutPricesHistoryList) do
166 if (type(hPrice) ~= "number") then
167 -- unrecognized entry in the history list, nuke it :(
168 iData.buyoutPricesHistoryList[pos] = nil;
169 end
170 end
171 hist = Auctioneer.Core.StoreMedianList(iData.buyoutPricesHistoryList);
172 end
173 end
174 if (name) then
175 local newData = string.format("%s|%s", data, hist);
176 local newInfo = string.format("%s|%s", cat, name);
177 AuctionConfig.data[auctKey][newsig] = newData;
178 AuctionConfig.info[newsig] = newInfo;
179 end
180 end
181 end
182 end
183 end
184  
185 AuctionConfig.bids = {};
186 if (AuctionBids) then
187 for player, pData in pairs(AuctionBids) do
188 AuctionConfig.bids[player] = {};
189 for time, bData in pairs(pData) do
190 local amount = bData.bidAmount;
191 local sig = bData.signature;
192 local owner = bData.itemOwner or "unknown";
193 local won = bData.itemWon;
194 if (won) then won = "1"; else won = "0"; end
195  
196 if (player and time and amount and sig and won) then
197 local newBid = string.format("%s|%s|%s|%s", sig, amount, won, owner);
198 AuctionConfig.bids[player][time] = newBid;
199 end
200 end
201 end
202 end
203  
204 AuctionConfig.version = 30200
205 end
206  
207 if AuctionConfig.version < 30201 then
208 -- Auto-convert to per-auctKey fixed prices
209 if (AuctionConfig.fixedprice) then
210 local fixedPrices = AuctionConfig.fixedprice;
211 for k, v in pairs(fixedPrices) do
212 local i,j, start,buy,dur = string.find(v, "(%d+):(%d+):(%d+)");
213 fixedPrices[k] = string.format("%s:%s:%d:%s", start, buy, 1, dur)
214 end
215 AuctionConfig.fixedprice = { ["global"] = fixedPrices };
216 end
217  
218 AuctionConfig.version = 30201
219 end
220  
221 if AuctionConfig.version < 30600 then
222 AuctionConfig.success = nil
223  
224 AuctionConfig.version = 30600
225 end
226  
227 -- Now the conversion is complete, wipe out the old data
228 AHSnapshot = nil;
229 AHSnapshotItemPrices = nil;
230 AuctionPrices = nil;
231 AuctionBids = nil;
232 end
233  
234 Auctioneer.Convert = {
235 Convert = convert,
236 }