diff --git a/src/gui/archipelagoWindow.ts b/src/gui/archipelagoWindow.ts index fe648a8..520dd50 100644 --- a/src/gui/archipelagoWindow.ts +++ b/src/gui/archipelagoWindow.ts @@ -951,7 +951,7 @@ function archipelagoDebug(){ height: 25, text: 'Colbys Decision', onClick: function() { - console.log(archipelago_connected_to_server); + console.log("archipelago_connected_to_server"); // console.log(ScenarioName[0]); // archipelago_settings.location_information = locationInfo.Full; // archipelago_send_message("GetDataPackage"); diff --git a/src/modules/archipelago.ts b/src/modules/archipelago.ts index 0a0493d..1fc8d82 100644 --- a/src/modules/archipelago.ts +++ b/src/modules/archipelago.ts @@ -1609,6 +1609,42 @@ function explodeRide(args: any){ return {}; } +function archipelago_update_locations(checked_locations){ + try{ + if(archipelago_locked_locations.length){ + console.log("Updating locations to latest progress from Server"); + for(let i = 0; i < checked_locations.length; i++){ + let inquired_location = checked_locations[i] - 2000000 //Locations in game have the 2000000 stripped out + for(let j = 0; j < archipelago_locked_locations.length; j++){ + if (archipelago_locked_locations[j].LocationID == inquired_location){ + let Locked = archipelago_locked_locations.slice(); + let Unlocked = archipelago_unlocked_locations.slice(); + Unlocked.push(Locked[j]); + Locked.splice(j,1); + archipelago_locked_locations = Locked; + archipelago_unlocked_locations = Unlocked; + } + } + } + ArchipelagoSaveLocations(archipelago_locked_locations, archipelago_unlocked_locations); + try{ + var Archipelago = GetModule("RCTRArchipelago") as RCTRArchipelago; + var lockedWindow = ui.getWindow("archipelago-locations"); + lockedWindow.findWidget("locked-location-list").items = Archipelago.CreateLockedList(); + } + catch{ + console.log("It appears the unlock shop is not open. They'll find the updated shop when they do so."); + } + } + else{ + context.setTimeout(() => {archipelago_update_locations(checked_locations)}, 500); + } + } + catch(e){ + console.log("Error in archipelago_update_locations:" + e); + } +} + function saveArchipelagoProgress(){ context.getParkStorage().set('RCTRando.ArchipelagoSettings', archipelago_settings); console.log("Progress Saved!") diff --git a/src/modules/archipelagoConnection.ts b/src/modules/archipelagoConnection.ts index e254b15..17753a1 100644 --- a/src/modules/archipelagoConnection.ts +++ b/src/modules/archipelagoConnection.ts @@ -109,6 +109,7 @@ function archipelago_select_message(type: string, message?: any){ connection.send({cmd: "Get", keys: []}); break; case "Set": + break; case "SetNotify": break; @@ -155,6 +156,9 @@ function ac_req(data) {//This is what we do when we receive a data packet Archipelago.SetImportedSettings(data.slot_data); } + // If the user has already made progress on this game, reflect that in the unlock shop + context.setTimeout(() => {archipelago_update_locations(data.checked_locations)}, 2000); + archipelago_connected_to_server = true; break;