diff --git a/README.md b/README.md
index aba172d..16bcb84 100644
--- a/README.md
+++ b/README.md
@@ -81,6 +81,7 @@ All of the command line arguments are optional.
- `--internal_backend` — Set the internal backend url when running the Screeps server in a local container. This will convert requests to a localhost backend to use the container name where the Screeps server is running.
- `--server_list` — Path to a custom server list json config file.
- `--beautify` — Formats .js files loaded in the client for debugging.
+- `--guest` — Enable guest mode for xxscreeps.
- `--debug` — Display verbose errors for development.
## Examples
@@ -121,6 +122,6 @@ npx screepers-steamless-client --server_list ./custom_server_list.json
## Tips
-This client uses "guest mode" by default in [xxscreeps](https://github.com/laverdet/xxscreeps/), providing a read-only view of the server when not signed in. To sign in with your Steam account, select "Sign Out" first, then click the Steam icon to sign in and play as normal.
+This client has an optional "guest mode" for [xxscreeps](https://github.com/laverdet/xxscreeps/) that can be enabled with `--guest` and provides a read-only view of the server when not signed in. To sign in with your Steam account, select "Sign Out" first, then click the Steam icon to sign in and play as normal.

diff --git a/scripts/release.sh b/scripts/release.sh
index 17db241..e71aede 100644
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -9,15 +9,15 @@ npx semantic-release
# Get the new version from package.json
newVersion=$(node -p "require('./package.json').version")
-# Revert package.json to its state in the Git repository
-git checkout HEAD -- package.json
+# Revert package.json and package-lock.json to their state in the Git repository
+git checkout HEAD -- package.json package-lock.json
# If the version has changed, update the version in package.json
if [[ "$currentVersion" != "$newVersion" ]]; then
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
npm version --no-git-tag-version $newVersion
- git add package.json
+ git add package.json package-lock.json
git commit -m "chore: release $newVersion [skip ci]"
git push
fi
diff --git a/src/clientApp.ts b/src/clientApp.ts
index c44b6e8..9a45086 100644
--- a/src/clientApp.ts
+++ b/src/clientApp.ts
@@ -68,6 +68,11 @@ const argv = (() => {
type: 'str',
help: 'Path to a custom server list json config file.',
});
+ parser.add_argument('--guest', {
+ action: 'store_true',
+ default: false,
+ help: 'Enable guest mode for xxscreeps.',
+ });
parser.add_argument('--beautify', {
action: 'store_true',
default: false,
@@ -214,7 +219,7 @@ koa.use(async (context, next) => {
const header = '
Screeps';
const replaceHeader = [
header,
- generateScriptTag(clientAuth, { backend: info.backend }),
+ generateScriptTag(clientAuth, { backend: info.backend, guest: argv.guest }),
generateScriptTag(removeDecorations, { backend: info.backend }),
generateScriptTag(customMenuLinks, { backend: info.backend, seasonLink, ptrLink, changeServerLink }),
].join('\n');
@@ -266,6 +271,9 @@ koa.use(async (context, next) => {
const ptrValue = prefix === '/ptr' ? 'true' : 'false';
src = src.replace(/(PTR: )[^,]*/, `$1${ptrValue}`);
+ const debugValue = argv.debug ? 'true' : 'false';
+ src = src.replace(/(DEBUG: )[^,]*/, `$1${debugValue}`);
+
return src;
} else if (context.path.endsWith('.js')) {
let src = await file.async('text');
diff --git a/src/inject/clientAuth.ts b/src/inject/clientAuth.ts
index f2c5c4d..bf2ee7f 100644
--- a/src/inject/clientAuth.ts
+++ b/src/inject/clientAuth.ts
@@ -1,7 +1,7 @@
/**
* This function is injected into the client to manage settings in local storage.
*/
-export function clientAuth(backend: string) {
+export function clientAuth(backend: string, guest: boolean) {
// Clear the local storage if the backend domain has changed
if (localStorage.backendDomain && localStorage.backendDomain !== backend) {
const keysToPreserve = ['game.room.displayOptions', 'game.world-map.displayOptions2', 'game.editor.hidden'];
@@ -15,32 +15,35 @@ export function clientAuth(backend: string) {
// Set the backend domain
localStorage.backendDomain = backend;
- // Set the auth token to guest if it's not set or if it's been more than an hour since the last token was set
- if (
- (localStorage.auth === 'null' && localStorage.prevAuth === 'null') ||
- 60 * 60 * 1000 < Date.now() - localStorage.lastToken ||
- (localStorage.prevAuth !== '"guest"' && (localStorage.auth === 'null' || !localStorage.auth))
- ) {
- localStorage.auth = '"guest"';
- }
-
// Set the client to skip tutorials and tip of the day
localStorage.tutorialVisited = 'true';
localStorage.placeSpawnTutorialAsked = '1';
localStorage.tipTipOfTheDay = '-1';
- // Set the last token to the current time
- localStorage.prevAuth = localStorage.auth;
- localStorage.lastToken = Date.now();
-
- // Update the last token if the auth token changes
- let auth = localStorage.auth;
- setInterval(() => {
- if (auth !== localStorage.auth) {
- auth = localStorage.auth;
- localStorage.lastToken = Date.now();
+ // Guest mode for xxscreeps
+ if (guest) {
+ // Set the auth token to guest if it's not set or if it's been more than an hour since the last token was set
+ if (
+ (localStorage.auth === 'null' && localStorage.prevAuth === 'null') ||
+ 60 * 60 * 1000 < Date.now() - localStorage.lastToken ||
+ (localStorage.prevAuth !== '"guest"' && (localStorage.auth === 'null' || !localStorage.auth))
+ ) {
+ localStorage.auth = '"guest"';
}
- }, 1000);
+
+ // Set the last token to the current time
+ localStorage.prevAuth = localStorage.auth;
+ localStorage.lastToken = Date.now();
+
+ // Update the last token if the auth token changes
+ let auth = localStorage.auth;
+ setInterval(() => {
+ if (auth !== localStorage.auth) {
+ auth = localStorage.auth;
+ localStorage.lastToken = Date.now();
+ }
+ }, 1000);
+ }
// The client will just fill this up with data until the application breaks.
if (localStorage['users.code.activeWorld']?.length > 1024 * 1024) {