Skip to content

Renew the Warcraft III sign-in from Battle.net before grill run launches - #90

Merged
Frotty merged 8 commits into
masterfrom
battlenet-sign-in
Nov 17, 2026
Merged

Frotty merged 8 commits into
masterfrom
battlenet-sign-in

Conversation

@Frotty

@Frotty Frotty commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Problem

grill run starts Reforged clients with -launch -editor -loadfile. Such a client signs in with EDITOR_TOKEN (HKCU\Software\Blizzard Entertainment\Warcraft III), which it replaces on each sign-in. Once the token lapses (overnight is enough), every run stops at the in-game login panel. The Battle.net app's own session doesn't help: a client the app starts with -loadfile shows the login panel too (measured on 3.0.1 and Battle.net 2.53).

Behavior

Before launching, grill run (and grill run --hot) renews the sign-in from the signed-in Battle.net app:

  1. Ask the app to start Warcraft III.
  2. Close that client before it signs in. Only a new Warcraft III.exe whose parent is Battle.net.exe is closed; other games are left alone.
  3. Store the one-time WEB_TOKEN the app wrote for it as EDITOR_TOKEN.
  4. Launch the map as before, and wait until the client replaces EDITOR_TOKEN as it signs in (about 10 s, at most 2 minutes).

Before step 1, grill starts battlenet-window.ps1 (the same script WurstScript's Run Map uses), from a content-named temp copy with -File, and waits until it is ready. It hooks window creation:

  • Each new Battle.net window is moved off-screen as it is created, shown out of sight and minimized without activation.
  • Its restore position is set back to where Battle.net put it.
  • A launcher window Battle.net shows again as the client signs in is hidden the same way.
  • A crash reporter of the renewal's closed client is closed.
  • With -FocusGame it brings the map's client to the front once it has a window, never a game that was already running.
  • It ends a minute after the map's client appears.

Steps 1–3 take about a second. The renewal holds the same loopback lock as WurstScript's Run Map (wurstscript/WurstScript#1624) and other tools that renew this sign-in, from the renewal until the client has signed in. Without that, another tool's renewal could replace the token before this client read it.

wurst.wc3LaunchMode in .vscode/settings.json is the same setting Run Map follows:

Value Behaviour
auto (default) Renews when Battle.net is open; otherwise launches with the stored sign-in and says a login may appear.
battlenet Refuses to launch when it cannot renew.
legacy Never renews.

Only Windows and the Battle.net-managed install are affected. Classic clients, macOS and Linux launch as before.

The mechanism and the lock are described in wurstscript/WurstScript#1624.

Validation

  • ./gradlew test: 148 passed, 2 skipped, including BattleNetSignInTests, which cover:
    • registry parsing;
    • the lock port, pinned to WurstScript's value for the same path;
    • the mode decisions;
    • the window watcher command.
  • Live on Windows, with an expired EDITOR_TOKEN restored first: grill run ExampleMap.w3x from a jar built from this branch printed "Renewing the Warcraft III sign-in from Battle.net..." and "Waiting for Warcraft III to sign in...". It exited 32 s after start, build included. The game reached the map's loading screen signed in.
  • Live with an earlier, polling version of the watcher: the Battle.net window was minimized within 0.1 s, and the game took the foreground 3 s later. The creation-hook version was verified live through an automated test run and the WurstScript Java path (no Battle.net window on screen or in the foreground, renewal to sign-in). It has not been run through grill run itself yet.

Gaps

  • Ctrl+C during the renewal does not close the client Battle.net was asked for. WurstScript's Run Map does, through its cancellation hook; grill has no equivalent.
  • wurst4vscode does not declare wurst.wc3LaunchMode, so VS Code does not suggest it, although the language server and grill both read it.

grill run starts Reforged clients with -launch -editor -loadfile, and such a
client signs in with EDITOR_TOKEN, which it renews on each sign-in. Once the
token lapses (overnight is enough) every run stops at the in-game login
panel. Battle.net's own session never reaches a client started with
-loadfile.

Before launching, grill now has the Battle.net app start the game, closes
that client before it spends the one-time WEB_TOKEN the app wrote for it,
and stores that token as EDITOR_TOKEN. The map then launches as before, and
grill waits until the client has replaced the token (about ten seconds) so
the shared lock with WurstScript's Run Map and the wc3-e2e-harness covers it.

wurst.wc3LaunchMode in .vscode/settings.json, as for Run Map: "auto" renews
when Battle.net is open, "battlenet" refuses to launch without a renewal,
"legacy" never renews. Only Windows and the Battle.net-managed install are
affected.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T14:47:36.200294Z 076e4c4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 929c8cbca3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/kotlin/file/Wc3MapRunner.kt Resolved
Asked to start Warcraft III for the sign-in renewal, the Battle.net app shows
its window in front and, depending on its "when I launch a game" setting,
leaves it there. Before asking, grill now starts battlenet-window.ps1 (a copy
of the wc3-e2e-harness script) and waits until it is ready. For 30 s it
minimizes every app window that appears or takes the foreground, without
activating it, and brings the map's client to the front once it has a
window, never a game that was already running.
…valid path settings optional

grill gave up on the Battle.net lock after 30 s, and in auto mode then
launched without it. Another grill, Run Map or harness run holds the lock
through its renewal and its client's sign-in, up to about 3.5 minutes, so the
unlocked launch could spend the token that client had not read yet. grill now
waits up to 4 minutes, says it is waiting, and if the lock is still held
refuses to launch in every mode.

Reading a path setting from .vscode/settings.json converted it outside the
error handler, so a path the system cannot represent aborted grill run where
it used to be ignored. It is ignored again.
@Frotty

Frotty commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c525d12ec4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/kotlin/file/Wc3MapRunner.kt Resolved
A registry query that timed out while grill waited for the launched client to sign in threw out of launchMap after the map was already running. grill run --hot treats that as a failed launch and rolls back to the previous hot reload session. The wait now reports such a failure and releases the lock instead of throwing.
@Frotty

Frotty commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 23915b521e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…h the lock

As in wc3-e2e-harness#61: the watcher ended after 30 s while a renewal keeps asking Battle.net every 25 s for up to 90 s. It now runs for the renewal timeout plus 15 s, and a successful renewal ends it together with the lock once the client has signed in, so it does not minimize a launcher the user opens later.
@Frotty

Frotty commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 35b209bdd3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Updates the copy of wc3-e2e-harness battlenet-window.ps1 (Frotty/wc3-e2e-harness#61): Battle.net creates a new window each time it is asked to start the game, so the watcher now hooks window creation, moves each new window off-screen before it shows and minimizes it there, instead of minimizing it after it flashed in front. The script is now run with -File from a content-named temp copy: passed with -EncodedCommand it came close to Windows' 32,767-character command line limit.
… grill run

Updates the copy of wc3-e2e-harness battlenet-window.ps1: Battle.net shows its window again as the launched client signs in, ten to twenty seconds after launch, so ending the watcher with the lock at that sign-in let it through. The watcher now ends itself a minute after the client appears (at most the renewal timeout plus 150 s), also hides a launcher window the app restores, and closes a crash reporter of the renewal's closed client.
@Frotty

Frotty commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: bfa3f16f36

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Updates the copy of wc3-e2e-harness battlenet-window.ps1. Until the run's client appeared, the watcher closed every new BlizzardError.exe, so a crash report from a game the user already had open was cut short too. It now closes a new reporter only when its parent is a renewal client it saw (started by Battle.net) or a process already gone that was not one of the games running before; every other reporter is left alone.
@Frotty

Frotty commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 076e4c44e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Frotty added a commit to wurstscript/WurstScript that referenced this pull request Nov 17, 2026
…et window out of sight (#1627)

* Never launch Run Map without the Battle.net sign-in lock

Run Map gave up on the renewal lock after 30 s and, in wc3LaunchMode "auto",
treated that like any renewal failure: it launched on the stored sign-in
without the lock. Another Run Map, grill run or harness run holds the lock
through its renewal (up to 90 s) and until its client signs in (up to
120 s), so that unlocked launch could spend the token the other client had
not read yet, leaving one of them at the login panel.

The lock wait now covers a renewal and a sign-in (240 s), says why the run
is waiting, and ends in a LockBusyException. RunMap.renewOrRefuse turns that
into a failed run in every mode; other renewal failures keep their fallback.
This mirrors grill run (wurstscript/WurstSetup#90).

* Hide the Battle.net window while Run Map renews the sign-in

Asked to start Warcraft III for the renewal, Battle.net creates a window
and shows it in front, and shows it again as the launched client signs
in, ten to twenty seconds later. The handoff after the launch
(BattleNetLaunchWindows) minimized it only once it had flashed on screen.

Before asking, the renewal now starts battlenet-window.ps1, a copy of the
wc3-e2e-harness script, run with -File from a content-named temp copy. It
hooks window creation: each new Battle.net window is moved off-screen as
it is created, shown out of sight, and minimized without activation with
its restore position set back, so the user's own next Restore opens it
normally. It also hides a window the app shows again or restores, closes
a crash reporter of the renewal's closed client, and ends a minute after
the map's client appears.

* Close only the renewal client's crash reporter (watcher copy)

Updates the copy of wc3-e2e-harness battlenet-window.ps1. Until the run's client appeared, the watcher closed every new BlizzardError.exe, so a crash report from a game the user already had open was cut short too. It now closes a new reporter only when its parent is a renewal client it saw (started by Battle.net) or a process already gone that was not one of the games running before; every other reporter is left alone.
@Frotty
Frotty merged commit b5ac4d1 into master Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant