Skip to content

Commit

Permalink
Fixed RS3 bug regarding url; and fixed unamed character.
Browse files Browse the repository at this point in the history
Also, removed unecessary jx values. Set character name to 'New Character' if displayName isn't set yet. Finally, fixed config on load so the preferred account should take precedence.
  • Loading branch information
smithcol11 committed Apr 4, 2024
1 parent 5df3b58 commit 5f5d83b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 54 deletions.
65 changes: 20 additions & 45 deletions app/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,28 @@ function getStandardAccountInfo(creds: Credentials): Promise<Account | number> {

// adds an account to the accounts_list store item
export function addNewAccount(account: Account) {
const updateSelectedPlay = () => {
selectedPlay.update((data) => {
data.account = account;
const [firstKey] = account.characters.keys();
data.character = account.characters.get(firstKey);
if (credentialsSub.size > 0) data.credentials = credentialsSub.get(account.userId);
return data;
});
};

accountList.update((data) => {
data.set(account.userId, account);
return data;
});
selectedPlay.update((data) => {
data.account = account;
const [firstKey] = account.characters.keys();
data.character = account.characters.get(firstKey);
if (credentialsSub.size > 0) data.credentials = credentialsSub.get(account.userId);
return data;
});

if (selectedPlaySub.account && configSub.selected_account) {
if (account.userId == configSub.selected_account) {
updateSelectedPlay();
}
} else if (!selectedPlaySub.account) {
updateSelectedPlay();
}
pendingOauth.set({});
}

Expand Down Expand Up @@ -443,8 +454,6 @@ export async function saveAllCreds() {

// asynchronously download and launch RS3's official .deb client using the given env variables
export function launchRS3Linux(
jx_access_token: string,
jx_refresh_token: string,
jx_session_id: string,
jx_character_id: string,
jx_display_name: string
Expand All @@ -455,10 +464,6 @@ export function launchRS3Linux(
const xml = new XMLHttpRequest();
const params: Record<string, string> = {};
if (hash) params.hash = <string>hash;
// if (jx_access_token) params.jx_access_token = jx_access_token; // setting these cause login to fail
// if (jx_refresh_token) params.jx_refresh_token = jx_refresh_token; // setting these cause login to fail
params.hash = '';
params.jx_refresh_token = '';
if (jx_session_id) params.jx_session_id = jx_session_id;
if (jx_character_id) params.jx_character_id = jx_character_id;
if (jx_display_name) params.jx_display_name = jx_display_name;
Expand Down Expand Up @@ -541,8 +546,6 @@ export function launchRS3Linux(
// then attempt to launch it with the given env variables
// last param indices whether --configure will be passed or not
function launchRuneLiteInner(
jx_access_token: string,
jx_refresh_token: string,
jx_session_id: string,
jx_character_id: string,
jx_display_name: string,
Expand All @@ -556,10 +559,6 @@ function launchRuneLiteInner(
const params: Record<string, string> = {};
if (id) params.id = <string>id;
if (jarPath) params.jar_path = <string>jarPath;
// if (jx_access_token) params.jx_access_token = jx_access_token; // setting these seem to cause login to fail
// if (jx_refresh_token) params.jx_refresh_token = jx_refresh_token; // setting these seem to cause login to fail
params.jx_access_token = '';
params.jx_refresh_token = '';
if (jx_session_id) params.jx_session_id = jx_session_id;
if (jx_character_id) params.jx_character_id = jx_character_id;
if (jx_display_name) params.jx_display_name = jx_display_name;
Expand Down Expand Up @@ -640,43 +639,23 @@ function launchRuneLiteInner(
}

export function launchRuneLite(
jx_access_token: string,
jx_refresh_token: string,
jx_session_id: string,
jx_character_id: string,
jx_display_name: string
) {
return launchRuneLiteInner(
jx_access_token,
jx_refresh_token,
jx_session_id,
jx_character_id,
jx_display_name,
false
);
return launchRuneLiteInner(jx_session_id, jx_character_id, jx_display_name, false);
}

export function launchRuneLiteConfigure(
jx_access_token: string,
jx_refresh_token: string,
jx_session_id: string,
jx_character_id: string,
jx_display_name: string
) {
return launchRuneLiteInner(
jx_access_token,
jx_refresh_token,
jx_session_id,
jx_character_id,
jx_display_name,
true
);
return launchRuneLiteInner(jx_session_id, jx_character_id, jx_display_name, true);
}

// locate hdos's .jar from their CDN, then attempt to launch it with the given env variables
export function launchHdos(
jx_access_token: string,
jx_refresh_token: string,
jx_session_id: string,
jx_character_id: string,
jx_display_name: string
Expand All @@ -687,10 +666,6 @@ export function launchHdos(
const xml = new XMLHttpRequest();
const params: Record<string, string> = {};
if (version) params.version = version;
// if (jx_access_token) params.jx_access_token = jx_access_token; // setting these cause login to fail
// if (jx_refresh_token) params.jx_refresh_token = jx_refresh_token; // setting these cause login to fail
params.jx_access_token = '';
params.jx_refresh_token = '';
if (jx_session_id) params.jx_session_id = jx_session_id;
if (jx_character_id) params.jx_character_id = jx_character_id;
if (jx_display_name) params.jx_display_name = jx_display_name;
Expand Down
12 changes: 5 additions & 7 deletions app/src/lib/Launch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,12 @@
case Game.osrs:
if ($selectedPlay.client == Client.runeLite) {
launchRuneLite(
<string>$selectedPlay.credentials?.access_token,
<string>$selectedPlay.credentials?.refresh_token,
<string>$selectedPlay.credentials?.session_id,
<string>$selectedPlay.character?.accountId,
<string>$selectedPlay.character?.displayName
);
} else if ($selectedPlay.client == Client.hdos) {
launchHdos(
<string>$selectedPlay.credentials?.access_token,
<string>$selectedPlay.credentials?.refresh_token,
<string>$selectedPlay.credentials?.session_id,
<string>$selectedPlay.character?.accountId,
<string>$selectedPlay.character?.displayName
Expand All @@ -66,8 +62,6 @@
break;
case Game.rs3:
launchRS3Linux(
<string>$selectedPlay.credentials?.access_token,
<string>$selectedPlay.credentials?.refresh_token,
<string>$selectedPlay.credentials?.session_id,
<string>$selectedPlay.character?.accountId,
<string>$selectedPlay.character?.displayName
Expand Down Expand Up @@ -144,7 +138,11 @@
{#if $selectedPlay.account}
{#each $selectedPlay.account.characters as character}
<option data-id={character[1].accountId} class="dark:bg-slate-900">
{character[1].displayName}
{#if character[1].displayName}
{character[1].displayName}
{:else}
New Character
{/if}
</option>
{/each}
{/if}
Expand Down
2 changes: 0 additions & 2 deletions app/src/lib/Settings/Osrs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
return;
}
launchRuneLiteConfigure(
<string>$selectedPlay.credentials?.access_token,
<string>$selectedPlay.credentials?.refresh_token,
<string>$selectedPlay.credentials?.session_id,
<string>$selectedPlay.character?.accountId,
<string>$selectedPlay.character?.displayName
Expand Down

0 comments on commit 5f5d83b

Please sign in to comment.