runtime.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. #pragma once
  2. #include <array>
  3. #include <cstddef>
  4. #include <cstdint>
  5. #include <optional>
  6. #include <span>
  7. #include <string_view>
  8. #include "../investment/investment.h"
  9. #include "abilities/definition.h"
  10. #include "bounties/definition.h"
  11. #include "collectibles/collectible_catalog.h"
  12. #include "constants/definition.h"
  13. #include "definition.h"
  14. #include "hash_names/definition.h"
  15. #include "inventory/buckets/definition.h"
  16. #include "items/catalysts/definition.h"
  17. #include "items/details/definition.h"
  18. #include "items/item_catalog.h"
  19. #include "items/socket_plugs/definition.h"
  20. #include "material_requirements/material_requirement_catalog.h"
  21. #include "nodes/definition.h"
  22. #include "progressions/definition.h"
  23. #include "records/definition.h"
  24. #include "rewards/definition.h"
  25. #include "scenarios/definition.h"
  26. #include "season_pass/definition.h"
  27. #include "sobjects/sobject_catalog.h"
  28. #include "socket_entry_buckets/definition.h"
  29. #include "socket_entry_lists/definition.h"
  30. #include "spawn_sets/definition.h"
  31. #include "starter_sets/definition.h"
  32. #include "vendors/definition.h"
  33. namespace sunrise::state::build_data::items::catalysts {
  34. struct Source;
  35. }
  36. namespace sunrise::state::build_data {
  37. /** Marks regenerated package data for the next complete shared-cache publication. */
  38. void invalidate_cache() noexcept;
  39. /**
  40. * Names the package content the mappings come from, so a changed mod set rebuilds the cache.
  41. * Call before initialize; zero stands for a host with no content manifest.
  42. * @param contentHash Leading bytes of the combined installed and mod fingerprint.
  43. */
  44. void bind_content(std::uint64_t contentHash) noexcept;
  45. /**
  46. * Loads the one build-data cache next to the module, when there is one.
  47. * Once a snapshot is on disk, later replacements are refused until State restarts. A failed first
  48. * commit withdraws that publication and restores nothing. Keep readers out until this returns.
  49. * @param module Loaded Sunrise DLL module, or null to turn off disk saving.
  50. * @param configuredEquipmentHash Hash of the authored equipment. Not a secret.
  51. * @return True when a valid cache loads or extraction can safely rebuild it.
  52. */
  53. [[nodiscard]] bool initialize(void* module, std::uint64_t configuredEquipmentHash) noexcept;
  54. /** Clears all cached build mappings and persistence paths. */
  55. void shutdown() noexcept;
  56. /** @return True when named package mappings are complete in State. */
  57. [[nodiscard]] bool named_catalog_ready() noexcept;
  58. /**
  59. * Marks the already-filled named catalog complete, and saves once all data is ready.
  60. * Call only while named readiness is false. A failed first commit withdraws the target and does
  61. * not restore an earlier ready catalog.
  62. * @return True when the catalog is nonempty and any needed cache write succeeds.
  63. */
  64. [[nodiscard]] bool publish_named_catalog() noexcept;
  65. /** @return True when the whole item definition table is in State. */
  66. [[nodiscard]] bool item_definitions_ready() noexcept;
  67. /** @return Dense item-definition row count, read under the lock. */
  68. [[nodiscard]] std::size_t item_definition_count() noexcept;
  69. /**
  70. * Publishes the whole installed-build item definition table in one step.
  71. * Call only while item readiness is false. A failed first commit withdraws the target and does
  72. * not restore an earlier ready table.
  73. * @param definitions Dense native-index mappings extracted from the running client.
  74. * @return True when the mappings pass the checks and any needed cache write succeeds.
  75. */
  76. [[nodiscard]] bool
  77. publish_item_definitions(std::span<const items::Definition> definitions) noexcept;
  78. /**
  79. * Finds one authored item hash inside its expected inventory bucket.
  80. * @param definitionHash Authored item definition hash.
  81. * @param bucketId Expected inventory bucket id.
  82. * @param definition Receives the one matching native definition.
  83. * @return True when the item data is ready and exactly one mapping matches.
  84. */
  85. [[nodiscard]] bool find_item_definition(std::uint32_t definitionHash,
  86. std::uint8_t bucketId,
  87. items::Definition& definition) noexcept;
  88. /**
  89. * Finds an authored base-item or plug hash without storing a native index in settings.
  90. * @param definitionHash Authored item or plug definition hash.
  91. * @param definition Receives the one matching installed-build mapping.
  92. * @return True when the item data is ready and exactly one native row matches.
  93. */
  94. [[nodiscard]] bool find_item_definition_hash(std::uint32_t definitionHash,
  95. items::Definition& definition) noexcept;
  96. /**
  97. * Finds one installed item by the native dense definition index used by Collections requests.
  98. * @param definitionIndex Native item-definition row index.
  99. * @param definition Receives the exact installed mapping.
  100. * @return True when the complete table is ready and contains the requested row.
  101. */
  102. [[nodiscard]] bool find_item_definition_index(std::uint16_t definitionIndex,
  103. items::Definition& definition) noexcept;
  104. /**
  105. * Reads the items one record grants when it is claimed.
  106. * @param definitionIndex Native record row.
  107. * @param rewards Receives the granted items; a record granting none leaves the count at zero.
  108. * @param rewardCount Receives the granted item count.
  109. * @return True when the record exists and its whole reward range read back.
  110. */
  111. [[nodiscard]] bool
  112. find_record_rewards(std::uint16_t definitionIndex,
  113. std::array<records::Reward, records::kRewardPerRecordCapacity>& rewards,
  114. std::size_t& rewardCount) noexcept;
  115. /** @return True when the whole dense collectible definition table is in State. */
  116. [[nodiscard]] bool collectible_definitions_ready() noexcept;
  117. /**
  118. * Publishes the installed collectible ordinal-to-item table in one step.
  119. * @param definitions Complete dense rows extracted from the investment root's collectible table.
  120. * @return True when the rows pass the checks and any needed cache write succeeds.
  121. */
  122. [[nodiscard]] bool
  123. publish_collectible_definitions(std::span<const collectibles::Definition> definitions) noexcept;
  124. /**
  125. * Resolves the native 15-bit collectible index carried by a Collections acquire request.
  126. * @param collectibleIndex Native collectible row ordinal.
  127. * @param itemDefinitionIndex Receives the installed item-definition row, or the unavailable
  128. * sentinel on failure.
  129. * @return True when both the complete table and an item link exist for this collectible.
  130. */
  131. [[nodiscard]] bool
  132. find_collectible_item_definition_index(std::uint16_t collectibleIndex,
  133. std::uint16_t& itemDefinitionIndex) noexcept;
  134. /** Finds one complete installed collectible row, including its acquisition material set. */
  135. [[nodiscard]] bool find_collectible_definition(std::uint16_t collectibleIndex,
  136. collectibles::Definition& definition) noexcept;
  137. /** @return True when every installed material-requirement set is available by native ordinal. */
  138. [[nodiscard]] bool material_requirement_sets_ready() noexcept;
  139. /** Publishes the complete dense native material-requirement table. */
  140. [[nodiscard]] bool publish_material_requirement_sets(
  141. std::span<const material_requirements::Definition> definitions) noexcept;
  142. /** Resolves one authored material-requirement set without embedding any prices in code. */
  143. [[nodiscard]] bool
  144. find_material_requirement_set(std::uint16_t requirementSetIndex,
  145. material_requirements::Definition& definition) noexcept;
  146. /** @return True when a complete configured-detail domain, empty or not, is published. */
  147. [[nodiscard]] bool configured_item_details_ready() noexcept;
  148. /**
  149. * Publishes configured item details. An empty domain is a complete one.
  150. * Call only while detail readiness is false. A failed first commit withdraws the target and does
  151. * not restore an earlier ready domain.
  152. * @param definitions Complete installed-build details for configured authored items.
  153. * @return True when the links pass the checks and any needed cache write succeeds.
  154. */
  155. [[nodiscard]] bool
  156. publish_configured_item_details(std::span<const items::details::Definition> definitions) noexcept;
  157. /**
  158. * Finds one configured item detail by native definition index.
  159. * @param definitionIndex Native installed-build item index.
  160. * @param definition Receives the matching configured detail.
  161. * @return True when the detail data is ready and holds that row.
  162. */
  163. [[nodiscard]] bool find_configured_item_detail(std::uint16_t definitionIndex,
  164. items::details::Definition& definition) noexcept;
  165. /** @return True when the exact installed ordinary-socket plug relation is in State. */
  166. [[nodiscard]] bool socket_plug_rules_ready() noexcept;
  167. /**
  168. * Publishes exact per-item, per-lane plug pools extracted from the installed packages.
  169. * @param rules Strictly item/lane-ordered rules.
  170. * @param pools Deduplicated contiguous pool ranges, beginning with the empty pool.
  171. * @param members Flat sorted plug-definition indices.
  172. * @return True when the relation and its item/detail links validate and any cache write succeeds.
  173. */
  174. [[nodiscard]] bool
  175. publish_socket_plug_rules(std::span<const items::socket_plugs::Rule> rules,
  176. std::span<const items::socket_plugs::Pool> pools,
  177. std::span<const items::socket_plugs::Member> members) noexcept;
  178. /**
  179. * Answers whether one installed plug definition is valid for one exact ordinary socket lane.
  180. * Missing or malformed relations fail closed.
  181. */
  182. [[nodiscard]] bool is_socket_plug_allowed(std::uint16_t itemDefinitionIndex,
  183. std::uint8_t lane,
  184. std::uint16_t plugDefinitionIndex) noexcept;
  185. /**
  186. * Walks every plug one exact ordinary socket lane accepts. Missing relations fail closed.
  187. * @return True when the lane has a pool and the visitor saw every member.
  188. */
  189. [[nodiscard]] bool visit_socket_plug_pool(std::uint16_t itemDefinitionIndex,
  190. std::uint8_t lane,
  191. items::socket_plugs::MemberVisitor visitor,
  192. void* context) noexcept;
  193. /** @return True when one plug definition occurs in any installed ordinary-socket plug pool. */
  194. [[nodiscard]] bool is_socket_plug_pooled(std::uint16_t plugDefinitionIndex) noexcept;
  195. /** @return True when the build-scoped exotic catalyst catalog is ready. */
  196. [[nodiscard]] bool exotic_catalysts_ready() noexcept;
  197. /**
  198. * Derives released and placeholder catalysts from one complete package pass.
  199. * The active PE identity supplies the build fingerprint.
  200. * @param source Complete installed item, detail, and socket-pool domains.
  201. * @param output Fixed storage that receives the catalyst catalog.
  202. * @param count Receives the used output row count.
  203. * @param report Receives catalog counts and the first unsafe released relation.
  204. * @return True when the complete catalog is safe for publication.
  205. */
  206. [[nodiscard]] bool derive_exotic_catalysts(const items::catalysts::Source& source,
  207. std::span<items::catalysts::Definition> output,
  208. std::size_t& count,
  209. items::catalysts::Report& report) noexcept;
  210. /**
  211. * @param source Complete installed item, detail, and socket-pool domains.
  212. * @param definitions Complete build-derived catalyst catalog.
  213. * @return True when validation, publication, and any due cache write succeed.
  214. */
  215. [[nodiscard]] bool
  216. publish_exotic_catalysts(const items::catalysts::Source& source,
  217. std::span<const items::catalysts::Definition> definitions) noexcept;
  218. /**
  219. * @param itemDefinitionIndex Native item definition index.
  220. * @param flags Candidate accumulated item-state bits.
  221. * @param plugs Candidate ordinary socket plugs.
  222. * @return Completed, unchanged, or failed without a partial change.
  223. */
  224. [[nodiscard]] items::catalysts::ApplyResult
  225. complete_exotic_catalyst(std::uint16_t itemDefinitionIndex,
  226. std::uint32_t& flags,
  227. std::span<std::optional<std::uint16_t>> plugs) noexcept;
  228. /**
  229. * Adds the released catalyst acquisition gates, the completion flags without an account mapping,
  230. * and the completion values to one Family-5 snapshot.
  231. * @param family Candidate Family-5 state.
  232. * @return True when all overrides fit and the complete state commits.
  233. */
  234. [[nodiscard]] bool complete_exotic_catalyst_investment(Family5State& family) noexcept;
  235. /**
  236. * Raises every account objective required by a released legacy catalyst.
  237. * @param values Candidate account objective bank.
  238. * @return True when all derived objectives fit and apply.
  239. */
  240. [[nodiscard]] bool complete_exotic_catalyst_objectives(std::span<std::int32_t> values) noexcept;
  241. /**
  242. * Raises the account acquired flags that the package maps released catalyst completions to.
  243. * @param flags Candidate account acquired-flag bank.
  244. * @return True when completion is disabled or every mapped flag is inside the bank.
  245. */
  246. [[nodiscard]] bool complete_exotic_catalyst_flags(std::span<std::uint8_t> flags) noexcept;
  247. /**
  248. * Resolves the item row that supplies one socketed catalyst's native perks and stat changes.
  249. * @param itemDefinitionIndex Native weapon definition index.
  250. * @param socketLane Ordinary socket lane.
  251. * @param plugDefinitionIndex Socketed plug definition index.
  252. * @return Effective definition index, or the input plug when no released completion matches.
  253. */
  254. [[nodiscard]] std::uint16_t
  255. resolve_exotic_catalyst_effect(std::uint16_t itemDefinitionIndex,
  256. std::uint8_t socketLane,
  257. std::uint16_t plugDefinitionIndex) noexcept;
  258. /**
  259. * @param itemDefinitionIndex Native item definition index.
  260. * @param socketLane Ordinary socket lane.
  261. * @return True when the catalog owns this catalyst socket lane.
  262. */
  263. [[nodiscard]] bool is_exotic_catalyst_lane(std::uint16_t itemDefinitionIndex,
  264. std::uint8_t socketLane) noexcept;
  265. /** @param enabled True to complete released catalysts during item resolution. */
  266. void set_exotic_catalyst_completion_enabled(bool enabled) noexcept;
  267. /**
  268. * Answers whether one profile definition needs an item-instance resident so the native socket
  269. * action route can materialize it. Only stackable installed socket plugs in the supported mod and
  270. * shader profile buckets qualify; currency/material/intrinsic rows do not.
  271. */
  272. [[nodiscard]] bool is_profile_action_source(std::uint16_t itemDefinitionIndex,
  273. std::uint8_t bucketId) noexcept;
  274. /**
  275. * Answers whether applying one plug spends a stack the account has to hold.
  276. * @param itemDefinitionIndex Installed plug-definition row.
  277. * @param bucketId Installed profile bucket the plug belongs to.
  278. * @return True only for a shader Collections can grant. An ornament stays owned once applied,
  279. * and a socket's default plug belongs to no stack at all.
  280. */
  281. [[nodiscard]] bool is_consumed_on_apply(std::uint16_t itemDefinitionIndex,
  282. std::uint8_t bucketId) noexcept;
  283. /** @return True when the whole incident-target table is in State. */
  284. [[nodiscard]] bool sobject_definitions_ready() noexcept;
  285. /**
  286. * Publishes the whole incident-target table in one step.
  287. * @param definitions Complete rows in wire-target order.
  288. * @return True when the rows pass the domain checks and fit fixed State storage.
  289. */
  290. [[nodiscard]] bool
  291. publish_sobject_definitions(std::span<const sobjects::Definition> definitions) noexcept;
  292. /** @return True when the whole presentation node table is in State. */
  293. [[nodiscard]] bool node_definitions_ready() noexcept;
  294. /**
  295. * Publishes the whole presentation node table in one step.
  296. * @param definitions Complete dense rows in native node order.
  297. * @return True when the rows pass the domain checks and fit fixed State storage.
  298. */
  299. [[nodiscard]] bool
  300. publish_node_definitions(std::span<const nodes::Definition> definitions) noexcept;
  301. /** @return True when the whole record definition table is in State. */
  302. [[nodiscard]] bool record_definitions_ready() noexcept;
  303. /**
  304. * Publishes the whole record catalog in one step.
  305. * @param definitions Complete dense rows in native record order.
  306. * @param objectives Complete flat objective bank in record then row order.
  307. * @param intervals Complete flat interval bank in record then step order.
  308. * @param rewards Complete flat reward bank in record then row order.
  309. * @return True when the rows pass the domain checks and fit fixed State storage.
  310. */
  311. [[nodiscard]] bool publish_record_definitions(std::span<const records::Definition> definitions,
  312. std::span<const records::Objective> objectives,
  313. std::span<const records::Interval> intervals,
  314. std::span<const records::Reward> rewards) noexcept;
  315. /**
  316. * Resolves the native record row an opcode-1801 claim names.
  317. * @param definitionIndex Native record row carried by the claim.
  318. * @param definition Receives the row, including its completion flag index, only on success.
  319. * @return True when the table is complete and the row exists.
  320. */
  321. [[nodiscard]] bool find_record_definition(std::uint16_t definitionIndex,
  322. records::Definition& definition) noexcept;
  323. /** @return True when the whole progression definition table is in State. */
  324. [[nodiscard]] bool progression_definitions_ready() noexcept;
  325. /**
  326. * Publishes the whole progression definition table and its step bank in one step.
  327. * @param definitions Dense rows in native definition order.
  328. * @param steps Complete flat step bank in definition then rank order.
  329. * @return True when the rows pass the checks and any needed cache write succeeds.
  330. */
  331. [[nodiscard]] bool
  332. publish_progression_definitions(std::span<const progressions::Definition> definitions,
  333. std::span<const progressions::Step> steps) noexcept;
  334. /**
  335. * Reads what each rank of one progression costs, in rank order.
  336. * @param definitionIndex Native progression definition index.
  337. * @param output Caller-owned fixed row storage.
  338. * @param count Receives the copied row count.
  339. * @return True when the table is ready and the whole ladder fits.
  340. */
  341. [[nodiscard]] bool find_progression_steps(std::uint16_t definitionIndex,
  342. std::span<progressions::Step> output,
  343. std::size_t& count) noexcept;
  344. /** @return True when the season pass reward list is in State. */
  345. [[nodiscard]] bool season_pass_ready() noexcept;
  346. /**
  347. * Publishes the season pass reward list with its fixed socket overrides.
  348. * @param rewards Complete reward rows in native reward order.
  349. * @return True when the rows pass the checks and any needed cache write succeeds.
  350. */
  351. [[nodiscard]] bool publish_season_pass(std::span<const season_pass::Reward> rewards) noexcept;
  352. /** Checks rows against the rules publish_season_pass applies to the whole list. */
  353. [[nodiscard]] bool valid_season_pass_rewards(std::span<const season_pass::Reward> rewards) noexcept;
  354. /**
  355. * Reads one season pass reward row.
  356. * @param rewardIndex Native reward-array index the opcode-2400 claim names.
  357. * @param reward Receives the row.
  358. * @return True when the catalog is ready and holds that row.
  359. */
  360. [[nodiscard]] bool find_season_pass_reward(std::uint16_t rewardIndex,
  361. season_pass::Reward& reward) noexcept;
  362. /** @return Season pass reward rows in State, including unavailable rows. */
  363. [[nodiscard]] std::size_t season_pass_reward_count() noexcept;
  364. /** @return True when the reward pools and item wrappers are in State. */
  365. [[nodiscard]] bool reward_definitions_ready() noexcept;
  366. /**
  367. * Publishes the complete reward graph in one step.
  368. * @param definitions Pools, entries, item rows, conditions, modifiers and socket overrides.
  369. * @return True when the graph passes the checks and any needed cache write succeeds.
  370. */
  371. [[nodiscard]] bool publish_reward_definitions(rewards::View definitions) noexcept;
  372. /** Checks a reward graph against the rules publish_reward_definitions applies. */
  373. [[nodiscard]] bool valid_reward_definitions(rewards::View definitions) noexcept;
  374. /**
  375. * Reads one item's reward row.
  376. * @param itemIndex Native item-definition index.
  377. * @param item Receives the row.
  378. * @return True when the catalog holds an extracted row for that item.
  379. */
  380. [[nodiscard]] bool find_reward_item(std::uint16_t itemIndex, rewards::Item& item) noexcept;
  381. /**
  382. * Lends the complete reward graph to one callback under the catalog's read lock.
  383. * @param context Caller state passed through unchanged.
  384. * @param consume Receives the graph, which stays valid only during the call.
  385. * @return The callback's result, or false when no graph is published.
  386. */
  387. [[nodiscard]] bool read_reward_definitions(void* context,
  388. bool (*consume)(void*, rewards::View) noexcept) noexcept;
  389. /** @return True when the repeatable bounty table is in State. */
  390. [[nodiscard]] bool repeatable_bounties_ready() noexcept;
  391. /**
  392. * Publishes every repeatable bounty and the item-type its pool is keyed by.
  393. * @param definitions Complete rows in ascending item-index order.
  394. * @return True when the rows pass the checks and any needed cache write succeeds.
  395. */
  396. [[nodiscard]] bool
  397. publish_repeatable_bounties(std::span<const bounties::Definition> definitions) noexcept;
  398. /**
  399. * Lists the item indices one repeatable vendor category rolls from.
  400. * @param itemType Item-type pair the pool is keyed by.
  401. * @param output Caller-owned fixed item-index storage.
  402. * @param count Receives the pool size.
  403. * @return True when the table is ready and the whole pool fits.
  404. */
  405. [[nodiscard]] bool repeatable_bounty_pool(const bounties::ItemType& itemType,
  406. std::span<std::uint16_t> output,
  407. std::size_t& count) noexcept;
  408. /** Sale rows the seasonal artifact offers. The shipped artifact declares 26. */
  409. inline constexpr std::size_t kArtifactSaleRowCapacity = 32;
  410. /** One artifact sale row and the unlock buying it sets. */
  411. struct ArtifactSaleRow {
  412. std::uint32_t itemHash{};
  413. std::uint16_t itemIndex{};
  414. /** Vendor category, which is the mod column the row sits in. */
  415. std::int32_t categoryIndex{};
  416. /** Global unlock flag slot the purchase sets, or the unavailable slot for the reset row. */
  417. std::uint16_t unlockFlagSlot{collectibles::kUnavailableFlagSlot};
  418. /** Character flag bank row that slot feeds, or the unavailable row for the reset row. */
  419. std::uint16_t characterFlagIndex{collectibles::kUnavailableFlagIndex};
  420. };
  421. /**
  422. * Lists the artifact's sale rows in vendor row order, with the unlock each one buys.
  423. * @param output Caller-owned fixed row storage.
  424. * @param count Receives the row count.
  425. * @return True when the vendor and collectible catalogs are ready and every row resolves.
  426. */
  427. [[nodiscard]] bool artifact_sale_rows(std::span<ArtifactSaleRow> output,
  428. std::size_t& count) noexcept;
  429. /**
  430. * Lists the definition index each slot of one scope's progression array carries.
  431. * @param scope Replicated object owning the array.
  432. * @param output Slot storage, one entry per slot the array holds.
  433. * @param count Receives the number of keyed slots.
  434. * @return True when the table is ready and every keyed slot fits.
  435. */
  436. [[nodiscard]] bool find_progression_slots(progressions::Scope scope,
  437. std::span<std::uint16_t> output,
  438. std::size_t& count) noexcept;
  439. /** @return True when a complete ability bucket domain, empty or not, is published. */
  440. [[nodiscard]] bool ability_buckets_ready() noexcept;
  441. /**
  442. * Publishes the ability buckets every configured subclass and ability selection publishes.
  443. * @param definitions Complete rows, or an empty complete domain.
  444. * @return True when the rows pass the checks and any needed cache write succeeds.
  445. */
  446. [[nodiscard]] bool
  447. publish_ability_buckets(std::span<const abilities::Definition> definitions) noexcept;
  448. /**
  449. * Finds the buckets one subclass publishes under one ability selection.
  450. * @param socketEntryListIndex Native socket-entry-list index of the subclass.
  451. * @param selection The character's 5 selected socket entries.
  452. * @param definition Receives the matching row.
  453. * @return True when the domain is ready and holds that exact key.
  454. */
  455. [[nodiscard]] bool find_ability_buckets(std::uint16_t socketEntryListIndex,
  456. const abilities::Selection& selection,
  457. abilities::Definition& definition) noexcept;
  458. /**
  459. * Drops the published ability bucket domain so the next investment refresh slice rebuilds it.
  460. * A committed subclass ability-entry change makes the published rows stale for their character,
  461. * since they were keyed by the selection in place when the domain was first built.
  462. */
  463. void invalidate_ability_buckets() noexcept;
  464. /**
  465. * @return True when at least one socket-entry list's resolved bucket destinations are published.
  466. * Never part of the on-disk content cache: it is small and cheap to recompute, so a warm boot that
  467. * skips re-extraction must not leave it empty for the whole session.
  468. */
  469. [[nodiscard]] bool socket_entry_buckets_ready() noexcept;
  470. /**
  471. * Publishes every socket-entry list's resolved per-entry ability-bucket destinations.
  472. * A derived cache of static content, so unlike the ability buckets above it never needs
  473. * invalidating: a subclass's entry table does not change after content extraction.
  474. * @param definitions Complete rows, one per socket-entry list that carries a super lane.
  475. * @return True when the rows pass the checks.
  476. */
  477. [[nodiscard]] bool publish_socket_entry_buckets(
  478. std::span<const socket_entry_buckets::Definition> definitions) noexcept;
  479. /**
  480. * Finds which of the 12 semantic ability buckets one socket entry resolves to.
  481. * @param socketEntryListIndex Native socket-entry-list index of the subclass.
  482. * @param entryIndex The entry to look up.
  483. * @param bucket Receives the resolved destination, or the no-destination sentinel.
  484. * @return True when the list's row is published and the entry index is in range.
  485. */
  486. [[nodiscard]] bool find_socket_entry_bucket(std::uint16_t socketEntryListIndex,
  487. std::uint8_t entryIndex,
  488. std::uint8_t& bucket) noexcept;
  489. /** @return True when the installed investment constants are in State. */
  490. [[nodiscard]] bool investment_constants_ready() noexcept;
  491. /**
  492. * Publishes the stat rows read from the installed investment constants blob.
  493. * @param value Constants extracted from the blob.
  494. * @return True when the row is extracted and any needed cache write succeeds.
  495. */
  496. [[nodiscard]] bool
  497. publish_investment_constants(const constants::InvestmentConstants& value) noexcept;
  498. /**
  499. * Reads the published investment constants.
  500. * @param value Receives the published stat rows.
  501. * @return True when the constants are in State.
  502. */
  503. [[nodiscard]] bool find_investment_constants(constants::InvestmentConstants& value) noexcept;
  504. /** @return True once the new-character table, empty or not, is in State. */
  505. [[nodiscard]] bool starter_sets_ready() noexcept;
  506. /**
  507. * Publishes the new-character table. It is read every boot and never joins the disk cache.
  508. * @param definitions One row per class; empty when the installed table did not read.
  509. * @return True when every row names a distinct playable class and fits its storage.
  510. */
  511. [[nodiscard]] bool
  512. publish_starter_sets(std::span<const starter_sets::Definition> definitions) noexcept;
  513. /**
  514. * Finds the items the packages give a new character of one class.
  515. * @param characterClass Class byte: 0 Titan, 1 Hunter, 2 Warlock.
  516. * @param definition Receives the class row.
  517. * @return True when the published table holds that class.
  518. */
  519. [[nodiscard]] bool find_starter_set(std::uint8_t characterClass,
  520. starter_sets::Definition& definition) noexcept;
  521. /** @return True when the whole inventory-bucket descriptor table is in State. */
  522. [[nodiscard]] bool inventory_bucket_descriptors_ready() noexcept;
  523. /**
  524. * Publishes the whole inventory-bucket routing table in one step.
  525. * Call only while bucket readiness is false. A failed first commit withdraws the target and does
  526. * not restore an earlier ready table.
  527. * @param descriptors Installed-build bucket descriptors.
  528. * @return True when the descriptors pass the checks and any needed cache write succeeds.
  529. */
  530. [[nodiscard]] bool publish_inventory_bucket_descriptors(
  531. std::span<const inventory::buckets::Descriptor> descriptors) noexcept;
  532. /**
  533. * Finds one inventory-bucket descriptor by native bucket id.
  534. * @param bucketId Native inventory-bucket id.
  535. * @param descriptor Receives the matching routing descriptor.
  536. * @return True when the bucket data is ready and holds that row.
  537. */
  538. [[nodiscard]] bool
  539. find_inventory_bucket_descriptor(std::uint8_t bucketId,
  540. inventory::buckets::Descriptor& descriptor) noexcept;
  541. /** @return True when the whole dense socket-entry-list table is in State. */
  542. [[nodiscard]] bool socket_entry_lists_ready() noexcept;
  543. /** @return Dense socket-entry-list row count, read under the lock. */
  544. [[nodiscard]] std::size_t socket_entry_list_count() noexcept;
  545. /**
  546. * Publishes the whole dense socket-entry-list table in one step.
  547. * Call only while socket-list readiness is false. A failed first commit withdraws the target and
  548. * does not restore an earlier ready table.
  549. * @param definitions Installed-build socket-entry-list definitions.
  550. * @param entryTables Per-entry inputs for the lists that carry a super lane.
  551. * @return True when the rows pass the checks and any needed cache write succeeds.
  552. */
  553. [[nodiscard]] bool
  554. publish_socket_entry_lists(std::span<const socket_entry_lists::Definition> definitions,
  555. std::span<const socket_entry_lists::EntryTable> entryTables) noexcept;
  556. /**
  557. * Finds one list's per-entry selection inputs.
  558. * @param definitionIndex Native socket-entry-list index.
  559. * @param table Receives the matching row.
  560. * @return True when a table is kept for that list.
  561. */
  562. [[nodiscard]] bool find_socket_entry_table(std::uint16_t definitionIndex,
  563. socket_entry_lists::EntryTable& table) noexcept;
  564. /**
  565. * Finds one socket-entry-list definition by native definition index.
  566. * @param definitionIndex Native socket-entry-list index.
  567. * @param definition Receives the matching installed-build row.
  568. * @return True when the socket-list data is ready and holds that row.
  569. */
  570. [[nodiscard]] bool find_socket_entry_list(std::uint16_t definitionIndex,
  571. socket_entry_lists::Definition& definition) noexcept;
  572. /** Number of subclass items every character class ships in this build. */
  573. inline constexpr std::size_t kSubclassGroupSize = 3;
  574. /**
  575. * Finds the 2 other subclasses that share one character class with a known member.
  576. * The installed manifest lists every subclass item as one dense run per class, in native
  577. * definition-index order, so the run holding a known member gives every other member.
  578. * @param memberDefinitionIndex Native item-definition index of one subclass in the class.
  579. * @param group Receives the 3 member indices, in native definition-index order.
  580. * @return True when every subclass item was found and `memberDefinitionIndex` is one of them.
  581. */
  582. [[nodiscard]] bool
  583. find_subclass_group(std::uint16_t memberDefinitionIndex,
  584. std::array<std::uint16_t, kSubclassGroupSize>& group) noexcept;
  585. /** @return True when a complete destination-layout domain, empty or not, is published. */
  586. [[nodiscard]] bool scenario_layouts_ready() noexcept;
  587. /**
  588. * Publishes the extracted destination layouts and their roster groups in one step.
  589. * @param definitions Complete rows swept from the installed packages.
  590. * @param groups Complete roster groups the same sweep reached.
  591. * @return True when the rows pass the checks and any needed cache write succeeds.
  592. */
  593. [[nodiscard]] bool
  594. publish_scenario_layouts(std::span<const scenarios::Definition> definitions,
  595. std::span<const scenarios::RosterGroup> groups) noexcept;
  596. /**
  597. * Copies one roster group by the table index a destination row carries.
  598. * @param index Roster table index.
  599. * @param group Receives the group.
  600. * @return True when the domain is ready and the index is inside its table.
  601. */
  602. [[nodiscard]] bool find_roster_group(std::size_t index, scenarios::RosterGroup& group) noexcept;
  603. /** @return Number of published destination layouts, read under the lock. */
  604. [[nodiscard]] std::size_t scenario_layout_count() noexcept;
  605. /**
  606. * Copies every published destination layout.
  607. * @param output Caller-owned fixed row storage.
  608. * @param count Receives the copied row count.
  609. * @return True when the domain is ready and output can hold every row.
  610. */
  611. [[nodiscard]] bool snapshot_scenario_layouts(std::span<scenarios::Definition> output,
  612. std::size_t& count) noexcept;
  613. /** @return True when a complete bubble-name table, empty or not, is published. */
  614. [[nodiscard]] bool hash_names_ready() noexcept;
  615. /**
  616. * Publishes the resolved bubble names in one step.
  617. * @param names Complete rows in ascending hash order, or an empty complete table.
  618. * @return True when the rows pass the checks and any needed cache write succeeds.
  619. */
  620. [[nodiscard]] bool publish_hash_names(std::span<const hash_names::Name> names) noexcept;
  621. /**
  622. * Finds one bubble's internal name by its hash.
  623. * @param hash Bubble name hash from a destination layout.
  624. * @param name Receives the matching row.
  625. * @return True when the table is ready and holds that exact hash.
  626. */
  627. [[nodiscard]] bool find_hash_name(std::uint32_t hash, hash_names::Name& name) noexcept;
  628. /** @return True when a complete spawn-set catalog, empty or not, is published. */
  629. [[nodiscard]] bool spawn_sets_ready() noexcept;
  630. /**
  631. * Publishes the spawn-set catalog extracted from the installed packages, in one step.
  632. * @param stems Complete stem rows in ascending name order, or an empty complete catalog.
  633. * @param nameHashes Complete flat bank in stem then hash order.
  634. * @param points Complete point bank in extraction order, which may be empty.
  635. * @return True when the rows pass the checks and any needed cache write succeeds.
  636. */
  637. [[nodiscard]] bool publish_spawn_sets(std::span<const spawn_sets::Stem> stems,
  638. std::span<const spawn_sets::NameHash> nameHashes,
  639. std::span<const spawn_sets::Point> points) noexcept;
  640. /**
  641. * Finds the spawn point of one map-package stem nearest a world position.
  642. * @param stem Normalized stem a destination row carries.
  643. * @param position World position to measure from.
  644. * @param point Receives the nearest point and the set it belongs to.
  645. * @param distance Receives the distance to it, in world units.
  646. * @return True when the catalog is ready, holds the stem, and the stem owns a point.
  647. */
  648. [[nodiscard]] bool
  649. find_nearest_spawn_point(std::string_view stem,
  650. const std::array<float, spawn_sets::kPositionComponents>& position,
  651. spawn_sets::Point& point,
  652. float& distance) noexcept;
  653. /**
  654. * Copies the whole flat spawn-name hash bank.
  655. * @param output Caller-owned fixed row storage.
  656. * @param count Receives the copied row count.
  657. * @return True when the catalog is ready and output can hold every row.
  658. */
  659. [[nodiscard]] bool snapshot_spawn_name_hashes(std::span<spawn_sets::NameHash> output,
  660. std::size_t& count) noexcept;
  661. /**
  662. * Finds the spawn sets one map-package stem declares.
  663. * @param stem Normalized stem a destination row carries.
  664. * @param output Caller-owned fixed row storage.
  665. * @param count Receives the copied row count.
  666. * @return True when the catalog is ready, holds the stem, and the range fits.
  667. */
  668. [[nodiscard]] bool find_spawn_sets(std::string_view stem,
  669. std::span<spawn_sets::NameHash> output,
  670. std::size_t& count) noexcept;
  671. /**
  672. * Finds one destination's bubble layout by package name.
  673. * @param name Package name the client's selection carried.
  674. * @param definition Receives the matching row.
  675. * @return True when the domain is ready and holds that exact name.
  676. */
  677. [[nodiscard]] bool find_scenario_layout(std::string_view name,
  678. scenarios::Definition& definition) noexcept;
  679. /** @return True when the installed vendor index is in State. */
  680. [[nodiscard]] bool vendor_catalog_ready() noexcept;
  681. /**
  682. * Publishes the vendor index and every extracted vendor definition in one step.
  683. * @param index Complete index rows in ascending index order.
  684. * @param definitions Extracted definitions in ascending index order, which may be empty.
  685. * @param saleRows Complete flat sale bank in definition then row order.
  686. * @param installedRows Complete flat installed bank in definition then row order.
  687. * @return True when the rows pass the checks and any needed cache write succeeds.
  688. */
  689. [[nodiscard]] bool
  690. publish_vendor_catalog(std::span<const vendors::IndexEntry> index,
  691. std::span<const vendors::Definition> definitions,
  692. std::span<const vendors::SaleRow> saleRows,
  693. std::span<const vendors::InstalledRow> installedRows) noexcept;
  694. /**
  695. * An unsupported catalyst build finishes without writing an incomplete cache.
  696. * @return True when required domains are ready and cache persistence safely finishes.
  697. */
  698. [[nodiscard]] bool persist() noexcept;
  699. } // namespace sunrise::state::build_data