Repository navigation
Sync: opt-in store_orders stream for refining store purchases - #403
Merged
netniV merged 1 commit intoDec 4, 2026
Merged
Conversation
Collaborator
|
This now has conflicts, and may have more once the Battlelogs PR is merged. |
blevouschurverantunt
force-pushed
the
feature/sync-store-orders
branch
from
December 3, 2026 02:34
6978447 to
9ef4d5a
Compare
New sync option `store_orders` (default false) and event type
`store_order`: one record per store order in the two refining store
categories, with the bundle, what was paid and what each chest granted.
The game delivers the result of a purchase in two forms, and both are read:
a single order (platform entity group OrderVirtualGood, one Order) and a
list of orders (OrdersVirtualGood, an Orders message), which is how a bulk
purchase arrives. Every order of a list goes through the same rules as a
single order; an order that fails them is skipped on its own and the others
are still sent. The records of one response are published together. The
Order and Orders messages are added to the generated protobuf roots.
Event: bid, at (Order.created, epoch seconds), category, tier, paid
[{rid, amount}] and chests [[{id, kind, qty}]], every key always present.
The order carries the bundle id but not the price, so the event is
resolved against the last store bundle snapshot of the session: the
category is the one listing the bundle (refining_materials or
refining_ship_parts only), the tier is the one cost entry whose quantity
equals the number of order items, and paid is that entry's resources.
Each order item gives one chest from its first customized content set.
An order is only sent when it has an id, a creation time and items, all
items share one non-zero bundle id, the bundle is listed in a refining
category, exactly one price matches the item count and it has resources;
the reason for a skip is logged at debug level without any id. A payload
that cannot be parsed sends nothing.
The order id only keys the record; it is not part of the event or of any
log line. An order is not sent again while it is among the 300 most recent
orders kept, whether it arrived alone or in a list: orders are a journal
(delivered one per request, acknowledged per record, and never removed by
a later response), so an order pruned from it would be sent again if the
game repeated its response. The platform response is read when any of
store_offers, store_bundles or store_orders is enabled, store bundles are
processed when either of the last two is, and each target receives only the
streams it enables.
Docs: a record carries no order id, so a retried record is identical and bid and
at together recognise it; only the 300 most recent orders are kept per
session, undelivered ones are dropped when a new session starts, and an
order is only recorded when the store bundles were received in the same
session.
Tests: single orders and their skip rules; a list of three orders of
different bundles and tiers; a list of 60 orders; the same order as a
single result and inside a list; a list mixing refining, unknown,
non-refining, mixed-bundle and incomplete orders; empty and unparseable
lists; the option off; and the wire types of Orders (repeated field 1) and
OrderItem.bundleId and bundleVersion (fixed32).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
blevouschurverantunt
force-pushed
the
feature/sync-store-orders
branch
from
December 4, 2026 00:30
9ef4d5a to
1d3260c
Compare
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.
Rebased onto
devnow that #401 (store bundles) has merged; this PR is a single commit.What changed and why
Adds an opt-in sync option,
store_orders, that sends onestore_orderrecord for each purchase order in the refining store categories. It is off by default, and only targets that enable it receive the records.The game delivers the result of a purchase in two forms, and both are read:
OrderVirtualGood, oneOrder;OrdersVirtualGood, anOrdersmessage (repeated Orderat field 1). A bulk purchase (a bulk refine) arrives this way: one response holds one order per bundle bought, each with its own order id and items of a single bundle id.Every order of a list goes through exactly the same rules as a single order. An order that fails a rule is skipped on its own; the other orders of the list are still sent. The records of one response are published together. A payload that cannot be parsed sends nothing. The
OrderandOrdersmessages are added tozig/deps/protobuf_roots.txt.Lists of other, non-refining purchases (for example several orders of other bundles in one response) produce nothing, because their bundles are not in a refining category.
Record shape, with invented values:
{"type":"store_order","bid":30,"at":1700000100,"category":"refining_materials","tier":1, "paid":[{"rid":4000000000,"amount":2000}], "chests":[[{"id":21,"kind":"resource","qty":100},{"id":22,"kind":"resource","qty":5}], [{"id":21,"kind":"resource","qty":101},{"id":22,"kind":"resource","qty":5}]]}bid: the bundle id.at:Order.created, epoch seconds.category:refining_materialsorrefining_ship_parts.tier: the zero-based index of the price entry that was paid, in the order of the bundle'scostlist.paid: that price entry's resources,{rid, amount}.chests: one list per order item, each the contents of that item's first customized content set as{id, kind, qty}. An item with no customized content gives[].How the price is found: the order names the bundle but not the price, so the mod resolves it against the last
store_bundlesnapshot of the session. The category is the one that lists the bundle. The price is the onecostentry whoseqtyequals the number of order items. An order is sent only if all of these hold; otherwise the reason is logged at debug level without any id:refining_materialsorrefining_ship_parts; anything else, such asalliance_games, is never sent);The order id only keys the record. An order is not sent again while it is among the 300 most recent orders kept, whether it arrived alone or inside a list. Orders are a journal (delivered one per request, acknowledged per record, never removed by a later response), so an order pruned from it would be sent again if the game repeated its response.
The platform response is read when any of
store_offers,store_bundlesorstore_ordersis on. Store bundles are processed whenstore_bundlesorstore_ordersis on, because orders resolve against them. A target still receives only the streams it enables.Files:
src/mod/config.h,src/mod/sync/{records.cc,state.cc,sync.cc,sync.h},zig/deps/protobuf_roots.txt,tests/sync_logic.cc, a row indocs/FEATURES.mdand the English settings example.Validation
zig build fmt,zig build mods build-tests -Dtarget=x86_64-windows-msvc,zig build test-sync test-mod test-codegen -Dtarget=x86_64-windows-msvc, the fullReleaseFastDLL build, andgit diff --check.tests/sync_logic.cc,store orders(single orders):alliance_gamesbundle and an unknown bundle send nothing;store_ordersreceives orders but not bundles.tests/sync_logic.cc,store order lists:at, and no order id in any record; the identical list again sends nothing;store_ordersreceives no orders.wire typestest gains two cases: hand-encoded bytes forOrderItem.bundleIdandbundleVersiondecode asfixed32, and anOrdersmessage holds repeated orders at field 1.Draintest helper now collects every record of an upload instead of only the last upload of a type.ReleaseFast), against a private sync endpoint:OrdersVirtualGoodlist of three orders, 4 items each. It produced threestore_orderrecords, one per bundle: categoryrefining_materials, tier index 2 of quantities 2/3/4, onepaidline, 4 chests, the sameat.refining_ship_parts, tier index 2 of quantities 1/2/3 (four orders) and 2/3/4 (one order), the sameat.OrderVirtualGood, each produced one correct record.Settings and platforms
store_orders, off by default, under[sync]and per target. Nothing is sent unless a target opts in.bidandattogether recognise it. This is documented indocs/FEATURES.md.🤖 Generated with Claude Code