comparison Main.lua @ 47:768c5f3587c2

Added optional location_label parameter to UpdateDBEntryLocation() to differentiate fishing locations, since the serializer is incapable of properly handling same-name fields with different values which are located in completely different tables.
author James D. Callahan III <jcallahan@curse.com>
date Wed, 20 Jun 2012 15:14:06 -0500
parents 786292c0bcc8
children 4668938a63e5
comparison
equal deleted inserted replaced
46:786292c0bcc8 47:768c5f3587c2
249 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true 249 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true
250 end 250 end
251 end -- do-block 251 end -- do-block
252 252
253 253
254 local function UpdateDBEntryLocation(entry_type, identifier) 254 local function UpdateDBEntryLocation(entry_type, identifier, location_label)
255 if not identifier then 255 if not identifier then
256 return 256 return
257 end 257 end
258 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() 258 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
259 local entry = DBEntry(entry_type, identifier) 259 local entry = DBEntry(entry_type, identifier)
260 local location_field = location_label or "locations"
260 entry[difficulty_token] = entry[difficulty_token] or {} 261 entry[difficulty_token] = entry[difficulty_token] or {}
261 entry[difficulty_token].locations = entry[difficulty_token].locations or {} 262 entry[difficulty_token][location_field] = entry[difficulty_token][location_field] or {}
262 263
263 local zone_token = ("%s:%d"):format(zone_name, area_id) 264 local zone_token = ("%s:%d"):format(zone_name, area_id)
264 local zone_data = entry[difficulty_token].locations[zone_token] 265 local zone_data = entry[difficulty_token][location_field][zone_token]
265 266
266 if not zone_data then 267 if not zone_data then
267 zone_data = {} 268 zone_data = {}
268 entry[difficulty_token].locations[zone_token] = zone_data 269 entry[difficulty_token][location_field][zone_token] = zone_data
269 end 270 end
270 local location_token = ("%s:%s:%s"):format(map_level, x, y) 271 local location_token = ("%s:%s:%s"):format(map_level, x, y)
271 zone_data[location_token] = zone_data[location_token] or true 272 zone_data[location_token] = zone_data[location_token] or true
272 return zone_data 273 return zone_data
273 end 274 end
1221 1222
1222 action_data.type = AF.OBJECT 1223 action_data.type = AF.OBJECT
1223 action_data.identifier = identifier 1224 action_data.identifier = identifier
1224 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then 1225 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
1225 local identifier = ("%s:%s"):format(spell_label, _G["GameTooltipTextLeft1"]:GetText() or "NONE") -- Possible fishing pool name. 1226 local identifier = ("%s:%s"):format(spell_label, _G["GameTooltipTextLeft1"]:GetText() or "NONE") -- Possible fishing pool name.
1226 action_data.zone_data = UpdateDBEntryLocation("zones", identifier) 1227 action_data.zone_data = UpdateDBEntryLocation("zones", identifier, "fishing_locations")
1227 action_data.type = AF.ZONE 1228 action_data.type = AF.ZONE
1228 action_data.identifier = identifier 1229 action_data.identifier = identifier
1229 end 1230 end
1230 end 1231 end
1231 private.tracked_line = spell_line 1232 private.tracked_line = spell_line