Skip to content

Commit

Permalink
If progress has been made on the server, it will be reflected in any …
Browse files Browse the repository at this point in the history
…opened game, even when starting from the beginning
  • Loading branch information
Crazycolbster authored and Die4Ever committed May 28, 2024
1 parent 89eaf0b commit fa24f83
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/archipelagoWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
36 changes: 36 additions & 0 deletions src/modules/archipelago.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ListViewWidget>("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!")
Expand Down
4 changes: 4 additions & 0 deletions src/modules/archipelagoConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function archipelago_select_message(type: string, message?: any){
connection.send({cmd: "Get", keys: []});
break;
case "Set":

break;
case "SetNotify":
break;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit fa24f83

Please sign in to comment.