Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,7 @@ A Gateway built before the mode would start for real, so Waypoint first asks `co
The list is read from the checkout's save database (`auth.db` and `characters.db` from LocalExile's database split on, or an
old `saves.db` until the servers migrate it) through the adapter, with nothing running or built: every account with
its characters, nothing secret. Showing the section reads it; **Reload accounts** reads it again.
The relational save layout supports browsing accounts, characters, ascendancies and stash counts in this section.

**Register** and **Create** are the dev protocol's `register`, `login` and `create_character` (the server's GettingStarted
step 8), so they work beside running servers. The character is created in Standard; the game's own creation screen offers
Expand Down
2 changes: 2 additions & 0 deletions docs/runtime-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ loading code. Old builds launched after a newer app cannot be forced to particip
`QueryAccounts` returns an optional typed `AccountData` inventory and never initializes/migrates storage. Browsing uses
one read-only SQLite snapshot; it exposes names, IDs, character summaries and opaque revision tokens, never credential
verifiers. A snapshot's `AccountWriteBlockedReason` explains runtime blockers, including the account service.
For the relational save layout, browsing uses `auth.accounts`, current character and ascendancy rows, and stash tab headers.
The relational layout is read-only in the offline account helper.

`ManageAccount` accepts a reviewed `AccountDataRequest` on UTF-8 stdin. Its required `ExpectedDatabase` must match
the selected profile's resolved database before backup or mutation; desktop registration requests carry the same
Expand Down
55 changes: 53 additions & 2 deletions scripts/AccountData.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Storage contract: LocalExile main 89b7aa908213ac8eb9b5ac5aa7ae54c14189c3e9 (one saves.db), and from the database split on
(LocalExile/LocalExile#758) characters.db with the accounts in auth.db, which this helper attaches as `auth` the way the
servers do. A change across both files commits in each file on its own: RuntimeBridge backs both up first.
servers do. The relational characters database is supported for browsing. A change across both files commits in
each file on its own: RuntimeBridge backs both up first.
This helper never initializes schemas, runs emulator code, or manages processes/backups.
RuntimeBridge supplies ownership checks, writer serialization and the backup policy.
"""
Expand Down Expand Up @@ -232,11 +233,56 @@ def catalog(accounts, writable, root, can_register=False):
"Ascendancy": asc, "League": data.get("League", ""), "LastPlayedUtc": data.get("LastPlayedUtc", ""),
"HasProgress": ch["save"] is not None})
result.append({"Id": a["id"], "Name": a["name"], "CreatedUtc": a["data"].get("CreatedUtc", ""),
"Revision": a["revision"], "Characters": characters, "StashTabs": len(a["tabs"])})
"Revision": a["revision"], "Characters": characters, "StashTabs": a.get("tab_count", len(a["tabs"]))})
return {"Exists": True, "Writable": writable, "CanRegister": can_register, "Notice": "" if writable else
"This storage layout can be browsed, but account changes are disabled because its schema or import state is unfamiliar.", "Accounts": result}


def relational_catalog(db, root):
"""Read the current layout without using the retained pre-migration character and stash rows."""
accounts = []
for row in db.execute("SELECT id,name,account FROM auth.accounts ORDER BY name COLLATE NOCASE,id LIMIT 2001"):
entry = record(row["account"])
require(entry.get("Id") == row["id"] and entry.get("Name") == row["name"], "Account identity columns and JSON disagree.")
accounts.append({"id": identity(row["id"]), "name": row["name"], "data": entry,
"characters": [], "tabs": [], "tab_count": 0, "revision": ""})
require(len(accounts) <= 2000, "Too many accounts for this version of the account manager.")
owners = {a["id"]: a for a in accounts}
by_name = {fold(a["name"]): a for a in accounts}
require(len(owners) == len(accounts) and len(by_name) == len(accounts), "Account identities or names are not unique.")
characters = db.execute("""
SELECT c.id, c.account_id, c.name, c.class, c.level, c.league, c.last_played_utc,
s.id AS active_save, a.family, a.ascendancy
FROM main.account_characters c
LEFT JOIN main.character_saves s ON s.name=c.name AND s.deleted_utc IS NULL
LEFT JOIN main.character_ascendancies a ON a.save=s.id
ORDER BY c.created_utc,c.id LIMIT 48001
""").fetchall()
require(len(characters) <= 48000, "Too many characters for this version of the account manager.")
for row in characters:
identity(row["id"])
require(row["account_id"] in owners, "A character points to an account that is missing.")
selection = {"Id": row["ascendancy"], "Family": row["family"]}
owners[row["account_id"]]["characters"].append({
"id": row["id"], "name": row["name"], "save": row["active_save"],
"data": {"Class": row["class"], "Level": row["level"], "League": row["league"], "LastPlayedUtc": row["last_played_utc"]},
"progress": {"MainAscendancy": {"Selection": selection}},
})
for key, count in db.execute("""
SELECT s.account, COUNT(*) FROM main.stash_saves s
JOIN main.stash_tab_headers t ON t.stash=s.id GROUP BY s.id
"""):
plain = key[6:] if fold(key).startswith("guild:") else key
candidates = {plain, plain.split(" (", 1)[0]} if plain.endswith(")") else {plain}
matches = [by_name[fold(n)] for n in candidates if fold(n) in by_name]
require(len(matches) <= 1, "A stash key has ambiguous account ownership.")
if matches:
matches[0]["tab_count"] += count
result = catalog(accounts, False, root)
result["Notice"] = "This save format supports browsing here. Use LocalExile to manage accounts."
return result


def credentials(password):
require(isinstance(password, str), "Password must contain 4-1024 characters.")
try:
Expand Down Expand Up @@ -361,6 +407,11 @@ def run(path, root, request, auth=None):
db.execute("PRAGMA foreign_keys=ON")
db.execute("BEGIN" if action == "List" else "BEGIN IMMEDIATE")
try:
if split(db) and db.execute("SELECT 1 FROM main.sqlite_master WHERE type='table' AND name='character_saves'").fetchone():
require(action == "List", "Account changes are disabled for this unfamiliar storage layout or pending account import.")
result = relational_catalog(db, root)
db.execute("COMMIT")
return result
accounts, writable = snapshot(db)
if action != "List":
require(writable, "Account changes are disabled for this unfamiliar storage layout or pending account import.")
Expand Down
3 changes: 3 additions & 0 deletions src/Launcher.Core/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,9 @@ This checkout has modified tracked files.</value>
<data name="Text_38d7db28699e" xml:space="preserve">
<value>Trap gauntlet</value>
</data>
<data name="Text_38e4650ae2c3" xml:space="preserve">
<value>This save format supports browsing here. Use LocalExile to manage accounts.</value>
</data>
<data xml:space="preserve" name="Text_3907fa7f8072">
<value>Appearance</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Launcher.Core/Resources/Strings.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,9 @@
<data name="Text_38d7db28699e" xml:space="preserve">
<value>Коридор ловушек</value>
</data>
<data name="Text_38e4650ae2c3" xml:space="preserve">
<value>Здесь можно просматривать сохранения этого формата. Управляйте аккаунтами в LocalExile.</value>
</data>
<data xml:space="preserve" name="Text_3907fa7f8072">
<value>Оформление</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Launcher.Core/Resources/Strings.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,9 @@
<data name="Text_38d7db28699e" xml:space="preserve">
<value>陷阱通道</value>
</data>
<data name="Text_38e4650ae2c3" xml:space="preserve">
<value>此存档格式支持在此浏览。请在 LocalExile 中管理账号。</value>
</data>
<data name="Text_3907fa7f8072" xml:space="preserve">
<value>外观</value>
</data>
Expand Down
37 changes: 37 additions & 0 deletions tests/AccountData.Tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,43 @@ def test_missing_database_is_not_created(self):
self.assertFalse(data.run(path, self.root, {"Action": "List"})["Exists"])
self.assertFalse(path.exists())

def test_relational_listing_uses_active_saves_and_keeps_both_databases_read_only(self):
auth = self.root / "auth.db"
characters = self.root / "characters.db"
with connect(auth) as db:
db.execute("CREATE TABLE accounts(id TEXT PRIMARY KEY,name TEXT,account TEXT)")
db.execute("INSERT INTO accounts VALUES(?,?,?)", (self.account, "Alpha", json.dumps({
"Id": self.account, "Name": "Alpha", "PasswordHash": "private-verifier",
})))
with connect(characters) as db:
db.executescript("""
CREATE TABLE account_characters(id TEXT PRIMARY KEY, account_id TEXT, name TEXT, class INTEGER,
level INTEGER, league TEXT, created_utc TEXT, last_played_utc TEXT);
CREATE TABLE character_saves(id INTEGER PRIMARY KEY, name TEXT COLLATE NOCASE, deleted_utc TEXT);
CREATE TABLE character_ascendancies(save INTEGER PRIMARY KEY, family TEXT, ascendancy TEXT);
CREATE TABLE stash_saves(id INTEGER PRIMARY KEY, account TEXT);
CREATE TABLE stash_tab_headers(stash INTEGER, tab INTEGER, PRIMARY KEY(stash,tab));
INSERT INTO character_saves VALUES (1,'newhero','deleted'), (2,'newhero',NULL);
INSERT INTO character_ascendancies VALUES (1,'Normal','OldWitch'), (2,'Normal','Witch3');
INSERT INTO stash_saves VALUES (1,'Alpha (Allflame)'), (2,'AlphaOther');
INSERT INTO stash_tab_headers VALUES (1,0), (1,1), (2,0);
""")
db.execute("INSERT INTO account_characters VALUES(?,?,?,?,?,?,?,?)",
(self.char, self.account, "NewHero", 3, 77, "Allflame", "2026-01-01", "2026-02-01"))
before = (auth.read_bytes(), characters.read_bytes())
view = data.run(characters, self.root, {"Action": "List"}, auth)
self.assertFalse(view["Writable"])
self.assertFalse(view["CanRegister"])
account, = view["Accounts"]
self.assertEqual(account["StashTabs"], 2)
char, = account["Characters"]
self.assertEqual((char["Name"], char["Ascendancy"], char["Level"], char["HasProgress"]),
("NewHero", "Elementalist", 77, True))
self.assertNotIn("private-verifier", json.dumps(view))
with self.assertRaisesRegex(data.AccountError, "Account changes are disabled"):
data.run(characters, self.root, {"Action": "Rename"}, auth)
self.assertEqual(before, (auth.read_bytes(), characters.read_bytes()))

def test_ascendancy_fallback_and_phrecia(self):
with connect(self.path) as db:
value = json.loads(db.execute("SELECT save FROM characters").fetchone()[0])
Expand Down