Repository navigation
Sync: opt-in store_orders stream for refining store purchases - #403
Open
blevouschurverantunt wants to merge 3 commits into
Open
blevouschurverantunt wants to merge 3 commits into
blevouschurverantunt wants to merge 3 commits into
Conversation
Several declared field types did not match what the game sends, so the values decoded wrongly or as 0. Corrected, field by field: - OfferDetails.validCount: int32 -> sint32 (zigzag) - OfferDetails.sameRemainingCount: int32 -> sint32 (zigzag) - Bundle.priority: uint32 -> fixed32 - Bundle.sortOrder: uint32 -> fixed32 - Cost.quantity: uint32 -> fixed32 - OrderItem.bundleId: uint32 -> fixed32 - OrderItem.bundleVersion: uint32 -> fixed32 - Resource.amountUlong: uint64 -> fixed64 - UserProfile.level: int32 -> fixed32 - UserProfile.levelLastAwarded: int32 -> fixed32 Visible effect: the store_offer event's valid_count and same_remaining_count were read doubled (5 available arrived as 10) and "unlimited" (-1) arrived as 1. They now carry the true values; the keys are unchanged. The fixed32/fixed64 fields previously read 0. Store offer prices fall back to Resource.amountUlong when Resource.amount is 0, so an amount carried only in amountUlong now decodes instead of reading 0. In the real store snapshots checked, every resource with amountUlong set also had an equal amount, so prices there are unchanged; faction offers were not among them. The own-profile comment in records.cc and sync.h is updated: the record's level is a fixed32 field and read 0 only because of the wrong type. The in-memory level is still what the profile stream uses. Tests decode hand-encoded wire bytes for each corrected field except OrderItem.bundleId and bundleVersion, which no generated code reads yet, and check the store_offer counts, including -1. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
New sync option `store_bundles` (default false) and event type
`store_bundle`, read from the same platform Bundles response as
`store_offers`, which is unchanged.
One event per category in a fixed list (refining_materials,
refining_ship_parts, alliance_games), carrying the whole snapshot of that
category's bundles sorted by bundle id. Each bundle has: bid, sort,
cost[{qty, res[{rid, amount}]}], req[{type, id, amount}],
dynamic[[{id, kind, qty}]], static[{id, kind, qty}], uses_left,
same_left, valid_from, valid_until and cooldown. Every key is always
present, cost and dynamic keep wire order, uses_left and same_left are
the decoded counts (-1 is unlimited), and valid_from/valid_until are
epoch seconds or null when the game sends no time or 0. No player,
account or alliance identifier is included.
The platform response is read when either store_offers or store_bundles
is enabled by any target; each processor runs only for its own option and
each target receives only the streams it enables. Unchanged snapshots are
not resent, and a response without a category keeps that category's last
record.
Docs: FEATURES.md row and the English example settings.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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>
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.
Builds on #401 (store bundles), which builds on #400 (protobuf wire-type fixes). Until those merge, the diff shows three commits; only the last one, 6978447, belongs to this PR.
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