diff options
Diffstat (limited to 'src/ap_state.cpp')
-rw-r--r-- | src/ap_state.cpp | 87 |
1 files changed, 10 insertions, 77 deletions
diff --git a/src/ap_state.cpp b/src/ap_state.cpp index ced4f83..8bc7ed0 100644 --- a/src/ap_state.cpp +++ b/src/ap_state.cpp | |||
@@ -52,11 +52,6 @@ struct APState { | |||
52 | std::set<int64_t> checked_locations; | 52 | std::set<int64_t> checked_locations; |
53 | std::map<std::string, bool> data_storage; | 53 | std::map<std::string, bool> data_storage; |
54 | 54 | ||
55 | std::map<std::tuple<int, int>, int64_t> ap_id_by_location_id; | ||
56 | std::map<std::string, int64_t> ap_id_by_item_name; | ||
57 | std::map<LingoColor, int64_t> ap_id_by_color; | ||
58 | std::map<int64_t, std::string> progressive_item_by_ap_id; | ||
59 | |||
60 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; | 55 | DoorShuffleMode door_shuffle_mode = kNO_DOORS; |
61 | bool color_shuffle = false; | 56 | bool color_shuffle = false; |
62 | bool painting_shuffle = false; | 57 | bool painting_shuffle = false; |
@@ -302,78 +297,18 @@ struct APState { | |||
302 | } | 297 | } |
303 | 298 | ||
304 | if (connected) { | 299 | if (connected) { |
305 | for (const MapArea& map_area : GD_GetMapAreas()) { | ||
306 | for (int section_id = 0; section_id < map_area.locations.size(); | ||
307 | section_id++) { | ||
308 | const Location& location = map_area.locations.at(section_id); | ||
309 | |||
310 | int64_t ap_id = apclient->get_location_id(location.ap_location_name); | ||
311 | if (ap_id == APClient::INVALID_NAME_ID) { | ||
312 | TrackerLog("Could not find AP location ID for " + | ||
313 | location.ap_location_name); | ||
314 | } else { | ||
315 | ap_id_by_location_id[{map_area.id, section_id}] = ap_id; | ||
316 | } | ||
317 | } | ||
318 | } | ||
319 | |||
320 | for (const Door& door : GD_GetDoors()) { | ||
321 | if (!door.skip_item) { | ||
322 | ap_id_by_item_name[door.item_name] = GetItemId(door.item_name); | ||
323 | |||
324 | if (!door.group_name.empty() && | ||
325 | !ap_id_by_item_name.count(door.group_name)) { | ||
326 | ap_id_by_item_name[door.group_name] = GetItemId(door.group_name); | ||
327 | } | ||
328 | |||
329 | for (const ProgressiveRequirement& prog_req : door.progressives) { | ||
330 | ap_id_by_item_name[prog_req.item_name] = | ||
331 | GetItemId(prog_req.item_name); | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | ap_id_by_color[LingoColor::kBlack] = GetItemId("Black"); | ||
337 | ap_id_by_color[LingoColor::kRed] = GetItemId("Red"); | ||
338 | ap_id_by_color[LingoColor::kBlue] = GetItemId("Blue"); | ||
339 | ap_id_by_color[LingoColor::kYellow] = GetItemId("Yellow"); | ||
340 | ap_id_by_color[LingoColor::kPurple] = GetItemId("Purple"); | ||
341 | ap_id_by_color[LingoColor::kOrange] = GetItemId("Orange"); | ||
342 | ap_id_by_color[LingoColor::kGreen] = GetItemId("Green"); | ||
343 | ap_id_by_color[LingoColor::kBrown] = GetItemId("Brown"); | ||
344 | ap_id_by_color[LingoColor::kGray] = GetItemId("Gray"); | ||
345 | |||
346 | RefreshTracker(); | 300 | RefreshTracker(); |
347 | } else { | 301 | } else { |
348 | client_active = false; | 302 | client_active = false; |
349 | } | 303 | } |
350 | } | 304 | } |
351 | 305 | ||
352 | bool HasCheckedGameLocation(int area_id, int section_id) { | 306 | bool HasCheckedGameLocation(int location_id) { |
353 | std::tuple<int, int> location_key = {area_id, section_id}; | 307 | return checked_locations.count(location_id); |
354 | |||
355 | if (ap_id_by_location_id.count(location_key)) { | ||
356 | return checked_locations.count(ap_id_by_location_id.at(location_key)); | ||
357 | } else { | ||
358 | return false; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | bool HasColorItem(LingoColor color) { | ||
363 | if (ap_id_by_color.count(color)) { | ||
364 | return inventory.count(ap_id_by_color.at(color)); | ||
365 | } else { | ||
366 | return false; | ||
367 | } | ||
368 | } | 308 | } |
369 | 309 | ||
370 | bool HasItem(const std::string& item, int quantity) { | 310 | bool HasItem(int item_id, int quantity) { |
371 | if (ap_id_by_item_name.count(item)) { | 311 | return inventory.count(item_id) && inventory.at(item_id) >= quantity; |
372 | int64_t ap_id = ap_id_by_item_name.at(item); | ||
373 | return inventory.count(ap_id) && inventory.at(ap_id) >= quantity; | ||
374 | } else { | ||
375 | return false; | ||
376 | } | ||
377 | } | 312 | } |
378 | 313 | ||
379 | bool HasAchievement(const std::string& name) { | 314 | bool HasAchievement(const std::string& name) { |
@@ -417,16 +352,12 @@ void AP_Connect(std::string server, std::string player, std::string password) { | |||
417 | GetState().Connect(server, player, password); | 352 | GetState().Connect(server, player, password); |
418 | } | 353 | } |
419 | 354 | ||
420 | bool AP_HasCheckedGameLocation(int area_id, int section_id) { | 355 | bool AP_HasCheckedGameLocation(int location_id) { |
421 | return GetState().HasCheckedGameLocation(area_id, section_id); | 356 | return GetState().HasCheckedGameLocation(location_id); |
422 | } | 357 | } |
423 | 358 | ||
424 | bool AP_HasColorItem(LingoColor color) { | 359 | bool AP_HasItem(int item_id, int quantity) { |
425 | return GetState().HasColorItem(color); | 360 | return GetState().HasItem(item_id, quantity); |
426 | } | ||
427 | |||
428 | bool AP_HasItem(const std::string& item, int quantity) { | ||
429 | return GetState().HasItem(item, quantity); | ||
430 | } | 361 | } |
431 | 362 | ||
432 | DoorShuffleMode AP_GetDoorShuffleMode() { return GetState().door_shuffle_mode; } | 363 | DoorShuffleMode AP_GetDoorShuffleMode() { return GetState().door_shuffle_mode; } |
@@ -451,6 +382,8 @@ bool AP_IsLocationVisible(int classification) { | |||
451 | return classification & kLOCATION_REDUCED; | 382 | return classification & kLOCATION_REDUCED; |
452 | case kPANELSANITY: | 383 | case kPANELSANITY: |
453 | return classification & kLOCATION_INSANITY; | 384 | return classification & kLOCATION_INSANITY; |
385 | default: | ||
386 | return false; | ||
454 | } | 387 | } |
455 | } | 388 | } |
456 | 389 | ||