Skip to main content

Module stock

Module stock 

Source
Expand description

StorageComponent ledgers and town storage search (Game). See docs/CITIZEN-AI.md and docs/RESOURCE-PRODUCTION-FLOW.md.

Structs§

Item
A StorageComponent entry (16 bytes): the raw material, the count and the reserved count.
RawMaterial
RawMaterialDescription: a template shared by ledger entries, not a stored entity.
Storage
A storage: its capacity and the goods in it, with their reservations.
StorageMatch
The result of a storage search: the storage and what it offers.
StorageSite
Registration in the manager’s ordinary (+0/+8) or market list.

Constants§

STOCK_SLOTS
The Status Bar stock slots (Game →, 0x20 bytes each): wood, stone, iron, firewood, tools, food, herbs, clothes, alcohol, coal, textile, custom 0..9.

Traits§

StorageSearchMap
What the storage search needs from the map: distances, reach and the markets’ areas.

Functions§

consume_stored
The ConsumeRawMaterial action: take goods out of a storage. Reserved requests skip the check that the goods are there; the changes happen in list order.
distribute
Hand out up to cap single units of the candidates matching mask, round-robin over the candidates and one unit per storage per pass, until the cap is reached or a pass adds nothing.
find_material_storage
The storage nearest cell (entrance path rank) that holds count of material (put false) or can take them (put true). Ordinary storages, then markets; exclude is skipped. A StorageLocation must accept the material’s flags. On a strict entrance-rank improvement the target point (slot scan, or a market use point) must exist with its own rank below the best, and the best becomes the entrance rank.
find_storage
Strict rank improvements, radius-list precedence, then storage. The covered-home flag is sticky after eligible material selection, even if its slot fails.
pickup_stored
The PickupStoredRawMaterial action: a citizen takes goods from a storage. A request of zero or less takes as much as the citizen can still carry (by weight).
scan_storages
The markets (radius list), then the storages, each taking a strictly better rank than best. With home, a market whose radius covers the home ends the search after the markets; without it, every storage is weighed. Returns the best rank and its match.
stock_slot
Which slot a raw material counts towards, in the original’s test order (food, then firewood, then single flag bits).
stock_table
Recompute the stock table from every storage.