Expand description
Trade routes file format support (campaign_maps/<map>/trade_routes.ptd).
These files contain the precomputed trade network of a campaign map: the spline curves trade routes follow, and the routes between regions and between ports. The game copies them into the trade manager of the campaign startpos.
§File Format
All values are little endian:
- Signature
\x89PTD\r\n\x1a\n,u32version (1 in Attila). u32region count, then each region key asu32length + bytes.u32spline count, then per spline: 4 flag bytes,u32segment count, and per segment the start point (u16,u16), the first control point as ani16offset from the start, the second control point as ani16offset from the end, and the end point (u16,u16). Points are in raw map units; offsets are at 100 times the raw scale.- Region routes, then port routes:
u32count, then per routeu32from,u32to,u32edge count and the edges.from/toindex the region table. A pair can appear more than once (alternative paths). - A trailing
u32(checksum?).
Structs§
- Trade
Route - A route between two regions or ports: the spline edges to follow, in order.
- Trade
Route Edge - A spline traversal in a route:
spline index * 2 + direction, where an odd value means the spline is traversed from end to start. - Trade
Routes - Decoded trade routes (
.ptd) file. - Trade
Spline - A spline of the trade network: a chain of cubic Bezier segments.
- Trade
Spline Segment - A cubic Bezier segment, in raw map units.