Skip to content

Commit c37e6d8

Browse files
committed
.rou files
1 parent 897be6b commit c37e6d8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
- [Town Hall Details](./patches/town-hall-details.md)
7575
- [File Formats](./file-formats.md)
7676
- [CPR](./file-formats/cpr.md)
77+
- [Trade Routes (.rou)](./file-formats/rou.md)
7778
- [Navigation Matrix](./file-formats/navigation-matrix.md)
7879
- [Navigation Vector](./file-formats/navigation-vector.md)
7980
- [Navpoint Matrix](./file-formats/navpoint-matrix.md)

src/file-formats/rou.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Trade Routes (.rou)
2+
The saved trade routes are stored in `./Save/AutoRoute`.
3+
An uncomporessed trade route is an array of route stops, 220 bytes each.
4+
The rou file format is defined as:
5+
```
6+
| 00 01 02 03 04 05 06 07 |
7+
00000000 | Output Length | Data |
8+
```
9+
10+
If the output length is bigger than `0` the file is compressed.
11+
Otherwise the absolute value of the negative output length denotes the length.
12+
13+
## Compression
14+
The compression algorithm has not been identified, but the decompression was [reproduced](https://github.com/P3Modding/p3-lib/tree/master/p3-rou).
15+
16+
## Trade Route Stops
17+
A trade route stop is defined as:
18+
```
19+
| 00 01 02 03 |
20+
00000000 | Unused | Town Index | Action |
21+
00000004 | Ware Order Array |
22+
...
23+
0000001c | Ware Price Array |
24+
...
25+
0000007c | Ware Amount Array |
26+
```
27+
The "direction" of a transaction is encoded in the price and amount:
28+
29+
|Price|Amount|Direction|
30+
||||
31+
|0|Negative|Ship -> Office|
32+
|0|Positive|Office -> Ship|
33+
|Positive|Positive|Ship -> Town|
34+
|Negative|Any|Town -> Ship|

0 commit comments

Comments
 (0)