8000 Zdxsv: keep the fast login result for a new user's lobby connect after the battle by inada-s · Pull Request #553 · inada-s/pcsx2 · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/zdxsv/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ this table says it is missing.

- **Switch for all online battle extensions**: `ZDXSV_EXTENSIONS=0`.
- **Online without DEV9**: with the platform info, a TCP battle, a GGPO battle and TLS; every connection menu button connects with no network setting, also from a blank card; ネット終了 closes the lobby connection and returns to the main menu; on with a server host (`ZDXSV_SERVER_HOST`).
- **Fast login**: DNAS and the login browser skipped; the game waits at DNAS (VM paused) for the login API's answer; no answer or a server error keeps it held (OSD, retry 2-30 s backoff) until it answers or the player resumes (then, like no token or a refused login, back to the network menu: no DNAS). The game's reconnect after a failed battle connect (its login browser) logs in the same way once its earlier file load ends; a failed login leaves the game in its browser; `ZdxsvFastLogin`, `ZdxsvLoginApiUrl`.
- **Fast login**: DNAS and the login browser skipped; the game waits at DNAS (VM paused) for the login API's answer; no answer or a server error keeps it held (OSD, retry 2-30 s backoff) until it answers or the player resumes (then, like no token or a refused login, back to the network menu: no DNAS). The game's reconnect after a failed battle connect (its login browser) logs in the same way once its earlier file load ends; a failed login leaves the game in its browser. The login result is written back when the game clears it for a newly made user, so the lobby connect after the battle has its address; `ZdxsvFastLogin`, `ZdxsvLoginApiUrl`.
- **Sign-in**: Settings → zdxsv → Account, or the fast login at DNAS with no token (VM paused), signs in through the server (Discord) and saves the token the fast login sends; `ZdxsvAuthUrl`. Signing in makes no zdxsv account: the first login, or one with an empty slot picked, makes it; Carry Over from PS2 links a PS2 account by its carry-over code. Account picks one of the Discord account's accounts (`ZdxsvAccount`); the server sets the limits.
- **Fast boot**: boot to the lobby user_id selection with no input; `ZdxsvFastBoot`, `ZdxsvFastBootState`, `ZdxsvFastBootLobby` (on through ID 1 into the lobby).
- **Platform info `0x9950` to the lobby**: `ZDXSV_PLATFORM_INFO`.
Expand Down
26 changes: 21 additions & 5 deletions pcsx2/Zdxsv/FastLogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Zdxsv
constexpr u32 kLobbyStep = kGp - 0x59f4; // in phase 0x17: 0 = browser load, 4 = browser closing, display restored
constexpr u8 kNetLoginBrowser = 0x27;
constexpr u8 kPhaseLoginBrowser = 0x17;
constexpr u8 kPhaseUserSelect = 3; // the user_id selection and the new user registration pages
constexpr u8 kStepBrowserLoad = 0;
constexpr u8 kStepParked = 7; // no step: the phase does nothing
constexpr u32 kLoaderQueue = kGp - 0x5dfc; // address of the file loader queue; its first byte is 1 while a load runs
Expand Down Expand Up @@ -279,18 +280,22 @@ namespace Zdxsv
return queue < Ps2MemSize::MainRam && eeMem->Main[queue] != 0;
}

void Apply(const LoginResult& r)
void PutResultArea(const LoginResult& r)
{
std::memset(&eeMem->Main[kResultBegin], 0, kResultEnd - kResultBegin);
const std::string lbs_id = r.lbs_info.substr(0, kLbsIdLen);
Put(kResultLbsId, lbs_id);
Put(kResultLbsId, r.lbs_info.substr(0, kLbsIdLen));
Put(kResultLoginKey, r.login_key);
Put(kResultSessionId, r.session_id);
Put(kResultLobbyAddr, r.lobby_addr);
Put(kResultLbsList, r.lbs_info);
Put(kResultStatus, "999");
}

