@@ -423,29 +423,29 @@ bool ArchipelagoClient::StartClient() {
423423 UpdateHints (data.at (hint_key.str ()));
424424 }
425425
426- std::unordered_set<std::string> games;
427- for (const APClient::NetworkPlayer& player : apClient->get_players ()) {
428- games.emplace (apClient->get_player_game (player.slot ));
429- }
430-
431- // item & location groups
432- bool groups_received = false ;
433- for (const std::string& game : games) {
434- const std::string item_group_key = " _read_item_name_groups_" + game;
435- if (data.contains (item_group_key)) {
436- groups_received = true ;
437- UpdateItemGroup (game, data.at (item_group_key));
426+ bool all_groups_received = false ;
427+ if (fetchingGroups.request_index != fetchingGroups.num_requests ) {
428+ const std::string& game = fetchingGroups.hint_group_games [fetchingGroups.request_index ];
429+ const std::string item_group = " _read_item_name_groups_" + game;
430+ const std::string location_group = " _read_location_name_groups_" + game;
431+ if (data.contains (item_group)) {
432+ UpdateItemGroup (game, data.at (item_group));
433+ }
434+ if (data.contains (location_group)) {
435+ UpdateLocationGroup (game, data.at (location_group));
438436 }
439- const std::string location_group_key = " _read_location_name_groups_" + game;
440- if (data.contains (location_group_key)) {
441- groups_received = true ;
442- UpdateLocationGroup (game, data.at (location_group_key));
437+ fetchingGroups.request_index ++;
438+ all_groups_received = fetchingGroups.request_index == fetchingGroups.num_requests ;
439+ if (!all_groups_received) {
440+ const std::string& next_game = fetchingGroups.hint_group_games [fetchingGroups.request_index ];
441+ apClient->Get ({ " _read_item_name_groups_" + next_game, " _read_location_name_groups_" + next_game});
443442 }
444443 }
445444
446445 // after getting grouping data, fetch location scouts
447446 // Foreign hints should be loaded from the save file as well
448- if (groups_received) {
447+ if (all_groups_received) {
448+ fetchingGroups.fetching = false ;
449449 ArchipelagoClient::InitForeignHints ();
450450 }
451451 });
@@ -462,26 +462,25 @@ void ArchipelagoClient::RequestInitData() {
462462 // To create a save file we'll need the following data:
463463 // Slot Data: received on connection, we already have this
464464 // Data package: received on connection, we already have this
465- // Location Scouts, Asynch request done here
466465 // Location and Item groups, Asynch request done here
466+ // Location Scouts, Asynch request done after item groups have been loaded
467467
468468 CVarSetInteger (CVAR_REMOTE_ARCHIPELAGO (" ConnectionStatus" ), 4 ); // fetching foreign hint and scout data
469469
470- // get location scouts
471- StartLocationScouts ();
472-
473470 // request the item and location groups
474471 std::unordered_set<std::string> games;
475472 for (const APClient::NetworkPlayer& player : apClient->get_players ()) {
476473 games.emplace (apClient->get_player_game (player.slot ));
477474 }
478475
479- std::list<std::string> requests ;
476+ fetchingGroups = ApHintFetchData () ;
480477 for (const std::string& game : games) {
481- requests.emplace_back (" _read_item_name_groups_" + game);
482- requests.emplace_back (" _read_location_name_groups_" + game);
478+ fetchingGroups.hint_group_games .emplace_back (game);
483479 }
484- apClient->Get (requests);
480+ fetchingGroups.num_requests = fetchingGroups.hint_group_games .size ();
481+ const std::string& firstGame = fetchingGroups.hint_group_games [0 ];
482+ fetchingGroups.fetching = true ;
483+ apClient->Get ({ " _read_item_name_groups_" + firstGame, " _read_location_name_groups_" + firstGame });
485484}
486485
487486// update the connection status if we have all data we need to initialize a save file
@@ -613,6 +612,9 @@ void ArchipelagoClient::InitForeignHints() {
613612
614613 hintsInitialized = true ;
615614 newInitDataReceived ();
615+
616+ // get location scouts
617+ StartLocationScouts ();
616618}
617619
618620void ArchipelagoClient::QueueExternalCheck (const int64_t apLocation) {
@@ -1561,6 +1563,14 @@ extern "C" void Archipelago_RequestInitData() {
15611563 ArchipelagoClient::GetInstance ().RequestInitData ();
15621564}
15631565
1566+ extern " C" size_t Archipelago_FetchHintMax () {
1567+ return ArchipelagoClient::GetInstance ().GetFetchingGroupMax ();
1568+ }
1569+
1570+ extern " C" size_t Archipelago_FetchHintCurrent () {
1571+ return ArchipelagoClient::GetInstance ().GetFetchingGroupCurrent ();
1572+ }
1573+
15641574void SetArchipelagoParsing (uint8_t state) {
15651575 isArchipelagoParsing = state;
15661576}
0 commit comments