Repository navigation
Conversation
…nd inspector sections The merge train dropped the Seat reservations and server directories (#2214), Idempotent match results (#2086), Match mailbox and one-writer state (#2212) and Live inspection and pprof sections from docs/en/gameserver.md and docs/zh/gameserver.md, and left the ticket properties section of #2072 under Player tokens. Restore the four sections and move the ticket section under Matchmaking. Remove the duplicates the train left beside it: docs/{en,zh}/server.md, recreated by a later title fix after the match handler section had moved into gameserver.md, and docs/{en,zh}/server-results.md with the note and changelog fragment of #2087, which describe gameserver.MatchResults and MemoryResultCommitter, an API that #2086's ResultsBackend replaced in the same merge.
equalResult compared only the number of record, wallet and score grants, so a retry of a committed match with different amounts was reported as an identical no-op. A committed record kept the version the caller sent, so every later writer holding that version still passed the optimistic check, and a first score below zero was dropped because a missing best score read as 0. Compare grants field by field and keep a copy of the committed result, store a committed record at its version plus one with a record that does not exist yet at version 0, and record a board's first score whatever its sign. Give ErrResultConflict a doc comment.
Rooms.Claim deleted the reservation, released the room lock and then joined, so a concurrent Join could take the freed seat and the claimant got ErrRoomFull with its reservation gone; a handler refusal or a busy server lost the reservation the same way, and JoinAttempt never saw the reservation's account. The merge of #2067 and #2068 also left join taking its account and metadata as ...any. Give join explicit account, meta and claim parameters, check and consume the reservation under the room lock while the claimed seat is left out of the capacity count, and pass res.Account to the handler. Room.Signal read r.handler without the lock that SetHandler takes; read it under the lock. Document the LeaveReason constants.
The default rule checked each candidate's query only against the room's oldest ticket, so two candidates that refuse each other could share a room, against the documented symmetric matching. Candidates are also taken in Should-score order, while the removal pass that drops the chosen tickets from the remaining list assumes ascending indexes: a reordered candidate stayed in the list and could be placed in a second room in the same Match call. Check a candidate's Must and MustNot terms against every ticket already in the room (the rating window is still measured from the oldest ticket, as documented), and sort the chosen indexes before the removal pass.
…e wallet
Spend negated its amount and checked only that the result was non-zero, so Spend("coins", -1000, key) added 1000 coins with no cap check, and Grant with a negative amount drained a balance past zero. A key replayed with a different currency, amount or operation returned the first change's result as if it were the same request, leaving ErrDuplicateKey unused, and a replayed Exchange returned the current balance of the target currency instead of its first result. Grants could also overflow int64.
Require positive amounts (ErrInvalidAmount), record the request under each key and answer a mismatch with ErrDuplicateKey, store both Exchange results for replay, refuse an exchange into the same currency, and treat an overflowing grant as ErrCapExceeded. Document the error values. Restore the Economy paragraph of liveops.md that #2241 added and a later merge dropped.
…S errors shipping-china.md still said NSGo Game ships no anti-addiction play-time or spending checks, while the same page documents pkg/online/antiaddiction (folded from #2239's pkg/online/compliance). Mark the status partial and point to the checks; real-name verification, reporting, the Purchases pre-check and the advisory screen stay tracked in #1649. Give the pkg/online/eos error values (#2094, restored by #2473) doc comments saying when each is returned.
…r sees the claim Claim now reached JoinAttempt before join looked the reservation up, so an expired claim reported the handler's refusal instead of ErrRoomFull and the handler saw claims that could never be admitted. Check the reservation first; join still checks and consumes it under the admitting lock.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up review of the online-2 bucket of the merge/2387 train, checked against current
main.Reviewed pull requests
#2263 docs: add runnable package examples
Landed intact. Its claim on #1559 is not met:
internal/repocheck/examples_test.gochecks a hard-coded list of 25 packages instead of every library package, so a new package without examples still passes (pkg/online/economy, for one, has none). Not changed here.#2239 feat(compliance): add mainland China policy checks
Already folded into
pkg/online/antiaddictionby #2473. Left over: the "Current status (planned)" box indocs/{en,zh}/shipping-china.mdstill said NSGo Game has no play-time or spending checks, while the same page documents them. This PR marks the status partial and links to the checks.#2241 feat(economy): add idempotent wallet core
Spendnegated its amount and only refused zero, soSpend("coins", -1000, k)minted 1000 coins and skipped the cap; a negativeGrantdrained a balance past zero. Amounts must now be positive (ErrInvalidAmount).ErrDuplicateKeywas declared but never returned). Each key now records its request, and a mismatch isErrDuplicateKey.Exchangereturned the target currency's current balance, not the first result. Both results are stored now. An exchange into the same currency is refused.ErrCapExceedednow.liveops.md(en and zh) was dropped by a later merge, so it is back.#2094 feat(online): add Epic Online Services boundary
A first draft of the same issue as the
PlatformAPI that #2473 restored. Nothing from #2094 should come back: itseos.Servicedocs describe an API that no longer exists. This PR only adds doc comments to the package's error values.#2067 feat(gameserver): add expiring seat reservations / #2214 feat(gameserver): sign reservations and track servers
#2214 contains all of #2067. Both landed in code. Problems:
Rooms.Claimdeleted the reservation, released the room lock and then joined. A concurrentJoincould take the freed seat, and the claimant gotErrRoomFullwith its reservation gone. A handler refusal or a busy server also lost the reservation, andJoinAttemptnever saw the account.joinnow takes explicitaccount, meta, claimparameters instead of the...anythe merge left. It checks and consumes the reservation under the same lock that admits the peer, leaves the claimed seat out of the capacity count, and passesres.Accountto the handler. A missing or expired reservation is refused before the handler is called.#2068 feat(gameserver): add match lifecycle handlers
Room.Signalreadr.handlerwithout the lockSetHandlertakes, which is a data race. It now reads it under the lock. TheLeaveReasonconstants got doc comments.docs/{en,zh}/server.mdcame back as a stray page (a later title fix recreated it after fix(docs): fold stray untitled pages into package docs and restore dropped sections #2453 moved its section intogameserver.md), so it is deleted.#2072 feat(gameserver): add matchmaking ticket queries
MustandMustNotare now checked between every pair in the room. The rating window still counts from the oldest ticket, as documented.Should-score order, but the pass that removes chosen tickets assumes ascending indexes. A reordered candidate stayed in the list and could be put in a second room in the sameMatchcall. The chosen indexes are now sorted before removal.#2086 feat(gameserver): add idempotent result commits / #2087 feat(gameserver): add idempotent match result commits
Two attempts at #1678. The merge kept #2086's
ResultsBackendcode but left #2087's docs, note and changelog fragment, which describeMatchResults/MemoryResultCommitter, an API that does not exist. #2086's own docs section was dropped. This PR deletes #2087's leftovers (docs/{en,zh}/server-results.md, its note and its fragment) and restores #2086's section. Bugs inResultsBackend.Commit:equalResultcompared only the number of grants, so a retry with different amounts was accepted as an identical no-op. It now compares grant by grant against a copy of the committed result.Version+1, and a record that does not exist yet is version 0.ErrResultConflictgot a doc comment.#2209 feat(netplay): add broadcast groups
Landed intact, and no defects found. #1697 is still open, and the WebSocket and UDP
SendManyfast paths are not implemented yet.#2212 feat(gameserver): add bounded match mailbox
The code and tests landed, but the "Match mailbox and one-writer state" section was dropped from
gameserver.md(en and zh). It is restored, together with the "Live inspection and pprof" section that the same merges dropped.Issues closed without meeting their acceptance
TestEveryPackageHasExamplesover every library package, only a fixed list.BackendClient, no transactional store, no outbox, no retry, no example. Only an in-memory boundary exists.MinCountwait timer.Signalruns on the caller's goroutine rather than the match goroutine, and there is no deadline beyond a pre-check of ctx.Terminateis not wired to drain, and the issue's tests (signal ordering versus ticks, terminate before stop on drain, label search) are missing.Rooms.Snapshotis not routed throughCall.Verification
go tool nsgo test ./pkg/online/gameserver/... ./pkg/online/economy/... ./pkg/online/eos/... ./internal/repocheck/...on the remote build host: pass. New tests cover claim versus concurrent joins, a claim refused by the handler, Signal versus SetHandler, a stale record version and a changed payload in results, negative scores, pairwise query refusal, Should reordering, negative and overflowing wallet amounts, key reuse, and Exchange replay.go tool nsgo check ./pkg/online/...: pass.bun run verify-notes,go run ./changelog check(tools module): pass.Screenshots: None