[PR #2298] [MERGED] Count leave_game for every player who leaves, owner included #4181

Closed
opened 2026-11-03 04:15:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2298
Author: @carlosnunez09
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: fix/leave-game-statistic


📝 Commits (5)

  • e50eb7c Count leave_game for every player who leaves, owner included
  • 1862395 Keep a leaving guest's play state until their statistics are saved
  • d62a1e5 Merge remote-tracking branch 'upstream/main' into fix/leave-game-statistic
  • d75f767 Merge remote-tracking branch 'upstream/main' into tmp-resolve-2298
  • 3caf28c Merge remote-tracking branch 'upstream/main' into tmp/merge-2298

📊 Changes

5 files changed (+74 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game/integrated.rs (+2 -0)
📝 crates/horizon-client/src/game/lan.rs (+31 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+3 -0)
📝 crates/horizon-client/src/game/lan_crafting.rs (+6 -4)
📝 tools/lan_e2e.py (+32 -3)

📄 Description

🤖 Opened by Carlos Nunez's AI agent (Claude Code), not by Carlos Nunez himself.

What and why

Vanilla gives every player the leave_game statistic when they leave. Horizon only counted it in the in-frame path (save_for_exit / begin_closing_save without a server thread), so in the default server-thread mode the world owner never got it, and neither did guests who left or were removed when the server stopped.

Fix: LanHost::award_leave_game counts it once per guest, before the guest is saved, in the three places a player leaves:

  • a guest's HostEvent::Left,
  • stop_integrated (the server thread stopping: the owner and every guest),
  • lan_close (LAN closing in the in-frame path).

It is once per guest because a guest is saved more than once on the way out (stop_integrated saves them, then lan_close saves them again).

Part of #2095 (item 4 of the report). Not touched here: the signal handling and the remote-world disconnect (#2116), the shutdown watchdog, save-error reporting and the quit-shortcut option.

Vanilla reference

  • PlayerList.remove: player.awardStat(Stats.LEAVE_GAME), then this.save(player).
  • MinecraftServer.stopServer: playerList.saveAll(), then playerList.removeAll() (which calls remove for each player).

How I checked it

Headless game in throwaway folders, open a creative world, wait until ready, horizon-ctl quit, read saves/W/players/stats/<uuid>.json:

  • main: no minecraft:leave_game entry.
  • this branch: "minecraft:leave_game": 1 (one, although the player is saved twice).

There is no harness for the lifecycle statistics; not added here. The guest path (Left, kicked at shutdown) is not run end to end: it needs two games (tools/lan_e2e.py), which I did not run.

Self-check

python3 tools/pr_ready.py --quick --base upstream/main on macOS:

Check Result
Scope ✅ 3 files, +36 −0
Cargo.lock ✅ unchanged
Public tree ✅
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 1321 passed
doc tests ✅
Parity ➖ not run (--quick): CI picks the affected harnesses

Label: a fix, none.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/2298 **Author:** [@carlosnunez09](https://github.com/carlosnunez09) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/leave-game-statistic` --- ### 📝 Commits (5) - [`e50eb7c`](https://github.com/horizon-rust/horizon/commit/e50eb7c71f5e5e7e7b27e2d8047f136e90f0ddc7) Count leave_game for every player who leaves, owner included - [`1862395`](https://github.com/horizon-rust/horizon/commit/1862395e4b72d7ed7d5e6ee1769727ac38964031) Keep a leaving guest's play state until their statistics are saved - [`d62a1e5`](https://github.com/horizon-rust/horizon/commit/d62a1e5d209ff616bad9faeb487838f946be8fc9) Merge remote-tracking branch 'upstream/main' into fix/leave-game-statistic - [`d75f767`](https://github.com/horizon-rust/horizon/commit/d75f767925aa6b65e779377dbca19898b7b3c9f3) Merge remote-tracking branch 'upstream/main' into tmp-resolve-2298 - [`3caf28c`](https://github.com/horizon-rust/horizon/commit/3caf28c4d6aa1446eaf4500b0e8fb38df590c3a3) Merge remote-tracking branch 'upstream/main' into tmp/merge-2298 ### 📊 Changes **5 files changed** (+74 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/integrated.rs` (+2 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+31 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+3 -0) 📝 `crates/horizon-client/src/game/lan_crafting.rs` (+6 -4) 📝 `tools/lan_e2e.py` (+32 -3) </details> ### 📄 Description > 🤖 Opened by Carlos Nunez's AI agent (Claude Code), not by Carlos Nunez himself. ## What and why Vanilla gives every player the `leave_game` statistic when they leave. Horizon only counted it in the in-frame path (`save_for_exit` / `begin_closing_save` without a server thread), so in the default server-thread mode the world owner never got it, and neither did guests who left or were removed when the server stopped. Fix: `LanHost::award_leave_game` counts it once per guest, before the guest is saved, in the three places a player leaves: - a guest's `HostEvent::Left`, - `stop_integrated` (the server thread stopping: the owner and every guest), - `lan_close` (LAN closing in the in-frame path). It is once per guest because a guest is saved more than once on the way out (`stop_integrated` saves them, then `lan_close` saves them again). Part of #2095 (item 4 of the report). Not touched here: the signal handling and the remote-world disconnect (#2116), the shutdown watchdog, save-error reporting and the quit-shortcut option. ## Vanilla reference - `PlayerList.remove`: `player.awardStat(Stats.LEAVE_GAME)`, then `this.save(player)`. - `MinecraftServer.stopServer`: `playerList.saveAll()`, then `playerList.removeAll()` (which calls `remove` for each player). ## How I checked it Headless game in throwaway folders, open a creative world, wait until ready, `horizon-ctl quit`, read `saves/W/players/stats/<uuid>.json`: - main: no `minecraft:leave_game` entry. - this branch: `"minecraft:leave_game": 1` (one, although the player is saved twice). There is no harness for the lifecycle statistics; not added here. The guest path (`Left`, kicked at shutdown) is not run end to end: it needs two games (`tools/lan_e2e.py`), which I did not run. ## Self-check `python3 tools/pr_ready.py --quick --base upstream/main` on macOS: | Check | Result | | --- | --- | | Scope | ✅ 3 files, +36 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 1321 passed | | doc tests | ✅ | | Parity | ➖ not run (--quick): CI picks the affected harnesses | Label: a fix, none. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:15:17 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4181
No description provided.