mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-22 22:19:08 +00:00
Compare commits
585 Commits
517dab35b1
...
15.0-beta1
Author | SHA1 | Date | |
---|---|---|---|
|
cd0e1fc47d | ||
|
f74b0cf984 | ||
b35284d3dd | |||
1cf3a2a726 | |||
|
90a8d7a953 | ||
|
71ad0a7343 | ||
|
f79d03ec48 | ||
c72542431a | |||
|
8e948af3bc | ||
|
de908e08b2 | ||
|
54d58a08f3 | ||
2176d49a39 | |||
2c740cf7e7 | |||
59680867c3 | |||
c78e309b16 | |||
|
d623aa0dfb | ||
|
fefa18fb03 | ||
|
be02b54744 | ||
|
c91d4104f8 | ||
|
9d0939199a | ||
|
07fb13cd29 | ||
c4424aa894 | |||
|
e3e3cb13c6 | ||
|
e78cd7d6e9 | ||
|
07fb7d20db | ||
|
6ba6ae5e6f | ||
|
8bf2ab62d9 | ||
|
69ee8a8480 | ||
|
32dfb37b9d | ||
|
25cf382971 | ||
|
5d8e98207d | ||
|
15059bc253 | ||
eacec144b0 | |||
e30c5e6b9e | |||
56510b5d7b | |||
|
677bd52c65 | ||
|
1e259b7f47 | ||
aa461fca68 | |||
|
ad7738cff8 | ||
f8e9ee6fec | |||
|
95d22bac89 | ||
1e77fd0b61 | |||
369e8a6fe9 | |||
5575c0ba5a | |||
|
d0d5a18120 | ||
7af16bff11 | |||
3d73c95080 | |||
f5d78f9eba | |||
caead883a5 | |||
|
04621d1be3 | ||
560ee2442d | |||
8b00661b22 | |||
ce5279a8dc | |||
7e8bcf44f7 | |||
bccf5343f4 | |||
cba329d9e2 | |||
|
ef76f0e758 | ||
|
701cb2e9d7 | ||
|
ca148022f7 | ||
|
005c47c322 | ||
|
913d6eceb0 | ||
|
7d0b1cd002 | ||
|
10e2d1ca36 | ||
cfb995b6e9 | |||
f56b6756f1 | |||
01d1ea6264 | |||
bc2513975f | |||
e73d6fcaac | |||
e750d10cee | |||
|
7469858f1f | ||
62da507aba | |||
6f8e30c55d | |||
2ff18a4f05 | |||
efcafe49f7 | |||
9e182871c7 | |||
041b9181f9 | |||
2ede94bc40 | |||
3a158c7609 | |||
6a07f28103 | |||
44de8d77bf | |||
be505ec459 | |||
3a310f1802 | |||
e28617fda6 | |||
46176a81e3 | |||
910dd65710 | |||
60f1618cc7 | |||
|
1885bd7166 | ||
30bda88e97 | |||
568bb1f5da | |||
61cbdef92d | |||
|
8d394c697c | ||
b6aece5b88 | |||
fe0afef36f | |||
|
cf7710fb61 | ||
9bc64b553b | |||
|
f5a6a31e4a | ||
23e252ad40 | |||
8b8cd9ae2d | |||
177e2ebf80 | |||
|
e7c63de55d | ||
|
8e9603bd33 | ||
|
7c3b0e5c9c | ||
a3437df7b7 | |||
|
5b02f51e17 | ||
0446123194 | |||
0c04966dc3 | |||
0b0b4f50c4 | |||
fa1849b855 | |||
059a4b22f7 | |||
876d53282e | |||
3be0166801 | |||
1f18894408 | |||
|
9399a92a4f | ||
|
681b1928b4 | ||
b890dab2b4 | |||
00ae20fa02 | |||
|
b84a164590 | ||
653e5e8b63 | |||
43da3e7693 | |||
d875ac8947 | |||
|
26ae50baf9 | ||
a4b4095232 | |||
16038879e4 | |||
a951896364 | |||
22035a4f2a | |||
598fdf04a4 | |||
|
67a0fccfad | ||
6d3adc6169 | |||
13da98dab8 | |||
|
1b6a6f1cd2 | ||
b730f8783e | |||
9b6b6d50c3 | |||
|
85e9f5745a | ||
6c09dcdd66 | |||
640a270ed6 | |||
fcac5479f1 | |||
fc8685d618 | |||
|
369ea29e1e | ||
f9b5f78b8a | |||
25c5a64d39 | |||
|
60ae50e016 | ||
|
d2496b6ec4 | ||
|
a3ee05737f | ||
c39810ff6a | |||
d4f8453c22 | |||
|
b8f3d0dd68 | ||
d903806e59 | |||
|
a6c526cfa0 | ||
04b6dfae48 | |||
ec1dc434ac | |||
|
71ea58c6de | ||
57ac1cbe0c | |||
|
8c395ed67c | ||
14e2839087 | |||
98c8445519 | |||
|
d6c2f9edf1 | ||
61aff3fa49 | |||
|
9742038b68 | ||
|
6faf4fa70a | ||
|
3e195df3c7 | ||
bbc1f7b3dc | |||
|
78258f13bc | ||
|
ce64d5f5d9 | ||
|
66198dea46 | ||
|
5e4f8db7d6 | ||
|
e5edfbadcf | ||
|
80f628063a | ||
|
b1bba967a1 | ||
|
7b3525954c | ||
|
c9bd21d579 | ||
d54341318e | |||
|
884b93c4c0 | ||
465df3bab1 | |||
8f9836793f | |||
|
4cd46e54aa | ||
|
c3bb512bd9 | ||
|
5d7a7b2955 | ||
3b6d3080f2 | |||
8bb6572943 | |||
157d028915 | |||
|
36c735ebfa | ||
|
59c399c795 | ||
|
29df467d27 | ||
|
14fac2ad37 | ||
|
9da6cd4817 | ||
|
362db76e13 | ||
f0f62961e1 | |||
a91d889646 | |||
|
cbde825785 | ||
a1233ee8a1 | |||
|
9193d69e0b | ||
|
3a76af0909 | ||
|
3fca0cf3ee | ||
db1a1c5dd9 | |||
6d2b93d3b3 | |||
0e3fdfb1b5 | |||
552cf72b98 | |||
|
9dae626237 | ||
|
883be19865 | ||
|
07e8547eb5 | ||
|
0200bc3720 | ||
0e13a7d124 | |||
|
a96a83e330 | ||
|
abd89b0748 | ||
e076aaf740 | |||
e1697a6ad1 | |||
|
a86f9dba0f | ||
9cf47e69d6 | |||
|
233ee16c44 | ||
bb8a0c7641 | |||
1191efa581 | |||
4f9c10d35f | |||
e50c1774fc | |||
c39554a210 | |||
1403a55e5d | |||
a171939ec3 | |||
a496e9397c | |||
a6f412c615 | |||
5b73654f94 | |||
009e57ee03 | |||
|
ea6aa4653a | ||
|
4a4c77ff04 | ||
|
8ed983b3cd | ||
|
f19829d029 | ||
|
dfb74e25f7 | ||
|
d5a13fb9f4 | ||
|
c9819f8957 | ||
|
d6aa09f96a | ||
|
ce641af6a9 | ||
|
38c9eb76a0 | ||
7a71df2952 | |||
|
51ffb2a1a3 | ||
01807fa753 | |||
e98407973f | |||
e3bfe2b668 | |||
3eb7901ad9 | |||
|
6ca9ddcffa | ||
|
d7a2efd623 | ||
|
18e8a34081 | ||
|
392bcf5c9a | ||
|
1998e94ae7 | ||
|
a6b7593a52 | ||
|
3b0fcf442f | ||
|
3105f6391c | ||
|
582f37dc15 | ||
|
4a359a4aed | ||
147ac56f11 | |||
|
9d2e07b1f6 | ||
|
8ca417baa9 | ||
|
5e8da0479a | ||
|
ffcc594ea3 | ||
|
b074a4d3ce | ||
|
35d37d4768 | ||
2fda7d8297 | |||
|
ae4a723889 | ||
bacd3e83c6 | |||
8360fab18a | |||
|
d8029b1d84 | ||
d5b57a56f4 | |||
|
4a6ac52d8c | ||
|
c2d58bb88f | ||
|
45aef2c0b9 | ||
|
1a1cd2d495 | ||
|
99e8534d76 | ||
|
79c8eac2ee | ||
|
c813b2b42d | ||
446db2c826 | |||
|
d53b681cf7 | ||
14b986609b | |||
3cd1200668 | |||
|
114c28e69c | ||
|
26c2255897 | ||
|
22b4a77e37 | ||
ccced859f5 | |||
|
386dbb7c80 | ||
|
7a0e50002b | ||
|
3ed2afa68e | ||
|
b4f96f54df | ||
|
b42c4fa7ca | ||
|
1251638508 | ||
|
528f047242 | ||
51bd344f10 | |||
e60c5f30a3 | |||
f149d84d4c | |||
|
856ee2aaca | ||
|
c1db57840e | ||
eafee92476 | |||
0340e19e04 | |||
376e882a14 | |||
d450d4743e | |||
e45e8a39c8 | |||
|
9404a03663 | ||
|
a7d405b02d | ||
16b4e737a3 | |||
|
2eac527439 | ||
|
78c7dd1303 | ||
|
6175a6b78a | ||
|
96000fc4ea | ||
6e940af08d | |||
719d063bd4 | |||
3bfd9de68d | |||
|
df0233f4c2 | ||
|
1e3855c9c3 | ||
fe49dec527 | |||
25a8abcd8e | |||
|
66c5a21d8f | ||
|
9f1bb055b7 | ||
|
fcf8693c4f | ||
a241ef8da0 | |||
33a7e9e512 | |||
|
9ab0a47812 | ||
4be3361aa3 | |||
74910d3d14 | |||
|
ad020759c7 | ||
908ee7292b | |||
|
3784a3d3d6 | ||
9623c28f4d | |||
|
2a5a0b0990 | ||
|
c277ff121e | ||
d1463f415f | |||
3d8d0e0d26 | |||
b449839538 | |||
9eb28def57 | |||
|
59b18560d4 | ||
|
45a5868bb8 | ||
ad5da0c924 | |||
7f5a3eaf83 | |||
9631c68ce6 | |||
6deee5e5e2 | |||
|
bed2a060ce | ||
2d51659ed2 | |||
|
e477706bf5 | ||
|
27efa57b7b | ||
|
d0b3e0c47e | ||
|
d8c36536be | ||
|
81b684aa42 | ||
|
cb2f4f319c | ||
29ff3d7b90 | |||
|
69aa6f66ec | ||
|
5c243ee8f0 | ||
|
d5ff6b4156 | ||
|
92cbf7ae43 | ||
|
c1f8569587 | ||
|
1d907611d1 | ||
|
34c09b3596 | ||
|
f2a8e18792 | ||
|
b80f205967 | ||
|
ef7ad2606c | ||
|
2eb3e77207 | ||
|
bb770b7b56 | ||
|
9eaa00cd89 | ||
cb23651f43 | |||
719763dfcb | |||
b5264a72ae | |||
|
4070cf9968 | ||
|
3be96c6816 | ||
|
d3252315d3 | ||
2327b7030d | |||
4224d08e72 | |||
c4a638dfe1 | |||
059462814e | |||
9a037fe5ae | |||
0f0f3d74ca | |||
|
e4c04e86c0 | ||
|
4e11a9c49e | ||
|
73cb7cd7df | ||
|
f14c152c72 | ||
ff972ec4ff | |||
|
39465d7f5c | ||
1ff35cb6f9 | |||
8754846901 | |||
79369a886a | |||
|
88110e9b2e | ||
|
4cddb3a38d | ||
|
7a698c7f1c | ||
|
55ca1c77be | ||
|
bdd16ee97f | ||
367e508984 | |||
d0d5c5c400 | |||
f829b1d74a | |||
|
0633b94e8f | ||
|
574ec4ede4 | ||
|
0c4dcd562c | ||
|
c69e236f9c | ||
|
daa4981922 | ||
|
cfeab64aaf | ||
|
e1b9a3e2e7 | ||
|
19cf605765 | ||
|
0c7faa4730 | ||
|
4c06769ff2 | ||
|
6430b5a0ac | ||
a03ddb3ccb | |||
6e553410d3 | |||
d08636c841 | |||
70a2ed062d | |||
|
ba46128bdd | ||
|
57afa6002a | ||
|
8ba4f8c872 | ||
|
ae2f76e066 | ||
|
89fc7e9af6 | ||
3176de3f1d | |||
|
bec37ee704 | ||
|
39688a4ccf | ||
|
22e525dafe | ||
|
ddf6f33a8a | ||
|
9965cd9151 | ||
|
44b748a766 | ||
|
1a6655bd1b | ||
|
f4e5f1b34d | ||
|
db36e61807 | ||
|
b2faa14ab5 | ||
|
da00a62d59 | ||
4ee45db51b | |||
8b644f6ee6 | |||
ba2b14b075 | |||
d85f4b3ebf | |||
4b6e3f86c2 | |||
|
31e2f5a8a0 | ||
333e8e590e | |||
|
97479eb953 | ||
|
8ed854be58 | ||
cd739c2c33 | |||
7fb3d1a197 | |||
2199543fbc | |||
b9c44b29be | |||
e69c065d6e | |||
|
891e53c72e | ||
|
d67963e616 | ||
|
eeed824329 | ||
|
1fe11b7b57 | ||
|
65c666cb57 | ||
|
6006e832f2 | ||
|
58e4643196 | ||
e2a796dbcd | |||
b37954722b | |||
e22eb89b92 | |||
b090c8e9bd | |||
70d63f87b8 | |||
db0ae42d45 | |||
55acc1b36d | |||
ba0acb87eb | |||
93eb27d8df | |||
60c3913a99 | |||
b4bcb330c7 | |||
100dd7b6d1 | |||
56b0eac2e9 | |||
|
86e32631d7 | ||
aee04e7bc6 | |||
|
23bcd592a4 | ||
6120165433 | |||
|
f59ab67672 | ||
|
5395d5731e | ||
4976a0140e | |||
|
2dc0a33eb7 | ||
|
794af62286 | ||
|
cd4233bedc | ||
|
8ef3a3d463 | ||
|
b27527ec0c | ||
|
f98b90ac2e | ||
|
1e0004bcd6 | ||
|
4e026e448c | ||
|
d3e37a251f | ||
|
da6900f606 | ||
|
3094b0ce1d | ||
|
b03ae8ad75 | ||
|
e7982e8082 | ||
|
c4b1596c97 | ||
|
a0845bba2c | ||
|
8c7cf3bc75 | ||
|
f5f488e778 | ||
|
9e14f989f9 | ||
|
b5f2004c26 | ||
|
14200212b7 | ||
|
3819ab25bf | ||
|
dc258ecbe0 | ||
|
95f2bec9a9 | ||
a288644e20 | |||
|
da4b3bebee | ||
|
564397645f | ||
|
b52f778f20 | ||
|
5ed2fcfb53 | ||
|
06bd47af4f | ||
|
21813fbe8b | ||
209b0320d5 | |||
|
88e53dbdc8 | ||
|
a873a952aa | ||
|
d3c7b1015c | ||
|
705207e2ce | ||
|
a23ff227e7 | ||
|
ff3be45c23 | ||
|
a1e94ccddb | ||
|
9936b3728a | ||
|
a43dacd988 | ||
|
c35a5e5cb1 | ||
|
eebd5e47db | ||
|
9c84e5df3f | ||
|
c6387c7784 | ||
|
05b65703d3 | ||
|
72276e2d3c | ||
|
c3a051a213 | ||
|
c53ed9fad6 | ||
|
e8be933ee6 | ||
e802c1a97f | |||
7116f143d5 | |||
|
97e9442d5e | ||
91fd082e93 | |||
|
e0bcb54a4b | ||
|
49d47b3b74 | ||
|
64781df29f | ||
|
e3e215b249 | ||
|
2dab9ac7a5 | ||
b56775f576 | |||
731c56d116 | |||
|
7db70f9c3f | ||
|
e3156546fa | ||
2f54904bab | |||
|
2bc3cc5b67 | ||
|
0e7916a51b | ||
|
b18d8d6574 | ||
|
0409577277 | ||
|
45d1f9aa80 | ||
|
d8771b3f68 | ||
|
4cbaac6dac | ||
|
d7137651f2 | ||
b991a399ef | |||
22d70f9334 | |||
b68172c225 | |||
f9f07e9001 | |||
7b7e00123e | |||
77f62e0c90 | |||
|
219995c643 | ||
55314513ce | |||
|
81b5a7c7c6 | ||
|
68f7d585b4 | ||
4cf6d1dd79 | |||
|
18bce69623 | ||
|
7db756e602 | ||
|
fa82dd6096 | ||
b4b2fad8e0 | |||
fce9361bf2 | |||
5cd81a980e | |||
80ddcb9d7d | |||
bbbf2b5282 | |||
|
6bf214af6e | ||
79c1492a73 | |||
|
af7ad964dd | ||
|
d7eb29d292 | ||
df1b6a933b | |||
|
79b573704b | ||
66044472d7 | |||
fee73f3253 | |||
|
fa24a3ec6b | ||
|
1f636d94d4 | ||
57186d4650 | |||
579ce8eae0 | |||
|
342a7cebd6 | ||
5fd23a2d70 | |||
|
1c738e5084 | ||
|
01c75fc578 | ||
1ab280a27a | |||
|
0d10c5e93c | ||
6d2424c0ef | |||
96fc367bcf | |||
|
3827229c74 | ||
7e914a0568 | |||
|
5bca185923 | ||
|
31085230a6 | ||
|
2864f3b3eb | ||
|
0e75dfd49f | ||
48539992e8 | |||
7b717fcccb | |||
de16655f76 | |||
9c19cf06e4 | |||
0f230244fe | |||
|
deb77463b0 | ||
|
85918fc23e | ||
2e7819927f | |||
|
51e170a8d0 | ||
f220ed179d | |||
3d4b98845a | |||
|
605dff4920 | ||
|
37f68a65ee | ||
f6c5da4cad | |||
4b81b62b72 | |||
|
692943669d |
4
.github/changelog.sh
vendored
4
.github/changelog.sh
vendored
@@ -5,8 +5,8 @@ tag=$(git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\
|
||||
# If we are a tag, show the part of the changelog till (but excluding) the last stable
|
||||
if [ -n "$tag" ]; then
|
||||
grep='^[0-9]\+\.[0-9]\+[^-]'
|
||||
next=$(cat changelog.txt | grep '^[0-9]' | awk 'BEGIN { show="false" } // { if (show=="true") print $0; if ($1=="'$tag'") show="true"} ' | grep "$grep" | head -n1 | sed 's/ .*//')
|
||||
cat changelog.txt | awk 'BEGIN { show="false" } /^[0-9]+.[0-9]+/ { if ($1=="'$next'") show="false"; if ($1=="'$tag'") show="true";} // { if (show=="true") print $0 }'
|
||||
next=$(cat changelog.md | grep '^[0-9]' | awk 'BEGIN { show="false" } // { if (show=="true") print $0; if ($1=="'$tag'") show="true"} ' | grep "$grep" | head -n1 | sed 's/ .*//')
|
||||
cat changelog.md | awk 'BEGIN { show="false" } /^[0-9]+.[0-9]+/ { if ($1=="'$next'") show="false"; if ($1=="'$tag'") show="true";} // { if (show=="true") print $0 }'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
12
.github/unused-strings.py
vendored
12
.github/unused-strings.py
vendored
@@ -39,7 +39,6 @@ def read_language_file(filename, strings_found, errors):
|
||||
skip = SkipType.NONE
|
||||
length = 0
|
||||
common_prefix = ""
|
||||
last_tiny_string = ""
|
||||
|
||||
with open(filename) as fp:
|
||||
for line in fp.readlines():
|
||||
@@ -114,17 +113,6 @@ def read_language_file(filename, strings_found, errors):
|
||||
name = line.split(":")[0].strip()
|
||||
strings_defined.append(name)
|
||||
|
||||
# If a string ends on _TINY or _SMALL, it can be the {TINY} variant.
|
||||
# Check for this by some fuzzy matching.
|
||||
if name.endswith(("_SMALL", "_TINY")):
|
||||
last_tiny_string = name
|
||||
elif last_tiny_string:
|
||||
matching_name = "_".join(last_tiny_string.split("_")[:-1])
|
||||
if name == matching_name:
|
||||
strings_found.add(last_tiny_string)
|
||||
else:
|
||||
last_tiny_string = ""
|
||||
|
||||
if skip == SkipType.EXTERNAL:
|
||||
strings_found.add(name)
|
||||
skip = SkipType.LENGTH
|
||||
|
11
.github/workflows/ci-build.yml
vendored
11
.github/workflows/ci-build.yml
vendored
@@ -26,8 +26,8 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- name: Clang
|
||||
compiler: clang-15
|
||||
cxxcompiler: clang++-15
|
||||
compiler: clang
|
||||
cxxcompiler: clang++
|
||||
libraries: libsdl2-dev
|
||||
- name: GCC - SDL2
|
||||
compiler: gcc
|
||||
@@ -80,10 +80,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
arch: x86
|
||||
- os: windows-latest
|
||||
arch: x64
|
||||
- arch: x86
|
||||
- arch: x64
|
||||
|
||||
name: Windows (${{ matrix.arch }})
|
||||
|
||||
@@ -91,7 +89,6 @@ jobs:
|
||||
secrets: inherit
|
||||
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
check_annotations:
|
||||
|
6
.github/workflows/ci-emscripten.yml
vendored
6
.github/workflows/ci-emscripten.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
emscripten:
|
||||
name: CI
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
# If you change this version, change the number in the cache step too.
|
||||
image: emscripten/emsdk:3.1.57
|
||||
@@ -19,6 +19,10 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Fix dubious ownership
|
||||
run: |
|
||||
git config --global --add safe.directory ${GITHUB_WORKSPACE}
|
||||
|
||||
- name: Setup cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
|
5
.github/workflows/ci-linux.yml
vendored
5
.github/workflows/ci-linux.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
linux:
|
||||
name: CI
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
CC: ${{ inputs.compiler }}
|
||||
CXX: ${{ inputs.cxxcompiler }}
|
||||
@@ -60,6 +60,9 @@ jobs:
|
||||
libicu-dev \
|
||||
liblzma-dev \
|
||||
liblzo2-dev \
|
||||
libogg-dev \
|
||||
libopus-dev \
|
||||
libopusfile-dev \
|
||||
${{ inputs.libraries }} \
|
||||
zlib1g-dev \
|
||||
# EOF
|
||||
|
2
.github/workflows/ci-macos.yml
vendored
2
.github/workflows/ci-macos.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
macos:
|
||||
name: CI
|
||||
|
||||
runs-on: macos-14
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||
|
||||
|
3
.github/workflows/ci-mingw.yml
vendored
3
.github/workflows/ci-mingw.yml
vendored
@@ -37,6 +37,9 @@ jobs:
|
||||
mingw-w64-${{ inputs.arch }}-libpng
|
||||
mingw-w64-${{ inputs.arch }}-lld
|
||||
mingw-w64-${{ inputs.arch }}-ninja
|
||||
mingw-w64-${{ inputs.arch }}-libogg
|
||||
mingw-w64-${{ inputs.arch }}-opus
|
||||
mingw-w64-${{ inputs.arch }}-opusfile
|
||||
|
||||
- name: Install OpenGFX
|
||||
shell: bash
|
||||
|
5
.github/workflows/ci-windows.yml
vendored
5
.github/workflows/ci-windows.yml
vendored
@@ -6,9 +6,6 @@ on:
|
||||
arch:
|
||||
required: true
|
||||
type: string
|
||||
os:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
@@ -17,7 +14,7 @@ jobs:
|
||||
windows:
|
||||
name: CI
|
||||
|
||||
runs-on: ${{ inputs.os }}
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
2
.github/workflows/codeql.yml
vendored
2
.github/workflows/codeql.yml
vendored
@@ -54,6 +54,8 @@ jobs:
|
||||
libicu-dev \
|
||||
liblzma-dev \
|
||||
liblzo2-dev \
|
||||
libopus-dev \
|
||||
libopusfile-dev \
|
||||
libsdl2-dev \
|
||||
zlib1g-dev \
|
||||
# EOF
|
||||
|
2
.github/workflows/release-docs.yml
vendored
2
.github/workflows/release-docs.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
docs:
|
||||
name: Docs
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download source
|
||||
|
4
.github/workflows/release-macos.yml
vendored
4
.github/workflows/release-macos.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
macos:
|
||||
name: MacOS
|
||||
|
||||
runs-on: macos-14
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Import code signing certificates
|
||||
uses: Apple-Actions/import-codesign-certs@v2
|
||||
uses: Apple-Actions/import-codesign-certs@v3
|
||||
with:
|
||||
# The certificates in a PKCS12 file encoded as a base64 string
|
||||
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
|
||||
|
4
.github/workflows/release-source.yml
vendored
4
.github/workflows/release-source.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
source:
|
||||
name: Source
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.metadata.outputs.version }}
|
||||
@@ -127,7 +127,7 @@ jobs:
|
||||
fi
|
||||
|
||||
mkdir -p build/bundles
|
||||
cp .changelog build/bundles/changelog.txt
|
||||
cp .changelog build/bundles/changelog.md
|
||||
cp .release_date build/bundles/released.txt
|
||||
cp README.md build/bundles/README.md
|
||||
echo "::endgroup::"
|
||||
|
2
.github/workflows/upload-gog.yml
vendored
2
.github/workflows/upload-gog.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
upload:
|
||||
name: Upload (GOG)
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download source
|
||||
|
2
.github/workflows/upload-steam.yml
vendored
2
.github/workflows/upload-steam.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
upload:
|
||||
name: Upload (Steam)
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download source
|
||||
|
@@ -152,9 +152,10 @@ if(NOT OPTION_DEDICATED)
|
||||
find_package(Fontconfig)
|
||||
endif()
|
||||
find_package(Harfbuzz)
|
||||
find_package(ICU OPTIONAL_COMPONENTS i18n)
|
||||
find_package(ICU OPTIONAL_COMPONENTS i18n uc)
|
||||
endif()
|
||||
endif()
|
||||
find_package(OpusFile)
|
||||
endif()
|
||||
if(APPLE)
|
||||
enable_language(OBJCXX)
|
||||
@@ -331,6 +332,8 @@ if(NOT OPTION_DEDICATED)
|
||||
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
|
||||
link_package(Harfbuzz TARGET harfbuzz::harfbuzz)
|
||||
link_package(ICU_i18n)
|
||||
link_package(ICU_uc)
|
||||
link_package(OpusFile TARGET OpusFile::opusfile)
|
||||
|
||||
if(SDL2_FOUND AND OPENGL_FOUND AND UNIX)
|
||||
# SDL2 dynamically loads OpenGL if needed, so do not link to OpenGL when
|
||||
@@ -388,8 +391,8 @@ if(EMSCRIPTEN)
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/CREDITS.md@/CREDITS.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/CONTRIBUTING.md@/CONTRIBUTING.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/COPYING.md@/COPYING.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/known-bugs.txt@/known-bugs.txt")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/changelog.txt@/changelog.txt")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/known-bugs.md@/known-bugs.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/changelog.md@/changelog.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/admin_network.md@/docs/admin_network.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/debugging_desyncs.md@/docs/debugging_desyncs.md")
|
||||
target_link_libraries(WASM::WASM INTERFACE "--preload-file ${CMAKE_SOURCE_DIR}/docs/desync.md@/docs/desync.md")
|
||||
|
@@ -254,6 +254,40 @@ int Func();
|
||||
|
||||
* If you are writing one or more template class in the dedicated header file, use file.hpp for its name instead of file.h. This will let others know that it is template library (includes also implementation), not just header with declarations.
|
||||
|
||||
### Code Comment Vertical Alignment
|
||||
|
||||
When adding code or comments to an existing formatted section, follow the existing style if possible without editing the preexisting lines.
|
||||
|
||||
If your addition cannot be aligned with existing code, do not align the comments with anything and use only a single space between the code and the comment.
|
||||
|
||||
Good:
|
||||
|
||||
```c++
|
||||
enum Vehicle {
|
||||
BUS, ///< Take the bus.
|
||||
+ CAR, ///< Drive your car.
|
||||
BIKE, ///< Ride your bike
|
||||
+ TRAIN, ///< Catch the train.
|
||||
}
|
||||
```
|
||||
|
||||
"Car" is shorter than Bike which allows you to easily align the new comment. "Train" is longer. It is *NOT* desirable to change the vertical comment alignment of this enum.
|
||||
|
||||
Bad:
|
||||
|
||||
```c++
|
||||
enum Vehicle {
|
||||
- BUS, ///< Take the bus.
|
||||
- BIKE, ///< Ride your bike
|
||||
+ BUS, ///< Take the bus.
|
||||
+ CAR, ///< Drive your car.
|
||||
+ BIKE, ///< Ride your bike
|
||||
+ TRAIN, ///< Catch the train.
|
||||
}
|
||||
```
|
||||
|
||||
OpenTTD used to vertically-align inline Doxygen comments as shown above. OpenTTD has since stopped strictly following this rule to keep diffs smaller and reduce pollution to the git blame history for non-functional changes.
|
||||
|
||||
### Other important rules
|
||||
* Put a space before and after binary operators: "a + b", "a == b", "a & b", "a <<= b", etc.. Exceptions are ".", "->" and "[]" (no spaces) and "," (just space after it).
|
||||
* Put parenthesis where it improves readability: "*(b++)" instead of "*b++", and "if ((a & b) && c == 2)" instead of "if (a & b && c == 2)".
|
||||
@@ -448,7 +482,7 @@ Do not mention two keywords; if two apply, pick one that best represents the com
|
||||
|
||||
The `<details>` part starts with a capital and does not end with a dot.
|
||||
Try to be descriptive to what the player will notice, not to what is actually being changed in the code.
|
||||
See `changelog.txt` for inspiration.
|
||||
See `changelog.md` for inspiration.
|
||||
|
||||
To further structure the changelog, you can add components. Example are:
|
||||
* "Network" for network specific changes.
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,7 @@ macro(compile_flags)
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(
|
||||
/Zc:preprocessor # Needed for __VA_OPT__() in macros.
|
||||
/MP # Enable multi-threaded compilation.
|
||||
/FC # Display the full path of source code files passed to the compiler in diagnostics.
|
||||
)
|
||||
@@ -55,6 +56,11 @@ macro(compile_flags)
|
||||
# This flag disables the broken optimisation to work around the bug
|
||||
add_compile_options(/d2ssa-rse-)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(
|
||||
-Wno-multichar
|
||||
)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
add_compile_options(
|
||||
-W
|
||||
|
37
cmake/FindOgg.cmake
Normal file
37
cmake/FindOgg.cmake
Normal file
@@ -0,0 +1,37 @@
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_library(Ogg_LIBRARY
|
||||
NAMES ogg
|
||||
)
|
||||
|
||||
set(Ogg_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of ogg")
|
||||
|
||||
set(Ogg_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of ogg")
|
||||
|
||||
set(Ogg_LINK_FLAGS "" CACHE STRING "Extra link flags of ogg")
|
||||
|
||||
find_path(Ogg_INCLUDE_PATH
|
||||
NAMES ogg.h
|
||||
PATH_SUFFIXES ogg
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(Ogg
|
||||
REQUIRED_VARS Ogg_LIBRARY Ogg_INCLUDE_PATH
|
||||
)
|
||||
|
||||
if (Ogg_FOUND)
|
||||
set(Ogg_dirs ${Ogg_INCLUDE_PATH})
|
||||
if(EXISTS "${Ogg_INCLUDE_PATH}/ogg")
|
||||
list(APPEND Ogg_dirs "${Ogg_INCLUDE_PATH}/ogg")
|
||||
endif()
|
||||
if (NOT TARGET Ogg::ogg)
|
||||
add_library(Ogg::ogg UNKNOWN IMPORTED)
|
||||
set_target_properties(Ogg::ogg PROPERTIES
|
||||
IMPORTED_LOCATION "${Ogg_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Ogg_dirs}"
|
||||
INTERFACE_COMPILE_OPTIONS "${Ogg_COMPILE_OPTIONS}"
|
||||
INTERFACE_LINK_LIBRARIES "${Ogg_LINK_LIBRARIES}"
|
||||
INTERFACE_LINK_FLAGS "${Ogg_LINK_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
37
cmake/FindOpus.cmake
Normal file
37
cmake/FindOpus.cmake
Normal file
@@ -0,0 +1,37 @@
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_library(Opus_LIBRARY
|
||||
NAMES opus
|
||||
)
|
||||
|
||||
set(Opus_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opus")
|
||||
|
||||
set(Opus_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opus")
|
||||
|
||||
set(Opus_LINK_FLAGS "" CACHE STRING "Extra link flags of opus")
|
||||
|
||||
find_path(Opus_INCLUDE_PATH
|
||||
NAMES opus.h
|
||||
PATH_SUFFIXES opus
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(Opus
|
||||
REQUIRED_VARS Opus_LIBRARY Opus_INCLUDE_PATH
|
||||
)
|
||||
|
||||
if (Opus_FOUND)
|
||||
set(Opus_dirs ${Opus_INCLUDE_PATH})
|
||||
if(EXISTS "${Opus_INCLUDE_PATH}/opus")
|
||||
list(APPEND Opus_dirs "${Opus_INCLUDE_PATH}/opus")
|
||||
endif()
|
||||
if (NOT TARGET Opus::opus)
|
||||
add_library(Opus::opus UNKNOWN IMPORTED)
|
||||
set_target_properties(Opus::opus PROPERTIES
|
||||
IMPORTED_LOCATION "${Opus_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Opus_dirs}"
|
||||
INTERFACE_COMPILE_OPTIONS "${Opus_COMPILE_OPTIONS}"
|
||||
INTERFACE_LINK_LIBRARIES "${Opus_LINK_LIBRARIES}"
|
||||
INTERFACE_LINK_FLAGS "${Opus_LINK_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
40
cmake/FindOpusFile.cmake
Normal file
40
cmake/FindOpusFile.cmake
Normal file
@@ -0,0 +1,40 @@
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_library(OpusFile_LIBRARY
|
||||
NAMES opusfile
|
||||
)
|
||||
|
||||
set(OpusFile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opusfile")
|
||||
|
||||
set(OpusFile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opusfile")
|
||||
|
||||
set(OpusFile_LINK_FLAGS "" CACHE STRING "Extra link flags of opusfile")
|
||||
|
||||
find_path(OpusFile_INCLUDE_PATH
|
||||
NAMES opusfile.h
|
||||
PATH_SUFFIXES opus
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(OpusFile
|
||||
REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_PATH
|
||||
)
|
||||
|
||||
find_package(Ogg)
|
||||
find_package(Opus)
|
||||
|
||||
if (OpusFile_FOUND)
|
||||
set(OpusFile_dirs ${OpusFile_INCLUDE_PATH})
|
||||
if(EXISTS "${OpusFile_INCLUDE_PATH}/opus")
|
||||
list(APPEND OpusFile_dirs "${OpusFile_INCLUDE_PATH}/opus")
|
||||
endif()
|
||||
if (NOT TARGET OpusFile::opusfile)
|
||||
add_library(OpusFile::opusfile UNKNOWN IMPORTED)
|
||||
set_target_properties(OpusFile::opusfile PROPERTIES
|
||||
IMPORTED_LOCATION "${OpusFile_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_dirs}"
|
||||
INTERFACE_COMPILE_OPTIONS "${OpusFile_COMPILE_OPTIONS}"
|
||||
INTERFACE_LINK_LIBRARIES "Ogg::ogg;Opus::opus;${OpusFile_LINK_LIBRARIES}"
|
||||
INTERFACE_LINK_FLAGS "${OpusFile_LINK_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
@@ -51,8 +51,8 @@ install(FILES
|
||||
${CMAKE_SOURCE_DIR}/README.md
|
||||
${CMAKE_SOURCE_DIR}/CREDITS.md
|
||||
${CMAKE_SOURCE_DIR}/CONTRIBUTING.md
|
||||
${CMAKE_SOURCE_DIR}/changelog.txt
|
||||
${CMAKE_SOURCE_DIR}/known-bugs.txt
|
||||
${CMAKE_SOURCE_DIR}/changelog.md
|
||||
${CMAKE_SOURCE_DIR}/known-bugs.md
|
||||
DESTINATION ${DOCS_DESTINATION_DIR}
|
||||
COMPONENT docs)
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
#
|
||||
# Create a single baseset meta file with the correct translations.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
#
|
||||
# Create a single GRF file based on sprites/<grfname>.nfo and sprites/*.png
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
#
|
||||
# Create a desktop file with the correct translations.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(NOT REV_MAJOR)
|
||||
set(REV_MAJOR 0)
|
||||
@@ -57,7 +57,6 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
)
|
||||
string(REGEX REPLACE "([0-9]+)-([0-9]+)-([0-9]+).*" "\\1\\2\\3" COMMITDATE "${COMMITDATE}")
|
||||
set(REV_ISODATE "${COMMITDATE}")
|
||||
string(SUBSTRING "${REV_ISODATE}" 0 4 REV_YEAR)
|
||||
|
||||
# Get the branch
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} symbolic-ref -q HEAD
|
||||
@@ -114,7 +113,6 @@ elseif(EXISTS "${CMAKE_SOURCE_DIR}/.ottdrev")
|
||||
list(GET OTTDREV 3 REV_HASH)
|
||||
list(GET OTTDREV 4 REV_ISTAG)
|
||||
list(GET OTTDREV 5 REV_ISSTABLETAG)
|
||||
list(GET OTTDREV 6 REV_YEAR)
|
||||
else()
|
||||
message(WARNING "No version detected; this build will NOT be network compatible")
|
||||
set(REV_VERSION "norev0000")
|
||||
@@ -123,14 +121,19 @@ else()
|
||||
set(REV_HASH "unknown")
|
||||
set(REV_ISTAG 0)
|
||||
set(REV_ISSTABLETAG 0)
|
||||
set(REV_YEAR "1970")
|
||||
endif()
|
||||
|
||||
# Extract REV_YEAR and REV_DATE from REV_ISODATE
|
||||
string(SUBSTRING "${REV_ISODATE}" 0 4 REV_YEAR)
|
||||
string(SUBSTRING "${REV_ISODATE}" 4 4 REV_DATE)
|
||||
# Drop leading 0 in REV_DATE if any
|
||||
string(REGEX REPLACE "^0?([0-9]+)" "\\1" REV_DATE "${REV_DATE}")
|
||||
|
||||
message(STATUS "Version string: ${REV_VERSION}")
|
||||
|
||||
if(GENERATE_OTTDREV)
|
||||
message(STATUS "Generating .ottdrev")
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/.ottdrev "${REV_VERSION}\t${REV_ISODATE}\t${REV_MODIFIED}\t${REV_HASH}\t${REV_ISTAG}\t${REV_ISSTABLETAG}\t${REV_YEAR}\n")
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/.ottdrev "${REV_VERSION}\t${REV_ISODATE}\t${REV_MODIFIED}\t${REV_HASH}\t${REV_ISTAG}\t${REV_ISSTABLETAG}\n")
|
||||
else()
|
||||
message(STATUS "Generating rev.cpp")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/rev.cpp.in"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
#
|
||||
# CMake script to automatically generate the enums in script_window.hpp
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
#
|
||||
# Runs a single regressoion test
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(NOT SCRIPT_API_SOURCE_FILE)
|
||||
message(FATAL_ERROR "Script needs SCRIPT_API_SOURCE_FILE defined")
|
||||
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(NOT INCLUDES_SOURCE_FILE)
|
||||
message(FATAL_ERROR "Script needs INCLUDES_SOURCE_FILE defined")
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# OpenTTD's admin network
|
||||
|
||||
Last updated: 2011-01-20
|
||||
Last updated: 2024-03-26
|
||||
|
||||
|
||||
## Table of contents
|
||||
@@ -49,10 +49,29 @@ Last updated: 2011-01-20
|
||||
Create a TCP connection to the server on port 3977. The application is
|
||||
expected to authenticate within 10 seconds.
|
||||
|
||||
To authenticate send a `ADMIN_PACKET_ADMIN_JOIN` packet.
|
||||
To authenticate send either an `ADMIN_PACKET_ADMIN_JOIN` or an
|
||||
`ADMIN_PACKET_ADMIN_JOIN_SECURE` packet.
|
||||
|
||||
The server will reply with `ADMIN_PACKET_SERVER_PROTOCOL` followed directly by
|
||||
`ADMIN_PACKET_SERVER_WELCOME`.
|
||||
The `ADMIN_PACKET_ADMIN_JOIN` packet sends the password without any
|
||||
encryption or safeguards over the connection, and as such has been disabled
|
||||
by default.
|
||||
|
||||
The `ADMIN_PACKET_ADMIN_JOIN_SECURE` packet initiates a key exchange
|
||||
authentication schema which tells te server which methods the client
|
||||
supports and the server makes a choice. The server will then send an
|
||||
`ADMIN_PACKET_SERVER_AUTH_REQUEST` packet to which the client has to respond
|
||||
with an `ADMIN_PACKET_ADMIN_AUTH_RESPONSE` packet.
|
||||
|
||||
The current choices for secure authentication are authorized keys, where
|
||||
the client has a private key and the server a list of authorized public
|
||||
keys, and a so-called password-authenticated key exchange which allows to
|
||||
authenticate using a password without actually sending the password.
|
||||
The server falls back to password authentication when the client's key is
|
||||
not in the list of authorized keys.
|
||||
|
||||
When authentication has succeeded for either of the `JOIN` schemas, the
|
||||
server will reply with `ADMIN_PACKET_SERVER_PROTOCOL` followed directly
|
||||
by `ADMIN_PACKET_SERVER_WELCOME`.
|
||||
|
||||
`ADMIN_PACKET_SERVER_PROTOCOL` contains details about the protocol version.
|
||||
It is the job of your application to check this number and decide whether
|
||||
|
97
docs/importing_town_data.md
Normal file
97
docs/importing_town_data.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Importing Town Data into OpenTTD
|
||||
|
||||
To aid players in scenario creation, OpenTTD's Scenario Editor can import town data from external JSON files. This enables players to use an image editing program to align town coordinates with a real-world heightmap using a map underlay, instead of guessing at the correct locations in Scenario Editor itself.
|
||||
|
||||
This town data consists of a JSON file storing an array of town data objects, each containing a name, location, target OpenTTD population, and whether it is marked as a city in the game.
|
||||
|
||||
This document describes the standard format for this JSON file and outlines a workflow for creating this data effectively.
|
||||
|
||||
## Table of contents
|
||||
|
||||
- Why load external data?
|
||||
- How to use this feature
|
||||
- Creating geodata
|
||||
- Town data format standards
|
||||
- Town data values
|
||||
- Loading geodata into OpenTTD
|
||||
- Tutorial: Creating town data
|
||||
|
||||
## Why load external data?
|
||||
|
||||
There are three benefits to using an image editing program to create towns instead of the OpenTTD Scenario Editor.
|
||||
|
||||
1. Placing towns accurately is much easier using a map underlay such as OpenStreetMap to match town locations with the corresponding heightmap.
|
||||
2. Storing town data in a JSON file instead of as an OpenTTD Scenario (.scn) doesn't require choosing your NewGRF house set before placing towns.
|
||||
3. Town coordinates are scaled by the map size, so you can load the data onto whatever size map you like.
|
||||
|
||||
## How to use this feature
|
||||
|
||||
### Creating geodata
|
||||
|
||||
Town data is a text file in the JSON format, with a list of towns, each containing a coordinate location and properties: name, population, and whether or not it should be a city in OpenTTD.
|
||||
|
||||
The format of this file is standardized for importing into OpenTTD and must be followed for OpenTTD to properly parse the data.
|
||||
|
||||
For use in OpenTTD, you will also need a matching heightmap of the terrain features, as a PNG.
|
||||
|
||||
#### Town data format standards
|
||||
|
||||
The following code sample is complete and can be used in OpenTTD.
|
||||
- The list of towns is enclosed in an array marked with square brackets `[]`
|
||||
- Each town is enclosed in curly braces `{}`, with a comma after each town except for the last in the list.
|
||||
- The properties separated by commas except for the last.
|
||||
- Property names are enclosed in double quotes `""` with a colon `:` separating it from the property value.
|
||||
- The name property value is enclosed in double quotes `"London"`, while all other property values `44910`, `true`, etc., are not.
|
||||
|
||||
```
|
||||
[
|
||||
{
|
||||
"name": "London",
|
||||
"population": 44910,
|
||||
"city": true,
|
||||
"x": 0.7998046875,
|
||||
"y": 0.708984375
|
||||
},
|
||||
{
|
||||
"name": "Canterbury",
|
||||
"population": 217.16,
|
||||
"city": false,
|
||||
"x": 0.83251953125,
|
||||
"y": 0.828125
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### Town data values
|
||||
|
||||
- Population is scaled down for use in OpenTTD. It is possible to generate huge cities by using a large number, but there is a practical limit to town size. The larger the town, the longer it will take to import town data, since towns are placed at a relatively small size and then expanded until the population is greater than the player-defined target.
|
||||
- X and Y coordinates are a proportion of the total map dimension, between 0 and 1. Just take the pixel coordinates of the town's location in the corresponding heightmap (more detail in the tutorial below) and divide each by the maximum value.
|
||||
- For example, London is at `726, 1638` in a 1024 px by 2048 px heightmap, so `726 / 1024 = 0.7998046875` and `1638 / 2048 = 0.708984375` gives the correct coordinates for OpenTTD.
|
||||
- The reason for these proportional coordinates is so the data can be used for any map size.
|
||||
- 0,0 is (approximately) the very top tile in OpenTTD. You can see tile coordinates in-game with the Land Info Tool.
|
||||
- In most image editing programs, 0,0 is the top-left corner of the image. You can rotate the image however you want relative to compass north to orient the map to your liking. Make sure you crop and resize the image before recording town locations.
|
||||
- In OpenTTD, X and Y axis are swapped compared to most image editing programs and the standard Cartesian coordinate system. From the 0,0 origin at top left, X is the axis along the left side and Y is the axis along the right side. You can still measure X and Y coordinates in your image editing program, just swap them before importing into OpenTTD or towns won't line up with your heightmap.
|
||||
|
||||
### Loading geodata into OpenTTD
|
||||
Using geodata to create a real-world location in OpenTTD is done in the Scenario Editor.
|
||||
|
||||
1. Choose the NewGRFs you want to use in the game.
|
||||
2. Load the heightmap which you created in the geodata workflow. Either rotation will work, but the clockwise rotation is considered "correct" and the coordinates in the Land Info Tool will match your data; counter clockwise maps will align properly but the coordinates won't match your data.
|
||||
3. In the Town Generation window, click `Load from file` and choose the .json file containing town data. The default directory to search for town data is `OpenTTD\scenario\heightmap`.
|
||||
4. (Optional) Manually add industries, rivers, trees, and objects.
|
||||
5. Save the game as a Scenario and exit to the main menu.
|
||||
6. Load the game with Play Scenario and enjoy.
|
||||
|
||||
Sometimes it's not possible to place a town, such as when the heightmap is very rough and a flat tile can't be found with a 16-tile radius of the target tile. In such cases, a sign will be placed on the target tile with the name of the town. The player can then place the town manually or change the heightmap settings and try again. This fallback also helps debug errors with data creation, such as if towns end up in the ocean.
|
||||
|
||||
## Tutorial: Creating town data
|
||||
|
||||
1. Load both your heightmap and a labeled map like OpenStreetMap as layers in an image editing program. You can use a free/open-source program like QGIS to acquire, align, and export these map images, if you like.
|
||||
2. Crop the image to your desired bounds, ensuring the aspect ratio is supported in OpenTTD (1:1, 1:2, 1:4, etc.).
|
||||
3. Resize the image to one of OpenTTD's supported map sizes, such as 512 px by 1024 px. Some image editors let you do this part of step 2. You can always load heightmaps and town data at a reduced size, so you may want to make this larger than your intended use in case you want it later.
|
||||
4. Use the labeled map layer to find the pixel coordinates of each town you'd like to include in your map. In GIMP this is displayed in the bottom left corner of the image window, and in Photoshop you need to enable the Info panel (F8) and switch to pixel units of measurement if not already.
|
||||
5. Some spreadsheets including Google Sheets can export data as JSON, so you may want to record it there, to export after step 8. Or you can build the JSON file manually.
|
||||
6. Adjust population numbers for OpenTTD.
|
||||
7. Change coordinates from pixels to proportion (0-1) of the total dimension: `x / maximum_x` and `y / maximum_y`, as described in "Town data values" above.
|
||||
8. Swap X and Y coordinates before importing to OpenTTD, since OpenTTD uses a reverse X and Y system than most image editors.
|
||||
9. Save the heightmap and town data files in your `OpenTTD\scenario\heightmap` folder.
|
@@ -721,10 +721,9 @@
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<li>m3 bit 6 : bit 8 of house type (m4), allowing 512 different types.</li>
|
||||
<li>m3 bit 5 : free</li>
|
||||
<li>m3 bits 6..5 : free</li>
|
||||
<li>m3 bits 4..0 : triggers activated <a href="#newhouses">(newhouses)</a></li>
|
||||
<li>m4 : <a href="landscape_externals.html">town building type</a> (with m3[6] bit)</li>
|
||||
<li>m4 : free</li>
|
||||
<li>m5 : see m3 bit 7</li>
|
||||
<li>m6 :
|
||||
<ul>
|
||||
@@ -740,6 +739,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>m6: bits 1..0: animated tile state</li>
|
||||
<li>m7 :
|
||||
<ul>
|
||||
<li>If <a href="#newhouses">newhouses</a> is activated
|
||||
@@ -759,10 +759,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>m8 bits 15..12 : free</li>
|
||||
<li>m8 bits 11..0 : <a href="landscape_externals.html">town building type</a></li>
|
||||
</ul>
|
||||
<small><a name="newhouses"></a>Newhouses is the name englobing a newGRF feature developed by TTDPatch devs (mainly Csaboka).<br>
|
||||
It allows the replacement of the properties as well as the graphics of houses in the game.<br>
|
||||
To distinguish between the standard behaviour and the newGRF one, HouseID (m4 + m3[6]) is tested for anything above 110.<br>
|
||||
To distinguish between the standard behaviour and the newGRF one, HouseID is tested for anything above 110.<br>
|
||||
110 is the count of standard houses. So above 110 means there is a new definition of at least one house</small>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -876,6 +878,25 @@
|
||||
<li>m2: index into the array of stations</li>
|
||||
<li>m3 bits 7..4: persistent random data for railway stations/waypoints and airports)</li>
|
||||
<li>m3 bits 7..4: <a href="#OwnershipInfo">owner</a> of tram tracks (road stop)</li>
|
||||
<li>m3 bits 3..2: ground type (road waypoints)
|
||||
<table>
|
||||
<tr>
|
||||
<td><tt>0</tt> </td>
|
||||
<td>on bare land</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>1</tt> </td>
|
||||
<td>on grass</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>2</tt> </td>
|
||||
<td>paved</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m3 bit 2: rail station / waypoint may have catenary pylons</li>
|
||||
<li>m3 bit 1: rail station / waypoint may have catenary wires</li>
|
||||
<li>m3 bit 0: rail station / waypoint is blocked</li>
|
||||
<li>m4: custom station id; 0 means standard graphics</li>
|
||||
<li>m4: <a href="#RoadType">Roadtype</a> for road stops</li>
|
||||
<li>m5: graphics index (range from 0..255 for each station type):
|
||||
@@ -956,6 +977,22 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>04</tt>..<tt>05</tt> </td>
|
||||
<td align=left>road waypoints
|
||||
<table>
|
||||
<tr>
|
||||
<td><tt>04</tt> </td>
|
||||
<td align=left>drive through X</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>05</tt> </td>
|
||||
<td align=left>drive through Y</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>00</tt>..<tt>05</tt> </td>
|
||||
<td align=left>ship dock
|
||||
@@ -989,17 +1026,16 @@
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m6 bit 7: rail station / waypoint may have catenary pylons</li>
|
||||
<li>m6 bit 6: rail station / waypoint may have catenary wires</li>
|
||||
<li>m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)</li>
|
||||
<li>m6 bits 6..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint, road waypoint)</li>
|
||||
<li>m6 bit 2: pbs reservation state for railway stations/waypoints</li>
|
||||
<li>m6 bit 0: rail station / waypoint is blocked</li>
|
||||
<li>m6 bits 1..0: animated tile state</li>
|
||||
|
||||
<li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>
|
||||
<li>m7: animation frame (railway stations/waypoints, airports)</li>
|
||||
<li>m8 bit 15: Snow or desert present (road waypoints)</li>
|
||||
<li>m8 bits 11..6: <a href="#TramType">Tramtype</a></li>
|
||||
<li>m8 bits 5..0: <a href="#TrackType">track type</a> for railway stations/waypoints</li>
|
||||
<li>m8 bits 5..0: custom road stop id; 0 means standard graphics</li>
|
||||
<li>m8 bits 5..0: custom road stop/waypoint id; 0 means standard graphics</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1016,99 +1052,94 @@
|
||||
<li>m1 bits 6..5 : Water class (sea, canal or river)
|
||||
<li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> (for sea, rivers, and coasts normally <tt>11</tt>)</li>
|
||||
<li>m2: Depot index (for depots only)</li>
|
||||
<li>m3 bit 0: Non-flooding state</li>
|
||||
<li>m4: Random data for canal or river tiles</li>
|
||||
<li>m5: tile type:
|
||||
<li>m5 bits 7..4: Water tile type:
|
||||
<table>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>00</tt> </td>
|
||||
<td align=left>water, canal or river</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>01</tt> </td>
|
||||
<td align=left>coast or riverbank</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>10</tt>..<tt>1B</tt> </td>
|
||||
<td align=left>canal locks
|
||||
<table>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>10</tt> </td>
|
||||
<td align=left>middle part, (SW-NE direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>11</tt> </td>
|
||||
<td align=left>middle part, (NW-SE direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>12</tt> </td>
|
||||
<td align=left>middle part, (NE-SW direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>13</tt> </td>
|
||||
<td align=left>middle part, (SE-NW direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>14</tt> </td>
|
||||
<td align=left>lower part, (SW-NE direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>15</tt> </td>
|
||||
<td align=left>lower part, (NW-SE direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>16</tt> </td>
|
||||
<td align=left>lower part, (NE-SW direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>17</tt> </td>
|
||||
<td align=left>lower part, (SE-NW direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>18</tt> </td>
|
||||
<td align=left>upper part, (SW-NE direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>19</tt> </td>
|
||||
<td align=left>upper part, (NW-SE direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>1A</tt> </td>
|
||||
<td align=left>upper part, (NE-SW direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>1B</tt> </td>
|
||||
<td align=left>upper part, (SE-NW direction)</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>80</tt>..<tt>83</tt> </td>
|
||||
<td align=left>ship depots
|
||||
<table>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>80</tt> </td>
|
||||
<td align=left>ship depot, NE part (X direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>81</tt> </td>
|
||||
<td align=left>ship depot, SW part (X direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>82</tt> </td>
|
||||
<td align=left>ship depot, NW part (Y direction)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>83</tt> </td>
|
||||
<td align=left>ship depot, SE part (Y direction)</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td><tt>0</tt> </td>
|
||||
<td>water, canal or river</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>1</tt> </td>
|
||||
<td>coast or riverbank</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>2</tt> </td>
|
||||
<td>canal lock<br>
|
||||
<ul>
|
||||
<li>m5 bits 3..2: Lock part
|
||||
<table>
|
||||
<tr>
|
||||
<td><tt>0</tt> </td>
|
||||
<td>Middle part</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>1</tt> </td>
|
||||
<td>Lower part</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>2</tt> </td>
|
||||
<td>Upper part</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m5 bits 1..0: Lock direction
|
||||
<table>
|
||||
<tr>
|
||||
<td><tt>0</tt> </td>
|
||||
<td>NE raised</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>1</tt> </td>
|
||||
<td>SE raised</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>2</tt> </td>
|
||||
<td>SW raised</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>3</tt> </td>
|
||||
<td>NW raised</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap valign=top><tt>3</tt> </td>
|
||||
<td>depot<br>
|
||||
<ul>
|
||||
<li>m5 bit 1: Depot axis
|
||||
<table>
|
||||
<tr>
|
||||
<td><tt>0</tt> </td>
|
||||
<td>X direction (NE-SW)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>1</tt> </td>
|
||||
<td>Y direction (NW-SE)</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m5 bit 0: Depot part
|
||||
<table>
|
||||
<tr>
|
||||
<td><tt>0</tt> </td>
|
||||
<td>North part</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>1</tt> </td>
|
||||
<td>South part</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
@@ -1451,6 +1482,7 @@
|
||||
</li>
|
||||
<li>m6 bits 5..3: random triggers (NewGRF)</li>
|
||||
<li>m6 bit 2: bit 8 of type (see m5)</li>
|
||||
<li>m6 bits 1..0: animated tile state</li>
|
||||
<li>m7: animation frame</li>
|
||||
</ul>
|
||||
</td>
|
||||
@@ -1623,6 +1655,7 @@
|
||||
<li>m2: index into the array of objects, bits 0 to 15 (upper bits in m5)</li>
|
||||
<li>m3: random bits</li>
|
||||
<li>m5: index into the array of objects, bits 16 to 23 (lower bits in m2)</li>
|
||||
<li>m6 bits 1..0: animated tile state</li>
|
||||
<li>m7: animation counter</li>
|
||||
</ul>
|
||||
</td>
|
||||
|
@@ -79,8 +79,8 @@ the array so you can quickly see what is used and what is not.
|
||||
<tr>
|
||||
<td rowspan="2">0</td>
|
||||
<td class="caption">ground</td>
|
||||
<td class="bits" rowspan=27><span class="used" title="Tile type">XXXX</span> <span class="used" title="Presence and direction of bridge above">XX</span> <span class="used" title="Tropic Zone: only meaningful in tropic climate. It contains the definition of the available zones">XX</span></td>
|
||||
<td class="bits" rowspan=27><span class="used" title="Tile height">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=29><span class="used" title="Tile type">XXXX</span> <span class="used" title="Presence and direction of bridge above">XX</span> <span class="used" title="Tropic Zone: only meaningful in tropic climate. It contains the definition of the available zones">XX</span></td>
|
||||
<td class="bits" rowspan=29><span class="used" title="Tile height">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOO</span><span class="usable" title="Owner (always OWNER_NONE)">1 OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Type of hedge on NE border">XXX</span> <span class="used" title="Snow presence">X</span><span class="free">OOOO</span></td>
|
||||
@@ -130,7 +130,7 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="bits"><span class="used" title="Tile type: simple road (00), level crossing (01), road depot (10)">OO</span> <span class="used" title="Disallow vehicles to go a specific direction">XX</span> <span class="used" title="Road pieces">XXXX</span></td>
|
||||
<td class="bits"><span class="free">OO</span> <span class="used" title="Pavement type">XXX</span><span class="free">OOO</span></td>
|
||||
<td class="bits"><span class="free">OO</span><span class="used" title="Snow/desert present">X</span> <span class="free">O</span><span class="used" title="Roadworks counter">XXXX</span></td>
|
||||
<td class="bits" rowspan=1><span class="free">OOOO</span> <span class="used" title="Tram type">XXXX XX<span class="free">OO OOOO</span></td>
|
||||
<td class="bits" rowspan=1><span class="free">OOOO</span> <span class="used" title="Tram type">XXXX XX</span><span class="free">OO OOOO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">level crossing</td>
|
||||
@@ -156,17 +156,17 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="caption">finished house</td>
|
||||
<td class="bits" rowspan=2><span class="used" title="House random bits">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="pool" title="Town index on pool">XXXX XXXX XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">1</span> <span class="used" title="House type (m4 + m3[6])">X</span><span class="free">O</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">XXX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="House type (m4 + m3[6])">XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">1</span><span class="free">OO</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">X XX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Age in years, clamped at 255">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="abuse" title="Newhouses activated: periodic processing time remaining; if not, lift position for houses 04 and 05">XXXX XX</span><span class="free">OO</span></td>
|
||||
<td class="bits" rowspan=2><span class="abuse" title="Newhouses activated: periodic processing time remaining; if not, lift position for houses 04 and 05">XXXX XX</span><span class="used" title="Animated tile state">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="abuse" title="If newhouses active, m7 is the current animation frame">XXXX</span> <span class="abuse" title="If newhouses active, m7 is the current animantion frame; if not, lift behaviour for houses 04 and 05">XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO</span> <span class="used" title="House type">XXXX XXXX XXXX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">house under construction</td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">O</span> <span class="used" title="House type (m4 + m3[6])">X</span><span class="free">O</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">XXX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits"><span class="free">OOO</span><span class="used" title="Construction stage">XX</span> <span class="used" title="Construction counter">XXX</span></td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">O</span><span class="used" title="House type (m4 + m3[6])">X</span><span class="free">O</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">X XX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits"><span class="free">OOO</span><span class="used" title="Construction stage">X X</span><span class="used" title="Construction counter">XXX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
@@ -181,14 +181,14 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=7>5</td>
|
||||
<td rowspan=8>5</td>
|
||||
<td class="caption">rail station</td>
|
||||
<td class="bits" rowspan=7><span class="free">O</span><span class="used" title="Water class">XX</span> <span class="used" title="Owner">XXXXX</span></td>
|
||||
<td class="bits" rowspan=7><span class="pool" title="Station index on pool">XXXX XXXX XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Random bits">XXXX</span> <span class="free">OOOO</span></td>
|
||||
<td class="bits" rowspan=8><span class="free">O</span><span class="used" title="Water class">XX</span> <span class="used" title="Owner">XXXXX</span></td>
|
||||
<td class="bits" rowspan=8><span class="pool" title="Station index on pool">XXXX XXXX XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Random bits">XXXX</span> <span class="free">O</span><span class="used" title="May have pylons">X</span><span class="used" title="May have wires">X</span><span class="used" title="Tile is blocked">X</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Custom station specifications ID">XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="used" title="Graphics index">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="May have pylons">X</span><span class="used" title="May have wires">X</span><span class="used" title="Station type">XXX</span> <span class="used" title="Reserved track">X</span><span class="free">O</span><span class="used" title="Tile is blocked">X</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">O</span><span class="used" title="Station type">XXX X</span><span class="used" title="Reserved track">X</span><span class="used" title="Animated tile state">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Animation frame">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO OOOO OO</span><span class="used" title="Railway type">XX XXXX</span></td>
|
||||
</tr>
|
||||
@@ -199,12 +199,17 @@ the array so you can quickly see what is used and what is not.
|
||||
<tr>
|
||||
<td class="caption">road stop</td>
|
||||
<td class="bits"><span class="used" title="Owner of tram">XXXX</span> <span class="free">OOOO</span></td>
|
||||
<td class="bits"><span class="free">OO</span><span class="used" title="Roadtype for road stop">XX XXXX</span></td>
|
||||
<td class="bits"><span class="usable" title="Graphics index">OOOO O</span><span class="used" title="Graphics index: 00 (exit towards NE), 01 (exit towards SE), 02 (exit towards SW), 03 (exit towards NW), 04 (drive through X), 05 (drive through Y)">XXX</span></td>
|
||||
<td class="bits" rowspan=5><span class="free">OO</span><span class="used" title="Station type">XX X</span><span class="free">OOO</span></td>
|
||||
<td class="bits"><span class="free">OOO</span><span class="used" title="Owner of road">X XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OO</span><span class="used" title="Roadtype for road stop">XX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="usable" title="Graphics index">OOOO O</span><span class="used" title="Graphics index: 00 (exit towards NE), 01 (exit towards SE), 02 (exit towards SW), 03 (exit towards NW), 04 (drive through X), 05 (drive through Y)">XXX</span></td>
|
||||
<td class="bits" rowspan=6><span class="free">O</span><span class="used" title="Station type">XXX X</span><span class="free">O</span><span class="used" title="Animated tile state">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOO</span><span class="used" title="Owner of road">X XXXX</span></td>
|
||||
<td class="bits"><span class="free">OOOO</span> <span class="used" title="Tram type">XXXX XX</span> <span class="used" title="Custom road stops specifications ID">XXXXXX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">road waypoint</td>
|
||||
<td class="bits"><span class="used" title="Owner of tram">XXXX</span> <span class="used" title="Pavement type">XX</span><span class="free">OO</span></td>
|
||||
<td class="bits"><span class="used" title="Snow/desert present">X</span><span class="free">OOO</span> <span class="used" title="Tram type">XXXX XX</span> <span class="used" title="Custom road stops specifications ID">XXXXXX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">airport</td>
|
||||
<td class="bits"><span class="used" title="Random bits">XXXX</span> <span class="free">OOOO</span></td>
|
||||
@@ -235,32 +240,37 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=4>6</td>
|
||||
<td class="caption">sea, shore</td>
|
||||
<td class="bits" rowspan=4><span class="used" title="Ship docking tile status">X</span> <span class="used" title="Water class">XX</span> <span class="used" title="Owner">XXXXX</span></td>
|
||||
<td class="bits" rowspan=3><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=4><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">O<span class="usable">OO</span>O</span> <span class="free">OOO</span><span class="used" title="Sea shore flag">X</span></td>
|
||||
<td class="bits" rowspan=4><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=4><span class="free">OOOO OOOO</td>
|
||||
<td rowspan=5>6</td>
|
||||
<td class="caption">sea</td>
|
||||
<td class="bits" rowspan=5><span class="used" title="Ship docking tile status">X</span> <span class="used" title="Water class">XX</span> <span class="used" title="Owner">XXXXX</span></td>
|
||||
<td class="bits" rowspan=4><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=5><span class="free">OOOO OOO</span><span class="used" title="Non-flooding state">X</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">0000</span> <span class="free">OOO0</span></td>
|
||||
<td class="bits" rowspan=5><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=5><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=5><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">canal, river</td>
|
||||
<td class="bits"><span class="used" title="Canal/river random bits">XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">O<span class="usable">OO</span>O</span> <span class="free">OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">0000</span> <span class="free">OOOO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">shore</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">0001</span> <span class="free">OOOO</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">lock</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">O<span class="usable">OO</span>1</span> <span class="used" title="Lock part">XX</span> <span class="used" title="Lock orientation m5[1..0]">XX</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">0010</span> <span class="used" title="Lock part">XX</span><span class="used" title="Lock orientation m5[1..0]">XX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">shipdepot</td>
|
||||
<td class="bits"><span class="pool" title="Depot index on pool">XXXX XXXX XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">1<span class="usable">OOO</span></span> <span class="free">OO</span><span class="used" title="Depot axis">X</span> <span class="used" title="Depot part">X</span></td>
|
||||
<td class="bits"><span class="used" title="Water tile type: coast, clear, lock, depot">0011</span> <span class="free">OO</span><span class="used" title="Depot axis">X</span><span class="used" title="Depot part">X</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan=2>8</td>
|
||||
@@ -270,7 +280,7 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="bits" rowspan=2><span class="used" title="Random bits">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Animation loop">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Industry graphics ID (m5 + m6[2])">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OO</span><span class="used" title="Random triggers (NewGRF)">XXX</span> <span class="used" title="Industry graphics ID (m5 + m6[2])">X</span><span class="free">OO</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OO</span><span class="used" title="Random triggers (NewGRF)">XXX</span> <span class="used" title="Industry graphics ID (m5 + m6[2])">X</span><span class="used" title="Animated tile state">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="Animation frame">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
</tr>
|
||||
@@ -303,7 +313,7 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="bits"><span class="used" title="Random bits">XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="pool" title="Object index on pool (m2 + m5)">XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OO</span><span class="used" title="Animated tile state">XX</span></td>
|
||||
<td class="bits"><span class="used" title="Animation counter">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=1><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
</tr>
|
||||
|
@@ -20,7 +20,7 @@ This guide is for OpenTTD developers/maintainers, to release a new version of Op
|
||||
|
||||
## Step 1: Prepare changelog documentation
|
||||
|
||||
1. Update the [changelog](../changelog.txt) with new changes since the last release.
|
||||
1. Update the [changelog](../changelog.md) with new changes since the last release.
|
||||
* Changelog entries are typically PR titles, but can be edited to be more helpful without context.
|
||||
* Don't include fixes to things which haven't previously been released (like fixes to features which are in the same changelog).
|
||||
* Order the entries by importance: `Feature > Add > Change > Fix`, then numerically by PR number.
|
||||
|
426
known-bugs.md
Normal file
426
known-bugs.md
Normal file
@@ -0,0 +1,426 @@
|
||||
# OpenTTD's known bugs
|
||||
|
||||
## Table of contents
|
||||
|
||||
- 1.0) About
|
||||
- 2.0) Known bugs
|
||||
|
||||
## 1.0) About
|
||||
|
||||
All bugs listed below are marked as known. Please do not submit any bugs
|
||||
that are the same as these. If you do, do not act surprised, because
|
||||
we WILL flame you!
|
||||
|
||||
The current list of known bugs that we intend to fix can be found in our
|
||||
bug tracking system at https://github.com/OpenTTD/OpenTTD/issues
|
||||
Also check the closed bugs when searching for your bug in this system as we
|
||||
might have fixed the bug in the mean time.
|
||||
|
||||
## 2.0) Known bugs
|
||||
|
||||
This section lists all known bugs that we do not intend to fix and the
|
||||
reasons why we think that fixing them is infeasible. We might make some
|
||||
minor improvements that reduce the scope of these bugs, but we will not
|
||||
be able to completely fix them.
|
||||
|
||||
### No suitable AI can be found:
|
||||
|
||||
If you have no AIs and an AI is started the so-called 'dummy' AI will
|
||||
be loaded. This AI does nothing but writing a message on the AI debug
|
||||
window and showing a red warning. There are basically two solutions
|
||||
for this problem: Either you set the number of AI players to 0 so that
|
||||
no AI is started. You find that setting at the top of the window in the
|
||||
"AI / Game Scripts Settings" window.
|
||||
|
||||
The other solution is acquiring (downloading) some AI. The easiest way
|
||||
to do this is via the "Check Online Content" button in the main (intro)
|
||||
menu or directly in the "AI / Game Scripts Settings" dialogue via the
|
||||
"Check Online Content" button.
|
||||
|
||||
### After a while of playing, colours get corrupted:
|
||||
|
||||
In Windows 7 the background slideshow corrupts the colour mapping
|
||||
of OpenTTD's 8bpp screen modes. Workarounds for this are:
|
||||
|
||||
* Switching to windowed mode, instead of fullscreen
|
||||
* Switching off background slideshow
|
||||
* Setting up the `32bpp-anim` or `32bpp-optimized` blitter
|
||||
|
||||
### Custom vehicle type name is incorrectly aligned:
|
||||
|
||||
Some NewGRFs use sprites that are bigger than normal in the "buy
|
||||
vehicle" window. Due to this they have to encode an offset for
|
||||
the vehicle type name. Upon renaming the vehicle type this encoded
|
||||
offset is stripped from the name because the "edit box" cannot show
|
||||
this encoding. As a result the custom vehicle type names will get
|
||||
the default alignment. The only way to (partially) fix this is by
|
||||
adding spaces to the custom name.
|
||||
|
||||
### Clipping problems [#119]:
|
||||
|
||||
In some cases sprites are not drawn as one would expect. Examples of
|
||||
this are aircraft that might be hidden below the runway or trees that
|
||||
in some cases are rendered over vehicles.
|
||||
|
||||
The primary cause of this problem is that OpenTTD does not have enough
|
||||
data (like a 3D model) to properly determine what needs to be drawn in
|
||||
front of what. OpenTTD has bounding boxes but in lots of cases they
|
||||
are either too big or too small and then cause problems with what
|
||||
needs to be drawn in front of what. Also some visual tricks are used.
|
||||
|
||||
For example trains at 8 pixels high, the catenary needs to be drawn
|
||||
above that. When you want to draw bridges on top of that, which are
|
||||
only one height level (= 8 pixels) higher, you are getting into some
|
||||
big problems.
|
||||
|
||||
We can not change the height levels; it would require us to either
|
||||
redraw all vehicle or all landscape graphics. Doing so would mean we
|
||||
leave the Transport Tycoon graphics, which in effect means OpenTTD
|
||||
will not be a Transport Tycoon clone anymore.
|
||||
|
||||
### Mouse scrolling not possible at the edges of the screen [#383] [#3966]:
|
||||
|
||||
Scrolling the viewport with the mouse cursor at the edges of the screen
|
||||
in the same direction of the edge will fail. If the cursor is near the
|
||||
edge the scrolling will be very slow.
|
||||
|
||||
OpenTTD only receives cursor position updates when the cursor is inside
|
||||
OpenTTD's window. It is not told how far you have moved the cursor
|
||||
outside of OpenTTD's window.
|
||||
|
||||
### Lost trains ignore (block) exit signals [#1473]:
|
||||
|
||||
If trains are lost they ignore block exit signals, blocking junctions
|
||||
with presignals. This is caused because the path finders cannot tell
|
||||
where the train needs to go. As such a random direction is chosen at
|
||||
each junction. This causes the trains to occasionally to make choices
|
||||
that are unwanted from a player's point of view.
|
||||
|
||||
This will not be fixed because lost trains are in almost all cases a
|
||||
network problem, e.g. a train can never reach a specific place. This
|
||||
makes the impact of fixing the bug enormously small against the amount
|
||||
of work needed to write a system that prevents the lost trains from
|
||||
taking the wrong direction.
|
||||
|
||||
### Vehicle owner of last transfer leg gets paid for all [#2427]:
|
||||
|
||||
When you make a transfer system that switches vehicle owners. This
|
||||
is only possible with 'industry stations', e.g. the oil rig station
|
||||
the owner of the vehicle that does the final delivery gets paid for
|
||||
the whole trip. It is not shared amongst the different vehicle
|
||||
owners that have participated in transporting the cargo.
|
||||
|
||||
This sharing is not done because it would enormously increase the
|
||||
memory and CPU usage in big games for something that is happening
|
||||
in only one corner case. We think it is not worth the effort until
|
||||
sharing of stations is an official feature.
|
||||
|
||||
### Forbid 90 degree turns does not work for crossing PBS paths [#2737]:
|
||||
|
||||
When you run a train through itself on a X junction with PBS turned on
|
||||
the train will not obey the 'forbid 90 degree turns' setting. This is
|
||||
due to the fact that we can not be sure that the setting was turned
|
||||
off when the track was reserved, which means that we assume it was
|
||||
turned on and that the setting does not hold at the time. We made it
|
||||
this way to allow one to change the setting in-game, but it breaks
|
||||
slightly when you are running your train through itself. Running a
|
||||
train through means that your network is broken and is thus a user
|
||||
error which OpenTTD tries to graciously handle.
|
||||
|
||||
Fixing this bug means that we need to record whether this particular
|
||||
setting was turned on or off at the time the reservation was made. This
|
||||
means adding quite a bit of data to the savegame for solving an issue
|
||||
that is basically an user error. We think it is not worth the effort.
|
||||
|
||||
### Duplicate (station) names after renaming [#3204]:
|
||||
|
||||
After renaming stations one can create duplicate station names. This
|
||||
is done giving a station the same custom name as another station with
|
||||
an automatically generated name.
|
||||
|
||||
The major part of this problem is that station names are translatable.
|
||||
Meaning that a station is called e.g. '<TOWN> Central' in English and
|
||||
'<TOWN> Centraal' in Dutch. This means that in network games the
|
||||
renaming of a town could cause the rename to succeed on some clients
|
||||
and fail at others. This creates an inconsistent game state that will
|
||||
be seen as a 'desync'. Secondly the custom names are intended to fall
|
||||
completely outside of the '<TOWN> <name>' naming of stations, so when
|
||||
you rename a town all station names are updated accordingly.
|
||||
|
||||
As a result the decision has been made that all custom names are only
|
||||
compared to the other custom names in the same class and not compared
|
||||
to the automatically generated names.
|
||||
|
||||
### Extreme CPU usage/hangs when using SDL and PulseAudio [#3294], OpenTTD hangs/freezes when closing, OpenTTD is slow, OpenTTD uses a lot of CPU:
|
||||
|
||||
OpenTTD can be extremely slow/use a lot of CPU when the sound is
|
||||
played via SDL and then through PulseAudio's ALSA wrapper. Under the
|
||||
same configuration OpenTTD, or rather SDL, might hang when exiting
|
||||
the game. This problem is seen most in Ubuntu 9.04 and higher.
|
||||
|
||||
This is because recent versions of the PulseAudio sound server
|
||||
are configured to use timer-based audio scheduling rather than
|
||||
interrupt-based audio scheduling. Configuring PulseAudio to force
|
||||
use of interrupt-based scheduling may resolve sound problems for
|
||||
some users. Under recent versions of Ubuntu Linux (9.04 and higher)
|
||||
this can be accomplished by changing the following line in the
|
||||
`/etc/pulse/default.pa` file:
|
||||
`load-module module-udev-detect`
|
||||
to
|
||||
`load-module module-udev-detect tsched=0`
|
||||
|
||||
Note that PulseAudio must be restarted for changes to take effect. Older
|
||||
versions of PulseAudio may use the module-hal-detect module instead.
|
||||
Adding tsched=0 to the end of that line will have a similar effect.
|
||||
|
||||
Another possible solution is selecting the "pulse" backend of SDL
|
||||
by either using `SDL_AUDIODRIVER=pulse openttd` at the command
|
||||
prompt or installing the `libsdl1.2debian-pulseaudio` package from
|
||||
Ubuntu's Universe repository. For other distributions a similar
|
||||
package needs to be installed.
|
||||
|
||||
### OpenTTD not properly resizing with SDL on X [#3305]:
|
||||
|
||||
Under some X window managers OpenTTD's window does not properly
|
||||
resize. You will either end up with a black bar at the right/bottom
|
||||
side of the window or you cannot see the right/bottom of the window,
|
||||
e.g. you cannot see the status bar. The problem is that OpenTTD does
|
||||
not always receive a resize event from SDL making it impossible for
|
||||
OpenTTD to know that the window was resized; sometimes moving the
|
||||
window will solve the problem.
|
||||
|
||||
Window managers that are known to exhibit this behaviour are GNOME's
|
||||
and KDE's. With the XFCE's and LXDE's window managers the resize
|
||||
event is sent when the user releases the mouse.
|
||||
|
||||
### Incorrect colours, crashes upon exit, debug warnings and smears upon window resizing with SDL on macOS [#3447]:
|
||||
|
||||
Video handling with (lib)SDL under macOS is known to fail on some
|
||||
versions of macOS with some hardware configurations. Some of
|
||||
the problems happen only under some circumstances whereas others
|
||||
are always present.
|
||||
|
||||
We suggest that the SDL video/sound backend is not used for OpenTTD
|
||||
in combinations with macOS.
|
||||
|
||||
### Train crashes entering same junction from block and path signals [#3928]:
|
||||
|
||||
When a train has reserved a path from a path signal to a two way
|
||||
block signal and the reservation passes a path signal through the
|
||||
back another train can enter the reserved path (only) via that
|
||||
same two way block signal.
|
||||
|
||||
The reason for this has to do with optimisation; to fix this issue
|
||||
the signal update has to pass all path signals until it finds either
|
||||
a train or a backwards facing signal. This is a very expensive task.
|
||||
|
||||
The (signal) setups that allow these crashes can furthermore be
|
||||
considered incorrectly signalled; one extra safe waiting point for
|
||||
the train entering from path signal just after the backwards facing
|
||||
signal (from the path signal train) resolves the issue.
|
||||
|
||||
### Crashes when run in a VM using Parallels Desktop [#4003]:
|
||||
|
||||
When the Windows version of OpenTTD is executed in a VM under
|
||||
Parallels Desktop a privileged instruction exception may be thrown.
|
||||
|
||||
As OpenTTD works natively on macOS as well as natively on Windows and
|
||||
these native builds both don't exhibit this behaviour this crash is
|
||||
most likely due to a bug in the virtual machine, something out of
|
||||
the scope of OpenTTD. Most likely this is due to Parallels Desktop
|
||||
lacking support for RDTSC calls. The problem can be avoided by using
|
||||
other VM-software, Wine, or running natively on macOS.
|
||||
|
||||
### Entry- and exit signals are not dragged [#4378]:
|
||||
|
||||
Unlike all other signal types, the entry- and exit signals are not
|
||||
dragged but instead normal signals are placed on subsequent track
|
||||
sections. This is done on purpose as this is the usually more
|
||||
convenient solution. There are little to no occasions where more
|
||||
than one entry or exit signal in a row are useful. This is different
|
||||
for all other signal types where several in a row can serve one
|
||||
purpose or another.
|
||||
|
||||
### (Temporary) wrong colours when switching to full screen [#4511]:
|
||||
|
||||
On Windows it can happen that you temporarily see wrong colours
|
||||
when switching to full screen OpenTTD, either by starting
|
||||
OpenTTD in full screen mode, changing to full screen mode or by
|
||||
ALT-TAB-ing into a full screen OpenTTD. This is caused by the
|
||||
fact that OpenTTD, by default, uses 8bpp paletted output. The
|
||||
wrong colours you are seeing is a temporary effect of the video
|
||||
driver switching to 8bpp palette mode.
|
||||
|
||||
This issue can be worked around in two ways:
|
||||
* Setting fullscreen_bpp to 32
|
||||
* Setting up the 32bpp-anim or 32bpp-optimized blitter
|
||||
|
||||
### Can't run OpenTTD with the -d option from a MSYS console [#4587]:
|
||||
|
||||
The MSYS console does not allow OpenTTD to open an extra console for
|
||||
debugging output. Compiling OpenTTD with the --enable-console
|
||||
configure option prevents this issue and allows the -d option to use
|
||||
the MSYS console for its output.
|
||||
|
||||
### Unreadable characters for non-latin locales [#4607]:
|
||||
|
||||
OpenTTD does not ship a non-latin font in its graphics files. As a
|
||||
result OpenTTD needs to acquire the font from somewhere else. What
|
||||
OpenTTD does is ask the operating system, or a system library, for
|
||||
the best font for a given language if the currently loaded font
|
||||
does not provide all characters of the chosen translation. This
|
||||
means that OpenTTD has no influence over the quality of the chosen
|
||||
font; it just does the best it can do.
|
||||
|
||||
If the text is unreadable there are several steps that you can take
|
||||
to improve this. The first step is finding a good font and configure
|
||||
this in the configuration file. See section 9.0 of README.md for
|
||||
more information. You can also increase the font size to make the
|
||||
characters bigger and possible better readable.
|
||||
|
||||
If the problem is with the clarity of the font you might want to
|
||||
enable anti-aliasing by setting the small_aa/medium_aa/large_aa
|
||||
settings to "true". However, anti-aliasing only works when a 32-bit
|
||||
blitter has been selected, e.g. `blitter = "32bpp-anim"`, as with the
|
||||
8 bits blitter there are not enough colours to properly perform the
|
||||
anti-aliasing.
|
||||
|
||||
### Train does not crash with itself [#4635]:
|
||||
|
||||
When a train drives in a circle the front engine passes through
|
||||
wagons of the same train without crashing. This is intentional.
|
||||
Signals are only aware of tracks, they do not consider the train
|
||||
length and whether there would be enough room for a train in some
|
||||
circle it might drive on. Also the path a train might take is not
|
||||
necessarily known when passing a signal.
|
||||
|
||||
Checking all circumstances would take a lot of additional
|
||||
computational power for signals, which is not considered worth
|
||||
the effort, as it does not add anything to gameplay.
|
||||
|
||||
Nevertheless trains shall not crash in normal operation, so making
|
||||
a train not crash with itself is the best solution for everyone.
|
||||
|
||||
### Aircraft coming through wall in rotated airports [#4705]:
|
||||
|
||||
With rotated airports, specifically hangars, you will see that the
|
||||
aircraft will show a part through the back wall of the hangar.
|
||||
|
||||
This can be solved by only drawing a part of the plane when being
|
||||
at the back of the hangar, however then with transparency turned on
|
||||
the aircraft would be shown partially which would be even weirder.
|
||||
|
||||
As such the current behaviour is deemed the least bad.
|
||||
The same applies to overly long ships and their depots.
|
||||
|
||||
### Vehicles not keeping their "maximum" speed [#4815]:
|
||||
|
||||
Vehicles that have not enough power to reach and maintain their
|
||||
advertised maximum speed might be constantly jumping between two
|
||||
speeds. This is due to the fact that speed and its calculations
|
||||
are done with integral numbers instead of floating point numbers.
|
||||
|
||||
As a result of this a vehicle will never reach its equilibrium
|
||||
between the drag/friction and propulsion. So in effect it will be
|
||||
in a vicious circle of speeding up and slowing down due to being
|
||||
just at the other side of the equilibrium.
|
||||
|
||||
Not speeding up when near the equilibrium will cause the vehicle to
|
||||
never come in the neighbourhood of the equilibrium and not slowing
|
||||
down when near the equilibrium will cause the vehicle to never slow
|
||||
down towards the equilibrium once it has come down a hill.
|
||||
|
||||
It is possible to calculate whether the equilibrium will be passed,
|
||||
but then all acceleration calculations need to be done twice.
|
||||
|
||||
### Settings not saved when OpenTTD crashes [#4846]:
|
||||
|
||||
The settings are not saved when OpenTTD crashes for several reasons.
|
||||
The most important is that the game state is broken and as such the
|
||||
settings might contain invalid values, or the settings have not even
|
||||
been loaded yet. This would cause invalid or totally wrong settings
|
||||
to be written to the configuration file.
|
||||
|
||||
A solution to that would be saving the settings whenever one changes,
|
||||
however due to the way the configuration file is saved this requires
|
||||
a flush of the file to the disk and OpenTTD needs to wait till that
|
||||
is finished. On some file system implementations this causes the
|
||||
flush of all 'write-dirty' caches, which can be a significant amount
|
||||
of data to be written. This can further be aggravated by spinning
|
||||
down disks to conserve power, in which case this disk needs to be
|
||||
spun up first. This means that many seconds may pass before the
|
||||
configuration file is actually written, and all that time OpenTTD
|
||||
will not be able to show any progress. Changing the way the
|
||||
configuration file is saved is not an option as that leaves us more
|
||||
vulnerable to corrupt configuration files.
|
||||
|
||||
Finally, crashes should not be happening. If they happen they should
|
||||
be reported and fixed, so essentially fixing this is fixing the wrong
|
||||
thing. If you really need the configuration changes to be saved,
|
||||
and you need to run a version that crashes regularly, then you can
|
||||
use the `saveconfig` command in the console to save the settings.
|
||||
|
||||
### Not all NewGRFs, AIs, game scripts are found [#4887]:
|
||||
|
||||
Under certain situations, where the path for the content within a
|
||||
tar file is the same as other content on the file system or in another
|
||||
tar file, it is possible that content is not found. A more thorough
|
||||
explanation and solutions are described in section 4.4 of README.md.
|
||||
|
||||
### Mouse cursor going missing with SDL [#4997]:
|
||||
|
||||
Under certain circumstances SDL does not notify OpenTTD of changes with
|
||||
respect to the mouse pointer, specifically whether the mouse pointer
|
||||
is within the bounds of OpenTTD or not. For example, if you "Alt-Tab"
|
||||
to another application the mouse cursor will still be shown in OpenTTD,
|
||||
and when you move the mouse outside of the OpenTTD window so the cursor
|
||||
gets hidden, open/move another application on top of the OpenTTD window
|
||||
and then Alt-tab back into OpenTTD the cursor will not be shown.
|
||||
|
||||
We cannot fix this problem as SDL simply does not provide the required
|
||||
information in these corner cases. This is a bug in SDL and as such
|
||||
there is little that we can do about it.
|
||||
|
||||
### Trains might not stop at platforms that are currently being changed [#5553]:
|
||||
|
||||
If you add tiles to or remove tiles from a platform while a train is
|
||||
approaching to stop at the same platform, that train can miss the place
|
||||
where it's supposed to stop and pass the station without stopping.
|
||||
|
||||
This is caused by the fact that the train is considered to already
|
||||
have stopped if it's beyond its assigned stopping location. We can't
|
||||
let the train stop just anywhere in the station because then it would
|
||||
never leave the station if you have the same station in the order
|
||||
list multiple times in a row or if there is only one station
|
||||
in theorder list (see #5684).
|
||||
|
||||
### Some houses and industries are not affected by transparency [#5817]:
|
||||
|
||||
Some of the default houses and industries (f.e. the iron ore mine) are
|
||||
not affected by the transparency options. This is because the graphics
|
||||
do not (completely) separate the ground from the building.
|
||||
|
||||
This is a bug of the original graphics, and unfortunately cannot be
|
||||
fixed with OpenGFX for the sake of maintaining compatibility with
|
||||
the original graphics.
|
||||
|
||||
### Involuntary cargo exchange with cargodist via neutral station [#6114]:
|
||||
|
||||
When two players serve a neutral station at an industry, a cross-company
|
||||
chain for cargo flow can and will be established which can only be
|
||||
interrupted if one of the players stops competing for the resources of
|
||||
that industry. There is an easy fix for this: If you are loading at the
|
||||
shared station make the order "no unload" and if you're unloading make
|
||||
it "no load". Cargodist will then figure out that it should not create
|
||||
such a route.
|
||||
|
||||
### Incorrect ending year displayed in end of game newspaper [#8625]
|
||||
|
||||
The ending year of the game is configurable, but the date displayed in
|
||||
the newspaper at the end of the game is part of the graphics, not text.
|
||||
|
||||
So to fix this would involve fixing the graphics in every baseset,
|
||||
including the original. Additionally, basesets are free to put this
|
||||
text in different positions (which they do), making a proper solution
|
||||
to this infinitely more complex for a part of the game that fewer than
|
||||
1% of players ever see.
|
389
known-bugs.txt
389
known-bugs.txt
@@ -1,389 +0,0 @@
|
||||
OpenTTD's known bugs
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
Table of contents
|
||||
-----------------
|
||||
1.0) About
|
||||
2.0) Known bugs
|
||||
|
||||
|
||||
1.0) About
|
||||
---- -----
|
||||
All bugs listed below are marked as known. Please do not submit any bugs
|
||||
that are the same as these. If you do, do not act surprised, because
|
||||
we WILL flame you!
|
||||
|
||||
The current list of known bugs that we intend to fix can be found in our
|
||||
bug tracking system at https://github.com/OpenTTD/OpenTTD/issues
|
||||
Also check the closed bugs when searching for your bug in this system as we
|
||||
might have fixed the bug in the mean time.
|
||||
|
||||
|
||||
2.0) Known bugs
|
||||
---- ----------------------------------
|
||||
This section lists all known bugs that we do not intend to fix and the
|
||||
reasons why we think that fixing them is infeasible. We might make some
|
||||
minor improvements that reduce the scope of these bugs, but we will not
|
||||
be able to completely fix them.
|
||||
|
||||
No suitable AI can be found:
|
||||
If you have no AIs and an AI is started the so-called 'dummy' AI will
|
||||
be loaded. This AI does nothing but writing a message on the AI debug
|
||||
window and showing a red warning. There are basically two solutions
|
||||
for this problem: Either you set the number of AI players to 0 so that
|
||||
no AI is started. You find that setting at the top of the window in the
|
||||
"AI / Game Scripts Settings" window.
|
||||
The other solution is acquiring (downloading) some AI. The easiest way
|
||||
to do this is via the "Check Online Content" button in the main (intro)
|
||||
menu or directly in the "AI / Game Scripts Settings" dialogue via the
|
||||
"Check Online Content" button.
|
||||
|
||||
After a while of playing, colours get corrupted:
|
||||
In Windows 7 the background slideshow corrupts the colour mapping
|
||||
of OpenTTD's 8bpp screen modes. Workarounds for this are:
|
||||
a) Switching to windowed mode, instead of fullscreen
|
||||
b) Switching off background slideshow
|
||||
c) Setting up the 32bpp-anim or 32bpp-optimized blitter
|
||||
|
||||
Custom vehicle type name is incorrectly aligned:
|
||||
Some NewGRFs use sprites that are bigger than normal in the "buy
|
||||
vehicle" window. Due to this they have to encode an offset for
|
||||
the vehicle type name. Upon renaming the vehicle type this encoded
|
||||
offset is stripped from the name because the "edit box" cannot show
|
||||
this encoding. As a result the custom vehicle type names will get
|
||||
the default alignment. The only way to (partially) fix this is by
|
||||
adding spaces to the custom name.
|
||||
|
||||
Clipping problems [#119]:
|
||||
In some cases sprites are not drawn as one would expect. Examples of
|
||||
this are aircraft that might be hidden below the runway or trees that
|
||||
in some cases are rendered over vehicles.
|
||||
The primary cause of this problem is that OpenTTD does not have enough
|
||||
data (like a 3D model) to properly determine what needs to be drawn in
|
||||
front of what. OpenTTD has bounding boxes but in lots of cases they
|
||||
are either too big or too small and then cause problems with what
|
||||
needs to be drawn in front of what. Also some visual tricks are used.
|
||||
For example trains at 8 pixels high, the catenary needs to be drawn
|
||||
above that. When you want to draw bridges on top of that, which are
|
||||
only one height level (= 8 pixels) higher, you are getting into some
|
||||
big problems.
|
||||
We can not change the height levels; it would require us to either
|
||||
redraw all vehicle or all landscape graphics. Doing so would mean we
|
||||
leave the Transport Tycoon graphics, which in effect means OpenTTD
|
||||
will not be a Transport Tycoon clone anymore.
|
||||
|
||||
Mouse scrolling not possible at the edges of the screen [#383] [#3966]:
|
||||
Scrolling the viewport with the mouse cursor at the edges of the screen
|
||||
in the same direction of the edge will fail. If the cursor is near the
|
||||
edge the scrolling will be very slow.
|
||||
OpenTTD only receives cursor position updates when the cursor is inside
|
||||
OpenTTD's window. It is not told how far you have moved the cursor
|
||||
outside of OpenTTD's window.
|
||||
|
||||
Lost trains ignore (block) exit signals [#1473]:
|
||||
If trains are lost they ignore block exit signals, blocking junctions
|
||||
with presignals. This is caused because the path finders cannot tell
|
||||
where the train needs to go. As such a random direction is chosen at
|
||||
each junction. This causes the trains to occasionally to make choices
|
||||
that are unwanted from a player's point of view.
|
||||
This will not be fixed because lost trains are in almost all cases a
|
||||
network problem, e.g. a train can never reach a specific place. This
|
||||
makes the impact of fixing the bug enormously small against the amount
|
||||
of work needed to write a system that prevents the lost trains from
|
||||
taking the wrong direction.
|
||||
|
||||
Vehicle owner of last transfer leg gets paid for all [#2427]:
|
||||
When you make a transfer system that switches vehicle owners. This
|
||||
is only possible with 'industry stations', e.g. the oil rig station
|
||||
the owner of the vehicle that does the final delivery gets paid for
|
||||
the whole trip. It is not shared amongst the different vehicle
|
||||
owners that have participated in transporting the cargo.
|
||||
This sharing is not done because it would enormously increase the
|
||||
memory and CPU usage in big games for something that is happening
|
||||
in only one corner case. We think it is not worth the effort until
|
||||
sharing of stations is an official feature.
|
||||
|
||||
Forbid 90 degree turns does not work for crossing PBS paths [#2737]:
|
||||
When you run a train through itself on a X junction with PBS turned on
|
||||
the train will not obey the 'forbid 90 degree turns' setting. This is
|
||||
due to the fact that we can not be sure that the setting was turned
|
||||
off when the track was reserved, which means that we assume it was
|
||||
turned on and that the setting does not hold at the time. We made it
|
||||
this way to allow one to change the setting in-game, but it breaks
|
||||
slightly when you are running your train through itself. Running a
|
||||
train through means that your network is broken and is thus a user
|
||||
error which OpenTTD tries to graciously handle.
|
||||
Fixing this bug means that we need to record whether this particular
|
||||
setting was turned on or off at the time the reservation was made. This
|
||||
means adding quite a bit of data to the savegame for solving an issue
|
||||
that is basically an user error. We think it is not worth the effort.
|
||||
|
||||
Duplicate (station) names after renaming [#3204]:
|
||||
After renaming stations one can create duplicate station names. This
|
||||
is done giving a station the same custom name as another station with
|
||||
an automatically generated name.
|
||||
The major part of this problem is that station names are translatable.
|
||||
Meaning that a station is called e.g. '<TOWN> Central' in English and
|
||||
'<TOWN> Centraal' in Dutch. This means that in network games the
|
||||
renaming of a town could cause the rename to succeed on some clients
|
||||
and fail at others. This creates an inconsistent game state that will
|
||||
be seen as a 'desync'. Secondly the custom names are intended to fall
|
||||
completely outside of the '<TOWN> <name>' naming of stations, so when
|
||||
you rename a town all station names are updated accordingly.
|
||||
As a result the decision has been made that all custom names are only
|
||||
compared to the other custom names in the same class and not compared
|
||||
to the automatically generated names.
|
||||
|
||||
Extreme CPU usage/hangs when using SDL and PulseAudio [#3294],
|
||||
OpenTTD hangs/freezes when closing, OpenTTD is slow, OpenTTD uses a lot of CPU:
|
||||
OpenTTD can be extremely slow/use a lot of CPU when the sound is
|
||||
played via SDL and then through PulseAudio's ALSA wrapper. Under the
|
||||
same configuration OpenTTD, or rather SDL, might hang when exiting
|
||||
the game. This problem is seen most in Ubuntu 9.04 and higher.
|
||||
|
||||
This is because recent versions of the PulseAudio sound server
|
||||
are configured to use timer-based audio scheduling rather than
|
||||
interrupt-based audio scheduling. Configuring PulseAudio to force
|
||||
use of interrupt-based scheduling may resolve sound problems for
|
||||
some users. Under recent versions of Ubuntu Linux (9.04 and higher)
|
||||
this can be accomplished by changing the following line in the
|
||||
/etc/pulse/default.pa file:
|
||||
load-module module-udev-detect
|
||||
to
|
||||
load-module module-udev-detect tsched=0
|
||||
Note that PulseAudio must be restarted for changes to take effect. Older
|
||||
versions of PulseAudio may use the module-hal-detect module instead.
|
||||
Adding tsched=0 to the end of that line will have a similar effect.
|
||||
|
||||
Another possible solution is selecting the "pulse" backend of SDL
|
||||
by either using "SDL_AUDIODRIVER=pulse openttd" at the command
|
||||
prompt or installing the 'libsdl1.2debian-pulseaudio' package from
|
||||
Ubuntu's Universe repository. For other distributions a similar
|
||||
package needs to be installed.
|
||||
|
||||
OpenTTD not properly resizing with SDL on X [#3305]:
|
||||
Under some X window managers OpenTTD's window does not properly
|
||||
resize. You will either end up with a black bar at the right/bottom
|
||||
side of the window or you cannot see the right/bottom of the window,
|
||||
e.g. you cannot see the status bar. The problem is that OpenTTD does
|
||||
not always receive a resize event from SDL making it impossible for
|
||||
OpenTTD to know that the window was resized; sometimes moving the
|
||||
window will solve the problem.
|
||||
Window managers that are known to exhibit this behaviour are GNOME's
|
||||
and KDE's. With the XFCE's and LXDE's window managers the resize
|
||||
event is sent when the user releases the mouse.
|
||||
|
||||
Incorrect colours, crashes upon exit, debug warnings and smears upon
|
||||
window resizing with SDL on macOS [#3447]:
|
||||
Video handling with (lib)SDL under macOS is known to fail on some
|
||||
versions of macOS with some hardware configurations. Some of
|
||||
the problems happen only under some circumstances whereas others
|
||||
are always present.
|
||||
We suggest that the SDL video/sound backend is not used for OpenTTD
|
||||
in combinations with macOS.
|
||||
|
||||
Train crashes entering same junction from block and path signals [#3928]:
|
||||
When a train has reserved a path from a path signal to a two way
|
||||
block signal and the reservation passes a path signal through the
|
||||
back another train can enter the reserved path (only) via that
|
||||
same two way block signal.
|
||||
The reason for this has to do with optimisation; to fix this issue
|
||||
the signal update has to pass all path signals until it finds either
|
||||
a train or a backwards facing signal. This is a very expensive task.
|
||||
The (signal) setups that allow these crashes can furthermore be
|
||||
considered incorrectly signalled; one extra safe waiting point for
|
||||
the train entering from path signal just after the backwards facing
|
||||
signal (from the path signal train) resolves the issue.
|
||||
|
||||
Crashes when run in a VM using Parallels Desktop [#4003]:
|
||||
When the Windows version of OpenTTD is executed in a VM under
|
||||
Parallels Desktop a privileged instruction exception may be thrown.
|
||||
As OpenTTD works natively on macOS as well as natively on Windows and
|
||||
these native builds both don't exhibit this behaviour this crash is
|
||||
most likely due to a bug in the virtual machine, something out of
|
||||
the scope of OpenTTD. Most likely this is due to Parallels Desktop
|
||||
lacking support for RDTSC calls. The problem can be avoided by using
|
||||
other VM-software, Wine, or running natively on macOS.
|
||||
|
||||
Entry- and exit signals are not dragged [#4378]:
|
||||
Unlike all other signal types, the entry- and exit signals are not
|
||||
dragged but instead normal signals are placed on subsequent track
|
||||
sections. This is done on purpose as this is the usually more
|
||||
convenient solution. There are little to no occasions where more
|
||||
than one entry or exit signal in a row are useful. This is different
|
||||
for all other signal types where several in a row can serve one
|
||||
purpose or another.
|
||||
|
||||
Station build date is incorrect [#4415]:
|
||||
The tile query tool will show the date of the last (re)construction
|
||||
at the station and not the date of the first construction. This is
|
||||
due to compatibility reasons with NewGRFs and the fact that it is
|
||||
wrong to say that the station is built in a particular year when it
|
||||
was completely destroyed/rebuilt later on.
|
||||
The tile query tool can be fixed by changing the "Build date" text
|
||||
to "Date at which the last (re)construction took place" but this is
|
||||
deemed too specific and long for that window.
|
||||
|
||||
(Temporary) wrong colours when switching to full screen [#4511]:
|
||||
On Windows it can happen that you temporarily see wrong colours
|
||||
when switching to full screen OpenTTD, either by starting
|
||||
OpenTTD in full screen mode, changing to full screen mode or by
|
||||
ALT-TAB-ing into a full screen OpenTTD. This is caused by the
|
||||
fact that OpenTTD, by default, uses 8bpp paletted output. The
|
||||
wrong colours you are seeing is a temporary effect of the video
|
||||
driver switching to 8bpp palette mode.
|
||||
|
||||
This issue can be worked around in two ways:
|
||||
a) Setting fullscreen_bpp to 32
|
||||
b) Setting up the 32bpp-anim or 32bpp-optimized blitter
|
||||
|
||||
Can't run OpenTTD with the -d option from a MSYS console [#4587]:
|
||||
The MSYS console does not allow OpenTTD to open an extra console for
|
||||
debugging output. Compiling OpenTTD with the --enable-console
|
||||
configure option prevents this issue and allows the -d option to use
|
||||
the MSYS console for its output.
|
||||
|
||||
Unreadable characters for non-latin locales [#4607]:
|
||||
OpenTTD does not ship a non-latin font in its graphics files. As a
|
||||
result OpenTTD needs to acquire the font from somewhere else. What
|
||||
OpenTTD does is ask the operating system, or a system library, for
|
||||
the best font for a given language if the currently loaded font
|
||||
does not provide all characters of the chosen translation. This
|
||||
means that OpenTTD has no influence over the quality of the chosen
|
||||
font; it just does the best it can do.
|
||||
|
||||
If the text is unreadable there are several steps that you can take
|
||||
to improve this. The first step is finding a good font and configure
|
||||
this in the configuration file. See section 9.0 of README.md for
|
||||
more information. You can also increase the font size to make the
|
||||
characters bigger and possible better readable.
|
||||
|
||||
If the problem is with the clarity of the font you might want to
|
||||
enable anti-aliasing by setting the small_aa/medium_aa/large_aa
|
||||
settings to "true". However, anti-aliasing only works when a 32-bit
|
||||
blitter has been selected, e.g. blitter = "32bpp-anim", as with the
|
||||
8 bits blitter there are not enough colours to properly perform the
|
||||
anti-aliasing.
|
||||
|
||||
Train does not crash with itself [#4635]:
|
||||
When a train drives in a circle the front engine passes through
|
||||
wagons of the same train without crashing. This is intentional.
|
||||
Signals are only aware of tracks, they do not consider the train
|
||||
length and whether there would be enough room for a train in some
|
||||
circle it might drive on. Also the path a train might take is not
|
||||
necessarily known when passing a signal.
|
||||
Checking all circumstances would take a lot of additional
|
||||
computational power for signals, which is not considered worth
|
||||
the effort, as it does not add anything to gameplay.
|
||||
Nevertheless trains shall not crash in normal operation, so making
|
||||
a train not crash with itself is the best solution for everyone.
|
||||
|
||||
Aircraft coming through wall in rotated airports [#4705]:
|
||||
With rotated airports, specifically hangars, you will see that the
|
||||
aircraft will show a part through the back wall of the hangar.
|
||||
This can be solved by only drawing a part of the plane when being
|
||||
at the back of the hangar, however then with transparency turned on
|
||||
the aircraft would be shown partially which would be even weirder.
|
||||
As such the current behaviour is deemed the least bad.
|
||||
The same applies to overly long ships and their depots.
|
||||
|
||||
Vehicles not keeping their "maximum" speed [#4815]:
|
||||
Vehicles that have not enough power to reach and maintain their
|
||||
advertised maximum speed might be constantly jumping between two
|
||||
speeds. This is due to the fact that speed and its calculations
|
||||
are done with integral numbers instead of floating point numbers.
|
||||
As a result of this a vehicle will never reach its equilibrium
|
||||
between the drag/friction and propulsion. So in effect it will be
|
||||
in a vicious circle of speeding up and slowing down due to being
|
||||
just at the other side of the equilibrium.
|
||||
|
||||
Not speeding up when near the equilibrium will cause the vehicle to
|
||||
never come in the neighbourhood of the equilibrium and not slowing
|
||||
down when near the equilibrium will cause the vehicle to never slow
|
||||
down towards the equilibrium once it has come down a hill.
|
||||
|
||||
It is possible to calculate whether the equilibrium will be passed,
|
||||
but then all acceleration calculations need to be done twice.
|
||||
|
||||
Settings not saved when OpenTTD crashes [#4846]:
|
||||
The settings are not saved when OpenTTD crashes for several reasons.
|
||||
The most important is that the game state is broken and as such the
|
||||
settings might contain invalid values, or the settings have not even
|
||||
been loaded yet. This would cause invalid or totally wrong settings
|
||||
to be written to the configuration file.
|
||||
|
||||
A solution to that would be saving the settings whenever one changes,
|
||||
however due to the way the configuration file is saved this requires
|
||||
a flush of the file to the disk and OpenTTD needs to wait till that
|
||||
is finished. On some file system implementations this causes the
|
||||
flush of all 'write-dirty' caches, which can be a significant amount
|
||||
of data to be written. This can further be aggravated by spinning
|
||||
down disks to conserve power, in which case this disk needs to be
|
||||
spun up first. This means that many seconds may pass before the
|
||||
configuration file is actually written, and all that time OpenTTD
|
||||
will not be able to show any progress. Changing the way the
|
||||
configuration file is saved is not an option as that leaves us more
|
||||
vulnerable to corrupt configuration files.
|
||||
|
||||
Finally, crashes should not be happening. If they happen they should
|
||||
be reported and fixed, so essentially fixing this is fixing the wrong
|
||||
thing. If you really need the configuration changes to be saved,
|
||||
and you need to run a version that crashes regularly, then you can
|
||||
use the 'saveconfig' command in the console to save the settings.
|
||||
|
||||
Not all NewGRFs, AIs, game scripts are found [#4887]:
|
||||
Under certain situations, where the path for the content within a
|
||||
tar file is the same as other content on the file system or in another
|
||||
tar file, it is possible that content is not found. A more thorough
|
||||
explanation and solutions are described in section 4.4 of README.md.
|
||||
|
||||
Mouse cursor going missing with SDL [#4997]:
|
||||
Under certain circumstances SDL does not notify OpenTTD of changes with
|
||||
respect to the mouse pointer, specifically whether the mouse pointer
|
||||
is within the bounds of OpenTTD or not. For example, if you "Alt-Tab"
|
||||
to another application the mouse cursor will still be shown in OpenTTD,
|
||||
and when you move the mouse outside of the OpenTTD window so the cursor
|
||||
gets hidden, open/move another application on top of the OpenTTD window
|
||||
and then Alt-tab back into OpenTTD the cursor will not be shown.
|
||||
|
||||
We cannot fix this problem as SDL simply does not provide the required
|
||||
information in these corner cases. This is a bug in SDL and as such
|
||||
there is little that we can do about it.
|
||||
|
||||
Trains might not stop at platforms that are currently being changed [#5553]:
|
||||
If you add tiles to or remove tiles from a platform while a train is
|
||||
approaching to stop at the same platform, that train can miss the place
|
||||
where it's supposed to stop and pass the station without stopping.
|
||||
This is caused by the fact that the train is considered to already
|
||||
have stopped if it's beyond its assigned stopping location. We can't
|
||||
let the train stop just anywhere in the station because then it would
|
||||
never leave the station if you have the same station in the order
|
||||
list multiple times in a row or if there is only one station
|
||||
in theorder list (see #5684).
|
||||
|
||||
Some houses and industries are not affected by transparency [#5817]:
|
||||
Some of the default houses and industries (f.e. the iron ore mine) are
|
||||
not affected by the transparency options. This is because the graphics
|
||||
do not (completely) separate the ground from the building.
|
||||
This is a bug of the original graphics, and unfortunately cannot be
|
||||
fixed with OpenGFX for the sake of maintaining compatibility with
|
||||
the original graphics.
|
||||
|
||||
Involuntary cargo exchange with cargodist via neutral station [#6114]:
|
||||
When two players serve a neutral station at an industry, a cross-company
|
||||
chain for cargo flow can and will be established which can only be
|
||||
interrupted if one of the players stops competing for the resources of
|
||||
that industry. There is an easy fix for this: If you are loading at the
|
||||
shared station make the order "no unload" and if you're unloading make
|
||||
it "no load". Cargodist will then figure out that it should not create
|
||||
such a route.
|
||||
|
||||
Incorrect ending year displayed in end of game newspaper [#8625]
|
||||
The ending year of the game is configurable, but the date displayed in
|
||||
the newspaper at the end of the game is part of the graphics, not text.
|
||||
So to fix this would involve fixing the graphics in every baseset,
|
||||
including the original. Additionally, basesets are free to put this
|
||||
text in different positions (which they do), making a proper solution
|
||||
to this infinitely more complex for a part of the game that fewer than
|
||||
1% of players ever see.
|
Binary file not shown.
@@ -1 +1 @@
|
||||
4f03553f614a06d86dc06376db3353c7
|
||||
8bc3926cb50e19747de498357417d973
|
||||
|
@@ -20,6 +20,7 @@ if(GRFCODEC_FOUND)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openttdgui.nfo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/palette.nfo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/roadstops.nfo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/road_waypoints.nfo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/signals.nfo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sloped_tracks.nfo
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tramtracks.nfo
|
||||
@@ -42,6 +43,7 @@ if(GRFCODEC_FOUND)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openttdgui_convert_tram.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openttdgui_group_livery.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/roadstops.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/road_waypoints.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/signals.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sloped_tracks.png
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tramtracks.png
|
||||
|
@@ -98,3 +98,4 @@
|
||||
#include "mono.nfo"
|
||||
#include "tunnel_portals.nfo"
|
||||
#include "palette.nfo"
|
||||
#include "road_waypoints.nfo"
|
||||
|
14
media/baseset/openttd/road_waypoints.nfo
Normal file
14
media/baseset/openttd/road_waypoints.nfo
Normal file
@@ -0,0 +1,14 @@
|
||||
// This file is part of OpenTTD.
|
||||
// OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
// OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
-1 * 0 0C "Road waypoints"
|
||||
//@@LINT OFF
|
||||
-1 * 3 05 19 04
|
||||
//@@LINT ON
|
||||
-1 sprites/road_waypoints.png 8bpp 10 10 64 40 -5 -22 normal
|
||||
-1 sprites/road_waypoints.png 8bpp 90 10 64 40 -31 -9 normal
|
||||
-1 sprites/road_waypoints.png 8bpp 170 10 64 35 -31 -4 normal
|
||||
-1 sprites/road_waypoints.png 8bpp 240 10 64 35 -57 -17 normal
|
BIN
media/baseset/openttd/road_waypoints.png
Normal file
BIN
media/baseset/openttd/road_waypoints.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
2
src/3rdparty/icu/CMakeLists.txt
vendored
2
src/3rdparty/icu/CMakeLists.txt
vendored
@@ -1,3 +1,5 @@
|
||||
add_subdirectory(tests)
|
||||
|
||||
add_files(
|
||||
scriptrun.cpp
|
||||
scriptrun.h
|
||||
|
7
src/3rdparty/icu/scriptrun.cpp
vendored
7
src/3rdparty/icu/scriptrun.cpp
vendored
@@ -184,13 +184,6 @@ UBool ScriptRun::next()
|
||||
parenStack[++startSP].scriptCode = scriptCode;
|
||||
}
|
||||
}
|
||||
|
||||
// if this character is a close paired character,
|
||||
// pop it from the stack
|
||||
if (pairIndex >= 0 && (pairIndex & 1) != 0 && parenSP >= 0) {
|
||||
parenSP -= 1;
|
||||
startSP -= 1;
|
||||
}
|
||||
} else {
|
||||
// if the run broke on a surrogate pair,
|
||||
// end it before the high surrogate
|
||||
|
4
src/3rdparty/icu/tests/CMakeLists.txt
vendored
Normal file
4
src/3rdparty/icu/tests/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
add_test_files(
|
||||
test_srtest.cpp
|
||||
CONDITION ICU_i18n_FOUND
|
||||
)
|
66
src/3rdparty/icu/tests/test_srtest.cpp
vendored
Normal file
66
src/3rdparty/icu/tests/test_srtest.cpp
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
// © 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2001-2016 - All Rights Reserved
|
||||
*
|
||||
*/
|
||||
/** @file test_srtest.cpp Test icu::ScriptRun result. */
|
||||
|
||||
#include "../../../stdafx.h"
|
||||
|
||||
#include "../../../3rdparty/catch2/catch.hpp"
|
||||
#include "../../../3rdparty/fmt/core.h"
|
||||
|
||||
#include "../scriptrun.h"
|
||||
|
||||
#include <span>
|
||||
#include <unicode/uscript.h>
|
||||
|
||||
static void TestScriptRun(std::span<const char16_t> testChars, std::span<const std::string_view> testResults)
|
||||
{
|
||||
icu::ScriptRun scriptRun(testChars.data(), 0, std::size(testChars));
|
||||
size_t i = 0;
|
||||
|
||||
while (scriptRun.next()) {
|
||||
int32_t start = scriptRun.getScriptStart();
|
||||
int32_t end = scriptRun.getScriptEnd();
|
||||
UScriptCode code = scriptRun.getScriptCode();
|
||||
|
||||
REQUIRE(i < std::size(testResults));
|
||||
CHECK(fmt::format("Script '{}' from {} to {}.", uscript_getName(code), start, end) == testResults[i]);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
REQUIRE(i == std::size(testResults));
|
||||
}
|
||||
|
||||
TEST_CASE("ICU ScriptRun")
|
||||
{
|
||||
/** Example string sequence as in srtest.cpp. */
|
||||
static const char16_t testChars[] = {
|
||||
0x0020, 0x0946, 0x0939, 0x093F, 0x0928, 0x094D, 0x0926, 0x0940, 0x0020,
|
||||
0x0627, 0x0644, 0x0639, 0x0631, 0x0628, 0x064A, 0x0629, 0x0020,
|
||||
0x0420, 0x0443, 0x0441, 0x0441, 0x043A, 0x0438, 0x0439, 0x0020,
|
||||
'E', 'n', 'g', 'l', 'i', 's', 'h', 0x0020,
|
||||
0x6F22, 0x5B75, 0x3068, 0x3072, 0x3089, 0x304C, 0x306A, 0x3068,
|
||||
0x30AB, 0x30BF, 0x30AB, 0x30CA,
|
||||
0xD801, 0xDC00, 0xD801, 0xDC01, 0xD801, 0xDC02, 0xD801, 0xDC03
|
||||
};
|
||||
|
||||
/** Expected results from script run. */
|
||||
static const std::string_view testResults[] = {
|
||||
"Script 'Devanagari' from 0 to 9.",
|
||||
"Script 'Arabic' from 9 to 17.",
|
||||
"Script 'Cyrillic' from 17 to 25.",
|
||||
"Script 'Latin' from 25 to 33.",
|
||||
"Script 'Han' from 33 to 35.",
|
||||
"Script 'Hiragana' from 35 to 41.",
|
||||
"Script 'Katakana' from 41 to 45.",
|
||||
"Script 'Deseret' from 45 to 53.",
|
||||
};
|
||||
|
||||
TestScriptRun(testChars, testResults);
|
||||
}
|
@@ -39,6 +39,11 @@ add_files(
|
||||
CONDITION ICU_i18n_FOUND AND HARFBUZZ_FOUND
|
||||
)
|
||||
|
||||
add_files(
|
||||
soundloader_opus.cpp
|
||||
CONDITION OpusFile_FOUND
|
||||
)
|
||||
|
||||
add_files(
|
||||
aircraft.h
|
||||
aircraft_cmd.cpp
|
||||
@@ -50,6 +55,7 @@ add_files(
|
||||
airport_gui.cpp
|
||||
animated_tile.cpp
|
||||
animated_tile_func.h
|
||||
animated_tile_map.h
|
||||
articulated_vehicles.cpp
|
||||
articulated_vehicles.h
|
||||
autocompletion.cpp
|
||||
@@ -307,6 +313,7 @@ add_files(
|
||||
newgrf_storage.h
|
||||
newgrf_text.cpp
|
||||
newgrf_text.h
|
||||
newgrf_text_type.h
|
||||
newgrf_town.cpp
|
||||
newgrf_town.h
|
||||
newgrf_townname.cpp
|
||||
@@ -343,6 +350,7 @@ add_files(
|
||||
picker_gui.h
|
||||
progress.cpp
|
||||
progress.h
|
||||
provider_manager.h
|
||||
querystring_gui.h
|
||||
rail.cpp
|
||||
rail.h
|
||||
@@ -414,6 +422,11 @@ add_files(
|
||||
sound.cpp
|
||||
sound_func.h
|
||||
sound_type.h
|
||||
soundloader.cpp
|
||||
soundloader_func.h
|
||||
soundloader_type.h
|
||||
soundloader_raw.cpp
|
||||
soundloader_wav.cpp
|
||||
sprite.cpp
|
||||
sprite.h
|
||||
spritecache.cpp
|
||||
|
@@ -242,18 +242,15 @@
|
||||
|
||||
/* static */ void AI::NewEvent(CompanyID company, ScriptEvent *event)
|
||||
{
|
||||
/* AddRef() and Release() need to be called at least once, so do it here */
|
||||
event->AddRef();
|
||||
ScriptObjectRef counter(event);
|
||||
|
||||
/* Clients should ignore events */
|
||||
if (_networking && !_network_server) {
|
||||
event->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Only AIs can have an event-queue */
|
||||
if (!Company::IsValidAiID(company)) {
|
||||
event->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -261,18 +258,14 @@
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(_current_company)->ai_instance->InsertEvent(event);
|
||||
cur_company.Restore();
|
||||
|
||||
event->Release();
|
||||
}
|
||||
|
||||
/* static */ void AI::BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company)
|
||||
{
|
||||
/* AddRef() and Release() need to be called at least once, so do it here */
|
||||
event->AddRef();
|
||||
ScriptObjectRef counter(event);
|
||||
|
||||
/* Clients should ignore events */
|
||||
if (_networking && !_network_server) {
|
||||
event->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -280,8 +273,6 @@
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
if (c != skip_company) AI::NewEvent(c, event);
|
||||
}
|
||||
|
||||
event->Release();
|
||||
}
|
||||
|
||||
/* static */ void AI::Save(CompanyID company)
|
||||
|
@@ -86,7 +86,7 @@ static WindowDesc _ai_config_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_GAME_OPTIONS, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_ai_config_widgets), std::end(_nested_ai_config_widgets)
|
||||
_nested_ai_config_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ struct AIConfigWindow : public Window {
|
||||
int line_height; ///< Height of a single AI-name line.
|
||||
Scrollbar *vscroll; ///< Cache of the vertical scrollbar.
|
||||
|
||||
AIConfigWindow() : Window(&_ai_config_desc)
|
||||
AIConfigWindow() : Window(_ai_config_desc)
|
||||
{
|
||||
this->InitNested(WN_GAME_OPTIONS_AI); // Initializes 'this->line_height' as a side effect.
|
||||
this->vscroll = this->GetScrollbar(WID_AIC_SCROLLBAR);
|
||||
|
@@ -17,12 +17,10 @@
|
||||
* Base values for flight levels above ground level for 'normal' flight and holding patterns.
|
||||
* Due to speed and direction, the actual flight level may be higher.
|
||||
*/
|
||||
enum AircraftFlyingAltitude {
|
||||
AIRCRAFT_MIN_FLYING_ALTITUDE = 120, ///< Minimum flying altitude above tile.
|
||||
AIRCRAFT_MAX_FLYING_ALTITUDE = 360, ///< Maximum flying altitude above tile.
|
||||
PLANE_HOLD_MAX_FLYING_ALTITUDE = 150, ///< holding flying altitude above tile of planes.
|
||||
HELICOPTER_HOLD_MAX_FLYING_ALTITUDE = 184 ///< holding flying altitude above tile of helicopters.
|
||||
};
|
||||
static constexpr int AIRCRAFT_MIN_FLYING_ALTITUDE = 120; ///< Minimum flying altitude above tile.
|
||||
static constexpr int AIRCRAFT_MAX_FLYING_ALTITUDE = 360; ///< Maximum flying altitude above tile.
|
||||
static constexpr int PLANE_HOLD_MAX_FLYING_ALTITUDE = 150; ///< holding flying altitude above tile of planes.
|
||||
static constexpr int HELICOPTER_HOLD_MAX_FLYING_ALTITUDE = 184; ///< holding flying altitude above tile of helicopters.
|
||||
|
||||
struct Aircraft;
|
||||
|
||||
|
@@ -630,13 +630,11 @@ void UpdateAircraftCache(Aircraft *v, bool update_range)
|
||||
/**
|
||||
* Special velocities for aircraft
|
||||
*/
|
||||
enum AircraftSpeedLimits {
|
||||
SPEED_LIMIT_TAXI = 50, ///< Maximum speed of an aircraft while taxiing
|
||||
SPEED_LIMIT_APPROACH = 230, ///< Maximum speed of an aircraft on finals
|
||||
SPEED_LIMIT_BROKEN = 320, ///< Maximum speed of an aircraft that is broken
|
||||
SPEED_LIMIT_HOLD = 425, ///< Maximum speed of an aircraft that flies the holding pattern
|
||||
SPEED_LIMIT_NONE = 0xFFFF, ///< No environmental speed limit. Speed limit is type dependent
|
||||
};
|
||||
static constexpr uint16_t SPEED_LIMIT_TAXI = 50; ///< Maximum speed of an aircraft while taxiing
|
||||
static constexpr uint16_t SPEED_LIMIT_APPROACH = 230; ///< Maximum speed of an aircraft on finals
|
||||
static constexpr uint16_t SPEED_LIMIT_BROKEN = 320; ///< Maximum speed of an aircraft that is broken
|
||||
static constexpr uint16_t SPEED_LIMIT_HOLD = 425; ///< Maximum speed of an aircraft that flies the holding pattern
|
||||
static constexpr uint16_t SPEED_LIMIT_NONE = UINT16_MAX; ///< No environmental speed limit. Speed limit is type dependent
|
||||
|
||||
/**
|
||||
* Sets the new speed for an aircraft
|
||||
@@ -1322,10 +1320,10 @@ void Aircraft::MarkDirty()
|
||||
|
||||
uint Aircraft::Crash(bool flooded)
|
||||
{
|
||||
uint pass = Vehicle::Crash(flooded) + 2; // pilots
|
||||
uint victims = Vehicle::Crash(flooded) + 2; // pilots
|
||||
this->crashed_counter = flooded ? 9000 : 0; // max 10000, disappear pretty fast when flooded
|
||||
|
||||
return pass;
|
||||
return victims;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1336,8 +1334,8 @@ static void CrashAirplane(Aircraft *v)
|
||||
{
|
||||
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
||||
|
||||
uint pass = v->Crash();
|
||||
SetDParam(0, pass);
|
||||
uint victims = v->Crash();
|
||||
SetDParam(0, victims);
|
||||
|
||||
v->cargo.Truncate();
|
||||
v->Next()->cargo.Truncate();
|
||||
@@ -1351,8 +1349,8 @@ static void CrashAirplane(Aircraft *v)
|
||||
newsitem = STR_NEWS_AIRCRAFT_CRASH;
|
||||
}
|
||||
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims));
|
||||
|
||||
NewsType newstype = NT_ACCIDENT;
|
||||
if (v->owner != _local_company) {
|
||||
|
@@ -97,6 +97,17 @@ void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, Eng
|
||||
|
||||
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
||||
seq.Draw(x, y, pal, (v->vehstatus & VS_CRASHED) != 0);
|
||||
|
||||
/* Aircraft can store cargo in their shadow, show this if present. */
|
||||
const Vehicle *u = v->Next();
|
||||
assert(u != nullptr);
|
||||
int dx = 0;
|
||||
if (u->cargo_cap > 0 && u->cargo_type != v->cargo_type) {
|
||||
dx = GetLargestCargoIconSize().width / 2;
|
||||
DrawCargoIconOverlay(x + dx, y, u->cargo_type);
|
||||
}
|
||||
if (v->cargo_cap > 0) DrawCargoIconOverlay(x - dx, y, v->cargo_type);
|
||||
|
||||
if (helicopter) {
|
||||
const Aircraft *a = Aircraft::From(v);
|
||||
VehicleSpriteSeq rotor_seq;
|
||||
|
@@ -83,7 +83,7 @@ static void PlaceAirport(TileIndex tile)
|
||||
struct BuildAirToolbarWindow : Window {
|
||||
int last_user_action; // Last started user action.
|
||||
|
||||
BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
||||
BuildAirToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->InitNested(window_number);
|
||||
this->OnInvalidateData();
|
||||
@@ -212,7 +212,7 @@ static WindowDesc _air_toolbar_desc(
|
||||
WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_air_toolbar_widgets), std::end(_nested_air_toolbar_widgets),
|
||||
_nested_air_toolbar_widgets,
|
||||
&BuildAirToolbarWindow::hotkeys
|
||||
);
|
||||
|
||||
@@ -228,7 +228,7 @@ Window *ShowBuildAirToolbar()
|
||||
if (!Company::IsValidID(_local_company)) return nullptr;
|
||||
|
||||
CloseWindowByClass(WC_BUILD_TOOLBAR);
|
||||
return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
||||
return AllocateWindowDescFront<BuildAirToolbarWindow>(_air_toolbar_desc, TRANSPORT_AIR);
|
||||
}
|
||||
|
||||
class BuildAirportWindow : public PickerWindowBase {
|
||||
@@ -249,7 +249,7 @@ class BuildAirportWindow : public PickerWindowBase {
|
||||
}
|
||||
|
||||
public:
|
||||
BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
|
||||
BuildAirportWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
|
||||
{
|
||||
this->CreateNestedTree();
|
||||
|
||||
@@ -384,13 +384,14 @@ public:
|
||||
case WID_AP_AIRPORT_LIST: {
|
||||
Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
|
||||
Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
|
||||
AirportClass *apclass = AirportClass::Get(_selected_airport_class);
|
||||
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
|
||||
const AirportSpec *as = apclass->GetSpec(i);
|
||||
const auto specs = AirportClass::Get(_selected_airport_class)->Specs();
|
||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(specs);
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const AirportSpec *as = *it;
|
||||
if (!as->IsAvailable()) {
|
||||
GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
|
||||
}
|
||||
DrawString(text, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
|
||||
DrawString(text, as->name, (static_cast<int>(as->index) == _selected_airport_index) ? TC_WHITE : TC_BLACK);
|
||||
row = row.Translate(0, this->line_height);
|
||||
text = text.Translate(0, this->line_height);
|
||||
}
|
||||
@@ -536,10 +537,9 @@ public:
|
||||
{
|
||||
/* First try to select an airport in the selected class. */
|
||||
AirportClass *sel_apclass = AirportClass::Get(_selected_airport_class);
|
||||
for (uint i = 0; i < sel_apclass->GetSpecCount(); i++) {
|
||||
const AirportSpec *as = sel_apclass->GetSpec(i);
|
||||
for (const AirportSpec *as : sel_apclass->Specs()) {
|
||||
if (as->IsAvailable()) {
|
||||
this->SelectOtherAirport(i);
|
||||
this->SelectOtherAirport(as->index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -551,7 +551,7 @@ public:
|
||||
if (as->IsAvailable()) {
|
||||
_selected_airport_class = cls.Index();
|
||||
this->vscroll->SetCount(cls.GetSpecCount());
|
||||
this->SelectOtherAirport(as->GetIndex());
|
||||
this->SelectOtherAirport(as->index);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -621,12 +621,12 @@ static WindowDesc _build_airport_desc(
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_build_airport_widgets), std::end(_nested_build_airport_widgets)
|
||||
_nested_build_airport_widgets
|
||||
);
|
||||
|
||||
static void ShowBuildAirportPicker(Window *parent)
|
||||
{
|
||||
new BuildAirportWindow(&_build_airport_desc, parent);
|
||||
new BuildAirportWindow(_build_airport_desc, parent);
|
||||
}
|
||||
|
||||
void InitializeAirportGui()
|
||||
|
@@ -8,7 +8,8 @@
|
||||
/** @file animated_tile.cpp Everything related to animated tiles. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/container_func.hpp"
|
||||
#include "animated_tile_func.h"
|
||||
#include "animated_tile_map.h"
|
||||
#include "tile_cmd.h"
|
||||
#include "viewport_func.h"
|
||||
#include "framerate_type.h"
|
||||
@@ -19,28 +20,53 @@
|
||||
std::vector<TileIndex> _animated_tiles;
|
||||
|
||||
/**
|
||||
* Removes the given tile from the animated tile table.
|
||||
* Stops animation on the given tile.
|
||||
* @param tile the tile to remove
|
||||
* @param immediate immediately delete the tile from the animated tile list instead of waiting for the next tick.
|
||||
*/
|
||||
void DeleteAnimatedTile(TileIndex tile)
|
||||
void DeleteAnimatedTile(TileIndex tile, bool immediate)
|
||||
{
|
||||
auto to_remove = std::find(_animated_tiles.begin(), _animated_tiles.end(), tile);
|
||||
if (to_remove != _animated_tiles.end()) {
|
||||
/* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */
|
||||
_animated_tiles.erase(to_remove);
|
||||
MarkTileDirtyByTile(tile);
|
||||
if (immediate) {
|
||||
if (GetAnimatedTileState(tile) == AnimatedTileState::None) return;
|
||||
|
||||
/* The tile may be switched to a non-animatable tile soon, so we should remove it from the
|
||||
* animated tile list early. */
|
||||
SetAnimatedTileState(tile, AnimatedTileState::None);
|
||||
|
||||
/* To avoid having to move everything after this tile in the animated tile list, look for this tile
|
||||
* in the animated tile list and replace with last entry if not last. */
|
||||
auto it = std::ranges::find(_animated_tiles, tile);
|
||||
if (it == std::end(_animated_tiles)) return;
|
||||
|
||||
if (std::next(it) != std::end(_animated_tiles)) *it = _animated_tiles.back();
|
||||
_animated_tiles.pop_back();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the tile was animated, mark it for deletion from the tile list on the next animation loop. */
|
||||
if (GetAnimatedTileState(tile) == AnimatedTileState::Animated) SetAnimatedTileState(tile, AnimatedTileState::Deleted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given tile to the animated tile table (if it does not exist
|
||||
* on that table yet). Also increases the size of the table if necessary.
|
||||
* Add the given tile to the animated tile table (if it does not exist yet).
|
||||
* @param tile the tile to make animated
|
||||
* @param mark_dirty whether to also mark the tile dirty.
|
||||
*/
|
||||
void AddAnimatedTile(TileIndex tile)
|
||||
void AddAnimatedTile(TileIndex tile, bool mark_dirty)
|
||||
{
|
||||
MarkTileDirtyByTile(tile);
|
||||
include(_animated_tiles, tile);
|
||||
if (mark_dirty) MarkTileDirtyByTile(tile);
|
||||
|
||||
const AnimatedTileState state = GetAnimatedTileState(tile);
|
||||
|
||||
/* Tile is already animated so nothing needs to happen. */
|
||||
if (state == AnimatedTileState::Animated) return;
|
||||
|
||||
/* Tile has no previous animation state, so add to the tile list. If the state is anything
|
||||
* other than None (e.g. Deleted) then the tile will still be in the list and does not need to be added again. */
|
||||
if (state == AnimatedTileState::None) _animated_tiles.push_back(tile);
|
||||
|
||||
SetAnimatedTileState(tile, AnimatedTileState::Animated);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,22 +74,29 @@ void AddAnimatedTile(TileIndex tile)
|
||||
*/
|
||||
void AnimateAnimatedTiles()
|
||||
{
|
||||
PerformanceAccumulator framerate(PFE_GL_LANDSCAPE);
|
||||
PerformanceAccumulator landscape_framerate(PFE_GL_LANDSCAPE);
|
||||
|
||||
const TileIndex *ti = _animated_tiles.data();
|
||||
while (ti < _animated_tiles.data() + _animated_tiles.size()) {
|
||||
const TileIndex curr = *ti;
|
||||
AnimateTile(curr);
|
||||
/* During the AnimateTile call, DeleteAnimatedTile could have been called,
|
||||
* deleting an element we've already processed and pushing the rest one
|
||||
* slot to the left. We can detect this by checking whether the index
|
||||
* in the current slot has changed - if it has, an element has been deleted,
|
||||
* and we should process the current slot again instead of going forward.
|
||||
* NOTE: this will still break if more than one animated tile is being
|
||||
* deleted during the same AnimateTile call, but no code seems to
|
||||
* be doing this anyway.
|
||||
*/
|
||||
if (*ti == curr) ++ti;
|
||||
for (auto it = std::begin(_animated_tiles); it != std::end(_animated_tiles); /* nothing */) {
|
||||
TileIndex &tile = *it;
|
||||
|
||||
if (GetAnimatedTileState(tile) != AnimatedTileState::Animated) {
|
||||
/* Tile should not be animated any more, mark it as not animated and erase it from the list. */
|
||||
SetAnimatedTileState(tile, AnimatedTileState::None);
|
||||
|
||||
/* Removing the last entry, no need to swap and continue. */
|
||||
if (std::next(it) == std::end(_animated_tiles)) {
|
||||
_animated_tiles.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Replace the current list entry with the back of the list to avoid moving elements. */
|
||||
*it = _animated_tiles.back();
|
||||
_animated_tiles.pop_back();
|
||||
continue;
|
||||
}
|
||||
|
||||
AnimateTile(tile);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,8 @@
|
||||
|
||||
#include "tile_type.h"
|
||||
|
||||
void AddAnimatedTile(TileIndex tile);
|
||||
void DeleteAnimatedTile(TileIndex tile);
|
||||
void AddAnimatedTile(TileIndex tile, bool mark_dirty = true);
|
||||
void DeleteAnimatedTile(TileIndex tile, bool immediate = false);
|
||||
void AnimateAnimatedTiles();
|
||||
void InitializeAnimatedTiles();
|
||||
|
||||
|
44
src/animated_tile_map.h
Normal file
44
src/animated_tile_map.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file animated_tile_map.h Maps accessors for animated tiles. */
|
||||
|
||||
#ifndef ANIMATED_TILE_MAP_H
|
||||
#define ANIMATED_TILE_MAP_H
|
||||
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "map_func.h"
|
||||
|
||||
/**
|
||||
* Animation state of a possibly-animated tile.
|
||||
*/
|
||||
enum class AnimatedTileState : uint8_t {
|
||||
None = 0, ///< Tile is not animated.
|
||||
Deleted = 1, ///< Tile was animated but should be removed.
|
||||
Animated = 3, ///< Tile is animated.
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the animated state of a tile.
|
||||
* @param t The tile.
|
||||
* @returns true iff the tile is animated.
|
||||
*/
|
||||
inline AnimatedTileState GetAnimatedTileState(Tile t)
|
||||
{
|
||||
return static_cast<AnimatedTileState>(GB(t.m6(), 0, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the animated state of a tile.
|
||||
* @param t The tile.
|
||||
*/
|
||||
inline void SetAnimatedTileState(Tile t, AnimatedTileState state)
|
||||
{
|
||||
SB(t.m6(), 0, 2, to_underlying(state));
|
||||
}
|
||||
|
||||
#endif /* ANIMATED_TILE_MAP_H */
|
@@ -99,18 +99,15 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
|
||||
|
||||
|
||||
/**
|
||||
* Returns the default (non-refitted) capacity of a specific EngineID.
|
||||
* Returns the default (non-refitted) cargo and capacity of a specific EngineID.
|
||||
* @param engine the EngineID of interest
|
||||
* @param cargo_type returns the default cargo type, if needed
|
||||
* @return capacity
|
||||
* @return cargo and capacity
|
||||
*/
|
||||
static inline uint16_t GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type)
|
||||
static inline std::pair<CargoID, uint16_t> GetVehicleDefaultCapacity(EngineID engine)
|
||||
{
|
||||
const Engine *e = Engine::Get(engine);
|
||||
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : INVALID_CARGO);
|
||||
if (cargo_type != nullptr) *cargo_type = cargo;
|
||||
if (!IsValidCargoID(cargo)) return 0;
|
||||
return e->GetDisplayDefaultCapacity();
|
||||
CargoID cargo = e->CanCarryCargo() ? e->GetDefaultCargoType() : INVALID_CARGO;
|
||||
return {cargo, IsValidCargoID(cargo) ? e->GetDisplayDefaultCapacity() : 0};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,9 +140,9 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
|
||||
CargoArray capacity{};
|
||||
const Engine *e = Engine::Get(engine);
|
||||
|
||||
CargoID cargo_type;
|
||||
uint16_t cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
|
||||
if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
|
||||
if (auto [cargo, cap] = GetVehicleDefaultCapacity(engine); IsValidCargoID(cargo)) {
|
||||
capacity[cargo] = cap;
|
||||
}
|
||||
|
||||
if (!e->IsGroundVehicle()) return capacity;
|
||||
|
||||
@@ -155,8 +152,9 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
|
||||
EngineID artic_engine = GetNextArticulatedPart(i, engine);
|
||||
if (artic_engine == INVALID_ENGINE) break;
|
||||
|
||||
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
|
||||
if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
|
||||
if (auto [cargo, cap] = GetVehicleDefaultCapacity(artic_engine); IsValidCargoID(cargo)) {
|
||||
capacity[cargo] += cap;
|
||||
}
|
||||
}
|
||||
|
||||
return capacity;
|
||||
@@ -172,9 +170,9 @@ CargoTypes GetCargoTypesOfArticulatedParts(EngineID engine)
|
||||
CargoTypes cargoes = 0;
|
||||
const Engine *e = Engine::Get(engine);
|
||||
|
||||
CargoID cargo_type;
|
||||
uint16_t cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
|
||||
if (cargo_type < NUM_CARGO && cargo_capacity > 0) SetBit(cargoes, cargo_type);
|
||||
if (auto [cargo, cap] = GetVehicleDefaultCapacity(engine); IsValidCargoID(cargo) && cap > 0) {
|
||||
SetBit(cargoes, cargo);
|
||||
}
|
||||
|
||||
if (!e->IsGroundVehicle()) return cargoes;
|
||||
|
||||
@@ -184,8 +182,9 @@ CargoTypes GetCargoTypesOfArticulatedParts(EngineID engine)
|
||||
EngineID artic_engine = GetNextArticulatedPart(i, engine);
|
||||
if (artic_engine == INVALID_ENGINE) break;
|
||||
|
||||
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
|
||||
if (cargo_type < NUM_CARGO && cargo_capacity > 0) SetBit(cargoes, cargo_type);
|
||||
if (auto [cargo, cap] = GetVehicleDefaultCapacity(artic_engine); IsValidCargoID(cargo) && cap > 0) {
|
||||
SetBit(cargoes, cargo);
|
||||
}
|
||||
}
|
||||
|
||||
return cargoes;
|
||||
|
@@ -167,7 +167,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
if (side == 1) {
|
||||
/* ensure primary engine of variant group is in list */
|
||||
for (const auto &variant : variants) {
|
||||
if (std::find(list.begin(), list.end(), variant) == list.end()) {
|
||||
if (std::ranges::find(list, variant, &GUIEngineListItem::engine_id) == list.end()) {
|
||||
const Engine *e = Engine::Get(variant);
|
||||
list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
}
|
||||
|
||||
public:
|
||||
ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
|
||||
ReplaceVehicleWindow(WindowDesc &desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
|
||||
{
|
||||
this->sel_railtype = INVALID_RAILTYPE;
|
||||
this->sel_roadtype = INVALID_ROADTYPE;
|
||||
@@ -594,7 +594,7 @@ public:
|
||||
if (it != this->engines[click_side].end()) {
|
||||
const auto &item = *it;
|
||||
const Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.matrix).WithWidth(WidgetDimensions::scaled.hsep_indent * (item.indent + 1), _current_text_dir == TD_RTL);
|
||||
if ((item.flags & EngineDisplayFlags::HasVariants) != EngineDisplayFlags::None && IsInsideMM(r.left, r.right, pt.x)) {
|
||||
if (HasFlag(item.flags, EngineDisplayFlags::HasVariants) && IsInsideMM(r.left, r.right, pt.x)) {
|
||||
/* toggle folded flag on engine */
|
||||
assert(item.variant_id != INVALID_ENGINE);
|
||||
Engine *engine = Engine::Get(item.variant_id);
|
||||
@@ -604,7 +604,7 @@ public:
|
||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
|
||||
return;
|
||||
}
|
||||
if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) e = item.engine_id;
|
||||
if (!HasFlag(item.flags, EngineDisplayFlags::Shaded)) e = item.engine_id;
|
||||
}
|
||||
|
||||
/* If Ctrl is pressed on the left side and we don't have any engines of the selected type, stop autoreplacing.
|
||||
@@ -715,10 +715,10 @@ static constexpr NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
@@ -766,7 +766,7 @@ static WindowDesc _replace_rail_vehicle_desc(
|
||||
WDP_AUTO, "replace_vehicle_train", 500, 140,
|
||||
WC_REPLACE_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_replace_rail_vehicle_widgets), std::end(_nested_replace_rail_vehicle_widgets)
|
||||
_nested_replace_rail_vehicle_widgets
|
||||
);
|
||||
|
||||
static constexpr NWidgetPart _nested_replace_road_vehicle_widgets[] = {
|
||||
@@ -779,10 +779,10 @@ static constexpr NWidgetPart _nested_replace_road_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
@@ -824,7 +824,7 @@ static WindowDesc _replace_road_vehicle_desc(
|
||||
WDP_AUTO, "replace_vehicle_road", 500, 140,
|
||||
WC_REPLACE_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_replace_road_vehicle_widgets), std::end(_nested_replace_road_vehicle_widgets)
|
||||
_nested_replace_road_vehicle_widgets
|
||||
);
|
||||
|
||||
static constexpr NWidgetPart _nested_replace_vehicle_widgets[] = {
|
||||
@@ -837,10 +837,10 @@ static constexpr NWidgetPart _nested_replace_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
@@ -878,7 +878,7 @@ static WindowDesc _replace_vehicle_desc(
|
||||
WDP_AUTO, "replace_vehicle", 456, 118,
|
||||
WC_REPLACE_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_replace_vehicle_widgets), std::end(_nested_replace_vehicle_widgets)
|
||||
_nested_replace_vehicle_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -889,11 +889,9 @@ static WindowDesc _replace_vehicle_desc(
|
||||
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
|
||||
{
|
||||
CloseWindowById(WC_REPLACE_VEHICLE, vehicletype);
|
||||
WindowDesc *desc;
|
||||
switch (vehicletype) {
|
||||
case VEH_TRAIN: desc = &_replace_rail_vehicle_desc; break;
|
||||
case VEH_ROAD: desc = &_replace_road_vehicle_desc; break;
|
||||
default: desc = &_replace_vehicle_desc; break;
|
||||
case VEH_TRAIN: new ReplaceVehicleWindow(_replace_rail_vehicle_desc, vehicletype, id_g); break;
|
||||
case VEH_ROAD: new ReplaceVehicleWindow(_replace_road_vehicle_desc, vehicletype, id_g); break;
|
||||
default: new ReplaceVehicleWindow(_replace_vehicle_desc, vehicletype, id_g); break;
|
||||
}
|
||||
new ReplaceVehicleWindow(desc, vehicletype, id_g);
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
/**
|
||||
* Autoslope check for tiles with an entrance on an edge.
|
||||
* E.g. depots and non-drive-through-road-stops.
|
||||
* E.g. depots and bay road-stops.
|
||||
*
|
||||
* The test succeeds if the slope is not steep and at least one corner of the entrance edge is on the TileMaxZ() level.
|
||||
*
|
||||
@@ -34,6 +34,27 @@ inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh
|
||||
return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoslope check for tiles with something built along an axis.
|
||||
* E.g. railway stations and drive through road stops.
|
||||
*
|
||||
* The test succeeds if the slope is not steep and at least one corner at either of the entrance edges is on the TileMaxZ() level.
|
||||
*
|
||||
* @note The test does not check if autoslope is enabled at all.
|
||||
*
|
||||
* @param tile The tile.
|
||||
* @param z_new New TileZ.
|
||||
* @param tileh_new New TileSlope.
|
||||
* @param axis The axis.
|
||||
* @return true iff terraforming is allowed.
|
||||
*/
|
||||
inline bool AutoslopeCheckForAxis(TileIndex tile, int z_new, Slope tileh_new, Axis axis)
|
||||
{
|
||||
DiagDirection direction = AxisToDiagDir(axis);
|
||||
return AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction) &&
|
||||
AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if autoslope is enabled for _current_company.
|
||||
*
|
||||
|
@@ -196,11 +196,11 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
}
|
||||
|
||||
private:
|
||||
void SetRoadStopTileData(TileIndex tile, uint8_t data, bool animation);
|
||||
bool SetRoadStopTileData(TileIndex tile, uint8_t data, bool animation);
|
||||
|
||||
public:
|
||||
inline void SetRoadStopRandomBits(TileIndex tile, uint8_t random_bits) { this->SetRoadStopTileData(tile, random_bits, false); }
|
||||
inline void SetRoadStopAnimationFrame(TileIndex tile, uint8_t frame) { this->SetRoadStopTileData(tile, frame, true); }
|
||||
inline bool SetRoadStopAnimationFrame(TileIndex tile, uint8_t frame) { return this->SetRoadStopTileData(tile, frame, true); }
|
||||
void RemoveRoadStopTileData(TileIndex tile);
|
||||
|
||||
static void PostDestructor(size_t index);
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent, bool animated>
|
||||
void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override {
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override {
|
||||
return Blitter_32bppSSE_Base::Encode(sprite, allocator);
|
||||
}
|
||||
std::string_view GetName() override { return "32bpp-sse4-anim"; }
|
||||
|
@@ -285,7 +285,7 @@ void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
|
||||
this->Draw<false>(bp, mode, zoom);
|
||||
}
|
||||
|
||||
template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
/* streams of pixels (a, r, g, b channels)
|
||||
*
|
||||
@@ -414,7 +414,7 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
||||
len += lengths[z][0] + lengths[z][1];
|
||||
}
|
||||
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(SpriteData) + len);
|
||||
Sprite *dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite) + sizeof(SpriteData) + len);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
@@ -438,10 +438,10 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
||||
return dest_sprite;
|
||||
}
|
||||
|
||||
template Sprite *Blitter_32bppOptimized::EncodeInternal<true>(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);
|
||||
template Sprite *Blitter_32bppOptimized::EncodeInternal<false>(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);
|
||||
template Sprite *Blitter_32bppOptimized::EncodeInternal<true>(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator);
|
||||
template Sprite *Blitter_32bppOptimized::EncodeInternal<false>(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator);
|
||||
|
||||
Sprite *Blitter_32bppOptimized::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_32bppOptimized::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
return this->EncodeInternal<true>(sprite, allocator);
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public:
|
||||
};
|
||||
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
|
||||
|
||||
std::string_view GetName() override { return "32bpp-optimized"; }
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
|
||||
protected:
|
||||
template <bool Tpal_to_rgb> void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
||||
template <bool Tpal_to_rgb> Sprite *EncodeInternal(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);
|
||||
template <bool Tpal_to_rgb> Sprite *EncodeInternal(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator);
|
||||
};
|
||||
|
||||
/** Factory for the optimised 32 bpp blitter (without palette animation). */
|
||||
|
@@ -115,10 +115,10 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
|
||||
Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
|
||||
}
|
||||
|
||||
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
Blitter_32bppSimple::Pixel *dst;
|
||||
Sprite *dest_sprite = static_cast<Sprite *>(allocator(sizeof(*dest_sprite) + static_cast<size_t>(sprite[ZOOM_LVL_MIN].height) * static_cast<size_t>(sprite[ZOOM_LVL_MIN].width) * sizeof(*dst)));
|
||||
Sprite *dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite) + static_cast<size_t>(sprite[ZOOM_LVL_MIN].height) * static_cast<size_t>(sprite[ZOOM_LVL_MIN].width) * sizeof(*dst));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
|
@@ -26,7 +26,7 @@ class Blitter_32bppSimple : public Blitter_32bppBase {
|
||||
public:
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
|
||||
|
||||
std::string_view GetName() override { return "32bpp-simple"; }
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@
|
||||
/** Instantiation of the SSE2 32bpp blitter factory. */
|
||||
static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
|
||||
|
||||
Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
/* First uint32_t of a line = the number of transparent pixels from the left.
|
||||
* Second uint32_t of a line = the number of transparent pixels from the right.
|
||||
@@ -51,7 +51,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
all_sprites_size += rgba_size + mv_size;
|
||||
}
|
||||
|
||||
Sprite *dst_sprite = (Sprite *) allocator(sizeof(Sprite) + sizeof(SpriteData) + all_sprites_size);
|
||||
Sprite *dst_sprite = allocator.Allocate<Sprite>(sizeof(Sprite) + sizeof(SpriteData) + all_sprites_size);
|
||||
dst_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dst_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dst_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
|
@@ -76,7 +76,7 @@ public:
|
||||
uint8_t data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator);
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(Blitter_32bppSSE_Base::SpriteFlags);
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
template <BlitterMode mode, Blitter_32bppSSE_Base::ReadMode read_mode, Blitter_32bppSSE_Base::BlockType bt_last, bool translucent>
|
||||
void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
||||
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override {
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override {
|
||||
return Blitter_32bppSSE_Base::Encode(sprite, allocator);
|
||||
}
|
||||
|
||||
|
@@ -397,7 +397,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
||||
}
|
||||
}
|
||||
|
||||
Sprite *Blitter_40bppAnim::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_40bppAnim::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
return this->EncodeInternal<false>(sprite, allocator);
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override;
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
|
||||
size_t BufferSize(uint width, uint height) override;
|
||||
Blitter::PaletteAnimation UsePaletteAnimation() override;
|
||||
bool NeedsAnimationBuffer() override;
|
||||
|
@@ -120,7 +120,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
||||
}
|
||||
}
|
||||
|
||||
Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
/* Make memory for all zoom-levels */
|
||||
uint memory = sizeof(SpriteData);
|
||||
@@ -219,7 +219,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
assert(size < memory);
|
||||
|
||||
/* Allocate the exact amount of memory we need */
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + size);
|
||||
Sprite *dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite) + size);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
|
@@ -23,7 +23,7 @@ public:
|
||||
};
|
||||
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
|
||||
|
||||
std::string_view GetName() override { return "8bpp-optimized"; }
|
||||
};
|
||||
|
@@ -61,10 +61,10 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
||||
}
|
||||
}
|
||||
|
||||
Sprite *Blitter_8bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_8bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
Sprite *dest_sprite;
|
||||
dest_sprite = static_cast<Sprite *>(allocator(sizeof(*dest_sprite) + static_cast<size_t>(sprite[ZOOM_LVL_MIN].height) * static_cast<size_t>(sprite[ZOOM_LVL_MIN].width)));
|
||||
dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite) + static_cast<size_t>(sprite[ZOOM_LVL_MIN].height) * static_cast<size_t>(sprite[ZOOM_LVL_MIN].width));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
|
@@ -17,7 +17,7 @@
|
||||
class Blitter_8bppSimple final : public Blitter_8bppBase {
|
||||
public:
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
|
||||
|
||||
std::string_view GetName() override { return "8bpp-simple"; }
|
||||
};
|
||||
|
@@ -15,10 +15,10 @@
|
||||
/** Instantiation of the null blitter factory. */
|
||||
static FBlitter_Null iFBlitter_Null;
|
||||
|
||||
Sprite *Blitter_Null::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
Sprite *Blitter_Null::Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)
|
||||
{
|
||||
Sprite *dest_sprite;
|
||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite));
|
||||
dest_sprite = allocator.Allocate<Sprite>(sizeof(*dest_sprite));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
|
@@ -18,7 +18,7 @@ public:
|
||||
uint8_t GetScreenDepth() override { return 0; }
|
||||
void Draw(Blitter::BlitterParams *, BlitterMode, ZoomLevel) override {};
|
||||
void DrawColourMappingRect(void *, int, int, PaletteID) override {};
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator) override;
|
||||
void *MoveTo(void *, int, int) override { return nullptr; };
|
||||
void SetPixel(void *, int, int, uint8_t) override {};
|
||||
void DrawRect(void *, int, int, uint8_t) override {};
|
||||
|
328
src/bmp.cpp
328
src/bmp.cpp
@@ -8,97 +8,32 @@
|
||||
/** @file bmp.cpp Read and write support for bmps. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "random_access_file_type.h"
|
||||
#include "bmp.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/alloc_func.hpp"
|
||||
#include "core/mem_func.hpp"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
|
||||
{
|
||||
buffer->pos = -1;
|
||||
buffer->file = file;
|
||||
buffer->read = 0;
|
||||
buffer->real_pos = ftell(file);
|
||||
}
|
||||
|
||||
static inline void AdvanceBuffer(BmpBuffer *buffer)
|
||||
{
|
||||
if (buffer->read < 0) return;
|
||||
|
||||
buffer->read = (int)fread(buffer->data, 1, BMP_BUFFER_SIZE, buffer->file);
|
||||
buffer->pos = 0;
|
||||
}
|
||||
|
||||
static inline bool EndOfBuffer(BmpBuffer *buffer)
|
||||
{
|
||||
if (buffer->read < 0) return false;
|
||||
|
||||
if (buffer->pos == buffer->read || buffer->pos < 0) AdvanceBuffer(buffer);
|
||||
return buffer->pos == buffer->read;
|
||||
}
|
||||
|
||||
static inline uint8_t ReadByte(BmpBuffer *buffer)
|
||||
{
|
||||
if (buffer->read < 0) return 0;
|
||||
|
||||
if (buffer->pos == buffer->read || buffer->pos < 0) AdvanceBuffer(buffer);
|
||||
buffer->real_pos++;
|
||||
return buffer->data[buffer->pos++];
|
||||
}
|
||||
|
||||
static inline uint16_t ReadWord(BmpBuffer *buffer)
|
||||
{
|
||||
uint16_t var = ReadByte(buffer);
|
||||
return var | (ReadByte(buffer) << 8);
|
||||
}
|
||||
|
||||
static inline uint32_t ReadDword(BmpBuffer *buffer)
|
||||
{
|
||||
uint32_t var = ReadWord(buffer);
|
||||
return var | (ReadWord(buffer) << 16);
|
||||
}
|
||||
|
||||
static inline void SkipBytes(BmpBuffer *buffer, int bytes)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < bytes; i++) ReadByte(buffer);
|
||||
}
|
||||
|
||||
static inline void SetStreamOffset(BmpBuffer *buffer, int offset)
|
||||
{
|
||||
if (fseek(buffer->file, offset, SEEK_SET) < 0) {
|
||||
buffer->read = -1;
|
||||
}
|
||||
buffer->pos = -1;
|
||||
buffer->real_pos = offset;
|
||||
AdvanceBuffer(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a 1 bpp uncompressed bitmap
|
||||
* The bitmap is converted to a 8 bpp bitmap
|
||||
*/
|
||||
static inline bool BmpRead1(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead1(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint x, y, i;
|
||||
uint8_t pad = GB(4 - info->width / 8, 0, 2);
|
||||
uint8_t *pixel_row;
|
||||
uint8_t b;
|
||||
for (y = info->height; y > 0; y--) {
|
||||
x = 0;
|
||||
pixel_row = &data->bitmap[(y - 1) * info->width];
|
||||
while (x < info->width) {
|
||||
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
|
||||
b = ReadByte(buffer);
|
||||
for (i = 8; i > 0; i--) {
|
||||
if (x < info->width) *pixel_row++ = GB(b, i - 1, 1);
|
||||
uint8_t pad = GB(4 - info.width / 8, 0, 2);
|
||||
for (uint y = info.height; y > 0; y--) {
|
||||
uint x = 0;
|
||||
uint8_t *pixel_row = &data.bitmap[(y - 1) * static_cast<size_t>(info.width)];
|
||||
while (x < info.width) {
|
||||
if (file.AtEndOfFile()) return false; // the file is shorter than expected
|
||||
uint8_t b = file.ReadByte();
|
||||
for (uint i = 8; i > 0; i--) {
|
||||
if (x < info.width) *pixel_row++ = GB(b, i - 1, 1);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
/* Padding for 32 bit align */
|
||||
SkipBytes(buffer, pad);
|
||||
file.SkipBytes(pad);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -107,27 +42,24 @@ static inline bool BmpRead1(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
* Reads a 4 bpp uncompressed bitmap
|
||||
* The bitmap is converted to a 8 bpp bitmap
|
||||
*/
|
||||
static inline bool BmpRead4(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead4(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint x, y;
|
||||
uint8_t pad = GB(4 - info->width / 2, 0, 2);
|
||||
uint8_t *pixel_row;
|
||||
uint8_t b;
|
||||
for (y = info->height; y > 0; y--) {
|
||||
x = 0;
|
||||
pixel_row = &data->bitmap[(y - 1) * info->width];
|
||||
while (x < info->width) {
|
||||
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
|
||||
b = ReadByte(buffer);
|
||||
uint8_t pad = GB(4 - info.width / 2, 0, 2);
|
||||
for (uint y = info.height; y > 0; y--) {
|
||||
uint x = 0;
|
||||
uint8_t *pixel_row = &data.bitmap[(y - 1) * static_cast<size_t>(info.width)];
|
||||
while (x < info.width) {
|
||||
if (file.AtEndOfFile()) return false; // the file is shorter than expected
|
||||
uint8_t b = file.ReadByte();
|
||||
*pixel_row++ = GB(b, 4, 4);
|
||||
x++;
|
||||
if (x < info->width) {
|
||||
if (x < info.width) {
|
||||
*pixel_row++ = GB(b, 0, 4);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
/* Padding for 32 bit align */
|
||||
SkipBytes(buffer, pad);
|
||||
file.SkipBytes(pad);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -136,56 +68,56 @@ static inline bool BmpRead4(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
* Reads a 4-bit RLE compressed bitmap
|
||||
* The bitmap is converted to a 8 bpp bitmap
|
||||
*/
|
||||
static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead4Rle(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint x = 0;
|
||||
uint y = info->height - 1;
|
||||
uint8_t *pixel = &data->bitmap[y * info->width];
|
||||
while (y != 0 || x < info->width) {
|
||||
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
|
||||
uint y = info.height - 1;
|
||||
uint8_t *pixel = &data.bitmap[y * static_cast<size_t>(info.width)];
|
||||
while (y != 0 || x < info.width) {
|
||||
if (file.AtEndOfFile()) return false; // the file is shorter than expected
|
||||
|
||||
uint8_t n = ReadByte(buffer);
|
||||
uint8_t c = ReadByte(buffer);
|
||||
uint8_t n = file.ReadByte();
|
||||
uint8_t c = file.ReadByte();
|
||||
if (n == 0) {
|
||||
switch (c) {
|
||||
case 0: // end of line
|
||||
x = 0;
|
||||
if (y == 0) return false;
|
||||
pixel = &data->bitmap[--y * info->width];
|
||||
pixel = &data.bitmap[--y * static_cast<size_t>(info.width)];
|
||||
break;
|
||||
|
||||
case 1: // end of bitmap
|
||||
return true;
|
||||
|
||||
case 2: { // delta
|
||||
if (EndOfBuffer(buffer)) return false;
|
||||
uint8_t dx = ReadByte(buffer);
|
||||
uint8_t dy = ReadByte(buffer);
|
||||
if (file.AtEndOfFile()) return false;
|
||||
uint8_t dx = file.ReadByte();
|
||||
uint8_t dy = file.ReadByte();
|
||||
|
||||
/* Check for over- and underflow. */
|
||||
if (x + dx >= info->width || x + dx < x || dy > y) return false;
|
||||
if (x + dx >= info.width || x + dx < x || dy > y) return false;
|
||||
|
||||
x += dx;
|
||||
y -= dy;
|
||||
pixel = &data->bitmap[y * info->width + x];
|
||||
pixel = &data.bitmap[y * info.width + x];
|
||||
break;
|
||||
}
|
||||
|
||||
default: { // uncompressed
|
||||
uint i = 0;
|
||||
while (i++ < c) {
|
||||
if (EndOfBuffer(buffer) || x >= info->width) return false;
|
||||
uint8_t b = ReadByte(buffer);
|
||||
if (file.AtEndOfFile() || x >= info.width) return false;
|
||||
uint8_t b = file.ReadByte();
|
||||
*pixel++ = GB(b, 4, 4);
|
||||
x++;
|
||||
if (i++ < c) {
|
||||
if (x >= info->width) return false;
|
||||
if (x >= info.width) return false;
|
||||
*pixel++ = GB(b, 0, 4);
|
||||
x++;
|
||||
}
|
||||
}
|
||||
/* Padding for 16 bit align */
|
||||
SkipBytes(buffer, ((c + 1) / 2) % 2);
|
||||
file.SkipBytes(((c + 1) / 2) % 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -194,10 +126,10 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
* pixels to be written is higher than the remaining line width.
|
||||
* Ignore the superfluous pixels instead of reporting an error. */
|
||||
uint i = 0;
|
||||
while (x < info->width && i++ < n) {
|
||||
while (x < info.width && i++ < n) {
|
||||
*pixel++ = GB(c, 4, 4);
|
||||
x++;
|
||||
if (x < info->width && i++ < n) {
|
||||
if (x < info.width && i++ < n) {
|
||||
*pixel++ = GB(c, 0, 4);
|
||||
x++;
|
||||
}
|
||||
@@ -210,18 +142,15 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
/**
|
||||
* Reads a 8 bpp bitmap
|
||||
*/
|
||||
static inline bool BmpRead8(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead8(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint i;
|
||||
uint y;
|
||||
uint8_t pad = GB(4 - info->width, 0, 2);
|
||||
uint8_t *pixel;
|
||||
for (y = info->height; y > 0; y--) {
|
||||
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
|
||||
pixel = &data->bitmap[(y - 1) * info->width];
|
||||
for (i = 0; i < info->width; i++) *pixel++ = ReadByte(buffer);
|
||||
uint8_t pad = GB(4 - info.width, 0, 2);
|
||||
for (uint y = info.height; y > 0; y--) {
|
||||
if (file.AtEndOfFile()) return false; // the file is shorter than expected
|
||||
uint8_t *pixel = &data.bitmap[(y - 1) * static_cast<size_t>(info.width)];
|
||||
for (uint i = 0; i < info.width; i++) *pixel++ = file.ReadByte();
|
||||
/* Padding for 32 bit align */
|
||||
SkipBytes(buffer, pad);
|
||||
file.SkipBytes(pad);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -229,49 +158,49 @@ static inline bool BmpRead8(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
/**
|
||||
* Reads a 8-bit RLE compressed bpp bitmap
|
||||
*/
|
||||
static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead8Rle(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint x = 0;
|
||||
uint y = info->height - 1;
|
||||
uint8_t *pixel = &data->bitmap[y * info->width];
|
||||
while (y != 0 || x < info->width) {
|
||||
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
|
||||
uint y = info.height - 1;
|
||||
uint8_t *pixel = &data.bitmap[y * static_cast<size_t>(info.width)];
|
||||
while (y != 0 || x < info.width) {
|
||||
if (file.AtEndOfFile()) return false; // the file is shorter than expected
|
||||
|
||||
uint8_t n = ReadByte(buffer);
|
||||
uint8_t c = ReadByte(buffer);
|
||||
uint8_t n = file.ReadByte();
|
||||
uint8_t c = file.ReadByte();
|
||||
if (n == 0) {
|
||||
switch (c) {
|
||||
case 0: // end of line
|
||||
x = 0;
|
||||
if (y == 0) return false;
|
||||
pixel = &data->bitmap[--y * info->width];
|
||||
pixel = &data.bitmap[--y * static_cast<size_t>(info.width)];
|
||||
break;
|
||||
|
||||
case 1: // end of bitmap
|
||||
return true;
|
||||
|
||||
case 2: { // delta
|
||||
if (EndOfBuffer(buffer)) return false;
|
||||
uint8_t dx = ReadByte(buffer);
|
||||
uint8_t dy = ReadByte(buffer);
|
||||
if (file.AtEndOfFile()) return false;
|
||||
uint8_t dx = file.ReadByte();
|
||||
uint8_t dy = file.ReadByte();
|
||||
|
||||
/* Check for over- and underflow. */
|
||||
if (x + dx >= info->width || x + dx < x || dy > y) return false;
|
||||
if (x + dx >= info.width || x + dx < x || dy > y) return false;
|
||||
|
||||
x += dx;
|
||||
y -= dy;
|
||||
pixel = &data->bitmap[y * info->width + x];
|
||||
pixel = &data.bitmap[y * static_cast<size_t>(info.width) + x];
|
||||
break;
|
||||
}
|
||||
|
||||
default: { // uncompressed
|
||||
for (uint i = 0; i < c; i++) {
|
||||
if (EndOfBuffer(buffer) || x >= info->width) return false;
|
||||
*pixel++ = ReadByte(buffer);
|
||||
if (file.AtEndOfFile() || x >= info.width) return false;
|
||||
*pixel++ = file.ReadByte();
|
||||
x++;
|
||||
}
|
||||
/* Padding for 16 bit align */
|
||||
SkipBytes(buffer, c % 2);
|
||||
file.SkipBytes(c % 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -279,7 +208,7 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
/* Apparently it is common to encounter BMPs where the count of
|
||||
* pixels to be written is higher than the remaining line width.
|
||||
* Ignore the superfluous pixels instead of reporting an error. */
|
||||
for (uint i = 0; x < info->width && i < n; i++) {
|
||||
for (uint i = 0; x < info.width && i < n; i++) {
|
||||
*pixel++ = c;
|
||||
x++;
|
||||
}
|
||||
@@ -291,22 +220,20 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
/**
|
||||
* Reads a 24 bpp uncompressed bitmap
|
||||
*/
|
||||
static inline bool BmpRead24(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead24(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint x, y;
|
||||
uint8_t pad = GB(4 - info->width * 3, 0, 2);
|
||||
uint8_t *pixel_row;
|
||||
for (y = info->height; y > 0; y--) {
|
||||
pixel_row = &data->bitmap[(y - 1) * info->width * 3];
|
||||
for (x = 0; x < info->width; x++) {
|
||||
if (EndOfBuffer(buffer)) return false; // the file is shorter than expected
|
||||
*(pixel_row + 2) = ReadByte(buffer); // green
|
||||
*(pixel_row + 1) = ReadByte(buffer); // blue
|
||||
*pixel_row = ReadByte(buffer); // red
|
||||
uint8_t pad = GB(4 - info.width * 3, 0, 2);
|
||||
for (uint y = info.height; y > 0; --y) {
|
||||
uint8_t *pixel_row = &data.bitmap[(y - 1) * static_cast<size_t>(info.width) * 3];
|
||||
for (uint x = 0; x < info.width; ++x) {
|
||||
if (file.AtEndOfFile()) return false; // the file is shorter than expected
|
||||
*(pixel_row + 2) = file.ReadByte(); // green
|
||||
*(pixel_row + 1) = file.ReadByte(); // blue
|
||||
*pixel_row = file.ReadByte(); // red
|
||||
pixel_row += 3;
|
||||
}
|
||||
/* Padding for 32 bit align */
|
||||
SkipBytes(buffer, pad);
|
||||
file.SkipBytes(pad);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -314,109 +241,98 @@ static inline bool BmpRead24(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
/*
|
||||
* Reads bitmap headers, and palette (if any)
|
||||
*/
|
||||
bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
bool BmpReadHeader(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
uint32_t header_size;
|
||||
assert(info != nullptr);
|
||||
MemSetT(info, 0);
|
||||
info = {};
|
||||
|
||||
/* Reading BMP header */
|
||||
if (ReadWord(buffer) != 0x4D42) return false; // signature should be 'BM'
|
||||
SkipBytes(buffer, 8); // skip file size and reserved
|
||||
info->offset = ReadDword(buffer);
|
||||
if (file.ReadWord() != 0x4D42) return false; // signature should be 'BM'
|
||||
file.SkipBytes(8); // skip file size and reserved
|
||||
info.offset = file.ReadDword() + file.GetStartPos();
|
||||
|
||||
/* Reading info header */
|
||||
header_size = ReadDword(buffer);
|
||||
uint32_t header_size = file.ReadDword();
|
||||
if (header_size < 12) return false; // info header should be at least 12 bytes long
|
||||
|
||||
info->os2_bmp = (header_size == 12); // OS/2 1.x or windows 2.x info header is 12 bytes long
|
||||
info.os2_bmp = (header_size == 12); // OS/2 1.x or windows 2.x info header is 12 bytes long
|
||||
|
||||
if (info->os2_bmp) {
|
||||
info->width = ReadWord(buffer);
|
||||
info->height = ReadWord(buffer);
|
||||
if (info.os2_bmp) {
|
||||
info.width = file.ReadWord();
|
||||
info.height = file.ReadWord();
|
||||
header_size -= 8;
|
||||
} else {
|
||||
info->width = ReadDword(buffer);
|
||||
info->height = ReadDword(buffer);
|
||||
info.width = file.ReadDword();
|
||||
info.height = file.ReadDword();
|
||||
header_size -= 12;
|
||||
}
|
||||
|
||||
if (ReadWord(buffer) != 1) return false; // BMP can have only 1 plane
|
||||
if (file.ReadWord() != 1) return false; // BMP can have only 1 plane
|
||||
|
||||
info->bpp = ReadWord(buffer);
|
||||
if (info->bpp != 1 && info->bpp != 4 && info->bpp != 8 && info->bpp != 24) {
|
||||
info.bpp = file.ReadWord();
|
||||
if (info.bpp != 1 && info.bpp != 4 && info.bpp != 8 && info.bpp != 24) {
|
||||
/* Only 1 bpp, 4 bpp, 8bpp and 24 bpp bitmaps are supported */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Reads compression method if available in info header*/
|
||||
if ((header_size -= 4) >= 4) {
|
||||
info->compression = ReadDword(buffer);
|
||||
info.compression = file.ReadDword();
|
||||
header_size -= 4;
|
||||
}
|
||||
|
||||
/* Only 4-bit and 8-bit rle compression is supported */
|
||||
if (info->compression > 2 || (info->compression > 0 && !(info->bpp == 4 || info->bpp == 8))) return false;
|
||||
|
||||
if (info->bpp <= 8) {
|
||||
uint i;
|
||||
if (info.compression > 2 || (info.compression > 0 && !(info.bpp == 4 || info.bpp == 8))) return false;
|
||||
|
||||
if (info.bpp <= 8) {
|
||||
/* Reads number of colours if available in info header */
|
||||
if (header_size >= 16) {
|
||||
SkipBytes(buffer, 12); // skip image size and resolution
|
||||
info->palette_size = ReadDword(buffer); // number of colours in palette
|
||||
SkipBytes(buffer, header_size - 16); // skip the end of info header
|
||||
file.SkipBytes(12); // skip image size and resolution
|
||||
info.palette_size = file.ReadDword(); // number of colours in palette
|
||||
file.SkipBytes(header_size - 16); // skip the end of info header
|
||||
}
|
||||
|
||||
uint maximum_palette_size = 1U << info->bpp;
|
||||
if (info->palette_size == 0) info->palette_size = maximum_palette_size;
|
||||
uint maximum_palette_size = 1U << info.bpp;
|
||||
if (info.palette_size == 0) info.palette_size = maximum_palette_size;
|
||||
|
||||
/* More palette colours than palette indices is not supported. */
|
||||
if (info->palette_size > maximum_palette_size) return false;
|
||||
if (info.palette_size > maximum_palette_size) return false;
|
||||
|
||||
data->palette = CallocT<Colour>(info->palette_size);
|
||||
data.palette.resize(info.palette_size);
|
||||
|
||||
for (i = 0; i < info->palette_size; i++) {
|
||||
data->palette[i].b = ReadByte(buffer);
|
||||
data->palette[i].g = ReadByte(buffer);
|
||||
data->palette[i].r = ReadByte(buffer);
|
||||
if (!info->os2_bmp) SkipBytes(buffer, 1); // unused
|
||||
for (auto &colour : data.palette) {
|
||||
colour.b = file.ReadByte();
|
||||
colour.g = file.ReadByte();
|
||||
colour.r = file.ReadByte();
|
||||
if (!info.os2_bmp) file.SkipBytes(1); // unused
|
||||
}
|
||||
}
|
||||
|
||||
return buffer->real_pos <= info->offset;
|
||||
return file.GetPos() <= info.offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads the bitmap
|
||||
* 1 bpp and 4 bpp bitmaps are converted to 8 bpp bitmaps
|
||||
*/
|
||||
bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
bool BmpReadBitmap(RandomAccessFile &file, BmpInfo &info, BmpData &data)
|
||||
{
|
||||
assert(info != nullptr && data != nullptr);
|
||||
|
||||
data->bitmap = CallocT<uint8_t>(static_cast<size_t>(info->width) * info->height * ((info->bpp == 24) ? 3 : 1));
|
||||
data.bitmap.resize(static_cast<size_t>(info.width) * info.height * ((info.bpp == 24) ? 3 : 1));
|
||||
|
||||
/* Load image */
|
||||
SetStreamOffset(buffer, info->offset);
|
||||
switch (info->compression) {
|
||||
case 0: // no compression
|
||||
switch (info->bpp) {
|
||||
case 1: return BmpRead1(buffer, info, data);
|
||||
case 4: return BmpRead4(buffer, info, data);
|
||||
case 8: return BmpRead8(buffer, info, data);
|
||||
case 24: return BmpRead24(buffer, info, data);
|
||||
file.SeekTo(info.offset, SEEK_SET);
|
||||
switch (info.compression) {
|
||||
case 0: // no compression
|
||||
switch (info.bpp) {
|
||||
case 1: return BmpRead1(file, info, data);
|
||||
case 4: return BmpRead4(file, info, data);
|
||||
case 8: return BmpRead8(file, info, data);
|
||||
case 24: return BmpRead24(file, info, data);
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: return BmpRead8Rle(file, info, data); // 8-bit RLE compression
|
||||
case 2: return BmpRead4Rle(file, info, data); // 4-bit RLE compression
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
case 1: return BmpRead8Rle(buffer, info, data); // 8-bit RLE compression
|
||||
case 2: return BmpRead4Rle(buffer, info, data); // 4-bit RLE compression
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void BmpDestroyData(BmpData *data)
|
||||
{
|
||||
assert(data != nullptr);
|
||||
free(data->palette);
|
||||
free(data->bitmap);
|
||||
}
|
||||
|
23
src/bmp.h
23
src/bmp.h
@@ -11,9 +11,10 @@
|
||||
#define BMP_H
|
||||
|
||||
#include "gfx_type.h"
|
||||
#include "random_access_file_type.h"
|
||||
|
||||
struct BmpInfo {
|
||||
uint32_t offset; ///< offset of bitmap data from .bmp file beginning
|
||||
size_t offset; ///< offset of bitmap data from .bmp file beginning
|
||||
uint32_t width; ///< bitmap width
|
||||
uint32_t height; ///< bitmap height
|
||||
bool os2_bmp; ///< true if OS/2 1.x or windows 2.x bitmap
|
||||
@@ -23,23 +24,11 @@ struct BmpInfo {
|
||||
};
|
||||
|
||||
struct BmpData {
|
||||
Colour *palette;
|
||||
uint8_t *bitmap;
|
||||
std::vector<Colour> palette;
|
||||
std::vector<uint8_t> bitmap;
|
||||
};
|
||||
|
||||
#define BMP_BUFFER_SIZE 1024
|
||||
|
||||
struct BmpBuffer {
|
||||
uint8_t data[BMP_BUFFER_SIZE];
|
||||
int pos;
|
||||
int read;
|
||||
FILE *file;
|
||||
uint real_pos;
|
||||
};
|
||||
|
||||
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file);
|
||||
bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data);
|
||||
bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data);
|
||||
void BmpDestroyData(BmpData *data);
|
||||
bool BmpReadHeader(RandomAccessFile &file, BmpInfo &info, BmpData &data);
|
||||
bool BmpReadBitmap(RandomAccessFile &file, BmpInfo &info, BmpData &data);
|
||||
|
||||
#endif /* BMP_H */
|
||||
|
@@ -44,13 +44,13 @@ static WindowDesc _background_desc(
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_BOOTSTRAP, WC_NONE,
|
||||
WDF_NO_CLOSE,
|
||||
std::begin(_background_widgets), std::end(_background_widgets)
|
||||
_background_widgets
|
||||
);
|
||||
|
||||
/** The background for the game. */
|
||||
class BootstrapBackground : public Window {
|
||||
public:
|
||||
BootstrapBackground() : Window(&_background_desc)
|
||||
BootstrapBackground() : Window(_background_desc)
|
||||
{
|
||||
this->InitNested(0);
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
@@ -80,13 +80,13 @@ static WindowDesc _bootstrap_errmsg_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_BOOTSTRAP, WC_NONE,
|
||||
WDF_MODAL | WDF_NO_CLOSE,
|
||||
std::begin(_nested_bootstrap_errmsg_widgets), std::end(_nested_bootstrap_errmsg_widgets)
|
||||
_nested_bootstrap_errmsg_widgets
|
||||
);
|
||||
|
||||
/** The window for a failed bootstrap. */
|
||||
class BootstrapErrorWindow : public Window {
|
||||
public:
|
||||
BootstrapErrorWindow() : Window(&_bootstrap_errmsg_desc)
|
||||
BootstrapErrorWindow() : Window(_bootstrap_errmsg_desc)
|
||||
{
|
||||
this->InitNested(1);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ static WindowDesc _bootstrap_download_status_window_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_NETWORK_STATUS_WINDOW, WC_NONE,
|
||||
WDF_MODAL | WDF_NO_CLOSE,
|
||||
std::begin(_nested_bootstrap_download_status_window_widgets), std::end(_nested_bootstrap_download_status_window_widgets)
|
||||
_nested_bootstrap_download_status_window_widgets
|
||||
);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ static WindowDesc _bootstrap_download_status_window_desc(
|
||||
struct BootstrapContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow {
|
||||
public:
|
||||
/** Simple call the constructor of the superclass. */
|
||||
BootstrapContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(&_bootstrap_download_status_window_desc)
|
||||
BootstrapContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(_bootstrap_download_status_window_desc)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ static WindowDesc _bootstrap_query_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_CONFIRM_POPUP_QUERY, WC_NONE,
|
||||
WDF_NO_CLOSE,
|
||||
std::begin(_bootstrap_query_widgets), std::end(_bootstrap_query_widgets)
|
||||
_bootstrap_query_widgets
|
||||
);
|
||||
|
||||
/** The window for the query. It can't use the generic query window as that uses sprites that don't exist yet. */
|
||||
@@ -198,7 +198,7 @@ class BootstrapAskForDownloadWindow : public Window, ContentCallback {
|
||||
|
||||
public:
|
||||
/** Start listening to the content client events. */
|
||||
BootstrapAskForDownloadWindow() : Window(&_bootstrap_query_desc)
|
||||
BootstrapAskForDownloadWindow() : Window(_bootstrap_query_desc)
|
||||
{
|
||||
this->InitNested(WN_CONFIRM_POPUP_QUERY_BOOTSTRAP);
|
||||
_network_content_client.AddCallback(this);
|
||||
|
@@ -27,12 +27,13 @@ enum BridgePieces {
|
||||
BRIDGE_PIECE_MIDDLE_ODD,
|
||||
BRIDGE_PIECE_MIDDLE_EVEN,
|
||||
BRIDGE_PIECE_HEAD,
|
||||
BRIDGE_PIECE_INVALID,
|
||||
NUM_BRIDGE_PIECES,
|
||||
};
|
||||
|
||||
DECLARE_POSTFIX_INCREMENT(BridgePieces)
|
||||
|
||||
static const uint MAX_BRIDGES = 13; ///< Maximal number of available bridge specs.
|
||||
constexpr uint SPRITES_PER_BRIDGE_PIECE = 32; ///< Number of sprites there are per bridge piece.
|
||||
|
||||
typedef uint BridgeType; ///< Bridge spec number.
|
||||
|
||||
|
@@ -151,7 +151,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type, GUIBridgeList &&bl) : Window(desc),
|
||||
BuildBridgeWindow(WindowDesc &desc, TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type, GUIBridgeList &&bl) : Window(desc),
|
||||
start_tile(start),
|
||||
end_tile(end),
|
||||
transport_type(transport_type),
|
||||
@@ -338,7 +338,7 @@ static WindowDesc _build_bridge_desc(
|
||||
WDP_AUTO, "build_bridge", 200, 114,
|
||||
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_build_bridge_widgets), std::end(_nested_build_bridge_widgets)
|
||||
_nested_build_bridge_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -435,7 +435,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
||||
}
|
||||
|
||||
if (!bl.empty()) {
|
||||
new BuildBridgeWindow(&_build_bridge_desc, start, end, transport_type, road_rail_type, std::move(bl));
|
||||
new BuildBridgeWindow(_build_bridge_desc, start, end, transport_type, road_rail_type, std::move(bl));
|
||||
} else {
|
||||
ShowErrorMessage(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, errmsg, WL_INFO, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
|
||||
}
|
||||
|
@@ -1048,9 +1048,9 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const auto &item = *it;
|
||||
uint indent = item.indent * WidgetDimensions::scaled.hsep_indent;
|
||||
bool has_variants = (item.flags & EngineDisplayFlags::HasVariants) != EngineDisplayFlags::None;
|
||||
bool is_folded = (item.flags & EngineDisplayFlags::IsFolded) != EngineDisplayFlags::None;
|
||||
bool shaded = (item.flags & EngineDisplayFlags::Shaded) != EngineDisplayFlags::None;
|
||||
bool has_variants = HasFlag(item.flags, EngineDisplayFlags::HasVariants);
|
||||
bool is_folded = HasFlag(item.flags, EngineDisplayFlags::IsFolded);
|
||||
bool shaded = HasFlag(item.flags, EngineDisplayFlags::Shaded);
|
||||
|
||||
if (item.indent > 0) {
|
||||
/* Draw tree continuation lines. */
|
||||
@@ -1138,9 +1138,9 @@ void GUIEngineListAddChildren(GUIEngineList &dst, const GUIEngineList &src, Engi
|
||||
dst.emplace_back(e->display_last_variant == INVALID_ENGINE ? item.engine_id : e->display_last_variant, item.engine_id, flags, indent);
|
||||
|
||||
/* Add variants if not folded */
|
||||
if ((item.flags & (EngineDisplayFlags::HasVariants | EngineDisplayFlags::IsFolded)) == EngineDisplayFlags::HasVariants) {
|
||||
if (HasFlag(item.flags, EngineDisplayFlags::HasVariants) && !HasFlag(item.flags, EngineDisplayFlags::IsFolded)) {
|
||||
/* Add this engine again as a child */
|
||||
if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) {
|
||||
if (!HasFlag(item.flags, EngineDisplayFlags::Shaded)) {
|
||||
dst.emplace_back(item.engine_id, item.engine_id, EngineDisplayFlags::None, indent + 1);
|
||||
}
|
||||
GUIEngineListAddChildren(dst, src, item.engine_id, indent + 1);
|
||||
@@ -1201,7 +1201,7 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
BuildVehicleWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS)
|
||||
BuildVehicleWindow(WindowDesc &desc, TileIndex tile, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS)
|
||||
{
|
||||
this->vehicle_type = type;
|
||||
this->listview_mode = tile == INVALID_TILE;
|
||||
@@ -1256,7 +1256,7 @@ struct BuildVehicleWindow : Window {
|
||||
|
||||
/* Select the first unshaded engine in the list as default when opening the window */
|
||||
EngineID engine = INVALID_ENGINE;
|
||||
auto it = std::find_if(this->eng_list.begin(), this->eng_list.end(), [&](GUIEngineListItem &item) { return (item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None; });
|
||||
auto it = std::ranges::find_if(this->eng_list, [&](GUIEngineListItem &item) { return !HasFlag(item.flags, EngineDisplayFlags::Shaded); });
|
||||
if (it != this->eng_list.end()) engine = it->engine_id;
|
||||
this->SelectEngine(engine);
|
||||
}
|
||||
@@ -1353,7 +1353,7 @@ struct BuildVehicleWindow : Window {
|
||||
this->eng_list.Filter(this->cargo_filter_criteria);
|
||||
if (0 == this->eng_list.size()) { // no engine passed through the filter, invalidate the previously selected engine
|
||||
this->SelectEngine(INVALID_ENGINE);
|
||||
} else if (std::find(this->eng_list.begin(), this->eng_list.end(), this->sel_engine) == this->eng_list.end()) { // previously selected engine didn't pass the filter, select the first engine of the list
|
||||
} else if (std::ranges::find(this->eng_list, this->sel_engine, &GUIEngineListItem::engine_id) == this->eng_list.end()) { // previously selected engine didn't pass the filter, select the first engine of the list
|
||||
this->SelectEngine(this->eng_list[0].engine_id);
|
||||
}
|
||||
}
|
||||
@@ -1426,7 +1426,7 @@ struct BuildVehicleWindow : Window {
|
||||
|
||||
/* ensure primary engine of variant group is in list */
|
||||
for (const auto &variant : variants) {
|
||||
if (std::find(list.begin(), list.end(), variant) == list.end()) {
|
||||
if (std::ranges::find(list, variant, &GUIEngineListItem::engine_id) == list.end()) {
|
||||
const Engine *e = Engine::Get(variant);
|
||||
list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
|
||||
if (e->u.rail.railveh_type != RAILVEH_WAGON) num_engines++;
|
||||
@@ -1568,7 +1568,7 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
|
||||
for (const auto &variant : variants) {
|
||||
if (std::find(this->eng_list.begin(), this->eng_list.end(), variant) == this->eng_list.end()) {
|
||||
if (std::ranges::find(this->eng_list, variant, &GUIEngineListItem::engine_id) == this->eng_list.end()) {
|
||||
const Engine *e = Engine::Get(variant);
|
||||
this->eng_list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
|
||||
}
|
||||
@@ -1606,6 +1606,35 @@ struct BuildVehicleWindow : Window {
|
||||
return list;
|
||||
}
|
||||
|
||||
void BuildVehicle()
|
||||
{
|
||||
EngineID sel_eng = this->sel_engine;
|
||||
if (sel_eng == INVALID_ENGINE) return;
|
||||
|
||||
CargoID cargo = this->cargo_filter_criteria;
|
||||
if (cargo == CargoFilterCriteria::CF_ANY || cargo == CargoFilterCriteria::CF_ENGINES || cargo == CargoFilterCriteria::CF_NONE) cargo = INVALID_CARGO;
|
||||
if (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) {
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
} else {
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildPrimaryVehicle, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
}
|
||||
|
||||
/* Update last used variant in hierarchy and refresh if necessary. */
|
||||
bool refresh = false;
|
||||
EngineID parent = sel_eng;
|
||||
while (parent != INVALID_ENGINE) {
|
||||
Engine *e = Engine::Get(parent);
|
||||
refresh |= (e->display_last_variant != sel_eng);
|
||||
e->display_last_variant = sel_eng;
|
||||
parent = e->info.variant_id;
|
||||
}
|
||||
|
||||
if (refresh) {
|
||||
InvalidateWindowData(WC_REPLACE_VEHICLE, this->vehicle_type, 0); // Update the autoreplace window
|
||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
@@ -1630,7 +1659,7 @@ struct BuildVehicleWindow : Window {
|
||||
if (it != this->eng_list.end()) {
|
||||
const auto &item = *it;
|
||||
const Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.matrix).WithWidth(WidgetDimensions::scaled.hsep_indent * (item.indent + 1), _current_text_dir == TD_RTL);
|
||||
if ((item.flags & EngineDisplayFlags::HasVariants) != EngineDisplayFlags::None && IsInsideMM(r.left, r.right, pt.x)) {
|
||||
if (HasFlag(item.flags, EngineDisplayFlags::HasVariants) && IsInsideMM(r.left, r.right, pt.x)) {
|
||||
/* toggle folded flag on engine */
|
||||
assert(item.variant_id != INVALID_ENGINE);
|
||||
Engine *engine = Engine::Get(item.variant_id);
|
||||
@@ -1640,7 +1669,7 @@ struct BuildVehicleWindow : Window {
|
||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
|
||||
return;
|
||||
}
|
||||
if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) e = item.engine_id;
|
||||
if (!HasFlag(item.flags, EngineDisplayFlags::Shaded)) e = item.engine_id;
|
||||
}
|
||||
this->SelectEngine(e);
|
||||
this->SetDirty();
|
||||
@@ -1668,34 +1697,9 @@ struct BuildVehicleWindow : Window {
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_BV_BUILD: {
|
||||
EngineID sel_eng = this->sel_engine;
|
||||
if (sel_eng != INVALID_ENGINE) {
|
||||
CargoID cargo = this->cargo_filter_criteria;
|
||||
if (cargo == CargoFilterCriteria::CF_ANY || cargo == CargoFilterCriteria::CF_ENGINES || cargo == CargoFilterCriteria::CF_NONE) cargo = INVALID_CARGO;
|
||||
if (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) {
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
} else {
|
||||
Command<CMD_BUILD_VEHICLE>::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildPrimaryVehicle, this->window_number, sel_eng, true, cargo, INVALID_CLIENT_ID);
|
||||
}
|
||||
|
||||
/* Update last used variant in hierarchy and refresh if necessary. */
|
||||
bool refresh = false;
|
||||
EngineID parent = sel_eng;
|
||||
while (parent != INVALID_ENGINE) {
|
||||
Engine *e = Engine::Get(parent);
|
||||
refresh |= (e->display_last_variant != sel_eng);
|
||||
e->display_last_variant = sel_eng;
|
||||
parent = e->info.variant_id;
|
||||
}
|
||||
if (refresh) {
|
||||
InvalidateWindowData(WC_REPLACE_VEHICLE, this->vehicle_type, 0); // Update the autoreplace window
|
||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
|
||||
return;
|
||||
}
|
||||
}
|
||||
case WID_BV_BUILD:
|
||||
this->BuildVehicle();
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_BV_RENAME: {
|
||||
EngineID sel_eng = this->sel_engine;
|
||||
@@ -1853,11 +1857,11 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
void OnQueryTextFinished(std::optional<std::string> str) override
|
||||
{
|
||||
if (str == nullptr) return;
|
||||
if (!str.has_value()) return;
|
||||
|
||||
Command<CMD_RENAME_ENGINE>::Post(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, this->rename_engine, str);
|
||||
Command<CMD_RENAME_ENGINE>::Post(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, this->rename_engine, *str);
|
||||
}
|
||||
|
||||
void OnDropdownSelect(WidgetID widget, int index) override
|
||||
@@ -1922,7 +1926,7 @@ static WindowDesc _build_vehicle_desc(
|
||||
WDP_AUTO, "build_vehicle", 240, 268,
|
||||
WC_BUILD_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_build_vehicle_widgets), std::end(_nested_build_vehicle_widgets),
|
||||
_nested_build_vehicle_widgets,
|
||||
&BuildVehicleWindow::hotkeys
|
||||
);
|
||||
|
||||
@@ -1938,5 +1942,5 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
|
||||
|
||||
CloseWindowById(WC_BUILD_VEHICLE, num);
|
||||
|
||||
new BuildVehicleWindow(&_build_vehicle_desc, tile, type);
|
||||
new BuildVehicleWindow(_build_vehicle_desc, tile, type);
|
||||
}
|
||||
|
@@ -128,7 +128,7 @@ struct CargoArray : std::array<uint, NUM_CARGO> {
|
||||
*/
|
||||
inline uint GetCount() const
|
||||
{
|
||||
return std::count_if(this->begin(), this->end(), [](uint amount) { return amount != 0; });
|
||||
return std::ranges::count_if(*this, [](uint amount) { return amount != 0; });
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -107,7 +107,7 @@ bool CargoDelivery::operator()(CargoPacket *cp)
|
||||
{
|
||||
uint remove = this->Preprocess(cp);
|
||||
this->source->RemoveFromMeta(cp, VehicleCargoList::MTA_DELIVER, remove);
|
||||
this->payment->PayFinalDelivery(cp, remove, this->current_tile);
|
||||
this->payment->PayFinalDelivery(this->cargo, cp, remove, this->current_tile);
|
||||
return this->Postprocess(cp, remove);
|
||||
}
|
||||
|
||||
|
@@ -40,9 +40,10 @@ class CargoDelivery : public CargoRemoval<VehicleCargoList> {
|
||||
protected:
|
||||
TileIndex current_tile; ///< Current tile cargo delivery is happening.
|
||||
CargoPayment *payment; ///< Payment object where payments will be registered.
|
||||
CargoID cargo; ///< The cargo type of the cargo.
|
||||
public:
|
||||
CargoDelivery(VehicleCargoList *source, uint max_move, CargoPayment *payment, TileIndex current_tile) :
|
||||
CargoRemoval<VehicleCargoList>(source, max_move), current_tile(current_tile), payment(payment) {}
|
||||
CargoDelivery(VehicleCargoList *source, uint max_move, CargoID cargo, CargoPayment *payment, TileIndex current_tile) :
|
||||
CargoRemoval<VehicleCargoList>(source, max_move), current_tile(current_tile), payment(payment), cargo(cargo) {}
|
||||
bool operator()(CargoPacket *cp);
|
||||
};
|
||||
|
||||
|
@@ -35,17 +35,14 @@ extern CargoMonitorMap _cargo_pickups;
|
||||
extern CargoMonitorMap _cargo_deliveries;
|
||||
|
||||
|
||||
/** Constants for encoding and extracting cargo monitors. */
|
||||
enum CargoCompanyBits {
|
||||
CCB_TOWN_IND_NUMBER_START = 0, ///< Start bit of the town or industry number.
|
||||
CCB_TOWN_IND_NUMBER_LENGTH = 16, ///< Number of bits of the town or industry number.
|
||||
CCB_IS_INDUSTRY_BIT = 16, ///< Bit indicating the town/industry number is an industry.
|
||||
CCB_IS_INDUSTRY_BIT_VALUE = 1ul << CCB_IS_INDUSTRY_BIT, ///< Value of the #CCB_IS_INDUSTRY_BIT bit.
|
||||
CCB_CARGO_TYPE_START = 19, ///< Start bit of the cargo type field.
|
||||
CCB_CARGO_TYPE_LENGTH = 6, ///< Number of bits of the cargo type field.
|
||||
CCB_COMPANY_START = 25, ///< Start bit of the company field.
|
||||
CCB_COMPANY_LENGTH = 4, ///< Number of bits of the company field.
|
||||
};
|
||||
/* Constants for encoding and extracting cargo monitors. */
|
||||
constexpr uint8_t CCB_TOWN_IND_NUMBER_START = 0; ///< Start bit of the town or industry number.
|
||||
constexpr uint8_t CCB_TOWN_IND_NUMBER_LENGTH = 16; ///< Number of bits of the town or industry number.
|
||||
constexpr uint8_t CCB_IS_INDUSTRY_BIT = 16; ///< Bit indicating the town/industry number is an industry.
|
||||
constexpr uint8_t CCB_CARGO_TYPE_START = 19; ///< Start bit of the cargo type field.
|
||||
constexpr uint8_t CCB_CARGO_TYPE_LENGTH = 6; ///< Number of bits of the cargo type field.
|
||||
constexpr uint8_t CCB_COMPANY_START = 25; ///< Start bit of the company field.
|
||||
constexpr uint8_t CCB_COMPANY_LENGTH = 4; ///< Number of bits of the company field.
|
||||
|
||||
static_assert(NUM_CARGO <= (1 << CCB_CARGO_TYPE_LENGTH));
|
||||
static_assert(MAX_COMPANIES <= (1 << CCB_COMPANY_LENGTH));
|
||||
|
@@ -432,11 +432,12 @@ void VehicleCargoList::AgeCargo()
|
||||
* @param next_station ID of the station the vehicle will go to next.
|
||||
* @param order_flags OrderUnloadFlags that will apply to the unload operation.
|
||||
* @param ge GoodsEntry for getting the flows.
|
||||
* @param cargo The cargo type of the cargo.
|
||||
* @param payment Payment object for registering transfers.
|
||||
* @param current_tile Current tile the cargo handling is happening on.
|
||||
* return If any cargo will be unloaded.
|
||||
*/
|
||||
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoPayment *payment, TileIndex current_tile)
|
||||
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoID cargo, CargoPayment *payment, TileIndex current_tile)
|
||||
{
|
||||
this->AssertCountConsistency();
|
||||
assert(this->action_counts[MTA_LOAD] == 0);
|
||||
@@ -512,7 +513,7 @@ bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID
|
||||
case MTA_TRANSFER:
|
||||
this->packets.push_front(cp);
|
||||
/* Add feeder share here to allow reusing field for next station. */
|
||||
share = payment->PayTransfer(cp, cp->count, current_tile);
|
||||
share = payment->PayTransfer(cargo, cp, cp->count, current_tile);
|
||||
cp->AddFeederShare(share);
|
||||
this->feeder_share += share;
|
||||
cp->next_hop = cargo_next;
|
||||
@@ -619,11 +620,12 @@ uint VehicleCargoList::Shift(uint max_move, VehicleCargoList *dest)
|
||||
* ranges defined by designation_counts.
|
||||
* @param dest StationCargoList to add transferred cargo to.
|
||||
* @param max_move Maximum amount of cargo to move.
|
||||
* @param cargo The cargo type of the cargo.
|
||||
* @param payment Payment object to register payments in.
|
||||
* @param current_tile Current tile the cargo handling is happening on.
|
||||
* @return Amount of cargo actually unloaded.
|
||||
*/
|
||||
uint VehicleCargoList::Unload(uint max_move, StationCargoList *dest, CargoPayment *payment, TileIndex current_tile)
|
||||
uint VehicleCargoList::Unload(uint max_move, StationCargoList *dest, CargoID cargo, CargoPayment *payment, TileIndex current_tile)
|
||||
{
|
||||
uint moved = 0;
|
||||
if (this->action_counts[MTA_TRANSFER] > 0) {
|
||||
@@ -633,7 +635,7 @@ uint VehicleCargoList::Unload(uint max_move, StationCargoList *dest, CargoPaymen
|
||||
}
|
||||
if (this->action_counts[MTA_TRANSFER] == 0 && this->action_counts[MTA_DELIVER] > 0 && moved < max_move) {
|
||||
uint move = std::min(this->action_counts[MTA_DELIVER], max_move - moved);
|
||||
this->ShiftCargo(CargoDelivery(this, move, payment, current_tile));
|
||||
this->ShiftCargo(CargoDelivery(this, move, cargo, payment, current_tile));
|
||||
moved += move;
|
||||
}
|
||||
return moved;
|
||||
|
@@ -478,7 +478,7 @@ public:
|
||||
|
||||
void InvalidateCache();
|
||||
|
||||
bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoPayment *payment, TileIndex current_tile);
|
||||
bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoID cargo, CargoPayment *payment, TileIndex current_tile);
|
||||
|
||||
/**
|
||||
* Marks all cargo in the vehicle as to be kept. This is mostly useful for
|
||||
@@ -498,7 +498,7 @@ public:
|
||||
template<MoveToAction Tfrom, MoveToAction Tto>
|
||||
uint Reassign(uint max_move);
|
||||
uint Return(uint max_move, StationCargoList *dest, StationID next_station, TileIndex current_tile);
|
||||
uint Unload(uint max_move, StationCargoList *dest, CargoPayment *payment, TileIndex current_tile);
|
||||
uint Unload(uint max_move, StationCargoList *dest, CargoID cargo, CargoPayment *payment, TileIndex current_tile);
|
||||
uint Shift(uint max_move, VehicleCargoList *dest);
|
||||
uint Truncate(uint max_move = UINT_MAX);
|
||||
uint Reroute(uint max_move, VehicleCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include "table/strings.h"
|
||||
#include "table/cargo_const.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
CargoSpec CargoSpec::array[NUM_CARGO];
|
||||
@@ -41,6 +43,20 @@ CargoTypes _standard_cargo_mask;
|
||||
*/
|
||||
static std::vector<CargoLabel> _default_cargo_labels;
|
||||
|
||||
/**
|
||||
* Default cargo translation for upto version 7 NewGRFs.
|
||||
* This maps the original 12 cargo slots to their original label. If a climate dependent cargo is not present it will
|
||||
* map to CT_INVALID. For default cargoes this ends up as a 1:1 mapping via climate slot -> label -> cargo ID.
|
||||
*/
|
||||
static std::array<CargoLabel, 12> _climate_dependent_cargo_labels;
|
||||
|
||||
/**
|
||||
* Default cargo translation for version 8+ NewGRFs.
|
||||
* This maps the 32 "bitnum" cargo slots to their original label. If a bitnum is not present it will
|
||||
* map to CT_INVALID.
|
||||
*/
|
||||
static std::array<CargoLabel, 32> _climate_independent_cargo_labels;
|
||||
|
||||
/**
|
||||
* Set up the default cargo types for the given landscape type.
|
||||
* @param l Landscape
|
||||
@@ -51,30 +67,37 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
|
||||
_cargo_mask = 0;
|
||||
_default_cargo_labels.clear();
|
||||
_climate_dependent_cargo_labels.fill(CT_INVALID);
|
||||
_climate_independent_cargo_labels.fill(CT_INVALID);
|
||||
|
||||
/* Copy from default cargo by label or index. */
|
||||
auto insert = std::begin(CargoSpec::array);
|
||||
for (const auto &cl : _default_climate_cargo[l]) {
|
||||
|
||||
/* Check if value is an index into the cargo table */
|
||||
if (std::holds_alternative<int>(cl)) {
|
||||
/* Copy the default cargo by index. */
|
||||
*insert = _default_cargo[std::get<int>(cl)];
|
||||
} else {
|
||||
/* Search for label in default cargo types and copy if found. */
|
||||
CargoLabel label = std::get<CargoLabel>(cl);
|
||||
auto found = std::find_if(std::begin(_default_cargo), std::end(_default_cargo), [&label](const CargoSpec &cs) { return cs.label == label; });
|
||||
if (found != std::end(_default_cargo)) {
|
||||
*insert = *found;
|
||||
} else {
|
||||
struct visitor {
|
||||
const CargoSpec &operator()(const int &index)
|
||||
{
|
||||
/* Copy the default cargo by index. */
|
||||
return _default_cargo[index];
|
||||
}
|
||||
const CargoSpec &operator()(const CargoLabel &label)
|
||||
{
|
||||
/* Search for label in default cargo types and copy if found. */
|
||||
auto found = std::ranges::find(_default_cargo, label, &CargoSpec::label);
|
||||
if (found != std::end(_default_cargo)) return *found;
|
||||
|
||||
/* Index or label is invalid, this should not happen. */
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
*insert = std::visit(visitor{}, cl);
|
||||
|
||||
if (insert->IsValid()) {
|
||||
SetBit(_cargo_mask, insert->Index());
|
||||
_default_cargo_labels.push_back(insert->label);
|
||||
_climate_dependent_cargo_labels[insert->Index()] = insert->label;
|
||||
_climate_independent_cargo_labels[insert->bitnum] = insert->label;
|
||||
}
|
||||
++insert;
|
||||
}
|
||||
@@ -85,6 +108,24 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
BuildCargoLabelMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default climate-dependent cargo translation table for a NewGRF, used if the NewGRF does not provide its own.
|
||||
* @return Default translation table for GRF version.
|
||||
*/
|
||||
std::span<const CargoLabel> GetClimateDependentCargoTranslationTable()
|
||||
{
|
||||
return _climate_dependent_cargo_labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default climate-independent cargo translation table for a NewGRF, used if the NewGRF does not provide its own.
|
||||
* @return Default translation table for GRF version.
|
||||
*/
|
||||
std::span<const CargoLabel> GetClimateIndependentCargoTranslationTable()
|
||||
{
|
||||
return _climate_independent_cargo_labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build cargo label map.
|
||||
* This is called multiple times during NewGRF initialization as cargos are defined, so that TranslateRefitMask() and
|
||||
@@ -130,23 +171,6 @@ Dimension GetLargestCargoIconSize()
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the CargoID of a 'bitnum' value.
|
||||
* @param bitnum 'bitnum' to find.
|
||||
* @return First CargoID with the given bitnum, or #INVALID_CARGO if not found or if the provided \a bitnum is invalid.
|
||||
*/
|
||||
CargoID GetCargoIDByBitnum(uint8_t bitnum)
|
||||
{
|
||||
if (bitnum == INVALID_CARGO_BITNUM) return INVALID_CARGO;
|
||||
|
||||
for (const CargoSpec *cs : CargoSpec::Iterate()) {
|
||||
if (cs->bitnum == bitnum) return cs->Index();
|
||||
}
|
||||
|
||||
/* No matching label was found, so it is invalid */
|
||||
return INVALID_CARGO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sprite for showing cargo of this type.
|
||||
* @return Sprite number to use.
|
||||
@@ -235,3 +259,41 @@ uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n) const
|
||||
if (this->is_freight) n *= _settings_game.vehicle.freight_trains;
|
||||
return this->WeightOfNUnits(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build comma-separated cargo acceptance string.
|
||||
* @param acceptance CargoArray filled with accepted cargo.
|
||||
* @param label Label to prefix cargo acceptance list.
|
||||
* @return String of accepted cargo, or nullopt if no cargo is accepted.
|
||||
*/
|
||||
std::optional<std::string> BuildCargoAcceptanceString(const CargoArray &acceptance, StringID label)
|
||||
{
|
||||
std::string_view list_separator = GetListSeparator();
|
||||
|
||||
/* Cargo acceptance is displayed in a extra multiline */
|
||||
std::stringstream line;
|
||||
line << GetString(label);
|
||||
|
||||
bool found = false;
|
||||
for (const CargoSpec *cs : _sorted_cargo_specs) {
|
||||
CargoID cid = cs->Index();
|
||||
if (acceptance[cid] > 0) {
|
||||
/* Add a comma between each item. */
|
||||
if (found) line << list_separator;
|
||||
found = true;
|
||||
|
||||
/* If the accepted value is less than 8, show it in 1/8:ths */
|
||||
if (acceptance[cid] < 8) {
|
||||
SetDParam(0, acceptance[cid]);
|
||||
SetDParam(1, cs->name);
|
||||
line << GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS);
|
||||
} else {
|
||||
line << GetString(cs->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) return line.str();
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ enum TownProductionEffect : uint8_t {
|
||||
};
|
||||
|
||||
/** Cargo classes. */
|
||||
enum CargoClass {
|
||||
enum CargoClass : uint16_t {
|
||||
CC_NOAVAILABLE = 0, ///< No cargo class has been specified
|
||||
CC_PASSENGERS = 1 << 0, ///< Passengers
|
||||
CC_MAIL = 1 << 1, ///< Mail
|
||||
@@ -57,9 +57,17 @@ enum CargoClass {
|
||||
CC_REFRIGERATED = 1 << 7, ///< Refrigerated cargo (Food, Fruit)
|
||||
CC_HAZARDOUS = 1 << 8, ///< Hazardous cargo (Nuclear Fuel, Explosives, etc.)
|
||||
CC_COVERED = 1 << 9, ///< Covered/Sheltered Freight (Transportation in Box Vans, Silo Wagons, etc.)
|
||||
CC_OVERSIZED = 1 << 10, ///< Oversized (stake/flatbed wagon)
|
||||
CC_POWDERIZED = 1 << 11, ///< Powderized, moist protected (powder/silo wagon)
|
||||
CC_NOT_POURABLE = 1 << 12, ///< Not Pourable (open wagon, but not hopper wagon)
|
||||
CC_POTABLE = 1 << 13, ///< Potable / food / clean.
|
||||
CC_NON_POTABLE = 1 << 14, ///< Non-potable / non-food / dirty.
|
||||
CC_SPECIAL = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes.
|
||||
};
|
||||
|
||||
/** Bitmask of cargo classes. */
|
||||
using CargoClasses = uint16_t;
|
||||
|
||||
static const uint8_t INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
|
||||
|
||||
static const uint TOWN_PRODUCTION_DIVISOR = 256;
|
||||
@@ -72,7 +80,7 @@ struct CargoSpec {
|
||||
uint8_t rating_colour;
|
||||
uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
|
||||
uint16_t multiplier = 0x100; ///< Capacity multiplier for vehicles. (8 fractional bits)
|
||||
uint16_t classes; ///< Classes of this cargo type. @see CargoClass
|
||||
CargoClasses classes; ///< Classes of this cargo type. @see CargoClass
|
||||
int32_t initial_payment; ///< Initial payment rate before inflation is applied.
|
||||
uint8_t transit_periods[2];
|
||||
|
||||
@@ -205,7 +213,8 @@ extern CargoTypes _standard_cargo_mask;
|
||||
void SetupCargoForClimate(LandscapeID l);
|
||||
bool IsDefaultCargo(CargoID cid);
|
||||
void BuildCargoLabelMap();
|
||||
CargoID GetCargoIDByBitnum(uint8_t bitnum);
|
||||
|
||||
std::optional<std::string> BuildCargoAcceptanceString(const CargoArray &acceptance, StringID label);
|
||||
|
||||
inline CargoID GetCargoIDByLabel(CargoLabel label)
|
||||
{
|
||||
|
@@ -20,20 +20,3 @@ void InitializeCheats()
|
||||
{
|
||||
memset(&_cheats, 0, sizeof(Cheats));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if any cheat has been used, false otherwise
|
||||
* @return has a cheat been used?
|
||||
*/
|
||||
bool CheatHasBeenUsed()
|
||||
{
|
||||
/* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
|
||||
const Cheat *cht = (Cheat*)&_cheats;
|
||||
const Cheat *cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
|
||||
|
||||
for (; cht != cht_last; cht++) {
|
||||
if (cht->been_used) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@@ -16,6 +16,5 @@ extern Cheats _cheats;
|
||||
|
||||
void ShowCheatWindow();
|
||||
|
||||
bool CheatHasBeenUsed();
|
||||
|
||||
#endif /* CHEAT_FUNC_H */
|
||||
|
@@ -129,6 +129,7 @@ static int32_t ClickChangeDateCheat(int32_t new_value, int32_t)
|
||||
InvalidateWindowClassesData(WC_BUS_STATION, 0);
|
||||
InvalidateWindowClassesData(WC_TRUCK_STATION, 0);
|
||||
InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
|
||||
InvalidateWindowClassesData(WC_FINANCES, 0);
|
||||
ResetSignalVariant();
|
||||
return TimerGameCalendar::year.base();
|
||||
}
|
||||
@@ -145,7 +146,7 @@ static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t)
|
||||
|
||||
/* Check if at least one mountain on the map is higher than the new value.
|
||||
* If yes, disallow the change. */
|
||||
for (TileIndex t = 0; t < Map::Size(); t++) {
|
||||
for (const auto t : Map::Iterate()) {
|
||||
if ((int32_t)TileHeight(t) > new_value) {
|
||||
ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
|
||||
/* Return old, unchanged value */
|
||||
@@ -230,7 +231,7 @@ struct CheatWindow : Window {
|
||||
uint line_height;
|
||||
Dimension icon; ///< Dimension of company icon sprite
|
||||
|
||||
CheatWindow(WindowDesc *desc) : Window(desc)
|
||||
CheatWindow(WindowDesc &desc) : Window(desc)
|
||||
{
|
||||
this->InitNested();
|
||||
}
|
||||
@@ -404,14 +405,14 @@ struct CheatWindow : Window {
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
void OnQueryTextFinished(std::optional<std::string> str) override
|
||||
{
|
||||
/* Was 'cancel' pressed or nothing entered? */
|
||||
if (str == nullptr || StrEmpty(str)) return;
|
||||
if (!str.has_value() || str->empty()) return;
|
||||
|
||||
const CheatEntry *ce = &_cheats_ui[clicked_widget];
|
||||
int oldvalue = (int32_t)ReadValue(ce->variable, ce->type);
|
||||
int value = atoi(str);
|
||||
int value = atoi(str->c_str());
|
||||
*ce->been_used = true;
|
||||
value = ce->proc(value, value - oldvalue);
|
||||
|
||||
@@ -429,12 +430,12 @@ static WindowDesc _cheats_desc(
|
||||
WDP_AUTO, "cheats", 0, 0,
|
||||
WC_CHEATS, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_cheat_widgets), std::end(_nested_cheat_widgets)
|
||||
_nested_cheat_widgets
|
||||
);
|
||||
|
||||
/** Open cheat window. */
|
||||
void ShowCheatWindow()
|
||||
{
|
||||
CloseWindowById(WC_CHEATS, 0);
|
||||
new CheatWindow(&_cheats_desc);
|
||||
new CheatWindow(_cheats_desc);
|
||||
}
|
||||
|
@@ -144,27 +144,11 @@ static void UpdateFences(TileIndex tile)
|
||||
assert(IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS));
|
||||
bool dirty = false;
|
||||
|
||||
bool neighbour = (IsTileType(TileAddXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TileAddXY(tile, 1, 0), CLEAR_FIELDS));
|
||||
if (!neighbour && GetFence(tile, DIAGDIR_SW) == 0) {
|
||||
SetFence(tile, DIAGDIR_SW, 3);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
neighbour = (IsTileType(TileAddXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TileAddXY(tile, 0, 1), CLEAR_FIELDS));
|
||||
if (!neighbour && GetFence(tile, DIAGDIR_SE) == 0) {
|
||||
SetFence(tile, DIAGDIR_SE, 3);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
neighbour = (IsTileType(TileAddXY(tile, -1, 0), MP_CLEAR) && IsClearGround(TileAddXY(tile, -1, 0), CLEAR_FIELDS));
|
||||
if (!neighbour && GetFence(tile, DIAGDIR_NE) == 0) {
|
||||
SetFence(tile, DIAGDIR_NE, 3);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
neighbour = (IsTileType(TileAddXY(tile, 0, -1), MP_CLEAR) && IsClearGround(TileAddXY(tile, 0, -1), CLEAR_FIELDS));
|
||||
if (!neighbour && GetFence(tile, DIAGDIR_NW) == 0) {
|
||||
SetFence(tile, DIAGDIR_NW, 3);
|
||||
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
|
||||
if (GetFence(tile, dir) != 0) continue;
|
||||
TileIndex neighbour = tile + TileOffsByDiagDir(dir);
|
||||
if (IsTileType(neighbour, MP_CLEAR) && IsClearGround(neighbour, CLEAR_FIELDS)) continue;
|
||||
SetFence(tile, dir, 3);
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@@ -177,30 +161,28 @@ static void TileLoopClearAlps(TileIndex tile)
|
||||
{
|
||||
int k = GetTileZ(tile) - GetSnowLine() + 1;
|
||||
|
||||
if (k < 0) {
|
||||
if (!IsSnowTile(tile)) {
|
||||
/* Below the snow line, do nothing if no snow. */
|
||||
if (!IsSnowTile(tile)) return;
|
||||
} else {
|
||||
/* At or above the snow line, make snow tile if needed. */
|
||||
if (!IsSnowTile(tile)) {
|
||||
if (k >= 0) {
|
||||
MakeSnow(tile);
|
||||
MarkTileDirtyByTile(tile);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update snow density. */
|
||||
uint current_density = GetClearDensity(tile);
|
||||
uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
|
||||
|
||||
if (current_density < req_density) {
|
||||
AddClearDensity(tile, 1);
|
||||
} else if (current_density > req_density) {
|
||||
AddClearDensity(tile, -1);
|
||||
} else {
|
||||
if (current_density == req_density) {
|
||||
/* Density at the required level. */
|
||||
if (k >= 0) return;
|
||||
ClearSnow(tile);
|
||||
} else {
|
||||
AddClearDensity(tile, current_density < req_density ? 1 : -1);
|
||||
}
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
|
@@ -27,16 +27,6 @@
|
||||
*/
|
||||
static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
||||
|
||||
/**
|
||||
* Returns from a function with a specific StringID as error.
|
||||
*
|
||||
* This macro is used to return from a function. The parameter contains the
|
||||
* StringID which will be returned.
|
||||
*
|
||||
* @param errcode The StringID to return
|
||||
*/
|
||||
#define return_cmd_error(errcode) return CommandCost(errcode);
|
||||
|
||||
void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, const CommandDataBuffer &cmd_data);
|
||||
|
||||
bool IsValidCommand(Commands cmd);
|
||||
|
@@ -21,12 +21,12 @@ struct GRFFile;
|
||||
* a possible error message/state together.
|
||||
*/
|
||||
class CommandCost {
|
||||
ExpensesType expense_type; ///< the type of expence as shown on the finances view
|
||||
Money cost; ///< The cost of this action
|
||||
StringID message; ///< Warning message for when success is unset
|
||||
ExpensesType expense_type; ///< the type of expence as shown on the finances view
|
||||
bool success; ///< Whether the command went fine up to this moment
|
||||
const GRFFile *textref_stack_grffile; ///< NewGRF providing the #TextRefStack content.
|
||||
uint textref_stack_size; ///< Number of uint32_t values to put on the #TextRefStack for the error message.
|
||||
const GRFFile *textref_stack_grffile = nullptr; ///< NewGRF providing the #TextRefStack content.
|
||||
uint textref_stack_size = 0; ///< Number of uint32_t values to put on the #TextRefStack for the error message.
|
||||
StringID extra_message = INVALID_STRING_ID; ///< Additional warning message for when success is unset
|
||||
|
||||
static uint32_t textref_stack[16];
|
||||
@@ -35,25 +35,25 @@ public:
|
||||
/**
|
||||
* Creates a command cost return with no cost and no error
|
||||
*/
|
||||
CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
CommandCost() : cost(0), message(INVALID_STRING_ID), expense_type(INVALID_EXPENSES), success(true) {}
|
||||
|
||||
/**
|
||||
* Creates a command return value with one, or optionally two, error message strings.
|
||||
*/
|
||||
explicit CommandCost(StringID msg, StringID extra_msg = INVALID_STRING_ID) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false), textref_stack_grffile(nullptr), textref_stack_size(0), extra_message(extra_msg) {}
|
||||
explicit CommandCost(StringID msg, StringID extra_msg = INVALID_STRING_ID) : cost(0), message(msg), expense_type(INVALID_EXPENSES), success(false), extra_message(extra_msg) {}
|
||||
|
||||
/**
|
||||
* Creates a command cost with given expense type and start cost of 0
|
||||
* @param ex_t the expense type
|
||||
*/
|
||||
explicit CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
explicit CommandCost(ExpensesType ex_t) : cost(0), message(INVALID_STRING_ID), expense_type(ex_t), success(true) {}
|
||||
|
||||
/**
|
||||
* Creates a command return value with the given start cost and expense type
|
||||
* @param ex_t the expense type
|
||||
* @param cst the initial cost of this command
|
||||
*/
|
||||
CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
CommandCost(ExpensesType ex_t, const Money &cst) : cost(cst), message(INVALID_STRING_ID), expense_type(ex_t), success(true) {}
|
||||
|
||||
|
||||
/**
|
||||
@@ -207,6 +207,9 @@ enum Commands : uint16_t {
|
||||
CMD_RENAME_WAYPOINT, ///< rename a waypoint
|
||||
CMD_REMOVE_FROM_RAIL_WAYPOINT, ///< remove a (rectangle of) tiles from a rail waypoint
|
||||
|
||||
CMD_BUILD_ROAD_WAYPOINT, ///< build a road waypoint
|
||||
CMD_REMOVE_FROM_ROAD_WAYPOINT, ///< remove a (rectangle of) tiles from a road waypoint
|
||||
|
||||
CMD_BUILD_ROAD_STOP, ///< build a road stop
|
||||
CMD_REMOVE_ROAD_STOP, ///< remove a road stop
|
||||
CMD_BUILD_LONG_ROAD, ///< build a complete road (not a "half" one)
|
||||
|
@@ -92,6 +92,7 @@ struct CompanyProperties {
|
||||
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.
|
||||
|
||||
TimerGameEconomy::Year inaugurated_year; ///< Economy year of starting the company.
|
||||
TimerGameCalendar::Year inaugurated_year_calendar; ///< Calendar year of starting the company. Used to display proper Inauguration year while in wallclock mode.
|
||||
|
||||
uint8_t months_empty = 0; ///< NOSAVE: Number of months this company has not had a client in multiplayer.
|
||||
uint8_t months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts
|
||||
|
@@ -368,7 +368,7 @@ CommandCost CheckOwnership(Owner owner, TileIndex tile)
|
||||
if (owner == _current_company) return CommandCost();
|
||||
|
||||
SetDParamsForOwnedBy(owner, tile);
|
||||
return_cmd_error(STR_ERROR_OWNED_BY);
|
||||
return CommandCost(STR_ERROR_OWNED_BY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +388,7 @@ CommandCost CheckTileOwnership(TileIndex tile)
|
||||
|
||||
/* no need to get the name of the owner unless we're the local company (saves some time) */
|
||||
if (IsLocalCompany()) SetDParamsForOwnedBy(owner, tile);
|
||||
return_cmd_error(STR_ERROR_OWNED_BY);
|
||||
return CommandCost(STR_ERROR_OWNED_BY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,12 +426,12 @@ set_name:;
|
||||
MarkWholeScreenDirty();
|
||||
|
||||
if (c->is_ai) {
|
||||
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||
auto cni = std::make_unique<CompanyNewsInformation>(c);
|
||||
SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
|
||||
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
|
||||
SetDParamStr(2, cni->company_name);
|
||||
SetDParam(3, t->index);
|
||||
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_COMPANY_INFO, NF_COMPANY, NR_TILE, c->last_build_coordinate.base(), NR_NONE, UINT32_MAX, cni);
|
||||
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_COMPANY_INFO, NF_COMPANY, NR_TILE, c->last_build_coordinate.base(), NR_NONE, UINT32_MAX, std::move(cni));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -608,6 +608,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
|
||||
c->avail_railtypes = GetCompanyRailTypes(c->index);
|
||||
c->avail_roadtypes = GetCompanyRoadTypes(c->index);
|
||||
c->inaugurated_year = TimerGameEconomy::year;
|
||||
c->inaugurated_year_calendar = TimerGameCalendar::year;
|
||||
|
||||
/* If starting a player company in singleplayer and a favorite company manager face is selected, choose it. Otherwise, use a random face.
|
||||
* In a network game, we'll choose the favorite face later in CmdCompanyCtrl to sync it to all clients. */
|
||||
@@ -795,7 +796,7 @@ static IntervalTimer<TimerGameEconomy> _economy_companies_yearly({TimerGameEcono
|
||||
/* Move expenses to previous years. */
|
||||
std::rotate(std::rbegin(c->yearly_expenses), std::rbegin(c->yearly_expenses) + 1, std::rend(c->yearly_expenses));
|
||||
c->yearly_expenses[0] = {};
|
||||
SetWindowDirty(WC_FINANCES, c->index);
|
||||
InvalidateWindowData(WC_FINANCES, c->index);
|
||||
}
|
||||
|
||||
if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) {
|
||||
@@ -945,13 +946,13 @@ CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID
|
||||
|
||||
if (!(flags & DC_EXEC)) return CommandCost();
|
||||
|
||||
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||
auto cni = std::make_unique<CompanyNewsInformation>(c);
|
||||
|
||||
/* Show the bankrupt news */
|
||||
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
|
||||
SetDParam(1, STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION);
|
||||
SetDParamStr(2, cni->company_name);
|
||||
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
|
||||
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, std::move(cni));
|
||||
|
||||
/* Remove the company */
|
||||
ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
|
||||
@@ -1084,7 +1085,7 @@ CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool p
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
if (primary) {
|
||||
if (scheme != LS_DEFAULT) SB(c->livery[scheme].in_use, 0, 1, colour != INVALID_COLOUR);
|
||||
if (scheme != LS_DEFAULT) AssignBit(c->livery[scheme].in_use, 0, colour != INVALID_COLOUR);
|
||||
if (colour == INVALID_COLOUR) colour = c->livery[LS_DEFAULT].colour1;
|
||||
c->livery[scheme].colour1 = colour;
|
||||
|
||||
@@ -1097,7 +1098,7 @@ CommandCost CmdSetCompanyColour(DoCommandFlag flags, LiveryScheme scheme, bool p
|
||||
CompanyAdminUpdate(c);
|
||||
}
|
||||
} else {
|
||||
if (scheme != LS_DEFAULT) SB(c->livery[scheme].in_use, 1, 1, colour != INVALID_COLOUR);
|
||||
if (scheme != LS_DEFAULT) AssignBit(c->livery[scheme].in_use, 1, colour != INVALID_COLOUR);
|
||||
if (colour == INVALID_COLOUR) colour = c->livery[LS_DEFAULT].colour2;
|
||||
c->livery[scheme].colour2 = colour;
|
||||
|
||||
@@ -1171,7 +1172,7 @@ CommandCost CmdRenameCompany(DoCommandFlag flags, const std::string &text)
|
||||
|
||||
if (!reset) {
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_COMPANY_NAME_CHARS) return CMD_ERROR;
|
||||
if (!IsUniqueCompanyName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
if (!IsUniqueCompanyName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
@@ -1214,7 +1215,7 @@ CommandCost CmdRenamePresident(DoCommandFlag flags, const std::string &text)
|
||||
|
||||
if (!reset) {
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) return CMD_ERROR;
|
||||
if (!IsUniquePresidentName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
if (!IsUniquePresidentName(text)) return CommandCost(STR_ERROR_NAME_MUST_BE_UNIQUE);
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
@@ -1300,7 +1301,7 @@ CommandCost CmdGiveMoney(DoCommandFlag flags, Money money, CompanyID dest_compan
|
||||
CommandCost amount(EXPENSES_OTHER, std::min<Money>(money, 20000000LL));
|
||||
|
||||
/* You can only transfer funds that is in excess of your loan */
|
||||
if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return_cmd_error(STR_ERROR_INSUFFICIENT_FUNDS);
|
||||
if (c->money - c->current_loan < amount.GetCost() || amount.GetCost() < 0) return CommandCost(STR_ERROR_INSUFFICIENT_FUNDS);
|
||||
if (!Company::IsValidID(dest_company)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
|
@@ -333,10 +333,13 @@ static constexpr NWidgetPart _nested_company_finances_widgets[] = {
|
||||
|
||||
/** Window class displaying the company finances. */
|
||||
struct CompanyFinancesWindow : Window {
|
||||
static constexpr int NUM_PERIODS = WID_CF_EXPS_PRICE3 - WID_CF_EXPS_PRICE1 + 1;
|
||||
|
||||
static Money max_money; ///< The maximum amount of money a company has had this 'run'
|
||||
bool small; ///< Window is toggled to 'small'.
|
||||
uint8_t first_visible = NUM_PERIODS - 1; ///< First visible expenses column. The last column (current) is always visible.
|
||||
|
||||
CompanyFinancesWindow(WindowDesc *desc, CompanyID company) : Window(desc)
|
||||
CompanyFinancesWindow(WindowDesc &desc, CompanyID company) : Window(desc)
|
||||
{
|
||||
this->small = false;
|
||||
this->CreateNestedTree();
|
||||
@@ -344,6 +347,7 @@ struct CompanyFinancesWindow : Window {
|
||||
this->FinishInitNested(company);
|
||||
|
||||
this->owner = (Owner)this->window_number;
|
||||
this->InvalidateData();
|
||||
}
|
||||
|
||||
void SetStringParameters(WidgetID widget) const override
|
||||
@@ -426,12 +430,12 @@ struct CompanyFinancesWindow : Window {
|
||||
case WID_CF_EXPS_PRICE1:
|
||||
case WID_CF_EXPS_PRICE2:
|
||||
case WID_CF_EXPS_PRICE3: {
|
||||
int period = widget - WID_CF_EXPS_PRICE1;
|
||||
if (period < this->first_visible) break;
|
||||
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
auto age = std::min(TimerGameEconomy::year - c->inaugurated_year, TimerGameEconomy::Year(2));
|
||||
int wid_offset = widget - WID_CF_EXPS_PRICE1;
|
||||
if (wid_offset <= age) {
|
||||
DrawYearColumn(r, TimerGameEconomy::year - (age - wid_offset), c->yearly_expenses[(age - wid_offset).base()]);
|
||||
}
|
||||
const auto &expenses = c->yearly_expenses[NUM_PERIODS - period - 1];
|
||||
DrawYearColumn(r, TimerGameEconomy::year - (NUM_PERIODS - period - 1), expenses);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -514,6 +518,24 @@ struct CompanyFinancesWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshVisibleColumns()
|
||||
{
|
||||
for (uint period = 0; period < this->first_visible; ++period) {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
const Expenses &expenses = c->yearly_expenses[NUM_PERIODS - period - 1];
|
||||
/* Show expenses column if it has any non-zero value in it. */
|
||||
if (std::ranges::any_of(expenses, [](const Money &value) { return value != 0; })) {
|
||||
this->first_visible = period;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnInvalidateData(int, bool) override
|
||||
{
|
||||
this->RefreshVisibleColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check on a regular interval if the maximum amount of money has changed.
|
||||
* If it has, rescale the window to fit the new amount.
|
||||
@@ -535,7 +557,7 @@ static WindowDesc _company_finances_desc(
|
||||
WDP_AUTO, "company_finances", 0, 0,
|
||||
WC_FINANCES, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_company_finances_widgets), std::end(_nested_company_finances_widgets)
|
||||
_nested_company_finances_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -548,7 +570,7 @@ void ShowCompanyFinances(CompanyID company)
|
||||
if (!Company::IsValidID(company)) return;
|
||||
if (BringWindowToFrontById(WC_FINANCES, company)) return;
|
||||
|
||||
new CompanyFinancesWindow(&_company_finances_desc, company);
|
||||
new CompanyFinancesWindow(_company_finances_desc, company);
|
||||
}
|
||||
|
||||
/* Association of liveries to livery classes */
|
||||
@@ -670,7 +692,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
SelectCompanyLiveryWindow(WindowDesc *desc, CompanyID company, GroupID group) : Window(desc)
|
||||
SelectCompanyLiveryWindow(WindowDesc &desc, CompanyID company, GroupID group) : Window(desc)
|
||||
{
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_SCL_MATRIX_SCROLLBAR);
|
||||
@@ -1082,14 +1104,14 @@ static WindowDesc _select_company_livery_desc(
|
||||
WDP_AUTO, "company_color_scheme", 0, 0,
|
||||
WC_COMPANY_COLOUR, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_select_company_livery_widgets), std::end(_nested_select_company_livery_widgets)
|
||||
_nested_select_company_livery_widgets
|
||||
);
|
||||
|
||||
void ShowCompanyLiveryWindow(CompanyID company, GroupID group)
|
||||
{
|
||||
SelectCompanyLiveryWindow *w = (SelectCompanyLiveryWindow *)BringWindowToFrontById(WC_COMPANY_COLOUR, company);
|
||||
if (w == nullptr) {
|
||||
new SelectCompanyLiveryWindow(&_select_company_livery_desc, company, group);
|
||||
new SelectCompanyLiveryWindow(_select_company_livery_desc, company, group);
|
||||
} else if (group != INVALID_GROUP) {
|
||||
w->SetSelectedGroup(company, group);
|
||||
}
|
||||
@@ -1349,7 +1371,7 @@ class SelectCompanyManagerFaceWindow : public Window
|
||||
}
|
||||
|
||||
public:
|
||||
SelectCompanyManagerFaceWindow(WindowDesc *desc, Window *parent) : Window(desc)
|
||||
SelectCompanyManagerFaceWindow(WindowDesc &desc, Window *parent) : Window(desc)
|
||||
{
|
||||
this->advanced = false;
|
||||
this->CreateNestedTree();
|
||||
@@ -1686,12 +1708,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
void OnQueryTextFinished(std::optional<std::string> str) override
|
||||
{
|
||||
if (str == nullptr) return;
|
||||
if (!str.has_value()) return;
|
||||
/* Set a new company manager face number */
|
||||
if (!StrEmpty(str)) {
|
||||
this->face = std::strtoul(str, nullptr, 10);
|
||||
if (!str->empty()) {
|
||||
this->face = std::strtoul(str->c_str(), nullptr, 10);
|
||||
ScaleAllCompanyManagerFaceBits(this->face);
|
||||
ShowErrorMessage(STR_FACE_FACECODE_SET, INVALID_STRING_ID, WL_INFO);
|
||||
this->UpdateData();
|
||||
@@ -1707,7 +1729,7 @@ static WindowDesc _select_company_manager_face_desc(
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_COMPANY_MANAGER_FACE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_select_company_manager_face_widgets), std::end(_nested_select_company_manager_face_widgets)
|
||||
_nested_select_company_manager_face_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1720,7 +1742,7 @@ static void DoSelectCompanyManagerFace(Window *parent)
|
||||
if (!Company::IsValidID((CompanyID)parent->window_number)) return;
|
||||
|
||||
if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return;
|
||||
new SelectCompanyManagerFaceWindow(&_select_company_manager_face_desc, parent);
|
||||
new SelectCompanyManagerFaceWindow(_select_company_manager_face_desc, parent);
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_company_infrastructure_widgets[] = {
|
||||
@@ -1770,7 +1792,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
|
||||
uint total_width; ///< String width of the total cost line.
|
||||
|
||||
CompanyInfrastructureWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
||||
CompanyInfrastructureWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->UpdateRailRoadTypes();
|
||||
|
||||
@@ -2084,7 +2106,7 @@ static WindowDesc _company_infrastructure_desc(
|
||||
WDP_AUTO, "company_infrastructure", 0, 0,
|
||||
WC_COMPANY_INFRASTRUCTURE, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_company_infrastructure_widgets), std::end(_nested_company_infrastructure_widgets)
|
||||
_nested_company_infrastructure_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -2094,7 +2116,7 @@ static WindowDesc _company_infrastructure_desc(
|
||||
static void ShowCompanyInfrastructure(CompanyID company)
|
||||
{
|
||||
if (!Company::IsValidID(company)) return;
|
||||
AllocateWindowDescFront<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
|
||||
AllocateWindowDescFront<CompanyInfrastructureWindow>(_company_infrastructure_desc, company);
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_company_widgets[] = {
|
||||
@@ -2113,7 +2135,7 @@ static constexpr NWidgetPart _nested_company_widgets[] = {
|
||||
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_C_DESC_INAUGURATION), SetDataTip(STR_COMPANY_VIEW_INAUGURATED_TITLE, STR_NULL), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_C_DESC_INAUGURATION), SetDataTip(STR_JUST_STRING2, STR_NULL), SetFill(1, 0),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
|
||||
NWidget(WWT_LABEL, COLOUR_GREY, WID_C_DESC_COLOUR_SCHEME), SetDataTip(STR_COMPANY_VIEW_COLOUR_SCHEME_TITLE, STR_NULL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_DESC_COLOUR_SCHEME_EXAMPLE), SetMinimalSize(30, 0), SetFill(1, 1),
|
||||
@@ -2196,7 +2218,7 @@ struct CompanyWindow : Window
|
||||
CWP_RELOCATE_HIDE, ///< Hide the relocate HQ button.
|
||||
};
|
||||
|
||||
CompanyWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
||||
CompanyWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->InitNested(window_number);
|
||||
this->owner = (Owner)this->window_number;
|
||||
@@ -2401,7 +2423,14 @@ struct CompanyWindow : Window
|
||||
break;
|
||||
|
||||
case WID_C_DESC_INAUGURATION:
|
||||
SetDParam(0, Company::Get((CompanyID)this->window_number)->inaugurated_year);
|
||||
if (TimerGameEconomy::UsingWallclockUnits()) {
|
||||
SetDParam(0, STR_COMPANY_VIEW_INAUGURATED_TITLE_WALLCLOCK);
|
||||
SetDParam(1, Company::Get(static_cast<CompanyID>(this->window_number))->inaugurated_year_calendar);
|
||||
SetDParam(2, Company::Get(static_cast<CompanyID>(this->window_number))->inaugurated_year);
|
||||
} else {
|
||||
SetDParam(0, STR_COMPANY_VIEW_INAUGURATED_TITLE);
|
||||
SetDParam(1, Company::Get(static_cast<CompanyID>(this->window_number))->inaugurated_year);
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_C_DESC_COMPANY_VALUE:
|
||||
@@ -2520,25 +2549,25 @@ struct CompanyWindow : Window
|
||||
this->RaiseButtons();
|
||||
}
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
void OnQueryTextFinished(std::optional<std::string> str) override
|
||||
{
|
||||
if (str == nullptr) return;
|
||||
if (!str.has_value()) return;
|
||||
|
||||
switch (this->query_widget) {
|
||||
default: NOT_REACHED();
|
||||
|
||||
case WID_C_GIVE_MONEY: {
|
||||
Money money = std::strtoull(str, nullptr, 10) / GetCurrency().rate;
|
||||
Money money = std::strtoull(str->c_str(), nullptr, 10) / GetCurrency().rate;
|
||||
Command<CMD_GIVE_MONEY>::Post(STR_ERROR_CAN_T_GIVE_MONEY, money, (CompanyID)this->window_number);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_C_PRESIDENT_NAME:
|
||||
Command<CMD_RENAME_PRESIDENT>::Post(STR_ERROR_CAN_T_CHANGE_PRESIDENT, str);
|
||||
Command<CMD_RENAME_PRESIDENT>::Post(STR_ERROR_CAN_T_CHANGE_PRESIDENT, *str);
|
||||
break;
|
||||
|
||||
case WID_C_COMPANY_NAME:
|
||||
Command<CMD_RENAME_COMPANY>::Post(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME, str);
|
||||
Command<CMD_RENAME_COMPANY>::Post(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME, *str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2556,7 +2585,7 @@ static WindowDesc _company_desc(
|
||||
WDP_AUTO, "company", 0, 0,
|
||||
WC_COMPANY, WC_NONE,
|
||||
0,
|
||||
std::begin(_nested_company_widgets), std::end(_nested_company_widgets)
|
||||
_nested_company_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -2567,7 +2596,7 @@ void ShowCompany(CompanyID company)
|
||||
{
|
||||
if (!Company::IsValidID(company)) return;
|
||||
|
||||
AllocateWindowDescFront<CompanyWindow>(&_company_desc, company);
|
||||
AllocateWindowDescFront<CompanyWindow>(_company_desc, company);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2581,7 +2610,7 @@ void DirtyCompanyInfrastructureWindows(CompanyID company)
|
||||
}
|
||||
|
||||
struct BuyCompanyWindow : Window {
|
||||
BuyCompanyWindow(WindowDesc *desc, WindowNumber window_number, bool hostile_takeover) : Window(desc), hostile_takeover(hostile_takeover)
|
||||
BuyCompanyWindow(WindowDesc &desc, WindowNumber window_number, bool hostile_takeover) : Window(desc), hostile_takeover(hostile_takeover)
|
||||
{
|
||||
this->InitNested(window_number);
|
||||
|
||||
@@ -2690,7 +2719,7 @@ static WindowDesc _buy_company_desc(
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUY_COMPANY, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
std::begin(_nested_buy_company_widgets), std::end(_nested_buy_company_widgets)
|
||||
_nested_buy_company_widgets
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -2702,6 +2731,6 @@ void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover)
|
||||
{
|
||||
auto window = BringWindowToFrontById(WC_BUY_COMPANY, company);
|
||||
if (window == nullptr) {
|
||||
new BuyCompanyWindow(&_buy_company_desc, company, hostile_takeover);
|
||||
new BuyCompanyWindow(_buy_company_desc, company, hostile_takeover);
|
||||
}
|
||||
}
|
||||
|
@@ -34,11 +34,11 @@ static const uint ICON_MAX_RECURSE = 10; ///< Maximum number of recursion
|
||||
return aliases;
|
||||
}
|
||||
|
||||
FILE *_iconsole_output_file;
|
||||
std::optional<FileHandle> _iconsole_output_file;
|
||||
|
||||
void IConsoleInit()
|
||||
{
|
||||
_iconsole_output_file = nullptr;
|
||||
_iconsole_output_file = std::nullopt;
|
||||
_redirect_console_to_client = INVALID_CLIENT_ID;
|
||||
_redirect_console_to_admin = INVALID_ADMIN_ID;
|
||||
|
||||
@@ -49,13 +49,12 @@ void IConsoleInit()
|
||||
|
||||
static void IConsoleWriteToLogFile(const std::string &string)
|
||||
{
|
||||
if (_iconsole_output_file != nullptr) {
|
||||
if (_iconsole_output_file.has_value()) {
|
||||
/* if there is an console output file ... also print it there */
|
||||
try {
|
||||
fmt::print(_iconsole_output_file, "{}{}\n", GetLogPrefix(), string);
|
||||
fmt::print(*_iconsole_output_file, "{}{}\n", GetLogPrefix(), string);
|
||||
} catch (const std::system_error &) {
|
||||
fclose(_iconsole_output_file);
|
||||
_iconsole_output_file = nullptr;
|
||||
_iconsole_output_file.reset();
|
||||
IConsolePrint(CC_ERROR, "Cannot write to console log file; closing the log file.");
|
||||
}
|
||||
}
|
||||
@@ -63,10 +62,9 @@ static void IConsoleWriteToLogFile(const std::string &string)
|
||||
|
||||
bool CloseConsoleLogIfActive()
|
||||
{
|
||||
if (_iconsole_output_file != nullptr) {
|
||||
if (_iconsole_output_file.has_value()) {
|
||||
IConsolePrint(CC_INFO, "Console log file closed.");
|
||||
fclose(_iconsole_output_file);
|
||||
_iconsole_output_file = nullptr;
|
||||
_iconsole_output_file.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user