Skip to content

Commit

Permalink
Improved initial game start by only requesting 1 games information at…
Browse files Browse the repository at this point in the history
… a time

Now allow saving while in startup without breaking item dictionaries

Added new popup whining about Typescript
  • Loading branch information
Crazycolbster authored and Die4Ever committed May 28, 2024
1 parent 9af1e75 commit 2a0309e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/OpenRCT2-CrowdControl/CCAds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ const adPool: Ad[] = [
header: "The archipelago client has detected a desync.",
message: "Tell the dev to make error reporting work better.",
button: "Discord"
},
{
title: "Typescript!",
header: "Ever want to pull your hair out learning the dumbest language?.",
message: "Try Typescript today!.",
button: "[object Object]"
}
]

Expand Down
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_settings.multiworld_games);
console.log(archipelago_connected_to_server);
// console.log(ScenarioName[0]);
// archipelago_settings.location_information = locationInfo.Full;
// archipelago_send_message("GetDataPackage");
Expand Down
21 changes: 16 additions & 5 deletions src/modules/archipelago.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RCTRArchipelago extends ModuleBase {
self.RemoveItems();//Removes everything from the invented items list. They'll be added back when Archipelago sends items
archipelago_send_message("Sync");
archipelago_send_message("LocationScouts");

// archipelago_send_message("GetDataPackage");
self.SetPostGenerationSettings();//Let the other settings to do their thing
//Setting rules for Archipelago, dictated by the YAML
Expand Down Expand Up @@ -72,6 +73,8 @@ class RCTRArchipelago extends ModuleBase {
archipelago_objectives = context.getParkStorage().get('RCTRando.ArchipelagoObjectives');
archipelago_settings = context.getParkStorage().get('RCTRando.ArchipelagoSettings');
}
full_item_id_to_name = context.getParkStorage().get("RCTRando.ArchipelagoItemIDToName");
full_location_id_to_name = context.getParkStorage().get("RCTRando.ArchipelagoLocationIDToName");
//Set up connection to client
if (!archipelago_connected_to_game)
init_archipelago_connection();
Expand All @@ -84,7 +87,7 @@ class RCTRArchipelago extends ModuleBase {
context.subscribe('action.execute',e => self.InterpretAction(e.player, e.action, e.args, e.result));
context.subscribe('interval.tick', (e: any) => self.CheckMonopoly());
archipelago_settings.deathlink_timeout = false;//Reset the Deathlink if the game was saved and closed during a timeout period

//Get our games if we don't have them yet
self.RequestGames();

//Set shortcuts
Expand Down Expand Up @@ -1509,35 +1512,43 @@ class RCTRArchipelago extends ModuleBase {
RequestGames(): void{
console.log("Captain Crunch");
var self = this;
let games = archipelago_settings.multiworld_games
let received_games = archipelago_settings.received_games
let games = archipelago_settings.multiworld_games;
let received_games = archipelago_settings.received_games;
archipelago_repeat_game_request_ready = false;
console.log(received_games);
if (!games.length || !archipelago_connected_to_server){//If we haven't received the game list yet, we can't actually do anything
context.setTimeout(() => {self.RequestGames();}, 250);
return;
}
console.log("We have the list of games!")
//If we haven't started yet or if the current game has already been received
if(!archipelago_current_game_request || received_games.indexOf(archipelago_current_game_request) !== -1){
for(let i = 0; i < games.length; i++){
if(received_games.indexOf(games[i]) === -1){
archipelago_current_game_request = games[i];
archipelago_repeat_game_request_ready = true;
console.log("We have a new game to request:");
console.log(archipelago_current_game_request);
archipelago_repeat_game_request_counter = 0;
break;
}
}
}

if(!archipelago_current_game_request || received_games.indexOf(archipelago_current_game_request) !== -1){//The above code couldn't find any new games, whch hypothetically means we have them all
console.log("We have all the games! Either that or future Colby is really annoyed right now");
return;
}
if (archipelago_repeat_game_request_counter > 40)
console.log("Request Counter:");
console.log(archipelago_repeat_game_request_counter);
if (archipelago_repeat_game_request_counter > 80){
archipelago_repeat_game_request_ready = true;
archipelago_repeat_game_request_counter = 0;
}
if (archipelago_repeat_game_request_ready)
archipelago_send_message("GetDataPackage", archipelago_current_game_request);
archipelago_repeat_game_request_counter ++;
context.setTimeout(() => {self.RequestGames();}, 2250);
context.setTimeout(() => {self.RequestGames();}, 250);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/modules/archipelagoConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ function ac_req(data) {//This is what we do when we receive a data packet
console.log(current_game);

archipelago_settings.received_games.push(current_game);
saveArchipelagoProgress();
break;

case "Bounced"://Keeps the connection alive and recevies the Deathlink Signal from other games
Expand Down

0 comments on commit 2a0309e

Please sign in to comment.