void Apply(const LoginResult& r)
{
PutResultArea(r);
std::memset(&eeMem->Main[kSelectedLbsId], 0, 16);
Put(kSelectedLbsId, lbs_id);
Put(kSelectedLbsId, r.lbs_info.substr(0, kLbsIdLen));
eeMem->Main[kLbsCount] = 1;
eeMem->Main[kNetState] = 0x27;
eeMem->Main[kNetSub] = 0;
Expand Down Expand Up @@ -366,7 +371,18 @@ namespace Zdxsv
const bool browser = in_phase && (s_fast.in_browser ||
(s_fast.last_phase != kPhaseLoginBrowser && eeMem->Main[kLobbyStep] == kStepBrowserLoad));
s_fast.last_phase = phase;
const bool at_dnas = (eeMem->Main[kNetState] == 0x21 && eeMem->Main[kLobbyPhase] == 2) || browser;
// The game clears the result area for a newly made user; the lobby connect after a battle reads it.
if (s_fast.applied && eeMem->Main[kResultStatus] == 0 && eeMem->Main[kNetState] == kNetLoginBrowser &&
phase != kPhaseUserSelect && phase != kPhaseLoginBrowser)
{
std::lock_guard lock(s_fast.mutex);
if (s_fast.result)
{
PutResultArea(*s_fast.result);
Console.WriteLn("Zdxsv: fast login: result area cleared by the game, restored");
}
}
const bool at_dnas =(eeMem->Main[kNetState] == 0x21 && eeMem->Main[kLobbyPhase] == 2) || browser;
if (s_fast.step == FastLogin::Step::Done)
{
// Every DNAS start logs in again: after ネット終了 or a lost lobby the game comes back here.
Expand Down
1 change: 1 addition & 0 deletions tests/zdxsv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Scripts are in `tests/zdxsv/` except `run.py` (repository root) and
| USB keyboard sends the physical key (Windows) | no test: by hand, Windows with a Japanese keyboard layout, USB port 1 = `hidkbd`, in a lobby room type `@`, `:`, `^`, `A` then Enter twice: the chat line is `@:^あ` | the same build with `HostKeyNumber` returning 0: the line is `あ` (the three symbols dropped) |
| Fast login | `ROUTE=top LIMIT=200 boottime.py` (server with `/lbs/login`): user_id screen with no ログイン press, emulog `Zdxsv: fast login: session`, no DNAS POST in `dnas.log` | `ZDXSV_FAST_LOGIN=0 ROUTE=top LIMIT=200 MAXS=150 boottime.py` fails (stops at TOP) |
| Fast login at the game's reconnect | `m4z.py` `EMU=1 CLIENTS="1 3" GGPO=7101 GGPO_CLIENTS=1` (DEV9 adapter off; client 3 without GGPO cannot reach the battle server, the game gives up and opens its reconnect): `p3 battle unreachable without DEV9, back online after the game's reconnect` (a second `ZdxsvOnline: online` within 180 s), emulog `fast login: by token, from the game's login browser` | a build without it: one `ZdxsvOnline: online`, FAIL |
| Lobby connect after the first battle of a new user | no test: by hand, `run.py rom` signed in with an unused user ID, make the user, play one battle: emulog `result area cleared by the game, restored` and the game returns to the lobby | a build without it: `no DEV9: connect to 0.0.0.0:0 refused` |
| Fast boot | `fastboot.py`: run 1 (no boot state) logs `Zdxsv: fast boot: saving` and reaches the user_id screen with no input, run 2 logs `Zdxsv: fast boot: loading` and reaches it within 5 s of the VM start (`LIMIT`); each prints its time from the launch and from the VM start; run 3 (`OTHER_CARD`, default the second of `CARDS`) logs `Zdxsv: fast boot: saving` (no load of run 1's state) and leaves one boot state; run 4 (unformatted card) logs `Zdxsv: fast boot: stopped, memory card error` within 15 s; passes with the local zdxsv stack and with `LOBBY=fake` (`boot_lobby.py`: lobby API login and the lobby up to the user_id list only) | `ZDXSV_FAST_BOOT=0 MAXS=60 boottime.py` fails (no user_id screen), also with `LOBBY=fake`; run 3 on a build that keys the boot state on the adapter path only fails (`loading`) |
| Platform info `0x9950` to the lobby | `m4z.py` with samples of the lobby `/api/stat`: the lobby counts each client by platform | none |
| Battle over TCP to the battle server, as a PS2 | `m4.py`: 4 emulators from a fresh boot, all at once (fast boot through the user_id selection to 戦場選択 with `ZDXSV_FAST_BOOT_LOBBY`, fast login to the fake lobby's login API), fake lobby replaying `TRACE`, one battle. Variant `MASHP=1 SHOW=1`: time-up with side 1 ahead, all 4 report a loss | none |
Expand Down
0