mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-19 12:39:11 +00:00
Compare commits
607 Commits
14.1
...
89182e4b15
Author | SHA1 | Date | |
---|---|---|---|
|
89182e4b15 | ||
|
a75532dd47 | ||
|
6d40780434 | ||
|
6335312b3c | ||
|
573b55cf9f | ||
|
23f8519624 | ||
|
ac06b4a7a6 | ||
|
3a3b1c5f04 | ||
|
a2dd8ed419 | ||
|
53d2153844 | ||
|
37f68a65ee | ||
f6c5da4cad | |||
4b81b62b72 | |||
|
692943669d | ||
517dab35b1 | |||
3c42f701d7 | |||
2c70ccb137 | |||
|
d11823df36 | ||
|
6efc1fa250 | ||
|
d72917b285 | ||
|
c325a2ebd4 | ||
676d64037d | |||
|
d9cadb49b0 | ||
5fefe0b61f | |||
f87c6990b0 | |||
|
071796660d | ||
|
c2daabc010 | ||
|
b2572c7ca8 | ||
|
9f13d3ff2b | ||
|
8f6e21617f | ||
|
b2f1a06def | ||
|
fea9ffa808 | ||
8a6745b26f | |||
766350bfd2 | |||
7e12b5ff0f | |||
|
42fc32243d | ||
19ca4089a1 | |||
|
5bc3723bcc | ||
5442b0dd2d | |||
28e814f62a | |||
|
fb4a370d3f | ||
|
46d7586ab1 | ||
|
29ce013eda | ||
ba47d1ca2b | |||
3f5a354f37 | |||
856ec901ca | |||
|
7fd2487c46 | ||
8d26d032e1 | |||
c85481564f | |||
4940b6ff0b | |||
|
26113e3622 | ||
ca52da6c95 | |||
d1b7619822 | |||
|
56ea002283 | ||
980dcaac6e | |||
ed67aedabf | |||
874cfe000b | |||
b731ab0632 | |||
d99c1337a2 | |||
f901722066 | |||
|
bb77d16e40 | ||
|
486af1a6fc | ||
460fab920c | |||
|
00c4b232b3 | ||
|
3f06aa441b | ||
|
9f63b9f65d | ||
|
870149406a | ||
18e56df5e1 | |||
f2f7573c3f | |||
|
77c188e6da | ||
|
6cea49c117 | ||
|
8349203038 | ||
77a7113ba6 | |||
|
f939e81bf0 | ||
|
95a89e43b2 | ||
34da94ffc8 | |||
d78f39a9df | |||
|
721cd2b8ad | ||
b30fe0d7da | |||
fde3b35a24 | |||
b76517816e | |||
cdc356e7bf | |||
d2c8b476b5 | |||
9f8c9724be | |||
d5671030b1 | |||
733284cc16 | |||
31c306c6cd | |||
|
dc22edc556 | ||
|
04cc0c8125 | ||
|
40e6230900 | ||
|
dfa2622153 | ||
|
e436e2ef40 | ||
|
64e1f1d4d9 | ||
|
4bf2dc3148 | ||
|
c1375cecf8 | ||
|
ffe76a0133 | ||
|
c3ee5e58a3 | ||
|
798ec4184b | ||
|
55a7c59d13 | ||
|
a5c2543efc | ||
|
cef9417c9f | ||
|
a313676189 | ||
|
ed888c617b | ||
|
59ac27f385 | ||
ec61951512 | |||
5b35fbd6f5 | |||
|
132e226b27 | ||
|
00cfd572ff | ||
|
cb3f99859c | ||
b74a7e749b | |||
731d46beb5 | |||
9008d793ab | |||
|
8710e9b8c8 | ||
|
019f93a65f | ||
|
ab7e2a1883 | ||
|
1a3cbaec56 | ||
|
849d1fa1b3 | ||
|
457d51fc49 | ||
|
a9318cf653 | ||
|
9dc1fdc385 | ||
|
16639939e9 | ||
|
ca4bef1504 | ||
|
71fc907584 | ||
|
a002803d1c | ||
|
4f3db8eeaf | ||
|
66354ab9eb | ||
|
1250ce8fdc | ||
|
4e9a280ef8 | ||
|
b9c894b717 | ||
|
455e202e03 | ||
4740eeaa43 | |||
|
d2f98440bb | ||
84ebae0bf5 | |||
cf94bd321d | |||
72b2840a97 | |||
|
99f497cb08 | ||
|
9fe9e4d398 | ||
d074ab909c | |||
|
cb26b0e92d | ||
f629d3c921 | |||
115ac2629b | |||
|
60cf37e0d1 | ||
9a7c30a109 | |||
9d2efd4c96 | |||
|
8b6661d486 | ||
|
0b50834f81 | ||
|
e0048d798f | ||
90029beb49 | |||
|
c17fa6032b | ||
|
ef99aa81a3 | ||
cf96d49ced | |||
|
65c9df49d9 | ||
|
2559bdfa6f | ||
|
9647fe1d05 | ||
f146680121 | |||
7147fe9e7a | |||
532ce1a907 | |||
1424a184d8 | |||
|
96d82b4363 | ||
|
4df44fea38 | ||
cc6e4768a9 | |||
|
b852a3f408 | ||
|
fd4cf699e5 | ||
|
98d37338df | ||
|
24b6ec80a9 | ||
|
87dbd4a833 | ||
|
d183d8e587 | ||
|
37a03b513f | ||
|
546a996d95 | ||
|
ad50c4f298 | ||
ef55cc7979 | |||
|
99b74c1064 | ||
|
826deaee57 | ||
|
97a34bf06e | ||
|
ee9895a970 | ||
440a633fcc | |||
33aedc43a5 | |||
|
8308998388 | ||
bf8de188ec | |||
72c55128d2 | |||
a6d401debf | |||
|
a60a81f34e | ||
|
0fdabca605 | ||
f44d8fa2e4 | |||
0075a95278 | |||
5bc9854be2 | |||
|
9b747a173d | ||
|
11ec156b64 | ||
|
57f5d27427 | ||
|
ceb0053dd9 | ||
|
339b0ea0ff | ||
|
fd80a1ec66 | ||
|
a4071b78d7 | ||
|
e8d25d68b9 | ||
e8249e9075 | |||
5159aa81d4 | |||
26bb87ebf1 | |||
1dc94d0670 | |||
6a3f50aa72 | |||
e20f48799e | |||
5e689ce25e | |||
|
9121770582 | ||
ac6a945e26 | |||
|
bef11941c6 | ||
|
95de90dd4e | ||
3814adaba8 | |||
|
c82a2575d7 | ||
|
ded4d63db2 | ||
d465257dd0 | |||
3b01d31280 | |||
|
c073165e34 | ||
|
aa895535e6 | ||
959ced71bb | |||
b4e00fa738 | |||
|
c5ef47ee09 | ||
|
1dfd0c19f4 | ||
|
c377c4740d | ||
a1a01e21cf | |||
|
fc7f184dbd | ||
|
1691b41b54 | ||
|
434c49a1f8 | ||
|
8fe5fdf122 | ||
|
8986fb0385 | ||
2114888485 | |||
|
e441033d68 | ||
40fa45a76a | |||
ed2db80990 | |||
57d7359b1a | |||
699c7e4c9d | |||
1c31e4b68c | |||
e028c15555 | |||
|
08140fdca3 | ||
6cbb8d02cf | |||
5df5e3f45c | |||
2a833a8968 | |||
7e049aa2b1 | |||
16eb17418b | |||
61c6ebaacc | |||
d43ff8dc49 | |||
f267b37a33 | |||
a28ab8cac2 | |||
6ee31a2a22 | |||
3b80a8255f | |||
|
7848e80f71 | ||
|
0d1fc47edb | ||
774f811217 | |||
3b75d8bbf8 | |||
21d11ee361 | |||
db56499c01 | |||
fe7bd3a266 | |||
d57bf84196 | |||
45886e50b2 | |||
|
04a3bf76e8 | ||
|
08d05bf4c0 | ||
4170c9923a | |||
|
78b83190cc | ||
|
715f8c0218 | ||
|
c355e98c58 | ||
63ce81570c | |||
42523379d9 | |||
d7c547d0db | |||
5a523cf212 | |||
6458980413 | |||
|
83d99ec11d | ||
|
f7bd080015 | ||
|
07b162ffc4 | ||
|
a0636d8200 | ||
|
a09749f6a6 | ||
|
1005c86c62 | ||
|
a02da5476e | ||
|
5878d09ef2 | ||
|
824687d1f0 | ||
|
0b9029b69c | ||
ef8eb66a2b | |||
|
b477a8458c | ||
|
018326321c | ||
|
257d312a58 | ||
|
b2218e75d4 | ||
48eb9b8bc9 | |||
|
8e2ccddd77 | ||
3ad143c43a | |||
|
672aa014d8 | ||
|
727392e0b3 | ||
a1b03ee69e | |||
|
f5a50a874f | ||
|
cd108fd9e4 | ||
839f486074 | |||
4eaeccdaeb | |||
|
29e932e087 | ||
|
090c3b3abf | ||
e83e2df023 | |||
12125bad82 | |||
c1520cf682 | |||
ca73f03334 | |||
44b8210037 | |||
003906becb | |||
|
bb9b8b90c7 | ||
9915c1f032 | |||
|
eda10abc8c | ||
3316b27496 | |||
|
afd7878de0 | ||
|
5592b4409b | ||
|
e8a56db21d | ||
|
4f2412a272 | ||
|
2587a21400 | ||
|
ff27b9e76a | ||
|
6cade18053 | ||
|
442daf58da | ||
6bc4a62c27 | |||
332cbca36e | |||
a42aa1a086 | |||
144bcbbaf1 | |||
|
21b640b5ff | ||
|
1b4bb1d38a | ||
|
f0f97c698b | ||
1773c5b810 | |||
|
df8eeb1b10 | ||
77f27e0804 | |||
052f421327 | |||
34758d0921 | |||
90ca3515da | |||
2976a46d06 | |||
|
883d3e7a9f | ||
54be756aae | |||
dc7c2bb30d | |||
de4e00c93f | |||
|
b5ad28022d | ||
1b127628cb | |||
7e28605830 | |||
4daf95b878 | |||
cdfffb551c | |||
74e09abf76 | |||
|
4e6d4fcf32 | ||
|
095bdf32fe | ||
|
62f5c595f3 | ||
|
4718971ccc | ||
995fca58a2 | |||
|
d7fa614a9d | ||
|
1fcf1a136d | ||
|
0f6bf90731 | ||
eb094a953c | |||
34ba969c74 | |||
fbdf26800b | |||
a4c2f0778a | |||
b905209421 | |||
830c9e2de8 | |||
|
97bea563d7 | ||
|
c544a2be0a | ||
|
eaafc57de6 | ||
8e881471c1 | |||
6771dbe62b | |||
a866166673 | |||
2cc700d606 | |||
83da886093 | |||
e8c78df39e | |||
d11622b9a0 | |||
|
df3e5ade11 | ||
7572cfd103 | |||
9854553e10 | |||
3c94e81665 | |||
7c322ebcf1 | |||
197fb00d31 | |||
338def1b06 | |||
f6a88e40a4 | |||
|
08cf106fc6 | ||
|
243c6bead3 | ||
|
931aa39018 | ||
9750826590 | |||
|
72b5c6a591 | ||
2047c27445 | |||
56cac21086 | |||
|
11aa3694fa | ||
3de8853e29 | |||
00e0021e3a | |||
295508fc53 | |||
f79ec7955a | |||
bd2a92331b | |||
f6b38e8e06 | |||
e4fc8ef595 | |||
|
6f36f3d714 | ||
|
92a171c3e0 | ||
d68e5159e1 | |||
|
3d2a8fb60c | ||
d683ec0183 | |||
|
d5e28a904d | ||
|
9954187680 | ||
|
77f02faf15 | ||
|
340c2802da | ||
|
e866ca8adc | ||
|
c0308acb03 | ||
8d312b305b | |||
|
e21c12afeb | ||
e16b982b6a | |||
3e83dcedfd | |||
8746be8bf2 | |||
|
907cb4fc53 | ||
|
8fb7d74dfe | ||
|
69acc132ca | ||
|
71087bb6d3 | ||
|
ca53e134be | ||
|
433484cda3 | ||
|
b8b01818ca | ||
|
575336ef43 | ||
|
8e12bd35ae | ||
4751179dc5 | |||
|
9aa6669266 | ||
|
84bbe235e4 | ||
|
f71ada4f30 | ||
|
f845b4bbc3 | ||
|
40a75e0b8d | ||
97c1738541 | |||
eebfb83aa2 | |||
|
8928f4979a | ||
|
caa7c44052 | ||
|
d09b5aaeba | ||
|
c01bf06ee1 | ||
|
018944dc20 | ||
668186ca5b | |||
ff35288ddf | |||
|
02c00f3e3e | ||
|
704e871a0e | ||
|
603154899a | ||
|
0f25eaa271 | ||
|
515303b8be | ||
|
2732b3d6c6 | ||
ea74ca0a76 | |||
|
f599108c16 | ||
|
4321cca5fb | ||
df2ee7b06c | |||
|
e904122441 | ||
|
7457f8d0ff | ||
|
5751da7809 | ||
|
e141734e54 | ||
|
2189607c34 | ||
|
e42aec5a89 | ||
|
0eaeeaabb6 | ||
|
704d3b8a9b | ||
|
00a09af1fd | ||
|
d4a6ee9554 | ||
|
3a3d8f3b53 | ||
737e3feaf0 | |||
|
7580eac2d5 | ||
2485de9462 | |||
107c208d87 | |||
|
ec3c8d3462 | ||
|
4af089b9be | ||
|
b7dfa3eb90 | ||
|
1cf8799810 | ||
|
d26629c15b | ||
|
5706801ea7 | ||
|
dd532cbc77 | ||
|
fb9d4afa5c | ||
88cf99017a | |||
322ca6ef54 | |||
3fc7b3b9a0 | |||
|
f08da1d373 | ||
ab94c8b511 | |||
|
6c5a8f55df | ||
|
a886bd9666 | ||
|
a3cfd23cf9 | ||
|
bd7120bae4 | ||
|
af1bd43b30 | ||
0058ebe472 | |||
|
818a57c9af | ||
|
d7c5e9e8ab | ||
|
7f49b6f25a | ||
|
5f4f9334ce | ||
|
4c0dca1411 | ||
|
fe12d38024 | ||
|
15d02f51ed | ||
|
b6c75dec3a | ||
|
26d1d5d6e7 | ||
|
6eff879e49 | ||
|
3c488e1eb8 | ||
|
ec4104ec6c | ||
|
3e625b5b1a | ||
|
b394c20519 | ||
|
a7625b8ae0 | ||
|
9db285a32b | ||
|
2d2191fbb3 | ||
|
23d733be95 | ||
|
24efdf6ac5 | ||
|
14d95ef1c9 | ||
|
100c043599 | ||
|
0cff40dd19 | ||
|
1addeddc07 | ||
|
8a37f6479a | ||
|
a06814c173 | ||
|
984202b101 | ||
|
d7b99cbe26 | ||
|
c768f4fc7a | ||
|
ee22fa34d7 | ||
|
eaf62f3969 | ||
b9ca3ead8b | |||
dc6305e8c1 | |||
|
95a8fab339 | ||
8b60fc3d35 | |||
|
2f0fe22d63 | ||
649c1cf14c | |||
|
ecf534522c | ||
|
27eadc13ec | ||
|
df461b0329 | ||
|
005892bfdb | ||
|
cca9dcdd57 | ||
|
9c95fbdb07 | ||
|
86cb184eb4 | ||
|
e4b3f3f495 | ||
|
bab5a8a787 | ||
|
381dee2e01 | ||
|
738624ded4 | ||
55a328c586 | |||
de8a840db5 | |||
|
82430a1086 | ||
|
e0e0d5f8fb | ||
|
ebd258b404 | ||
|
32b0fb9f6e | ||
|
04ce1c08ae | ||
|
ab315d0dc9 | ||
|
6e0f58f700 | ||
|
3a71f36393 | ||
|
ae27ce12a7 | ||
|
ce3d0097f6 | ||
|
08ff1ab93e | ||
|
ab353f8ad5 | ||
|
8b9f59d320 | ||
|
8dda387f82 | ||
|
5806c2aba4 | ||
|
0c432bdc4d | ||
|
ab52f7eecf | ||
|
b8b80cb42e | ||
|
aef8a345b2 | ||
|
63b9284a7e | ||
a9de766fa6 | |||
|
30e1a61c04 | ||
|
216905ce1f | ||
25aeb1c5a5 | |||
|
8fb26612c0 | ||
|
ef40c5e240 | ||
|
634b67bf13 | ||
|
1a2b54498b | ||
2d48829999 | |||
00b442d6f9 | |||
bc3bd642b9 | |||
|
845b894fd8 | ||
|
0fd576bfbc | ||
|
626ee4ab41 | ||
8172e25273 | |||
b2ca6e1ac8 | |||
cff48c0f63 | |||
41b3314d76 | |||
278c3a7db1 | |||
|
c5afc9173c | ||
|
f180262aee | ||
|
d7c485d4b9 | ||
|
8f22066b9a | ||
|
aff09306de | ||
|
253ba0d354 | ||
|
b53d79b1d2 | ||
a602845d0a | |||
|
3fd5c33ae6 | ||
|
7824ae5b59 | ||
|
b307541099 | ||
|
890040ceea | ||
|
667adf7df9 | ||
f0a891c4f7 | |||
|
c0b5510a94 | ||
|
c4f9479507 | ||
|
fad77261ea | ||
d4f0f0e2c5 | |||
|
529d813496 | ||
e93d081a4a | |||
59420d57ec | |||
a61311fcb0 | |||
bf865dc536 | |||
|
f612bc6ee2 | ||
|
2fb1593550 | ||
|
e775ef2b70 | ||
|
149592e4dd | ||
|
e939f59cbb | ||
|
7b1e3cfeb5 | ||
86be6d7e0b | |||
912d7bd80e | |||
ae3390fe48 | |||
0463d4c198 | |||
56cf89d189 | |||
8afef45d4e | |||
|
ddb3914074 | ||
|
677ec70b0e | ||
|
c25d9f5c81 | ||
|
222832f1d4 | ||
|
7135330819 | ||
|
b22fb43cea | ||
2b79e7cdf5 | |||
|
bb86023d50 | ||
|
4c117dd2d8 | ||
|
8015d96a50 | ||
|
5d2e6e4efa | ||
|
ca146c8ddd | ||
|
409c073eca | ||
|
7bab2c1cc3 | ||
|
c637d376d0 | ||
|
ad9080338c | ||
|
bff69e192b | ||
|
25d1238907 | ||
|
2d7ad9f717 | ||
|
f1bf39f38b | ||
|
a4d4301a0c |
@@ -14,3 +14,7 @@ notifications:
|
||||
pull-request:
|
||||
issue:
|
||||
tag-created:
|
||||
workflow-run:
|
||||
only:
|
||||
- .github/workflows/release.yml
|
||||
- .github/workflows/ci-nightly.yml
|
||||
|
403
.github/workflows/ci-build.yml
vendored
403
.github/workflows/ci-build.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: CI
|
||||
name: CI - Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@@ -17,79 +17,22 @@ jobs:
|
||||
emscripten:
|
||||
name: Emscripten
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
container:
|
||||
# If you change this version, change the number in the cache step too.
|
||||
image: emscripten/emsdk:3.1.42
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /emsdk/upstream/emscripten/cache
|
||||
key: 3.1.42-${{ runner.os }}
|
||||
|
||||
- name: Patch Emscripten to support LZMA
|
||||
run: |
|
||||
cd /emsdk/upstream/emscripten
|
||||
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
|
||||
|
||||
- name: Build (host tools)
|
||||
run: |
|
||||
mkdir build-host
|
||||
cd build-host
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. -DOPTION_TOOLS_ONLY=ON
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc) --target tools
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
emcmake cmake .. -DHOST_BINARY_DIR=../build-host
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc) --target openttd
|
||||
echo "::endgroup::"
|
||||
uses: ./.github/workflows/ci-emscripten.yml
|
||||
secrets: inherit
|
||||
|
||||
linux:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Clang - Debug
|
||||
- name: Clang
|
||||
compiler: clang-15
|
||||
cxxcompiler: clang++-15
|
||||
libraries: libsdl2-dev
|
||||
- name: Clang - Release
|
||||
compiler: clang-15
|
||||
cxxcompiler: clang++-15
|
||||
libraries: libsdl2-dev
|
||||
extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF
|
||||
- name: GCC - SDL2
|
||||
compiler: gcc
|
||||
cxxcompiler: g++
|
||||
libraries: libsdl2-dev
|
||||
- name: GCC - SDL1.2
|
||||
compiler: gcc
|
||||
cxxcompiler: g++
|
||||
libraries: libsdl1.2-dev
|
||||
- name: GCC - Dedicated
|
||||
compiler: gcc
|
||||
cxxcompiler: g++
|
||||
@@ -99,332 +42,57 @@ jobs:
|
||||
|
||||
name: Linux (${{ matrix.name }})
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
CXX: ${{ matrix.cxxcompiler }}
|
||||
uses: ./.github/workflows/ci-linux.yml
|
||||
secrets: inherit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg
|
||||
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
echo "::group::Update apt"
|
||||
sudo apt-get update
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Install dependencies"
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
liballegro4-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libfontconfig-dev \
|
||||
libharfbuzz-dev \
|
||||
libicu-dev \
|
||||
liblzma-dev \
|
||||
liblzo2-dev \
|
||||
${{ matrix.libraries }} \
|
||||
zlib1g-dev \
|
||||
# EOF
|
||||
|
||||
echo "::group::Install vcpkg dependencies"
|
||||
|
||||
# Disable vcpkg integration, as we mostly use system libraries.
|
||||
mv vcpkg.json vcpkg-disabled.json
|
||||
|
||||
# We only use breakpad from vcpkg, as its CMake files
|
||||
# are a bit special. So the Ubuntu's variant doesn't work.
|
||||
./vcpkg/vcpkg install breakpad
|
||||
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
- name: Get OpenGFX
|
||||
run: |
|
||||
mkdir -p ~/.local/share/openttd/baseset
|
||||
cd ~/.local/share/openttd/baseset
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake ${{ matrix.extra-cmake-parameters }}
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc)
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
(
|
||||
cd build
|
||||
ctest -j $(nproc) --timeout 120
|
||||
)
|
||||
|
||||
# Re-enable vcpkg.
|
||||
mv vcpkg-disabled.json vcpkg.json
|
||||
|
||||
# Check no tracked files have been modified.
|
||||
git diff --exit-code
|
||||
with:
|
||||
compiler: ${{ matrix.compiler }}
|
||||
cxxcompiler: ${{ matrix.cxxcompiler }}
|
||||
libraries: ${{ matrix.libraries }}
|
||||
extra-cmake-parameters: ${{ matrix.extra-cmake-parameters }}
|
||||
|
||||
macos:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: arm64
|
||||
- name: arm64 - Debug
|
||||
arch: arm64
|
||||
full_arch: arm64
|
||||
extra-cmake-parameters: -DCMAKE_BUILD_TYPE=Debug
|
||||
- name: arm64 - Release
|
||||
arch: arm64
|
||||
full_arch: arm64
|
||||
extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF
|
||||
|
||||
name: Mac OS (${{ matrix.arch }})
|
||||
name: Mac OS (${{ matrix.name }})
|
||||
|
||||
runs-on: macos-14
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||
uses: ./.github/workflows/ci-macos.yml
|
||||
secrets: inherit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg
|
||||
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
- name: Install OpenGFX
|
||||
run: |
|
||||
mkdir -p ~/Documents/OpenTTD/baseset
|
||||
cd ~/Documents/OpenTTD/baseset
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. \
|
||||
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.full_arch }} \
|
||||
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-osx \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(sysctl -n hw.logicalcpu) cores"
|
||||
cmake --build . -j $(sysctl -n hw.logicalcpu)
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build
|
||||
ctest -j $(sysctl -n hw.logicalcpu) --timeout 120
|
||||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
full_arch: ${{ matrix.full_arch }}
|
||||
extra-cmake-parameters: ${{ matrix.extra-cmake-parameters }}
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [windows-latest]
|
||||
arch: [x86, x64]
|
||||
|
||||
name: Windows (${{ matrix.os }} / ${{ matrix.arch }})
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg
|
||||
.\vcpkg\bootstrap-vcpkg.bat -disableMetrics
|
||||
|
||||
- name: Install OpenGFX
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
cd "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install MSVC problem matcher
|
||||
uses: ammaraskar/msvc-problem-matcher@master
|
||||
|
||||
- name: Configure developer command prompt for ${{ matrix.arch }}
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
env:
|
||||
NINJA_STATUS: "[%f/%t -- %e] " # [finished_edges/total_edges -- elapsed_time], default value is "[%f/%t] "
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
shell: bash
|
||||
run: |
|
||||
cd build
|
||||
ctest --timeout 120
|
||||
|
||||
|
||||
msys2:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- msystem: MINGW64
|
||||
arch: x86_64
|
||||
- msystem: MINGW32
|
||||
arch: i686
|
||||
- os: windows-latest
|
||||
arch: x86
|
||||
- os: windows-latest
|
||||
arch: x64
|
||||
|
||||
name: MinGW (${{ matrix.arch }})
|
||||
name: Windows (${{ matrix.arch }})
|
||||
|
||||
runs-on: windows-latest
|
||||
uses: ./.github/workflows/ci-windows.yml
|
||||
secrets: inherit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: ${{ matrix.msystem }}
|
||||
release: false
|
||||
install: >-
|
||||
git
|
||||
make
|
||||
mingw-w64-${{ matrix.arch }}-cmake
|
||||
mingw-w64-${{ matrix.arch }}-gcc
|
||||
mingw-w64-${{ matrix.arch }}-lzo2
|
||||
mingw-w64-${{ matrix.arch }}-libpng
|
||||
mingw-w64-${{ matrix.arch }}-lld
|
||||
mingw-w64-${{ matrix.arch }}-ninja
|
||||
|
||||
- name: Install OpenGFX
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
cd "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
shell: msys2 {0}
|
||||
env:
|
||||
NINJA_STATUS: "[%f/%t -- %e] " # [finished_edges/total_edges -- elapsed_time], default value is "[%f/%t] "
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
cd build
|
||||
ctest --timeout 120
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
check_annotations:
|
||||
name: Check Annotations
|
||||
@@ -433,7 +101,6 @@ jobs:
|
||||
- linux
|
||||
- macos
|
||||
- windows
|
||||
- msys2
|
||||
|
||||
if: always() && github.event_name == 'pull_request'
|
||||
|
||||
|
61
.github/workflows/ci-emscripten.yml
vendored
Normal file
61
.github/workflows/ci-emscripten.yml
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
name: CI (Emscripten)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
||||
jobs:
|
||||
emscripten:
|
||||
name: CI
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
container:
|
||||
# If you change this version, change the number in the cache step too.
|
||||
image: emscripten/emsdk:3.1.57
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /emsdk/upstream/emscripten/cache
|
||||
key: 3.1.57-${{ runner.os }}
|
||||
|
||||
- name: Add liblzma support
|
||||
run: |
|
||||
cp ${GITHUB_WORKSPACE}/os/emscripten/ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/
|
||||
|
||||
- name: Build (host tools)
|
||||
run: |
|
||||
mkdir build-host
|
||||
cd build-host
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. -DOPTION_TOOLS_ONLY=ON
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc) --target tools
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
emcmake cmake .. -DHOST_BINARY_DIR=../build-host
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc) --target openttd
|
||||
echo "::endgroup::"
|
123
.github/workflows/ci-linux.yml
vendored
Normal file
123
.github/workflows/ci-linux.yml
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
name: CI (Linux)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
compiler:
|
||||
required: true
|
||||
type: string
|
||||
cxxcompiler:
|
||||
required: true
|
||||
type: string
|
||||
libraries:
|
||||
required: true
|
||||
type: string
|
||||
extra-cmake-parameters:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
name: CI
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CC: ${{ inputs.compiler }}
|
||||
CXX: ${{ inputs.cxxcompiler }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
echo "::group::Update apt"
|
||||
sudo apt-get update
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Install dependencies"
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
liballegro4-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libfontconfig-dev \
|
||||
libharfbuzz-dev \
|
||||
libicu-dev \
|
||||
liblzma-dev \
|
||||
liblzo2-dev \
|
||||
${{ inputs.libraries }} \
|
||||
zlib1g-dev \
|
||||
# EOF
|
||||
|
||||
echo "::group::Install vcpkg dependencies"
|
||||
|
||||
# Disable vcpkg integration, as we mostly use system libraries.
|
||||
mv vcpkg.json vcpkg-disabled.json
|
||||
|
||||
# We only use breakpad from vcpkg, as its CMake files
|
||||
# are a bit special. So the Ubuntu's variant doesn't work.
|
||||
${{ runner.temp }}/vcpkg/vcpkg install breakpad
|
||||
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
- name: Get OpenGFX
|
||||
run: |
|
||||
mkdir -p ~/.local/share/openttd/baseset
|
||||
cd ~/.local/share/openttd/baseset
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake ${{ inputs.extra-cmake-parameters }}
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc)
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
(
|
||||
cd build
|
||||
ctest -j $(nproc) --timeout 120
|
||||
)
|
||||
|
||||
# Re-enable vcpkg.
|
||||
mv vcpkg-disabled.json vcpkg.json
|
||||
|
||||
# Check no tracked files have been modified.
|
||||
git diff --exit-code
|
90
.github/workflows/ci-macos.yml
vendored
Normal file
90
.github/workflows/ci-macos.yml
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
name: CI (MacOS)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
required: true
|
||||
type: string
|
||||
full_arch:
|
||||
required: true
|
||||
type: string
|
||||
extra-cmake-parameters:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
||||
jobs:
|
||||
macos:
|
||||
name: CI
|
||||
|
||||
runs-on: macos-14
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||
|
||||
steps:
|
||||
- name: Setup Xcode version
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: latest-stable
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
- name: Install OpenGFX
|
||||
run: |
|
||||
mkdir -p ~/Documents/OpenTTD/baseset
|
||||
cd ~/Documents/OpenTTD/baseset
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. \
|
||||
-DCMAKE_OSX_ARCHITECTURES=${{ inputs.full_arch }} \
|
||||
-DVCPKG_TARGET_TRIPLET=${{ inputs.arch }}-osx \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
||||
${{ inputs.extra-cmake-parameters }} \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(sysctl -n hw.logicalcpu) cores"
|
||||
cmake --build . -j $(sysctl -n hw.logicalcpu)
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd build
|
||||
ctest -j $(sysctl -n hw.logicalcpu) --timeout 120
|
83
.github/workflows/ci-mingw.yml
vendored
Normal file
83
.github/workflows/ci-mingw.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: CI (MinGW)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
required: true
|
||||
type: string
|
||||
msystem:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
||||
jobs:
|
||||
mingw:
|
||||
name: CI
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: ${{ inputs.msystem }}
|
||||
release: false
|
||||
install: >-
|
||||
git
|
||||
make
|
||||
mingw-w64-${{ inputs.arch }}-cmake
|
||||
mingw-w64-${{ inputs.arch }}-gcc
|
||||
mingw-w64-${{ inputs.arch }}-lzo2
|
||||
mingw-w64-${{ inputs.arch }}-libpng
|
||||
mingw-w64-${{ inputs.arch }}-lld
|
||||
mingw-w64-${{ inputs.arch }}-ninja
|
||||
|
||||
- name: Install OpenGFX
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
cd "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install GCC problem matcher
|
||||
uses: ammaraskar/gcc-problem-matcher@master
|
||||
|
||||
- name: Build
|
||||
shell: msys2 {0}
|
||||
env:
|
||||
NINJA_STATUS: "[%f/%t -- %e] " # [finished_edges/total_edges -- elapsed_time], default value is "[%f/%t] "
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
cd build
|
||||
ctest --timeout 120
|
82
.github/workflows/ci-nightly.yml
vendored
Normal file
82
.github/workflows/ci-nightly.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
name: CI - Nightly
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: GCC - SDL1.2
|
||||
compiler: gcc
|
||||
cxxcompiler: g++
|
||||
libraries: libsdl1.2-dev
|
||||
|
||||
name: Linux (${{ matrix.name }})
|
||||
|
||||
uses: ./.github/workflows/ci-linux.yml
|
||||
secrets: inherit
|
||||
|
||||
with:
|
||||
compiler: ${{ matrix.compiler }}
|
||||
cxxcompiler: ${{ matrix.cxxcompiler }}
|
||||
libraries: ${{ matrix.libraries }}
|
||||
extra-cmake-parameters:
|
||||
|
||||
macos:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x64
|
||||
full_arch: x86_64
|
||||
|
||||
name: Mac OS (${{ matrix.arch }})
|
||||
|
||||
uses: ./.github/workflows/ci-macos.yml
|
||||
secrets: inherit
|
||||
|
||||
with:
|
||||
arch: ${{ matrix.arch }}
|
||||
full_arch: ${{ matrix.full_arch }}
|
||||
|
||||
mingw:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- msystem: MINGW64
|
||||
arch: x86_64
|
||||
- msystem: MINGW32
|
||||
arch: i686
|
||||
|
||||
name: MinGW (${{ matrix.arch }})
|
||||
|
||||
uses: ./.github/workflows/ci-mingw.yml
|
||||
secrets: inherit
|
||||
|
||||
with:
|
||||
msystem: ${{ matrix.msystem }}
|
||||
arch: ${{ matrix.arch }}
|
||||
|
||||
check_annotations:
|
||||
name: Check Annotations
|
||||
needs:
|
||||
- linux
|
||||
- macos
|
||||
- mingw
|
||||
|
||||
if: always()
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check annotations
|
||||
uses: OpenTTD/actions/annotation-check@v5
|
87
.github/workflows/ci-windows.yml
vendored
Normal file
87
.github/workflows/ci-windows.yml
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
name: CI (Windows)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
required: true
|
||||
type: string
|
||||
os:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
name: CI
|
||||
|
||||
runs-on: ${{ inputs.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}\vcpkg
|
||||
${{ runner.temp }}\vcpkg\bootstrap-vcpkg.bat -disableMetrics
|
||||
|
||||
- name: Install OpenGFX
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
cd "C:/Users/Public/Documents/OpenTTD/baseset"
|
||||
|
||||
echo "::group::Download OpenGFX"
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Unpack OpenGFX"
|
||||
unzip opengfx-all.zip
|
||||
echo "::endgroup::"
|
||||
|
||||
rm -f opengfx-all.zip
|
||||
|
||||
- name: Install MSVC problem matcher
|
||||
uses: ammaraskar/msvc-problem-matcher@master
|
||||
|
||||
- name: Configure developer command prompt for ${{ inputs.arch }}
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{ inputs.arch }}
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
env:
|
||||
NINJA_STATUS: "[%f/%t -- %e] " # [finished_edges/total_edges -- elapsed_time], default value is "[%f/%t] "
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DVCPKG_TARGET_TRIPLET=${{ inputs.arch }}-windows-static \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
shell: bash
|
||||
run: |
|
||||
cd build
|
||||
ctest --timeout 120
|
42
.github/workflows/codeql.yml
vendored
42
.github/workflows/codeql.yml
vendored
@@ -26,6 +26,19 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup vcpkg caching
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
||||
|
||||
- name: Install vcpkg
|
||||
run: |
|
||||
git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}/vcpkg
|
||||
${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
echo "::group::Update apt"
|
||||
@@ -44,13 +57,28 @@ jobs:
|
||||
libsdl2-dev \
|
||||
zlib1g-dev \
|
||||
# EOF
|
||||
|
||||
echo "::group::Install vcpkg dependencies"
|
||||
|
||||
# Disable vcpkg integration, as we mostly use system libraries.
|
||||
mv vcpkg.json vcpkg-disabled.json
|
||||
|
||||
# We only use breakpad from vcpkg, as its CMake files
|
||||
# are a bit special. So the Ubuntu's variant doesn't work.
|
||||
${{ runner.temp }}/vcpkg/vcpkg install breakpad
|
||||
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
|
||||
- name: Set number of make jobs
|
||||
- name: Prepare build
|
||||
run: |
|
||||
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
@@ -58,8 +86,14 @@ jobs:
|
||||
languages: cpp
|
||||
config-file: ./.github/codeql/codeql-config.yml
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc)
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
|
9
.github/workflows/preview-build.yml
vendored
9
.github/workflows/preview-build.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
# If you change this version, change the number in the cache step too.
|
||||
image: emscripten/emsdk:3.1.42
|
||||
image: emscripten/emsdk:3.1.57
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -38,12 +38,11 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /emsdk/upstream/emscripten/cache
|
||||
key: 3.1.42-${{ runner.os }}
|
||||
key: 3.1.57-${{ runner.os }}
|
||||
|
||||
- name: Patch Emscripten to support LZMA
|
||||
- name: Add liblzma support
|
||||
run: |
|
||||
cd /emsdk/upstream/emscripten
|
||||
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
|
||||
cp ${GITHUB_WORKSPACE}/os/emscripten/ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/
|
||||
|
||||
- name: Build (host tools)
|
||||
run: |
|
||||
|
@@ -5,7 +5,7 @@ if(NOT BINARY_NAME)
|
||||
endif()
|
||||
|
||||
project(${BINARY_NAME}
|
||||
VERSION 14.0
|
||||
VERSION 15.0
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
@@ -157,7 +157,7 @@ enum SomeEnumeration {
|
||||
* Use curly braces and put the contained statements on their own lines (e.g., don't put them directly after the **if**).
|
||||
* Opening curly bracket **{** stays on the first line, closing curly bracket **}** gets a line to itself (except for the **}** preceding an **else**, which should be on the same line as the **else**).
|
||||
* When only a single statement is contained, the brackets can be omitted. In this case, put the single statement on the same line as the preceding keyword (**if**, **while**, etc.). Note that this is only allowed for if statements without an **else** clause.
|
||||
* All fall throughs must be documented, using a **FALLTHROUGH** define/macro.
|
||||
* Non-trivial fall throughs must be documented, using a `[[fallthrough]]` attribute.
|
||||
* The NOT_REACHED() macro can be used in default constructs that should never be reached.
|
||||
* Unconditional loops are written with **`for (;;) {`**
|
||||
|
||||
@@ -180,7 +180,7 @@ switch (a) {
|
||||
|
||||
case 1:
|
||||
DoSomething();
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
|
||||
case 2:
|
||||
DoMore();
|
||||
@@ -191,7 +191,7 @@ switch (a) {
|
||||
int r = 2;
|
||||
|
||||
DoEvenMore(a);
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
case 4: {
|
||||
@@ -248,7 +248,7 @@ Templates are a very powerful C++ tool, but they can easily confuse beginners. T
|
||||
* Templates are to be documented in a very clear and verbose manner. Never assume anything in the documentation.
|
||||
* the template keyword and the template layout get a separate line. typenames are either "T" or preceded by a "T", integers get a single capital letter or a descriptive name preceded by "T".
|
||||
```c++
|
||||
template <typename T, typename Tsomething, int N, byte Tnumber_of_something>
|
||||
template <typename T, typename Tsomething, int N, uint8_t Tnumber_of_something>
|
||||
int Func();
|
||||
```
|
||||
|
||||
|
32
Doxyfile.in
32
Doxyfile.in
@@ -3,6 +3,8 @@
|
||||
# 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/>.
|
||||
|
||||
# Doxyfile 1.9.4
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -13,6 +15,7 @@ PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = ${CPACK_BINARY_DIR}/docs/source/
|
||||
CREATE_SUBDIRS = YES
|
||||
CREATE_SUBDIRS_LEVEL = 8
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
@@ -35,8 +38,10 @@ STRIP_FROM_PATH = ./
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
JAVADOC_BANNER = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
PYTHON_DOCSTRING = YES
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 2
|
||||
@@ -45,6 +50,7 @@ OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
OPTIMIZE_OUTPUT_SLICE = NO
|
||||
EXTENSION_MAPPING =
|
||||
MARKDOWN_SUPPORT = YES
|
||||
TOC_INCLUDE_HEADINGS = 0
|
||||
@@ -60,16 +66,19 @@ INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
NUM_PROC_THREADS = 1
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_PRIV_VIRTUAL = NO
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
EXTRACT_ANON_NSPACES = YES
|
||||
RESOLVE_UNNAMED_PARAMS = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
@@ -78,6 +87,7 @@ INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_HEADERFILE = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
@@ -107,9 +117,11 @@ QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_IF_INCOMPLETE_DOC = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LINE_FORMAT = "at line $line of file $file"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the input files
|
||||
@@ -150,6 +162,10 @@ REFERENCES_LINK_SOURCE = YES
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
CLANG_ADD_INC_PATHS = YES
|
||||
CLANG_OPTIONS =
|
||||
CLANG_DATABASE_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -175,6 +191,7 @@ HTML_DYNAMIC_SECTIONS = NO
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_FEEDURL =
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||
DOCSET_PUBLISHER_NAME = Publisher
|
||||
@@ -197,12 +214,17 @@ GENERATE_ECLIPSEHELP = NO
|
||||
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
DISABLE_INDEX = NO
|
||||
GENERATE_TREEVIEW = YES
|
||||
FULL_SIDEBAR = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
OBFUSCATE_EMAILS = YES
|
||||
HTML_FORMULA_FORMAT = png
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
FORMULA_MACROFILE =
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_VERSION = MathJax_2
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
|
||||
MATHJAX_EXTENSIONS =
|
||||
@@ -221,6 +243,7 @@ GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
LATEX_MAKEINDEX_CMD = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
EXTRA_PACKAGES =
|
||||
@@ -232,9 +255,9 @@ PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
LATEX_TIMESTAMP = NO
|
||||
LATEX_EMOJI_DIRECTORY =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -244,7 +267,6 @@ COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
RTF_SOURCE_CODE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -259,12 +281,12 @@ MAN_LINKS = NO
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
XML_NS_MEMB_FILE_SCOPE = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the DOCBOOK output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_DOCBOOK = NO
|
||||
DOCBOOK_OUTPUT = docbook
|
||||
DOCBOOK_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -311,7 +333,6 @@ EXTERNAL_PAGES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
DIA_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
@@ -324,6 +345,8 @@ COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
DOT_UML_DETAILS = NO
|
||||
DOT_WRAP_THRESHOLD = 17
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
@@ -331,6 +354,7 @@ CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DIR_GRAPH_MAX_DEPTH = 1
|
||||
DOT_IMAGE_FORMAT = png
|
||||
INTERACTIVE_SVG = NO
|
||||
DOT_PATH =
|
||||
|
@@ -15,6 +15,7 @@ set(AI_COMPAT_SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_12.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_13.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_14.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_15.nut
|
||||
)
|
||||
|
||||
foreach(AI_COMPAT_SOURCE_FILE IN LISTS AI_COMPAT_SOURCE_FILES)
|
||||
|
@@ -4,3 +4,5 @@
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
AILog.Info("14 API compatibility in effect.");
|
||||
|
6
bin/ai/compat_15.nut
Normal file
6
bin/ai/compat_15.nut
Normal file
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
@@ -12,6 +12,7 @@ set(GS_COMPAT_SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_12.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_13.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_14.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_15.nut
|
||||
)
|
||||
|
||||
foreach(GS_COMPAT_SOURCE_FILE IN LISTS GS_COMPAT_SOURCE_FILES)
|
||||
|
@@ -4,3 +4,5 @@
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
GSLog.Info("14 API compatibility in effect.");
|
||||
|
6
bin/game/compat_15.nut
Normal file
6
bin/game/compat_15.nut
Normal file
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
136
changelog.txt
136
changelog.txt
@@ -1,134 +1,3 @@
|
||||
14.1 (2024-05-03)
|
||||
------------------------------------------------------------------------
|
||||
Add: Check that towns can build roads before generating map (#12503)
|
||||
Fix #12228: Ships could get lost due to pathfinder not considering reversing in some cases (#12474)
|
||||
Fix #12433: Width of unit number display was too narrow (#12534)
|
||||
Fix #12502: Desync related to vehicle replacement (#12512)
|
||||
Fix #12506: Desync after new oil rig is constructed (#12511)
|
||||
Fix #12584: Crash on some tar files during tar scan (#12586)
|
||||
Fix: [SDL2] Keypad numbers did not function (#12596)
|
||||
Fix: Houses and industry tiles could accept incorrect cargo (#12547)
|
||||
Fix: Map generation stage strings were incorrect (#12549)
|
||||
Fix: [Script] Allow only 255 league tables, as 255 itself is the invalid id sentinel (#12545)
|
||||
Fix: Mark vehicle status bars dirty when a vehicle leaves unbunching depot (#12516)
|
||||
Fix: Do not show train waiting for unbunching as waiting for free path (#12515)
|
||||
Fix: Smooth outliers in unbunching round trip calculations (#12513)
|
||||
|
||||
|
||||
14.0 (2024-04-13)
|
||||
------------------------------------------------------------------------
|
||||
Update: New title game for 14.0
|
||||
Fix #12477: Crash when launching OpenTTD from within a Dropbox folder (#12478)
|
||||
Fix #12233: Mini order list overlaps vehicle group name (#12423)
|
||||
Fix #12114: Viewport coords of crashed aircraft not updated when falling (#12424)
|
||||
Fix #12395: Ensure president name widget is tall enough (#12419)
|
||||
Fix #12415: Incorrect payment for aircraft secondary cargo (#12416)
|
||||
Fix #12387: [NewGRF] Wrong tile offset passed to rail station CB 149 (slope check)
|
||||
Fix #12388: Autoreplacing train heads slowly made the unit number grow (#12389)
|
||||
Fix #12368: Incorrect offset for click position within industry chain window (#12370)
|
||||
Fix: Aircraft can float above the ground when crashed (#12425)
|
||||
Fix: Segfault when using -q without providing a . character (#12418)
|
||||
Fix: Wrong scrolling dropdown list position with RTL (#12412)
|
||||
Fix: [Win32] Force font mapper to only use TrueType fonts (#12406)
|
||||
Fix: "-q" displays NewGRF IDs in the wrong byte-order (#12397)
|
||||
Fix: Do not send chat to clients that have not authorized yet (#12377)
|
||||
Fix: [NewGRF] Label for fruit incorrectly changed to `FRUI` from `FRUT` (#12367)
|
||||
Fix: [Script] ScriptSubsidy::GetExpireDate should return an economy-date (#12372)
|
||||
Revert #11603: [Script] AI/GSTimeMode was not the best solution for economy/calendar support (#12362)
|
||||
|
||||
|
||||
14.0-RC3 (2024-03-23)
|
||||
------------------------------------------------------------------------
|
||||
Fix #12347: Crash attempting to find catchment tiles of a station with no catchment area (#12348)
|
||||
Fix #12319: Some SSE blitters were broken due to ODR violations (#12322)
|
||||
Fix #12302: Allow empty train engines to use an invalid cargo type (#12325)
|
||||
Fix #12305: Crash with large positive sprite x offset in engine preview window (#12313)
|
||||
Fix #12166: Crash when opening tram road stop build window (#12168)
|
||||
Fix #12092: Incorrect x-axis in cargo payment graph window (#12359)
|
||||
Fix: Crash when attempting to join a company while not joined (#12353)
|
||||
Change: Show unbunching action in timetable window (#12351)
|
||||
Change: [Windows] Switch to Microsoft Azure code signing certificate (#12292)
|
||||
|
||||
|
||||
14.0-RC2 (2024-03-16)
|
||||
------------------------------------------------------------------------
|
||||
Update: Bump bundled OpenTTD TTF fonts to version v0.6 (#12276)
|
||||
Update: Developer credits (#12173, #12235)
|
||||
Change: Use (at least) standard toolbar button size for signal selection buttons (#12265)
|
||||
Change: [Script] Match FormatString behaviour more closely (#12205)
|
||||
Fix #12236: Ship pathfinder causes crash when ship is already at destination (#12238)
|
||||
Fix #12225: [Script] Missing AI::ResetConfig support for running AI config (#12226)
|
||||
Fix #12203: When unbunching at a depot, don't overlook implicit orders (#12220)
|
||||
Fix #12196: Always show selected content, even when filtering and disable "select upgrade" button when filtering (#12201)
|
||||
Fix #12195: Reset cursor when no Object is selected (#12207)
|
||||
Fix #12176: Ships are circling in one place (#12181)
|
||||
Fix #12154: Incorrect calendar day lengths with minutes per year setting (#12158)
|
||||
Fix #12148: Do not draw decimals when number of digits is 0 (#12150)
|
||||
Fix #12147: Reset all saved settings to their default before loading a game (#12210)
|
||||
Fix #12145: Incorrect date handling in date cheat in wallclock time-keeping mode (#12146)
|
||||
Fix #12134: Use correct error messages if clearing drive-through road stops fails (#12139)
|
||||
Fix #12133: [Script] Don't crash when emergency saving (#12138)
|
||||
Fix #12127: Truncation ellipses rendered shadows even for black font without shadows (#12132)
|
||||
Fix #12119: Remove red warning text when maximum loan is zero (#12141)
|
||||
Fix #12118: When adding an unbunching order, properly check for unsafe conditions (#12136)
|
||||
Fix #12076: Do not allow 'join' command on dedicated servers (#12208)
|
||||
Fix #12010: Use economy timer for vehicle stats minimum age, not calendar (#12142)
|
||||
Fix: Improved ship movement when no path to destination is found (#12285, #12286)
|
||||
Fix: Initialize _switch_mode_time so crash-logs before first game have a realistic time (#12184)
|
||||
Fix: [Script] Only show debug script window at the end of savegame loading (#12135)
|
||||
Fix: [Script] Broken ScriptText circular reference detection (#12187)
|
||||
Fix: Ordering of command per tick limit and pause mode filtering (#12126)
|
||||
Fix: Only reset unbunching departure data in the correct depot (#12155)
|
||||
Fix: Off by one in TimerGameEconomy::ConvertDateToYMD in wallclock mode (#12143)
|
||||
Fix: Missing savegame conversion for current_order (#12188)
|
||||
Fix: Helptext for timekeeping unit setting erroneously refers to vehicle movement (#12172)
|
||||
Fix: Don't show "insert order" errors in the console (#12245)
|
||||
Fix: Don't defer OnResize() after ReInit() (#12174)
|
||||
Remove: [Script] random_deviation from setting description table (#12221)
|
||||
Revert #11993: New number format system does not and cannot work for CJK languages (#12157)
|
||||
Revert #11606: Don't auto-build past tunnelbridge ends (#12244)
|
||||
|
||||
|
||||
14.0-RC1 (2024-02-18)
|
||||
------------------------------------------------------------------------
|
||||
Feature: Fully user configurable number format and abbreviations (#11993)
|
||||
Add: Show cargo icons on subsidy list window (#12079)
|
||||
Add: [Script] GetAirportNumHelipads (#12085)
|
||||
Change: Show 6 or 2 orientation buttons in NewGRF road stop picker as appropriate (#12090)
|
||||
Change: Show cargo icons on Industry View window (#12071)
|
||||
Change: Improve performance of finding free pool slots (#12055)
|
||||
Change: Draw north-side farm fences/hedges/walls on tile edge, instead of 1/16th in (#12048)
|
||||
Change: When adding orders, Ctrl+Click on a depot to unbunch, instead of service if required (#12023)
|
||||
Change: Store running AI config inside Company (#12003)
|
||||
Change: Show speed before destination in vehicle status bar (#11932)
|
||||
Change: Replace long list of cargo filter buttons with a multi-select dropdown list (#11552)
|
||||
Change: [Script] Use company randomizer when adding random deviation (#12065)
|
||||
Fix #12074: Don't allow "part" command for dedicated servers (#12075)
|
||||
Fix #12052: NewGRFs clearing industry cargo slots could fallback to default instead of empty (#12053)
|
||||
Fix #12050: Add default size, shade and pin control buttons to company livery widget (#12080)
|
||||
Fix #12041: Tarball extraction failing due to incorrect filename (#12044)
|
||||
Fix #12037: Blurry OpenTTD font on Mac OS (#12047)
|
||||
Fix #12029: Don't show Sandbox Options in multiplayer (#12032)
|
||||
Fix #12024: Autoreplace failed news message for trains must go to lead engine (#12025)
|
||||
Fix #12022: Adjust economy date when changing timekeeping units in Scenario Editor (#12042)
|
||||
Fix #12020: Unbunch and service if needed should be mutually exclusive depot order types (#12021)
|
||||
Fix #12019: Correctly highlight depot unbunch action in dropdown (#12021)
|
||||
Fix #12014: Remove water when area clearing ship depot (#12030)
|
||||
Fix #11840: Ship pathfinder always returns a valid trackdir if one is available (#12031)
|
||||
Fix #10983: [AdminPort] Correct order of messages (#11140)
|
||||
Fix #10405: [Script] Test engine and vehicle type validity for ScriptGroup::GetNumEngines (#11887)
|
||||
Fix #10079: Don't render at 1000fps if HW acceleration + vsync is requested but not active (#12067)
|
||||
Fix: Shadows of individual character glyphs could be drawn over other characters (#12115)
|
||||
Fix: Don't invalidate station list on vehicle load/unload (#12112)
|
||||
Fix: NewGRF roadstops were ignored if only in default class (#12089)
|
||||
Fix: Visually also disable vsync when not using HW acceleration (#12066)
|
||||
Fix: Industry tiles and houses could accept incorrect cargo types (#12062)
|
||||
Fix: Redraw orders when a station feature is added/removed (#12061)
|
||||
Fix: For content service, fallback to TCP downloads when HTTP stalls (#12056)
|
||||
Fix: Don't issue autoreplace failed news message for command test mode (#12026)
|
||||
Remove: Setting "no_http_content_downloads" (#12058)
|
||||
|
||||
|
||||
14.0-beta3 (2024-02-06)
|
||||
------------------------------------------------------------------------
|
||||
Add: [Script] ScriptTileList_StationCoverage to get station coverage area (#12015)
|
||||
@@ -7181,8 +7050,3 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Colours in map window for routes
|
||||
- Fix: Road drive side
|
||||
- Fix: 'Fund road construction' not clickable when unavailable
|
||||
|
||||
|
||||
0.1.0 (2004-03-06)
|
||||
------------------------------------------------------------------------
|
||||
Initial release
|
||||
|
@@ -74,12 +74,6 @@ macro(compile_flags)
|
||||
|
||||
# We use 'ABCD' multichar for SaveLoad chunks identifiers
|
||||
-Wno-multichar
|
||||
|
||||
# Compilers complains about that we break strict-aliasing.
|
||||
# On most places we don't see how to fix it, and it doesn't
|
||||
# break anything. So disable strict-aliasing to make the
|
||||
# compiler all happy.
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
|
||||
# Ninja processes the output so the output from the compiler
|
||||
|
@@ -56,7 +56,7 @@ function(set_options)
|
||||
|
||||
option(OPTION_DEDICATED "Build dedicated server only (no GUI)" OFF)
|
||||
option(OPTION_INSTALL_FHS "Install with Filesystem Hierarchy Standard folders" ${DEFAULT_OPTION_INSTALL_FHS})
|
||||
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" OFF)
|
||||
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" ON)
|
||||
option(OPTION_USE_NSIS "Use NSIS to create windows installer; enable only for stable releases" OFF)
|
||||
option(OPTION_TOOLS_ONLY "Build only tools target" OFF)
|
||||
option(OPTION_DOCS_ONLY "Build only docs target" OFF)
|
||||
|
@@ -4,6 +4,7 @@ set(CPACK_BUNDLE_NAME "OpenTTD")
|
||||
set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/os/macosx/openttd.icns")
|
||||
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
|
||||
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/os/macosx/splash.png")
|
||||
set(CPACK_BUNDLE_APPLE_ENTITLEMENTS "${CMAKE_SOURCE_DIR}/os/macosx/openttd.entitlements")
|
||||
set(CPACK_DMG_FORMAT "UDBZ")
|
||||
|
||||
# Create a temporary Info.plist.in, where we will fill in the version via
|
||||
|
@@ -49,7 +49,8 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
string(SUBSTRING "${FULLHASH}" 0 10 SHORTHASH)
|
||||
|
||||
# Get the last commit date
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --pretty=format:%ci HEAD
|
||||
set(ENV{TZ} "UTC0")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --date=iso-local --pretty=format:%cd HEAD
|
||||
OUTPUT_VARIABLE COMMITDATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
.Op Fl M Ar musicset
|
||||
.Op Fl n Ar host Ns Oo : Ns Ar port Oc Ns Op # Ns Ar company
|
||||
.Op Fl p Ar password
|
||||
.Op Fl P Ar password
|
||||
.Op Fl q Ar savegame
|
||||
.Op Fl r Ar width Ns x Ns Ar height
|
||||
.Op Fl s Ar driver
|
||||
@@ -100,10 +99,6 @@ play as.
|
||||
Password used to join server.
|
||||
Only useful with
|
||||
.Fl n .
|
||||
.It Fl P Ar password
|
||||
Password used to join company.
|
||||
Only useful with
|
||||
.Fl n .
|
||||
.It Fl q Ar savegame
|
||||
Write some information about the specified savegame and exit.
|
||||
.It Fl Q
|
||||
|
@@ -7,15 +7,17 @@ This guide is for OpenTTD developers/maintainers, to release a new version of Op
|
||||
* If this is a beta version release, skip this step.
|
||||
|
||||
* If this is an RC1 (first Release Candidate) build, create a new branch `release/nn` where `nn` is the major version number, then apply changes similar to [PR#9573](https://github.com/OpenTTD/OpenTTD/pull/9573). You also need to forwardport the changelog, as in [PR#10113](https://github.com/OpenTTD/OpenTTD/pull/10113).
|
||||
* Update CMakeLists.txt
|
||||
* Add a new (empty) AI compatibility script in bin/ai/
|
||||
* Add the new version to CheckAPIVersion in src/ai/ai_info.cpp + src/game/game_info.cpp
|
||||
* Add the new version to src/script/api/ai_changelog.hpp + src/script/api/game_changelog.hpp
|
||||
* Update the version of regression in bin/ai/regression/regression_info.nut
|
||||
* Add a note to src/saveload/saveload.h about which savegame version is used in the branch.
|
||||
* Update the version in `CMakeLists.txt` in the master branch, heading for the next major release, e.g. from 14.0 to 15.0.
|
||||
* Add a new (empty) AI compatibility script in `bin/ai/`
|
||||
* Add the new version to CheckAPIVersion in `src/ai/ai_info.cpp` and `src/game/game_info.cpp`
|
||||
* Add the new version to `src/script/api/ai_changelog.hpp` and `src/script/api/game_changelog.hpp`
|
||||
* Update the version of regression in `bin/ai/regression/regression_info.nut`
|
||||
* Add a note to `src/saveload/saveload.h` about which savegame version is used in the branch.
|
||||
|
||||
* If this is a later RC or release build and the release branch already exists, you'll need to backport fixes and language from master to this branch, which were merged after the branch diverged from master. You can use these two helper scripts: https://github.com/OpenTTD/scripts/tree/main/backport
|
||||
|
||||
* If this is a maintenance release, update the version in `CMakeLists.txt` in the release branch, e.g. from 14.0 to 14.1.
|
||||
|
||||
## Step 1: Prepare changelog documentation
|
||||
|
||||
1. Update the [changelog](../changelog.txt) with new changes since the last release.
|
||||
@@ -29,20 +31,26 @@ This guide is for OpenTTD developers/maintainers, to release a new version of Op
|
||||
|
||||
1. Go to https://github.com/OpenTTD/website/new/main/_posts and write a new announcement post. See a [previous example](https://github.com/OpenTTD/website/pull/238) for a template.
|
||||
2. Create a new branch for this post and open a PR for it.
|
||||
3. Write announcement text for socials like Forum/Discord/Twitter/Reddit and include it in the PR.
|
||||
3. Write announcement text for the store pages and socials like TT-Forums / Discord / Twitter / Reddit / Fosstodon / etc., and include it in the PR.
|
||||
4. Create a Steam news image for that post and include it in the PR.
|
||||
5. Check the website post (preview link via checks page) and make corrections. We usually just use the GitHub web interface for this and squash the result later.
|
||||
5. Check the website post ("View Deployment" link) and make corrections. We usually just use the GitHub web interface for this and squash the result later.
|
||||
6. Get this PR approved, but do not merge yet.
|
||||
|
||||
## Step 3: Make the actual OpenTTD release
|
||||
|
||||
1. Go to https://github.com/OpenTTD/OpenTTD/releases/new and create a new tag matching the release number. For the body of the release, see any older release. "Set as a pre-release" for a beta or RC, set as latest for a real release.
|
||||
2. Merge website PR.
|
||||
3. Wait for the OpenTTD release checks to be complete.
|
||||
4. Check that website links to the new release are working and correct, using the [staging website](https://www-staging.openttd.org/).
|
||||
5. If this is a full release, ask orudge to update the Microsoft Store and TrueBrain to move the release from the "testing" to "default" branch on Steam.
|
||||
1. Confirm that the version in `CMakeLists.txt` matches the intended release version.
|
||||
2. Go to https://github.com/OpenTTD/OpenTTD/releases/new and create a new tag matching the release number. For the body of the release, copy in the changelog. "Set as a pre-release" for a beta or RC.
|
||||
3. Wait for the OpenTTD release workflow to be complete.
|
||||
4. If this is a full release:
|
||||
* for `Steam`: under Steamworks -> SteamPipe -> Builds, set the "testing" branch live on the "default" branch. This will request 2FA validation.
|
||||
* for `GOG`: under Builds, "Publish" the freshly uploaded builds to `Master`, `GOG-use only` and `Testing`.
|
||||
* for `Microsoft Store`: ask orudge to publish the new release.
|
||||
|
||||
Access to `Steam`, `GOG` and/or `Microsoft Store` requires a developer account on that platform.
|
||||
You will need access to the shared keystore in order to create such an account.
|
||||
For help and/or access to either or both, please contact TrueBrain.
|
||||
|
||||
## Step 4: Tell the world
|
||||
|
||||
1. Tag and create a website release to trigger the actions that update the website.
|
||||
2. After the website is live, make announcements on social media. You may need to coordinate with other developers who can make posts on Twitter, Reddit, Steam, and GOG.
|
||||
1. Merge the website PR. This will publish the release post.
|
||||
2. Make announcements on social media and store pages. You may need to coordinate with other developers who can make posts on TT-Forums, Twitter, Reddit, Fosstodon, Discord, Steam, GOG, Microsoft Store, etc.
|
||||
|
Binary file not shown.
@@ -1,4 +1,3 @@
|
||||
FROM emscripten/emsdk:3.1.42
|
||||
FROM emscripten/emsdk:3.1.57
|
||||
|
||||
COPY emsdk-liblzma.patch /
|
||||
RUN cd /emsdk/upstream/emscripten && patch -p1 < /emsdk-liblzma.patch
|
||||
COPY ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/liblzma.py
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
Please use docker with the supplied `Dockerfile` to build for emscripten.
|
||||
It takes care of a few things:
|
||||
- Use a version of emscripten we know works
|
||||
- Patch in LibLZMA support (as this is not supported by upstream)
|
||||
- Use a version of emscripten we know works.
|
||||
- Add LibLZMA library under contrib ports.
|
||||
|
||||
First, build the docker image by navigating in the folder this `README.md` is in, and executing:
|
||||
```
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# LibLZMA is a custom addition to the emscripten SDK, so it is possible
|
||||
# someone patched their SDK. Test out if the SDK supports LibLZMA.
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_FLAGS "-sUSE_LIBLZMA=1")
|
||||
set(CMAKE_REQUIRED_FLAGS "--use-port=contrib.liblzma")
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <lzma.h>
|
||||
@@ -12,9 +12,9 @@ check_cxx_source_compiles("
|
||||
if (LIBLZMA_FOUND)
|
||||
add_library(LibLZMA::LibLZMA INTERFACE IMPORTED)
|
||||
set_target_properties(LibLZMA::LibLZMA PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "-sUSE_LIBLZMA=1"
|
||||
INTERFACE_LINK_LIBRARIES "-sUSE_LIBLZMA=1"
|
||||
INTERFACE_COMPILE_OPTIONS "--use-port=contrib.liblzma"
|
||||
INTERFACE_LINK_LIBRARIES "--use-port=contrib.liblzma"
|
||||
)
|
||||
else()
|
||||
message(WARNING "You are using an emscripten SDK without LibLZMA support. Many savegames won't be able to load in OpenTTD. Please apply 'emsdk-liblzma.patch' to your local emsdk installation.")
|
||||
message(WARNING "You are using an emscripten SDK without LibLZMA support. Many savegames won't be able to load in OpenTTD. Please copy liblzma.py to your ports/contrib folder in your local emsdk installation.")
|
||||
endif()
|
||||
|
@@ -1,198 +0,0 @@
|
||||
From 84d0e9112d5c87a714abd21ec8547921f46f37b5 Mon Sep 17 00:00:00 2001
|
||||
From: milek7 <me@milek7.pl>
|
||||
Date: Tue, 8 Dec 2020 01:03:31 +0100
|
||||
Subject: [PATCH] Add liblzma port
|
||||
|
||||
---
|
||||
src/settings.js | 4 ++
|
||||
tools/ports/liblzma.py | 151 +++++++++++++++++++++++++++++++++++++++++
|
||||
tools/settings.py | 1 +
|
||||
3 files changed, 156 insertions(+)
|
||||
create mode 100644 tools/ports/liblzma.py
|
||||
|
||||
diff --git a/src/settings.js b/src/settings.js
|
||||
index f93140d..7b6bec9 100644
|
||||
--- a/src/settings.js
|
||||
+++ b/src/settings.js
|
||||
@@ -1451,6 +1451,10 @@ var USE_GIFLIB = false;
|
||||
// [compile+link]
|
||||
var USE_LIBJPEG = false;
|
||||
|
||||
+// 1 = use liblzma from emscripten-ports
|
||||
+// [compile+link]
|
||||
+var USE_LIBLZMA = false;
|
||||
+
|
||||
// 1 = use libpng from emscripten-ports
|
||||
// [compile+link]
|
||||
var USE_LIBPNG = false;
|
||||
diff --git a/tools/ports/liblzma.py b/tools/ports/liblzma.py
|
||||
new file mode 100644
|
||||
index 0000000..6872a8b
|
||||
--- /dev/null
|
||||
+++ b/tools/ports/liblzma.py
|
||||
@@ -0,0 +1,151 @@
|
||||
+# Copyright 2020 The Emscripten Authors. All rights reserved.
|
||||
+# Emscripten is available under two separate licenses, the MIT license and the
|
||||
+# University of Illinois/NCSA Open Source License. Both these licenses can be
|
||||
+# found in the LICENSE file.
|
||||
+
|
||||
+import os
|
||||
+import shutil
|
||||
+import logging
|
||||
+from pathlib import Path
|
||||
+
|
||||
+VERSION = '5.4.2'
|
||||
+HASH = '149f980338bea3d66de1ff5994b2b236ae1773135eda68b62b009df0c9dcdf5467f8cb2c06da95a71b6556d60bd3d21f475feced34d5dfdb80ee95416a2f9737'
|
||||
+
|
||||
+
|
||||
+def needed(settings):
|
||||
+ return settings.USE_LIBLZMA
|
||||
+
|
||||
+
|
||||
+def get(ports, settings, shared):
|
||||
+ ports.fetch_project('liblzma', f'https://tukaani.org/xz/xz-{VERSION}.tar.gz', sha512hash=HASH)
|
||||
+
|
||||
+ def create(final):
|
||||
+ logging.info('building port: liblzma')
|
||||
+
|
||||
+ ports.clear_project_build('liblzma')
|
||||
+
|
||||
+ source_path = os.path.join(ports.get_dir(), 'liblzma', f'xz-{VERSION}', 'src', 'liblzma')
|
||||
+ ports.write_file(os.path.join(source_path, 'config.h'), config_h)
|
||||
+ ports.install_headers(os.path.join(source_path, 'api'), pattern='lzma.h')
|
||||
+ ports.install_headers(os.path.join(source_path, 'api', 'lzma'), pattern='*.h', target='lzma')
|
||||
+
|
||||
+ build_flags = ['-DHAVE_CONFIG_H', '-DTUKLIB_SYMBOL_PREFIX=lzma_', '-fvisibility=hidden']
|
||||
+ exclude_files = ['crc32_small.c', 'crc64_small.c', 'crc32_tablegen.c', 'crc64_tablegen.c', 'price_tablegen.c', 'fastpos_tablegen.c',
|
||||
+ 'tuklib_exit.c', 'tuklib_mbstr_fw.c', 'tuklib_mbstr_width.c', 'tuklib_open_stdxxx.c', 'tuklib_progname.c']
|
||||
+ include_dirs_rel = ['../common', 'api', 'check', 'common', 'delta', 'lz', 'lzma', 'rangecoder', 'simple']
|
||||
+
|
||||
+ include_dirs = [os.path.join(source_path, p) for p in include_dirs_rel]
|
||||
+ ports.build_port(source_path, final, 'liblzma', flags=build_flags, exclude_files=exclude_files, includes=include_dirs)
|
||||
+
|
||||
+ return [shared.cache.get_lib('liblzma.a', create, what='port')]
|
||||
+
|
||||
+
|
||||
+def clear(ports, settings, shared):
|
||||
+ shared.cache.erase_lib('liblzma.a')
|
||||
+
|
||||
+
|
||||
+def process_args(ports):
|
||||
+ return []
|
||||
+
|
||||
+
|
||||
+def show():
|
||||
+ return 'liblzma (USE_LIBLZMA=1; public domain)'
|
||||
+
|
||||
+
|
||||
+config_h = '''
|
||||
+#define ASSUME_RAM 128
|
||||
+#define ENABLE_NLS 1
|
||||
+#define HAVE_CHECK_CRC32 1
|
||||
+#define HAVE_CHECK_CRC64 1
|
||||
+#define HAVE_CHECK_SHA256 1
|
||||
+#define HAVE_CLOCK_GETTIME 1
|
||||
+#define HAVE_DCGETTEXT 1
|
||||
+#define HAVE_DECL_CLOCK_MONOTONIC 1
|
||||
+#define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
|
||||
+#define HAVE_DECODERS 1
|
||||
+#define HAVE_DECODER_ARM 1
|
||||
+#define HAVE_DECODER_ARMTHUMB 1
|
||||
+#define HAVE_DECODER_DELTA 1
|
||||
+#define HAVE_DECODER_IA64 1
|
||||
+#define HAVE_DECODER_LZMA1 1
|
||||
+#define HAVE_DECODER_LZMA2 1
|
||||
+#define HAVE_DECODER_POWERPC 1
|
||||
+#define HAVE_DECODER_SPARC 1
|
||||
+#define HAVE_DECODER_X86 1
|
||||
+#define HAVE_DLFCN_H 1
|
||||
+#define HAVE_ENCODERS 1
|
||||
+#define HAVE_ENCODER_ARM 1
|
||||
+#define HAVE_ENCODER_ARMTHUMB 1
|
||||
+#define HAVE_ENCODER_DELTA 1
|
||||
+#define HAVE_ENCODER_IA64 1
|
||||
+#define HAVE_ENCODER_LZMA1 1
|
||||
+#define HAVE_ENCODER_LZMA2 1
|
||||
+#define HAVE_ENCODER_POWERPC 1
|
||||
+#define HAVE_ENCODER_SPARC 1
|
||||
+#define HAVE_ENCODER_X86 1
|
||||
+#define HAVE_FCNTL_H 1
|
||||
+#define HAVE_FUTIMENS 1
|
||||
+#define HAVE_GETOPT_H 1
|
||||
+#define HAVE_GETOPT_LONG 1
|
||||
+#define HAVE_GETTEXT 1
|
||||
+#define HAVE_IMMINTRIN_H 1
|
||||
+#define HAVE_INTTYPES_H 1
|
||||
+#define HAVE_LIMITS_H 1
|
||||
+#define HAVE_MBRTOWC 1
|
||||
+#define HAVE_MEMORY_H 1
|
||||
+#define HAVE_MF_BT2 1
|
||||
+#define HAVE_MF_BT3 1
|
||||
+#define HAVE_MF_BT4 1
|
||||
+#define HAVE_MF_HC3 1
|
||||
+#define HAVE_MF_HC4 1
|
||||
+#define HAVE_OPTRESET 1
|
||||
+#define HAVE_POSIX_FADVISE 1
|
||||
+#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
|
||||
+#define HAVE_PTHREAD_PRIO_INHERIT 1
|
||||
+#define HAVE_STDBOOL_H 1
|
||||
+#define HAVE_STDINT_H 1
|
||||
+#define HAVE_STDLIB_H 1
|
||||
+#define HAVE_STRINGS_H 1
|
||||
+#define HAVE_STRING_H 1
|
||||
+#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1
|
||||
+#define HAVE_SYS_PARAM_H 1
|
||||
+#define HAVE_SYS_STAT_H 1
|
||||
+#define HAVE_SYS_TIME_H 1
|
||||
+#define HAVE_SYS_TYPES_H 1
|
||||
+#define HAVE_UINTPTR_T 1
|
||||
+#define HAVE_UNISTD_H 1
|
||||
+#define HAVE_VISIBILITY 1
|
||||
+#define HAVE_WCWIDTH 1
|
||||
+#define HAVE__BOOL 1
|
||||
+#define HAVE___BUILTIN_ASSUME_ALIGNED 1
|
||||
+#define HAVE___BUILTIN_BSWAPXX 1
|
||||
+#define MYTHREAD_POSIX 1
|
||||
+#define NDEBUG 1
|
||||
+#define PACKAGE "xz"
|
||||
+#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
|
||||
+#define PACKAGE_NAME "XZ Utils"
|
||||
+#define PACKAGE_STRING "XZ Utils 5.4.0"
|
||||
+#define PACKAGE_TARNAME "xz"
|
||||
+#define PACKAGE_VERSION "5.4.0"
|
||||
+#define SIZEOF_SIZE_T 4
|
||||
+#define STDC_HEADERS 1
|
||||
+#define TUKLIB_CPUCORES_SYSCONF 1
|
||||
+#define TUKLIB_FAST_UNALIGNED_ACCESS 1
|
||||
+#define TUKLIB_PHYSMEM_SYSCONF 1
|
||||
+#ifndef _ALL_SOURCE
|
||||
+# define _ALL_SOURCE 1
|
||||
+#endif
|
||||
+#ifndef _GNU_SOURCE
|
||||
+# define _GNU_SOURCE 1
|
||||
+#endif
|
||||
+#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
+# define _POSIX_PTHREAD_SEMANTICS 1
|
||||
+#endif
|
||||
+#ifndef _TANDEM_SOURCE
|
||||
+# define _TANDEM_SOURCE 1
|
||||
+#endif
|
||||
+#ifndef __EXTENSIONS__
|
||||
+# define __EXTENSIONS__ 1
|
||||
+#endif
|
||||
+#define VERSION "5.4.0"
|
||||
+'''
|
||||
diff --git a/tools/settings.py b/tools/settings.py
|
||||
index 10d6ca0..827e4a9 100644
|
||||
--- a/tools/settings.py
|
||||
+++ b/tools/settings.py
|
||||
@@ -40,6 +40,7 @@ PORTS_SETTINGS = {
|
||||
'USE_SDL_NET',
|
||||
'USE_SDL_GFX',
|
||||
'USE_LIBJPEG',
|
||||
+ 'USE_LIBLZMA',
|
||||
'USE_OGG',
|
||||
'USE_REGAL',
|
||||
'USE_BOOST_HEADERS',
|
||||
--
|
||||
2.34.1
|
139
os/emscripten/ports/liblzma.py
Normal file
139
os/emscripten/ports/liblzma.py
Normal file
@@ -0,0 +1,139 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
VERSION = '5.4.6'
|
||||
HASH = '495cc890d25c075c927c907b77e60d86dd8a4c377cea5b1172c8e916984149a7bb5fb32db25091f7219346b83155b47e4bc0404cc8529d992014cd7ed0c278b7'
|
||||
|
||||
URL = 'https://github.com/tukaani-project/xz'
|
||||
DESCRIPTION = 'liblzma provides a general-purpose data-compression library.'
|
||||
LICENSE = 'LGPL-2.1'
|
||||
|
||||
def get(ports, settings, shared):
|
||||
ports.fetch_project('contrib.liblzma', f'https://github.com/tukaani-project/xz/releases/download/v{VERSION}/xz-{VERSION}.tar.xz', sha512hash=HASH)
|
||||
|
||||
def create(final):
|
||||
logging.info('building port: contrib.liblzma')
|
||||
|
||||
ports.clear_project_build('contrib.liblzma')
|
||||
|
||||
source_path = os.path.join(ports.get_dir(), 'contrib.liblzma', f'xz-{VERSION}', 'src', 'liblzma')
|
||||
ports.write_file(os.path.join(source_path, 'config.h'), config_h)
|
||||
ports.install_headers(os.path.join(source_path, 'api'), pattern='lzma.h')
|
||||
ports.install_headers(os.path.join(source_path, 'api', 'lzma'), pattern='*.h', target='lzma')
|
||||
|
||||
build_flags = ['-DHAVE_CONFIG_H', '-DTUKLIB_SYMBOL_PREFIX=lzma_', '-fvisibility=hidden']
|
||||
exclude_files = ['crc32_small.c', 'crc64_small.c', 'crc32_tablegen.c', 'crc64_tablegen.c', 'price_tablegen.c', 'fastpos_tablegen.c',
|
||||
'tuklib_exit.c', 'tuklib_mbstr_fw.c', 'tuklib_mbstr_width.c', 'tuklib_open_stdxxx.c', 'tuklib_progname.c']
|
||||
include_dirs_rel = ['../common', 'api', 'check', 'common', 'delta', 'lz', 'lzma', 'rangecoder', 'simple']
|
||||
|
||||
include_dirs = [os.path.join(source_path, p) for p in include_dirs_rel]
|
||||
ports.build_port(source_path, final, 'contrib.liblzma', flags=build_flags, exclude_files=exclude_files, includes=include_dirs)
|
||||
|
||||
return [shared.cache.get_lib('liblzma.a', create, what='port')]
|
||||
|
||||
|
||||
def clear(ports, settings, shared):
|
||||
shared.cache.erase_lib('liblzma.a')
|
||||
|
||||
|
||||
def process_args(ports):
|
||||
return []
|
||||
|
||||
|
||||
config_h = '''
|
||||
#define ASSUME_RAM 128
|
||||
#define ENABLE_NLS 1
|
||||
#define HAVE_CHECK_CRC32 1
|
||||
#define HAVE_CHECK_CRC64 1
|
||||
#define HAVE_CHECK_SHA256 1
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
#define HAVE_DCGETTEXT 1
|
||||
#define HAVE_DECL_CLOCK_MONOTONIC 1
|
||||
#define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
|
||||
#define HAVE_DECODERS 1
|
||||
#define HAVE_DECODER_ARM 1
|
||||
#define HAVE_DECODER_ARMTHUMB 1
|
||||
#define HAVE_DECODER_DELTA 1
|
||||
#define HAVE_DECODER_IA64 1
|
||||
#define HAVE_DECODER_LZMA1 1
|
||||
#define HAVE_DECODER_LZMA2 1
|
||||
#define HAVE_DECODER_POWERPC 1
|
||||
#define HAVE_DECODER_SPARC 1
|
||||
#define HAVE_DECODER_X86 1
|
||||
#define HAVE_DLFCN_H 1
|
||||
#define HAVE_ENCODERS 1
|
||||
#define HAVE_ENCODER_ARM 1
|
||||
#define HAVE_ENCODER_ARMTHUMB 1
|
||||
#define HAVE_ENCODER_DELTA 1
|
||||
#define HAVE_ENCODER_IA64 1
|
||||
#define HAVE_ENCODER_LZMA1 1
|
||||
#define HAVE_ENCODER_LZMA2 1
|
||||
#define HAVE_ENCODER_POWERPC 1
|
||||
#define HAVE_ENCODER_SPARC 1
|
||||
#define HAVE_ENCODER_X86 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_FUTIMENS 1
|
||||
#define HAVE_GETOPT_H 1
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
#define HAVE_GETTEXT 1
|
||||
#define HAVE_IMMINTRIN_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_MBRTOWC 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
#define HAVE_MF_BT2 1
|
||||
#define HAVE_MF_BT3 1
|
||||
#define HAVE_MF_BT4 1
|
||||
#define HAVE_MF_HC3 1
|
||||
#define HAVE_MF_HC4 1
|
||||
#define HAVE_OPTRESET 1
|
||||
#define HAVE_POSIX_FADVISE 1
|
||||
#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
|
||||
#define HAVE_PTHREAD_PRIO_INHERIT 1
|
||||
#define HAVE_STDBOOL_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_UINTPTR_T 1
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_VISIBILITY 1
|
||||
#define HAVE_WCWIDTH 1
|
||||
#define HAVE__BOOL 1
|
||||
#define HAVE___BUILTIN_ASSUME_ALIGNED 1
|
||||
#define HAVE___BUILTIN_BSWAPXX 1
|
||||
#define MYTHREAD_POSIX 1
|
||||
#define NDEBUG 1
|
||||
#define PACKAGE "xz"
|
||||
#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
|
||||
#define PACKAGE_NAME "XZ Utils"
|
||||
#define PACKAGE_STRING "XZ Utils 5.4.0"
|
||||
#define PACKAGE_TARNAME "xz"
|
||||
#define PACKAGE_VERSION "5.4.0"
|
||||
#define SIZEOF_SIZE_T 4
|
||||
#define STDC_HEADERS 1
|
||||
#define TUKLIB_CPUCORES_SYSCONF 1
|
||||
#define TUKLIB_FAST_UNALIGNED_ACCESS 1
|
||||
#define TUKLIB_PHYSMEM_SYSCONF 1
|
||||
#ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE 1
|
||||
#endif
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# define _POSIX_PTHREAD_SEMANTICS 1
|
||||
#endif
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# define _TANDEM_SOURCE 1
|
||||
#endif
|
||||
#ifndef __EXTENSIONS__
|
||||
# define __EXTENSIONS__ 1
|
||||
#endif
|
||||
#define VERSION "5.4.0"
|
||||
'''
|
@@ -33,5 +33,7 @@
|
||||
<string>True</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.13.0</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.simulation-games</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
11
os/macosx/openttd.entitlements
Normal file
11
os/macosx/openttd.entitlements
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<!-- As requested in https://partner.steamgames.com/doc/store/application/platforms, allows arbitrary plugin loads on hardened runtime -->
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
@@ -4,7 +4,7 @@ class Regression extends AIInfo {
|
||||
function GetShortName() { return "REGR"; }
|
||||
function GetDescription() { return "This runs regression-tests on some commands. On the same map the result should always be the same."; }
|
||||
function GetVersion() { return 1; }
|
||||
function GetAPIVersion() { return "14"; }
|
||||
function GetAPIVersion() { return "15"; }
|
||||
function GetDate() { return "2007-03-18"; }
|
||||
function CreateInstance() { return "Regression"; }
|
||||
function UseAsRandomAI() { return false; }
|
||||
|
@@ -6093,7 +6093,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
GetNumEngines(): 1
|
||||
GetNumEngines(): 1
|
||||
GetNumEngines(): 0
|
||||
GetName(): Group 0
|
||||
GetName(): Group 1
|
||||
GetName(): (null : 0x00000000)
|
||||
AIVehicle.SellVehicle(): true
|
||||
AITile.DemolishTile(): true
|
||||
@@ -7510,7 +7510,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
BuildRailDepot(): false
|
||||
BuildRailDepot(): true
|
||||
BuildRailDepot(): true
|
||||
BuildRailDepot(): false
|
||||
BuildRailDepot(): true
|
||||
GetRailDepotFrontTile(): 33412
|
||||
IsBuildable(): false
|
||||
DepotList
|
||||
@@ -7604,12 +7604,12 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
BuildRoadDepot(): false
|
||||
BuildRoadDepot(): true
|
||||
BuildRoadDepot(): true
|
||||
BuildRoadDepot(): false
|
||||
BuildRoadDepot(): true
|
||||
HasRoadType(Road): true
|
||||
HasRoadType(Tram): false
|
||||
GetLastError(): 259
|
||||
GetLastErrorString(): ERR_ALREADY_BUILT
|
||||
GetErrorCategory(): 1
|
||||
GetLastError(): 0
|
||||
GetLastErrorString(): ERR_NONE
|
||||
GetErrorCategory(): 0
|
||||
IsRoadTile(): false
|
||||
GetRoadDepotFrontTile(): 33412
|
||||
IsRoadDepotTile(): true
|
||||
@@ -9471,7 +9471,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
IsStoppedInDepot(): false
|
||||
--Accounting--
|
||||
GetCosts(): -5947
|
||||
Should be: -5946
|
||||
Should be: -5947
|
||||
GetName(): Road Vehicle #1
|
||||
SetName(): true
|
||||
GetName(): MyVehicleName
|
||||
@@ -9485,7 +9485,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
GetAgeLeft(): 5489
|
||||
GetCurrentSpeed(): 7
|
||||
GetRunningCost(): 421
|
||||
GetProfitThisYear(): -1
|
||||
GetProfitThisYear(): 0
|
||||
GetProfitLastYear(): 0
|
||||
GetCurrentValue(): 5947
|
||||
GetVehicleType(): 1
|
||||
@@ -9604,7 +9604,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||
16 => 0
|
||||
14 => 0
|
||||
13 => 0
|
||||
12 => -1
|
||||
12 => 0
|
||||
ProfitLastYear ListDump:
|
||||
17 => 0
|
||||
16 => 0
|
||||
|
@@ -4,7 +4,7 @@ class StationList extends AIInfo {
|
||||
function GetShortName() { return "REGS"; }
|
||||
function GetDescription() { return "This runs stationlist-tests on some commands. On the same map the result should always be the same."; }
|
||||
function GetVersion() { return 1; }
|
||||
function GetAPIVersion() { return "14"; }
|
||||
function GetAPIVersion() { return "15"; }
|
||||
function GetDate() { return "2007-03-18"; }
|
||||
function CreateInstance() { return "StationList"; }
|
||||
function UseAsRandomAI() { return false; }
|
||||
|
4
src/3rdparty/md5/md5.h
vendored
4
src/3rdparty/md5/md5.h
vendored
@@ -57,8 +57,8 @@
|
||||
static const size_t MD5_HASH_BYTES = 16;
|
||||
|
||||
/** Container for storing a MD5 hash/checksum/digest. */
|
||||
struct MD5Hash : std::array<byte, MD5_HASH_BYTES> {
|
||||
MD5Hash() : std::array<byte, MD5_HASH_BYTES>{} {}
|
||||
struct MD5Hash : std::array<uint8_t, MD5_HASH_BYTES> {
|
||||
MD5Hash() : std::array<uint8_t, MD5_HASH_BYTES>{} {}
|
||||
|
||||
/**
|
||||
* Exclusively-or the given hash into this hash.
|
||||
|
@@ -650,8 +650,7 @@ public:
|
||||
_fs->AddInstruction(_OP_LOADINT, _exst._deref,_integer(constval));
|
||||
}
|
||||
else if(ctype == OT_FLOAT && sizeof(SQFloat) == sizeof(SQInt32)) {
|
||||
SQFloat f = _float(constval);
|
||||
_fs->AddInstruction(_OP_LOADFLOAT, _exst._deref,*((SQInt32 *)&f));
|
||||
_fs->AddInstruction(_OP_LOADFLOAT, _exst._deref, std::bit_cast<SQInt32>(_float(constval)));
|
||||
}
|
||||
else {
|
||||
_fs->AddInstruction(_OP_LOAD, _exst._deref, _fs->GetConstant(constval));
|
||||
@@ -697,7 +696,7 @@ public:
|
||||
break;
|
||||
case TK_FLOAT:
|
||||
if(sizeof(SQFloat) == sizeof(SQInt32)) {
|
||||
_fs->AddInstruction(_OP_LOADFLOAT, _fs->PushTarget(),*((SQInt32 *)&_lex._fvalue));
|
||||
_fs->AddInstruction(_OP_LOADFLOAT, _fs->PushTarget(), std::bit_cast<SQInt32>(_lex._fvalue));
|
||||
}
|
||||
else {
|
||||
_fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->GetNumericConstant(_lex._fvalue));
|
||||
|
19
src/3rdparty/squirrel/squirrel/sqfuncstate.cpp
vendored
19
src/3rdparty/squirrel/squirrel/sqfuncstate.cpp
vendored
@@ -199,7 +199,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
|
||||
}
|
||||
}
|
||||
else if(inst.op==_OP_LOADFLOAT) {
|
||||
printf("[%03d] %15s %d %f %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3);
|
||||
printf("[%03d] %15s %d %f %d %d\n",n,g_InstrDesc[inst.op].name,inst._arg0,std::bit_cast<SQFloat>(inst._arg1),inst._arg2,inst._arg3);
|
||||
}
|
||||
else if(inst.op==_OP_ARITH){
|
||||
printf("[%03d] %15s %d %d %d %c\n",n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
|
||||
@@ -242,19 +242,20 @@ SQInteger SQFuncState::GetConstant(const SQObject &cons)
|
||||
|
||||
void SQFuncState::SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2,SQInteger arg3)
|
||||
{
|
||||
_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&arg0);
|
||||
_instructions[pos]._arg1=(SQInt32)*((SQUnsignedInteger *)&arg1);
|
||||
_instructions[pos]._arg2=(unsigned char)*((SQUnsignedInteger *)&arg2);
|
||||
_instructions[pos]._arg3=(unsigned char)*((SQUnsignedInteger *)&arg3);
|
||||
_instructions[pos]._arg0 = (unsigned char)std::bit_cast<SQUnsignedInteger>(arg0);
|
||||
_instructions[pos]._arg1 = (SQInt32)std::bit_cast<SQUnsignedInteger>(arg1);
|
||||
_instructions[pos]._arg2 = (unsigned char)std::bit_cast<SQUnsignedInteger>(arg2);
|
||||
_instructions[pos]._arg3 = (unsigned char)std::bit_cast<SQUnsignedInteger>(arg3);
|
||||
}
|
||||
|
||||
void SQFuncState::SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val)
|
||||
{
|
||||
switch(arg){
|
||||
case 0:_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&val);break;
|
||||
case 1:case 4:_instructions[pos]._arg1=(SQInt32)*((SQUnsignedInteger *)&val);break;
|
||||
case 2:_instructions[pos]._arg2=(unsigned char)*((SQUnsignedInteger *)&val);break;
|
||||
case 3:_instructions[pos]._arg3=(unsigned char)*((SQUnsignedInteger *)&val);break;
|
||||
case 0: _instructions[pos]._arg0 = (unsigned char)std::bit_cast<SQUnsignedInteger>(val); break;
|
||||
case 1:
|
||||
case 4: _instructions[pos]._arg1 = (SQInt32)std::bit_cast<SQUnsignedInteger>(val); break;
|
||||
case 2: _instructions[pos]._arg2 = (unsigned char)std::bit_cast<SQUnsignedInteger>(val); break;
|
||||
case 3: _instructions[pos]._arg3 = (unsigned char)std::bit_cast<SQUnsignedInteger>(val); break;
|
||||
};
|
||||
}
|
||||
|
||||
|
8
src/3rdparty/squirrel/squirrel/sqvm.cpp
vendored
8
src/3rdparty/squirrel/squirrel/sqvm.cpp
vendored
@@ -51,7 +51,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
|
||||
case BW_XOR: res = i1 ^ i2; break;
|
||||
case BW_SHIFTL: res = i1 << i2; break;
|
||||
case BW_SHIFTR: res = i1 >> i2; break;
|
||||
case BW_USHIFTR:res = (SQInteger)(*((SQUnsignedInteger*)&i1) >> i2); break;
|
||||
case BW_USHIFTR:res = (SQInteger)(std::bit_cast<SQUnsignedInteger>(i1) >> i2); break;
|
||||
default: { Raise_Error("internal vm error bitwise op failed"); return false; }
|
||||
}
|
||||
}
|
||||
@@ -472,10 +472,10 @@ bool SQVM::DerefInc(SQInteger op,SQObjectPtr &target, SQObjectPtr &self, SQObjec
|
||||
|
||||
#define arg0 (_i_._arg0)
|
||||
#define arg1 (_i_._arg1)
|
||||
#define sarg1 (*(const_cast<SQInt32 *>(&_i_._arg1)))
|
||||
#define sarg1 (std::bit_cast<SQInt32>(_i_._arg1))
|
||||
#define arg2 (_i_._arg2)
|
||||
#define arg3 (_i_._arg3)
|
||||
#define sarg3 ((SQInteger)*((const signed char *)&_i_._arg3))
|
||||
#define sarg3 ((SQInteger)std::bit_cast<char>(_i_._arg3))
|
||||
|
||||
SQRESULT SQVM::Suspend()
|
||||
{
|
||||
@@ -764,7 +764,7 @@ exception_restore:
|
||||
continue;
|
||||
case _OP_LOAD: TARGET = ci->_literals[arg1]; continue;
|
||||
case _OP_LOADINT: TARGET = (SQInteger)arg1; continue;
|
||||
case _OP_LOADFLOAT: TARGET = *((const SQFloat *)&arg1); continue;
|
||||
case _OP_LOADFLOAT: TARGET = std::bit_cast<SQFloat>(arg1); continue;
|
||||
case _OP_DLOAD: TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue;
|
||||
case _OP_TAILCALL:
|
||||
temp_reg = STK(arg1);
|
||||
|
@@ -52,6 +52,8 @@ add_files(
|
||||
animated_tile_func.h
|
||||
articulated_vehicles.cpp
|
||||
articulated_vehicles.h
|
||||
autocompletion.cpp
|
||||
autocompletion.h
|
||||
autoreplace.cpp
|
||||
autoreplace_base.h
|
||||
autoreplace_cmd.cpp
|
||||
@@ -75,6 +77,7 @@ add_files(
|
||||
bridge_map.cpp
|
||||
bridge_map.h
|
||||
build_vehicle_gui.cpp
|
||||
cachecheck.cpp
|
||||
cargo_type.h
|
||||
cargoaction.cpp
|
||||
cargoaction.h
|
||||
@@ -136,6 +139,10 @@ add_files(
|
||||
dock_gui.cpp
|
||||
driver.cpp
|
||||
driver.h
|
||||
dropdown.cpp
|
||||
dropdown_common_type.h
|
||||
dropdown_func.h
|
||||
dropdown_type.h
|
||||
economy.cpp
|
||||
economy_base.h
|
||||
economy_cmd.h
|
||||
@@ -248,6 +255,7 @@ add_files(
|
||||
music_gui.cpp
|
||||
newgrf.cpp
|
||||
newgrf.h
|
||||
newgrf_act5.h
|
||||
newgrf_airport.cpp
|
||||
newgrf_airport.h
|
||||
newgrf_airporttiles.cpp
|
||||
@@ -330,6 +338,9 @@ add_files(
|
||||
palette_func.h
|
||||
pbs.cpp
|
||||
pbs.h
|
||||
picker_func.h
|
||||
picker_gui.cpp
|
||||
picker_gui.h
|
||||
progress.cpp
|
||||
progress.h
|
||||
querystring_gui.h
|
||||
@@ -391,6 +402,8 @@ add_files(
|
||||
signs_func.h
|
||||
signs_gui.cpp
|
||||
signs_type.h
|
||||
slider.cpp
|
||||
slider_func.h
|
||||
slope_func.h
|
||||
slope_type.h
|
||||
smallmap_gui.cpp
|
||||
@@ -466,7 +479,6 @@ add_files(
|
||||
tilearea_type.h
|
||||
tilehighlight_func.h
|
||||
tilehighlight_type.h
|
||||
tilematrix_type.hpp
|
||||
timetable.h
|
||||
timetable_cmd.cpp
|
||||
timetable_cmd.h
|
||||
|
@@ -40,7 +40,7 @@
|
||||
/* Clients shouldn't start AIs */
|
||||
if (_networking && !_network_server) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company *c = Company::Get(company);
|
||||
|
||||
AIConfig *config = c->ai_config.get();
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
c->ai_info = info;
|
||||
assert(c->ai_instance == nullptr);
|
||||
c->ai_instance = new AIInstance();
|
||||
c->ai_instance = std::make_unique<AIInstance>();
|
||||
c->ai_instance->Initialize(info);
|
||||
c->ai_instance->LoadOnStack(config->GetToLoadData());
|
||||
config->SetToLoadData(nullptr);
|
||||
@@ -81,7 +81,7 @@
|
||||
assert(_settings_game.difficulty.competitor_speed <= 4);
|
||||
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (c->is_ai) {
|
||||
PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
|
||||
@@ -109,11 +109,10 @@
|
||||
if (_networking && !_network_server) return;
|
||||
PerformanceMeasurer::SetInactive((PerformanceElement)(PFE_AI0 + company));
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company *c = Company::Get(company);
|
||||
|
||||
delete c->ai_instance;
|
||||
c->ai_instance = nullptr;
|
||||
c->ai_instance.reset();
|
||||
c->ai_info = nullptr;
|
||||
c->ai_config.reset();
|
||||
|
||||
@@ -129,7 +128,7 @@
|
||||
* for the server owner to unpause the script again. */
|
||||
if (_network_dedicated) return;
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(company)->ai_instance->Pause();
|
||||
|
||||
cur_company.Restore();
|
||||
@@ -137,7 +136,7 @@
|
||||
|
||||
/* static */ void AI::Unpause(CompanyID company)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(company)->ai_instance->Unpause();
|
||||
|
||||
cur_company.Restore();
|
||||
@@ -145,7 +144,7 @@
|
||||
|
||||
/* static */ bool AI::IsPaused(CompanyID company)
|
||||
{
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
bool paused = Company::Get(company)->ai_instance->IsPaused();
|
||||
|
||||
cur_company.Restore();
|
||||
@@ -259,7 +258,7 @@
|
||||
}
|
||||
|
||||
/* Queue the event */
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
Company::Get(_current_company)->ai_instance->InsertEvent(event);
|
||||
cur_company.Restore();
|
||||
|
||||
@@ -293,7 +292,7 @@
|
||||
|
||||
/* When doing emergency saving, an AI can be not fully initialised. */
|
||||
if (c->ai_instance != nullptr) {
|
||||
Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, company);
|
||||
c->ai_instance->Save();
|
||||
cur_company.Restore();
|
||||
return;
|
||||
|
@@ -82,7 +82,7 @@ static constexpr NWidgetPart _nested_ai_config_widgets[] = {
|
||||
};
|
||||
|
||||
/** Window definition for the configure AI window. */
|
||||
static WindowDesc _ai_config_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _ai_config_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_GAME_OPTIONS, WC_NONE,
|
||||
0,
|
||||
@@ -128,20 +128,20 @@ struct AIConfigWindow : public Window {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_AIC_DECREASE_NUMBER:
|
||||
case WID_AIC_INCREASE_NUMBER:
|
||||
case WID_AIC_DECREASE_INTERVAL:
|
||||
case WID_AIC_INCREASE_INTERVAL:
|
||||
*size = maxdim(*size, NWidgetScrollbar::GetHorizontalDimension());
|
||||
size = maxdim(size, NWidgetScrollbar::GetHorizontalDimension());
|
||||
break;
|
||||
|
||||
case WID_AIC_LIST:
|
||||
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
|
||||
resize->height = this->line_height;
|
||||
size->height = 8 * this->line_height;
|
||||
resize.height = this->line_height;
|
||||
size.height = 8 * this->line_height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
static bool CheckAPIVersion(const std::string &api_version)
|
||||
{
|
||||
static const std::set<std::string> versions = { "0.7", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14" };
|
||||
static const std::set<std::string> versions = { "0.7", "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14", "15" };
|
||||
return versions.find(api_version) != versions.end();
|
||||
}
|
||||
|
||||
|
@@ -73,14 +73,14 @@ struct AircraftCache {
|
||||
*/
|
||||
struct Aircraft final : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
|
||||
uint16_t crashed_counter; ///< Timer for handling crash animations.
|
||||
byte pos; ///< Next desired position of the aircraft.
|
||||
byte previous_pos; ///< Previous desired position of the aircraft.
|
||||
uint8_t pos; ///< Next desired position of the aircraft.
|
||||
uint8_t previous_pos; ///< Previous desired position of the aircraft.
|
||||
StationID targetairport; ///< Airport to go to next.
|
||||
byte state; ///< State of the airport. @see AirportMovementStates
|
||||
uint8_t state; ///< State of the airport. @see AirportMovementStates
|
||||
Direction last_direction;
|
||||
byte number_consecutive_turns; ///< Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
|
||||
byte turn_counter; ///< Ticks between each turn to prevent > 45 degree turns.
|
||||
byte flags; ///< Aircraft flags. @see AirVehicleFlags
|
||||
uint8_t number_consecutive_turns; ///< Protection to prevent the aircraft of making a lot of turns in order to reach a specific point.
|
||||
uint8_t turn_counter; ///< Ticks between each turn to prevent > 45 degree turns.
|
||||
uint8_t flags; ///< Aircraft flags. @see AirVehicleFlags
|
||||
|
||||
AircraftCache acache;
|
||||
|
||||
|
@@ -134,7 +134,7 @@ static StationID FindNearestHangar(const Aircraft *v)
|
||||
const Station *next_dest = nullptr;
|
||||
if (max_range != 0) {
|
||||
if (v->current_order.IsType(OT_GOTO_STATION) ||
|
||||
(v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType() != ODATFB_NEAREST_DEPOT)) {
|
||||
(v->current_order.IsType(OT_GOTO_DEPOT) && (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) == 0)) {
|
||||
last_dest = Station::GetIfValid(v->last_station_visited);
|
||||
next_dest = Station::GetIfValid(v->current_order.GetDestination());
|
||||
} else {
|
||||
@@ -655,7 +655,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
|
||||
* ~ acceleration * 77 (km-ish/h / 256)
|
||||
*/
|
||||
uint spd = v->acceleration * 77;
|
||||
byte t;
|
||||
uint8_t t;
|
||||
|
||||
/* Adjust speed limits by plane speed factor to prevent taxiing
|
||||
* and take-off speeds being too low. */
|
||||
@@ -672,7 +672,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
|
||||
speed_limit = v->vcache.cached_max_speed;
|
||||
}
|
||||
|
||||
v->subspeed = (t = v->subspeed) + (byte)spd;
|
||||
v->subspeed = (t = v->subspeed) + (uint8_t)spd;
|
||||
|
||||
/* Aircraft's current speed is used twice so that very fast planes are
|
||||
* forced to slow down rapidly in the short distance needed. The magic
|
||||
@@ -699,7 +699,7 @@ static int UpdateAircraftSpeed(Aircraft *v, uint speed_limit = SPEED_LIMIT_NONE,
|
||||
spd = v->GetOldAdvanceSpeed(spd);
|
||||
|
||||
spd += v->progress;
|
||||
v->progress = (byte)spd;
|
||||
v->progress = (uint8_t)spd;
|
||||
return spd >> 8;
|
||||
}
|
||||
|
||||
@@ -825,7 +825,7 @@ template int GetAircraftFlightLevel(Aircraft *v, bool takeoff);
|
||||
* @param rotation The rotation of the airport.
|
||||
* @return The index of the entry point
|
||||
*/
|
||||
static byte AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc, Direction rotation)
|
||||
static uint8_t AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc, Direction rotation)
|
||||
{
|
||||
assert(v != nullptr);
|
||||
assert(apc != nullptr);
|
||||
@@ -1288,7 +1288,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
|
||||
*/
|
||||
const Station *st = GetTargetAirportIfValid(v);
|
||||
if (st == nullptr) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
CommandCost ret = Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommand::None, {});
|
||||
cur_company.Restore();
|
||||
|
||||
@@ -1654,7 +1654,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass
|
||||
|
||||
/* Send the helicopter to a hangar if needed for replacement */
|
||||
if (v->NeedsAutomaticServicing()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommand::Service | DepotCommand::LocateHangar, {});
|
||||
cur_company.Restore();
|
||||
}
|
||||
@@ -1669,7 +1669,7 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
|
||||
/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
|
||||
* if it is an airplane, look for LANDING, for helicopter HELILANDING
|
||||
* it is possible to choose from multiple landing runways, so loop until a free one is found */
|
||||
byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
|
||||
uint8_t landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
|
||||
const AirportFTA *current = apc->layout[v->pos].next;
|
||||
while (current != nullptr) {
|
||||
if (current->heading == landingtype) {
|
||||
@@ -1705,7 +1705,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *)
|
||||
|
||||
/* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */
|
||||
if (v->NeedsAutomaticServicing()) {
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company, v->owner);
|
||||
Command<CMD_SEND_VEHICLE_TO_DEPOT>::Do(DC_EXEC, v->index, DepotCommand::Service, {});
|
||||
cur_company.Restore();
|
||||
}
|
||||
@@ -1816,8 +1816,8 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
|
||||
const AirportFTA *current = &apc->layout[v->pos];
|
||||
/* we have arrived in an important state (eg terminal, hangar, etc.) */
|
||||
if (current->heading == v->state) {
|
||||
byte prev_pos = v->pos; // location could be changed in state, so save it before-hand
|
||||
byte prev_state = v->state;
|
||||
uint8_t prev_pos = v->pos; // location could be changed in state, so save it before-hand
|
||||
uint8_t prev_state = v->state;
|
||||
_aircraft_state_handlers[v->state](v, apc);
|
||||
if (v->state != FLYING) v->previous_pos = prev_pos;
|
||||
if (v->state != prev_state || v->pos != prev_pos) UpdateAircraftCache(v);
|
||||
@@ -1953,7 +1953,7 @@ static const MovementTerminalMapping _airport_terminal_mapping[] = {
|
||||
* @param last_terminal Terminal number to stop examining.
|
||||
* @return A terminal or helipad has been found, and has been assigned to the aircraft.
|
||||
*/
|
||||
static bool FreeTerminal(Aircraft *v, byte i, byte last_terminal)
|
||||
static bool FreeTerminal(Aircraft *v, uint8_t i, uint8_t last_terminal)
|
||||
{
|
||||
assert(last_terminal <= lengthof(_airport_terminal_mapping));
|
||||
Station *st = Station::Get(v->targetairport);
|
||||
|
@@ -110,12 +110,12 @@ AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Directi
|
||||
|
||||
AirportFTAClass::AirportFTAClass(
|
||||
const AirportMovingData *moving_data_,
|
||||
const byte *terminals_,
|
||||
const byte num_helipads_,
|
||||
const byte *entry_points_,
|
||||
const uint8_t *terminals_,
|
||||
const uint8_t num_helipads_,
|
||||
const uint8_t *entry_points_,
|
||||
Flags flags_,
|
||||
const AirportFTAbuildup *apFA,
|
||||
byte delta_z_
|
||||
uint8_t delta_z_
|
||||
) :
|
||||
moving_data(moving_data_),
|
||||
terminals(terminals_),
|
||||
@@ -204,7 +204,7 @@ static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildu
|
||||
* @param airport_type %Airport type to query FTA from. @see AirportTypes
|
||||
* @return Finite state machine of the airport.
|
||||
*/
|
||||
const AirportFTAClass *GetAirport(const byte airport_type)
|
||||
const AirportFTAClass *GetAirport(const uint8_t airport_type)
|
||||
{
|
||||
if (airport_type == AT_DUMMY) return &_airportfta_dummy;
|
||||
return AirportSpec::Get(airport_type)->fsm;
|
||||
@@ -215,7 +215,7 @@ const AirportFTAClass *GetAirport(const byte airport_type)
|
||||
* @param hangar_tile The tile on which the vehicle is build
|
||||
* @return The position (index in airport node array) where the aircraft ends up
|
||||
*/
|
||||
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
|
||||
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile)
|
||||
{
|
||||
const Station *st = Station::GetByTile(hangar_tile);
|
||||
const AirportFTAClass *apc = st->airport.GetFTA();
|
||||
|
@@ -152,12 +152,12 @@ public:
|
||||
|
||||
AirportFTAClass(
|
||||
const AirportMovingData *moving_data,
|
||||
const byte *terminals,
|
||||
const byte num_helipads,
|
||||
const byte *entry_points,
|
||||
const uint8_t *terminals,
|
||||
const uint8_t num_helipads,
|
||||
const uint8_t *entry_points,
|
||||
Flags flags,
|
||||
const AirportFTAbuildup *apFA,
|
||||
byte delta_z
|
||||
uint8_t delta_z
|
||||
);
|
||||
|
||||
~AirportFTAClass();
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
* @param position Element number to get movement data about.
|
||||
* @return Pointer to the movement data.
|
||||
*/
|
||||
const AirportMovingData *MovingData(byte position) const
|
||||
const AirportMovingData *MovingData(uint8_t position) const
|
||||
{
|
||||
assert(position < nofelements);
|
||||
return &moving_data[position];
|
||||
@@ -175,12 +175,12 @@ public:
|
||||
|
||||
const AirportMovingData *moving_data; ///< Movement data.
|
||||
struct AirportFTA *layout; ///< state machine for airport
|
||||
const byte *terminals; ///< %Array with the number of terminal groups, followed by the number of terminals in each group.
|
||||
const byte num_helipads; ///< Number of helipads on this airport. When 0 helicopters will go to normal terminals.
|
||||
const uint8_t *terminals; ///< %Array with the number of terminal groups, followed by the number of terminals in each group.
|
||||
const uint8_t num_helipads; ///< Number of helipads on this airport. When 0 helicopters will go to normal terminals.
|
||||
Flags flags; ///< Flags for this airport type.
|
||||
byte nofelements; ///< number of positions the airport consists of
|
||||
const byte *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
|
||||
byte delta_z; ///< Z adjustment for helicopter pads
|
||||
uint8_t nofelements; ///< number of positions the airport consists of
|
||||
const uint8_t *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
|
||||
uint8_t delta_z; ///< Z adjustment for helicopter pads
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
|
||||
@@ -190,12 +190,12 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
|
||||
struct AirportFTA {
|
||||
AirportFTA *next; ///< possible extra movement choices from this position
|
||||
uint64_t block; ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports
|
||||
byte position; ///< the position that an airplane is at
|
||||
byte next_position; ///< next position from this position
|
||||
byte heading; ///< heading (current orders), guiding an airplane to its target on an airport
|
||||
uint8_t position; ///< the position that an airplane is at
|
||||
uint8_t next_position; ///< next position from this position
|
||||
uint8_t heading; ///< heading (current orders), guiding an airplane to its target on an airport
|
||||
};
|
||||
|
||||
const AirportFTAClass *GetAirport(const byte airport_type);
|
||||
byte GetVehiclePosOnBuild(TileIndex hangar_tile);
|
||||
const AirportFTAClass *GetAirport(const uint8_t airport_type);
|
||||
uint8_t GetVehiclePosOnBuild(TileIndex hangar_tile);
|
||||
|
||||
#endif /* AIRPORT_H */
|
||||
|
@@ -22,7 +22,8 @@
|
||||
#include "station_type.h"
|
||||
#include "newgrf_airport.h"
|
||||
#include "newgrf_callbacks.h"
|
||||
#include "widgets/dropdown_type.h"
|
||||
#include "dropdown_type.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "hotkeys.h"
|
||||
#include "vehicle_func.h"
|
||||
@@ -41,11 +42,11 @@
|
||||
|
||||
static AirportClassID _selected_airport_class; ///< the currently visible airport class
|
||||
static int _selected_airport_index; ///< the index of the selected airport in the current class or -1
|
||||
static byte _selected_airport_layout; ///< selected airport layout number.
|
||||
static uint8_t _selected_airport_layout; ///< selected airport layout number.
|
||||
|
||||
static void ShowBuildAirportPicker(Window *parent);
|
||||
|
||||
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
|
||||
SpriteID GetCustomAirportSprite(const AirportSpec *as, uint8_t layout);
|
||||
|
||||
void CcBuildAirport(Commands, const CommandCost &result, TileIndex tile)
|
||||
{
|
||||
@@ -63,8 +64,8 @@ static void PlaceAirport(TileIndex tile)
|
||||
{
|
||||
if (_selected_airport_index == -1) return;
|
||||
|
||||
byte airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
|
||||
byte layout = _selected_airport_layout;
|
||||
uint8_t airport_type = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
|
||||
uint8_t layout = _selected_airport_layout;
|
||||
bool adjacent = _ctrl_pressed;
|
||||
|
||||
auto proc = [=](bool test, StationID to_join) -> bool {
|
||||
@@ -207,7 +208,7 @@ static constexpr NWidgetPart _nested_air_toolbar_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _air_toolbar_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _air_toolbar_desc(
|
||||
WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
|
||||
WC_BUILD_TOOLBAR, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
@@ -240,8 +241,8 @@ class BuildAirportWindow : public PickerWindowBase {
|
||||
{
|
||||
DropDownList list;
|
||||
|
||||
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(AirportClass::Get((AirportClassID)i)->name, i, false));
|
||||
for (const auto &cls : AirportClass::Classes()) {
|
||||
list.push_back(MakeDropDownListStringItem(cls.name, cls.Index()));
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -276,7 +277,7 @@ public:
|
||||
const AirportSpec *as = ac->GetSpec(_selected_airport_index);
|
||||
if (as->IsAvailable()) {
|
||||
/* Ensure the airport layout is valid. */
|
||||
_selected_airport_layout = Clamp(_selected_airport_layout, 0, as->num_table - 1);
|
||||
_selected_airport_layout = Clamp(_selected_airport_layout, 0, static_cast<uint8_t>(as->layouts.size() - 1));
|
||||
selectFirstAirport = false;
|
||||
this->UpdateSelectSize();
|
||||
}
|
||||
@@ -305,7 +306,7 @@ public:
|
||||
StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
|
||||
if (string != STR_UNDEFINED) {
|
||||
SetDParam(0, string);
|
||||
} else if (as->num_table > 1) {
|
||||
} else if (as->layouts.size() > 1) {
|
||||
SetDParam(0, STR_STATION_BUILD_AIRPORT_LAYOUT_NAME);
|
||||
SetDParam(1, _selected_airport_layout + 1);
|
||||
}
|
||||
@@ -316,17 +317,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_AP_CLASS_DROPDOWN: {
|
||||
Dimension d = {0, 0};
|
||||
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
|
||||
d = maxdim(d, GetStringBoundingBox(AirportClass::Get((AirportClassID)i)->name));
|
||||
for (const auto &cls : AirportClass::Classes()) {
|
||||
d = maxdim(d, GetStringBoundingBox(cls.name));
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -335,11 +336,11 @@ public:
|
||||
const AirportSpec *as = AirportSpec::Get(i);
|
||||
if (!as->enabled) continue;
|
||||
|
||||
size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width);
|
||||
size.width = std::max(size.width, GetStringBoundingBox(as->name).width + padding.width);
|
||||
}
|
||||
|
||||
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
|
||||
size->height = 5 * this->line_height;
|
||||
size.height = 5 * this->line_height;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -347,13 +348,13 @@ public:
|
||||
for (int i = 0; i < NUM_AIRPORTS; i++) {
|
||||
const AirportSpec *as = AirportSpec::Get(i);
|
||||
if (!as->enabled) continue;
|
||||
for (byte layout = 0; layout < as->num_table; layout++) {
|
||||
for (uint8_t layout = 0; layout < static_cast<uint8_t>(as->layouts.size()); layout++) {
|
||||
SpriteID sprite = GetCustomAirportSprite(as, layout);
|
||||
if (sprite != 0) {
|
||||
Dimension d = GetSpriteSize(sprite);
|
||||
d.width += WidgetDimensions::scaled.framerect.Horizontal();
|
||||
d.height += WidgetDimensions::scaled.framerect.Vertical();
|
||||
*size = maxdim(d, *size);
|
||||
size = maxdim(d, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,12 +364,12 @@ public:
|
||||
for (int i = NEW_AIRPORT_OFFSET; i < NUM_AIRPORTS; i++) {
|
||||
const AirportSpec *as = AirportSpec::Get(i);
|
||||
if (!as->enabled) continue;
|
||||
for (byte layout = 0; layout < as->num_table; layout++) {
|
||||
for (uint8_t layout = 0; layout < static_cast<uint8_t>(as->layouts.size()); layout++) {
|
||||
StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
|
||||
if (string == STR_UNDEFINED) continue;
|
||||
|
||||
Dimension d = GetStringMultiLineBoundingBox(string, *size);
|
||||
*size = maxdim(d, *size);
|
||||
Dimension d = GetStringMultiLineBoundingBox(string, size);
|
||||
size = maxdim(d, size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -473,14 +474,14 @@ public:
|
||||
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
|
||||
int w = as->size_x;
|
||||
int h = as->size_y;
|
||||
Direction rotation = as->rotation[_selected_airport_layout];
|
||||
Direction rotation = as->layouts[_selected_airport_layout].rotation;
|
||||
if (rotation == DIR_E || rotation == DIR_W) Swap(w, h);
|
||||
SetTileSelectSize(w, h);
|
||||
|
||||
this->preview_sprite = GetCustomAirportSprite(as, _selected_airport_layout);
|
||||
|
||||
this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0);
|
||||
this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table);
|
||||
this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1U >= as->layouts.size());
|
||||
|
||||
int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
|
||||
if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
@@ -495,8 +496,8 @@ public:
|
||||
break;
|
||||
|
||||
case WID_AP_AIRPORT_LIST: {
|
||||
int num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
|
||||
if (num_clicked == INT_MAX) break;
|
||||
int32_t num_clicked = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
|
||||
if (num_clicked == INT32_MAX) break;
|
||||
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
|
||||
if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
|
||||
break;
|
||||
@@ -545,14 +546,12 @@ public:
|
||||
if (change_class) {
|
||||
/* If that fails, select the first available airport
|
||||
* from the first class where airports are available. */
|
||||
for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
|
||||
AirportClass *apclass = AirportClass::Get(j);
|
||||
for (uint i = 0; i < apclass->GetSpecCount(); i++) {
|
||||
const AirportSpec *as = apclass->GetSpec(i);
|
||||
for (const auto &cls : AirportClass::Classes()) {
|
||||
for (const auto &as : cls.Specs()) {
|
||||
if (as->IsAvailable()) {
|
||||
_selected_airport_class = j;
|
||||
this->vscroll->SetCount(apclass->GetSpecCount());
|
||||
this->SelectOtherAirport(i);
|
||||
_selected_airport_class = cls.Index();
|
||||
this->vscroll->SetCount(cls.GetSpecCount());
|
||||
this->SelectOtherAirport(as->GetIndex());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -618,7 +617,7 @@ static constexpr NWidgetPart _nested_build_airport_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _build_airport_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _build_airport_desc(
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
|
66
src/autocompletion.cpp
Normal file
66
src/autocompletion.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 autocompletion.cpp Generic auto-completion engine. */
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "autocompletion.h"
|
||||
|
||||
#include "console_internal.h"
|
||||
#include "town.h"
|
||||
#include "network/network_base.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
bool AutoCompletion::AutoComplete()
|
||||
{
|
||||
// We are pressing TAB for the first time after reset.
|
||||
if (this->suggestions.empty()) {
|
||||
this->InitSuggestions(this->textbuf->buf);
|
||||
if (this->suggestions.empty()) {
|
||||
return false;
|
||||
}
|
||||
this->ApplySuggestion(prefix, suggestions[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// We are pressing TAB again on the same text.
|
||||
if (this->current_suggestion_index + 1 < this->suggestions.size()) {
|
||||
this->ApplySuggestion(prefix, this->suggestions[++this->current_suggestion_index]);
|
||||
} else {
|
||||
// We are out of options, restore original text.
|
||||
this->textbuf->Assign(initial_buf);
|
||||
this->Reset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AutoCompletion::Reset()
|
||||
{
|
||||
this->prefix = "";
|
||||
this->query = "";
|
||||
this->initial_buf.clear();
|
||||
this->suggestions.clear();
|
||||
this->current_suggestion_index = 0;
|
||||
}
|
||||
|
||||
void AutoCompletion::InitSuggestions(std::string_view text)
|
||||
{
|
||||
this->initial_buf = text;
|
||||
size_t space_pos = this->initial_buf.find_last_of(' ');
|
||||
this->query = this->initial_buf;
|
||||
if (space_pos == std::string::npos) {
|
||||
this->prefix = "";
|
||||
} else {
|
||||
this->prefix = this->query.substr(0, space_pos + 1);
|
||||
this->query.remove_prefix(space_pos + 1);
|
||||
}
|
||||
|
||||
this->suggestions = this->GetSuggestions(prefix, query);
|
||||
this->current_suggestion_index = 0;
|
||||
}
|
46
src/autocompletion.h
Normal file
46
src/autocompletion.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 autocompletion.h Generic auto-completion engine. */
|
||||
|
||||
#ifndef AUTOCOMPLETION_H
|
||||
#define AUTOCOMPLETION_H
|
||||
|
||||
#include "textbuf_type.h"
|
||||
|
||||
class AutoCompletion {
|
||||
protected:
|
||||
Textbuf *textbuf;
|
||||
|
||||
private:
|
||||
std::string initial_buf; ///< Value of text buffer when we started current suggestion session.
|
||||
|
||||
std::string_view prefix; ///< Prefix of the text before the last space.
|
||||
std::string_view query; ///< Last token of the text. This is used to based the suggestions on.
|
||||
|
||||
std::vector<std::string> suggestions;
|
||||
size_t current_suggestion_index;
|
||||
|
||||
public:
|
||||
AutoCompletion(Textbuf *textbuf) : textbuf(textbuf)
|
||||
{
|
||||
this->Reset();
|
||||
}
|
||||
virtual ~AutoCompletion() = default;
|
||||
|
||||
// Returns true the textbuf was updated.
|
||||
bool AutoComplete();
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
void InitSuggestions(std::string_view text);
|
||||
|
||||
virtual std::vector<std::string> GetSuggestions(std::string_view prefix, std::string_view query) = 0;
|
||||
virtual void ApplySuggestion(std::string_view prefix, std::string_view suggestion) = 0;
|
||||
};
|
||||
|
||||
#endif /* AUTOCOMPLETION_H */
|
@@ -362,7 +362,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
|
||||
|
||||
/* Refit the vehicle if needed */
|
||||
if (refit_cargo != CARGO_NO_REFIT) {
|
||||
byte subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo);
|
||||
uint8_t subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo);
|
||||
|
||||
cost.AddCost(std::get<0>(Command<CMD_REFIT_VEHICLE>::Do(DC_EXEC, new_veh->index, refit_cargo, subtype, false, false, 0)));
|
||||
assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace()
|
||||
|
@@ -24,7 +24,8 @@
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "rail_gui.h"
|
||||
#include "road_gui.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
#include "dropdown_type.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "autoreplace_cmd.h"
|
||||
#include "group_cmd.h"
|
||||
#include "settings_cmd.h"
|
||||
@@ -33,8 +34,6 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group);
|
||||
|
||||
static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
|
||||
{
|
||||
return Engine::Get(a.engine_id)->list_position < Engine::Get(b.engine_id)->list_position;
|
||||
@@ -72,7 +71,6 @@ void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
|
||||
static const StringID _start_replace_dropdown[] = {
|
||||
STR_REPLACE_VEHICLES_NOW,
|
||||
STR_REPLACE_VEHICLES_WHEN_OLD,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -85,7 +83,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
bool reset_sel_engine; ///< Also reset #sel_engine while updating left and/or right and no valid engine selected.
|
||||
GroupID sel_group; ///< Group selected to replace.
|
||||
int details_height; ///< Minimal needed height of the details panels, in text lines (found so far).
|
||||
byte sort_criteria; ///< Criteria of sorting vehicles.
|
||||
uint8_t sort_criteria; ///< Criteria of sorting vehicles.
|
||||
bool descending_sort_order; ///< Order of sorting vehicles.
|
||||
bool show_hidden_engines; ///< Whether to show the hidden engines.
|
||||
RailType sel_railtype; ///< Type of rail tracks selected. #INVALID_RAILTYPE to show all.
|
||||
@@ -113,27 +111,6 @@ class ReplaceVehicleWindow : public Window {
|
||||
return true;
|
||||
}
|
||||
|
||||
void AddChildren(const GUIEngineList &source, GUIEngineList &target, EngineID parent, int indent, int side)
|
||||
{
|
||||
for (const auto &item : source) {
|
||||
if (item.variant_id != parent || item.engine_id == parent) continue;
|
||||
|
||||
const Engine *e = Engine::Get(item.engine_id);
|
||||
EngineDisplayFlags flags = item.flags;
|
||||
if (e->display_last_variant != INVALID_ENGINE) flags &= ~EngineDisplayFlags::Shaded;
|
||||
target.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) {
|
||||
/* Add this engine again as a child */
|
||||
if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) {
|
||||
target.emplace_back(item.engine_id, item.engine_id, EngineDisplayFlags::None, indent + 1);
|
||||
}
|
||||
AddChildren(source, target, item.engine_id, indent + 1, side);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an engines list
|
||||
* @param draw_left true if generating the left list, otherwise false
|
||||
@@ -143,7 +120,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
std::vector<EngineID> variants;
|
||||
EngineID selected_engine = INVALID_ENGINE;
|
||||
VehicleType type = (VehicleType)this->window_number;
|
||||
byte side = draw_left ? 0 : 1;
|
||||
uint8_t side = draw_left ? 0 : 1;
|
||||
|
||||
GUIEngineList list;
|
||||
|
||||
@@ -207,7 +184,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
|
||||
this->engines[side].clear();
|
||||
if (side == 1) {
|
||||
AddChildren(list, this->engines[side], INVALID_ENGINE, 0, side);
|
||||
GUIEngineListAddChildren(this->engines[side], list);
|
||||
} else {
|
||||
this->engines[side].swap(list);
|
||||
}
|
||||
@@ -315,26 +292,26 @@ public:
|
||||
this->sel_group = id_g;
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_RV_SORT_ASCENDING_DESCENDING: {
|
||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_LEFT_MATRIX:
|
||||
case WID_RV_RIGHT_MATRIX:
|
||||
resize->height = GetEngineListHeight((VehicleType)this->window_number);
|
||||
size->height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize->height;
|
||||
resize.height = GetEngineListHeight((VehicleType)this->window_number);
|
||||
size.height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize.height;
|
||||
break;
|
||||
|
||||
case WID_RV_LEFT_DETAILS:
|
||||
case WID_RV_RIGHT_DETAILS:
|
||||
size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
|
||||
size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
@@ -345,7 +322,7 @@ public:
|
||||
d = maxdim(d, GetStringBoundingBox(str));
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -354,7 +331,7 @@ public:
|
||||
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -363,7 +340,7 @@ public:
|
||||
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -374,7 +351,7 @@ public:
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -385,18 +362,16 @@ public:
|
||||
}
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_START_REPLACE: {
|
||||
Dimension d = GetStringBoundingBox(STR_REPLACE_VEHICLES_START);
|
||||
for (int i = 0; _start_replace_dropdown[i] != INVALID_STRING_ID; i++) {
|
||||
d = maxdim(d, GetStringBoundingBox(_start_replace_dropdown[i]));
|
||||
}
|
||||
d = maxdim(d, GetStringListBoundingBox(_start_replace_dropdown));
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -424,7 +399,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_RV_SORT_DROPDOWN:
|
||||
SetDParam(0, _engine_sort_listing[this->window_number][this->sort_criteria]);
|
||||
SetDParam(0, std::data(_engine_sort_listing[this->window_number])[this->sort_criteria]);
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
@@ -487,11 +462,9 @@ public:
|
||||
case WID_RV_LEFT_MATRIX:
|
||||
case WID_RV_RIGHT_MATRIX: {
|
||||
int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
|
||||
EngineID start = static_cast<EngineID>(this->vscroll[side]->GetPosition()); // what is the offset for the start (scrolling)
|
||||
EngineID end = static_cast<EngineID>(std::min<size_t>(this->vscroll[side]->GetCapacity() + start, this->engines[side].size()));
|
||||
|
||||
/* Do the actual drawing */
|
||||
DrawEngineList((VehicleType)this->window_number, r, this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
|
||||
DrawEngineList((VehicleType)this->window_number, r, this->engines[side], *this->vscroll[side], this->sel_engine[side], side == 0, this->sel_group);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -565,8 +538,8 @@ public:
|
||||
|
||||
case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
|
||||
DropDownList list;
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ENGINES, 1, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_WAGONS, 0, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_REPLACE_ENGINES, 1));
|
||||
list.push_back(MakeDropDownListStringItem(STR_REPLACE_WAGONS, 0));
|
||||
ShowDropDownList(this, std::move(list), this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
|
||||
break;
|
||||
}
|
||||
@@ -609,7 +582,7 @@ public:
|
||||
|
||||
case WID_RV_LEFT_MATRIX:
|
||||
case WID_RV_RIGHT_MATRIX: {
|
||||
byte click_side;
|
||||
uint8_t click_side;
|
||||
if (widget == WID_RV_LEFT_MATRIX) {
|
||||
click_side = 0;
|
||||
} else {
|
||||
@@ -789,7 +762,7 @@ static constexpr NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _replace_rail_vehicle_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _replace_rail_vehicle_desc(
|
||||
WDP_AUTO, "replace_vehicle_train", 500, 140,
|
||||
WC_REPLACE_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
@@ -847,7 +820,7 @@ static constexpr NWidgetPart _nested_replace_road_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _replace_road_vehicle_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _replace_road_vehicle_desc(
|
||||
WDP_AUTO, "replace_vehicle_road", 500, 140,
|
||||
WC_REPLACE_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
@@ -901,7 +874,7 @@ static constexpr NWidgetPart _nested_replace_vehicle_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _replace_vehicle_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _replace_vehicle_desc(
|
||||
WDP_AUTO, "replace_vehicle", 456, 118,
|
||||
WC_REPLACE_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
|
@@ -158,8 +158,8 @@ struct BaseSet {
|
||||
*/
|
||||
std::optional<std::string> GetTextfile(TextfileType type) const
|
||||
{
|
||||
for (uint i = 0; i < NUM_FILES; i++) {
|
||||
auto textfile = ::GetTextfile(type, BASESET_DIR, this->files[i].filename);
|
||||
for (const auto &file : this->files) {
|
||||
auto textfile = ::GetTextfile(type, BASESET_DIR, file.filename);
|
||||
if (textfile.has_value()) {
|
||||
return textfile;
|
||||
}
|
||||
@@ -313,8 +313,8 @@ static const uint NUM_SONGS_AVAILABLE = 1 + NUM_SONG_CLASSES * NUM_SONGS_CLASS;
|
||||
static const uint NUM_SONGS_PLAYLIST = 32;
|
||||
|
||||
/* Functions to read DOS music CAT files, similar to but not quite the same as sound effect CAT files */
|
||||
char *GetMusicCatEntryName(const std::string &filename, size_t entrynum);
|
||||
byte *GetMusicCatEntryData(const std::string &filename, size_t entrynum, size_t &entrylen);
|
||||
std::optional<std::string> GetMusicCatEntryName(const std::string &filename, size_t entrynum);
|
||||
std::optional<std::vector<uint8_t>> GetMusicCatEntryData(const std::string &filename, size_t entrynum);
|
||||
|
||||
enum MusicTrackType {
|
||||
MTT_STANDARDMIDI, ///< Standard MIDI file
|
||||
@@ -324,7 +324,7 @@ enum MusicTrackType {
|
||||
/** Metadata about a music track. */
|
||||
struct MusicSongInfo {
|
||||
std::string songname; ///< name of song displayed in UI
|
||||
byte tracknr; ///< track number of song displayed in UI
|
||||
uint8_t tracknr; ///< track number of song displayed in UI
|
||||
std::string filename; ///< file on disk containing song (when used in MusicSet class)
|
||||
MusicTrackType filetype; ///< decoder required for song file
|
||||
int cat_index; ///< entry index in CAT file, for filetype==MTT_MPSMIDI
|
||||
@@ -338,7 +338,7 @@ struct MusicSet : BaseSet<MusicSet, NUM_SONGS_AVAILABLE, false> {
|
||||
/** Data about individual songs in set. */
|
||||
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE];
|
||||
/** Number of valid songs in set. */
|
||||
byte num_available;
|
||||
uint8_t num_available;
|
||||
|
||||
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
|
||||
};
|
||||
|
@@ -325,8 +325,8 @@ template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci,
|
||||
if (!md5sum) return s->files[0].filename.c_str();
|
||||
|
||||
MD5Hash md5;
|
||||
for (uint i = 0; i < Tbase_set::NUM_FILES; i++) {
|
||||
md5 ^= s->files[i].hash;
|
||||
for (const auto &file : s->files) {
|
||||
md5 ^= file.hash;
|
||||
}
|
||||
if (md5 == ci->md5sum) return s->files[0].filename.c_str();
|
||||
}
|
||||
|
@@ -19,16 +19,11 @@
|
||||
typedef Pool<BaseStation, StationID, 32, 64000> StationPool;
|
||||
extern StationPool _station_pool;
|
||||
|
||||
struct StationSpecList {
|
||||
const StationSpec *spec;
|
||||
uint32_t grfid; ///< GRF ID of this custom station
|
||||
uint16_t localidx; ///< Station ID within GRF of station
|
||||
};
|
||||
|
||||
struct RoadStopSpecList {
|
||||
const RoadStopSpec *spec;
|
||||
uint32_t grfid; ///< GRF ID of this custom road stop
|
||||
uint16_t localidx; ///< Station ID within GRF of road stop
|
||||
template <typename T>
|
||||
struct SpecMapping {
|
||||
const T *spec; ///< Custom spec.
|
||||
uint32_t grfid; ///< GRF ID of this custom spec.
|
||||
uint16_t localidx; ///< Local ID within GRF of this custom spec.
|
||||
};
|
||||
|
||||
struct RoadStopTileData {
|
||||
@@ -64,7 +59,7 @@ struct StationRect : public Rect {
|
||||
struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
TileIndex xy; ///< Base tile of the station
|
||||
TrackedViewportSign sign; ///< NOSAVE: Dimensions of sign
|
||||
byte delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
|
||||
uint8_t delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
|
||||
|
||||
std::string name; ///< Custom name
|
||||
StringID string_id; ///< Default name (town area) of station
|
||||
@@ -74,13 +69,13 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
Owner owner; ///< The owner of this station
|
||||
StationFacility facilities; ///< The facilities that this station has
|
||||
|
||||
std::vector<StationSpecList> speclist; ///< List of rail station specs of this station.
|
||||
std::vector<RoadStopSpecList> roadstop_speclist; ///< List of road stop specs of this station
|
||||
std::vector<SpecMapping<StationSpec>> speclist; ///< List of rail station specs of this station.
|
||||
std::vector<SpecMapping<RoadStopSpec>> roadstop_speclist; ///< List of road stop specs of this station
|
||||
|
||||
TimerGameCalendar::Date build_date; ///< Date of construction
|
||||
|
||||
uint16_t random_bits; ///< Random bits assigned to this station
|
||||
byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station
|
||||
uint8_t waiting_triggers; ///< Waiting triggers (NewGRF) for this station
|
||||
uint8_t cached_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
|
||||
uint8_t cached_roadstop_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing should happen.
|
||||
CargoTypes cached_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask
|
||||
@@ -118,7 +113,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
* @param available will return false if ever the variable asked for does not exist
|
||||
* @return the value stored in the corresponding variable
|
||||
*/
|
||||
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0;
|
||||
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const = 0;
|
||||
|
||||
/**
|
||||
* Update the coordinated of the sign (as shown in the viewport).
|
||||
@@ -184,7 +179,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
return (this->facilities & ~FACIL_WAYPOINT) != 0;
|
||||
}
|
||||
|
||||
inline byte GetRoadStopRandomBits(TileIndex tile) const
|
||||
inline uint8_t GetRoadStopRandomBits(TileIndex tile) const
|
||||
{
|
||||
for (const RoadStopTileData &tile_data : this->custom_roadstop_tile_data) {
|
||||
if (tile_data.tile == tile) return tile_data.random_bits;
|
||||
@@ -192,7 +187,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline byte GetRoadStopAnimationFrame(TileIndex tile) const
|
||||
inline uint8_t GetRoadStopAnimationFrame(TileIndex tile) const
|
||||
{
|
||||
for (const RoadStopTileData &tile_data : this->custom_roadstop_tile_data) {
|
||||
if (tile_data.tile == tile) return tile_data.animation_frame;
|
||||
@@ -201,11 +196,11 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
|
||||
}
|
||||
|
||||
private:
|
||||
void SetRoadStopTileData(TileIndex tile, byte data, bool animation);
|
||||
void SetRoadStopTileData(TileIndex tile, uint8_t data, bool animation);
|
||||
|
||||
public:
|
||||
inline void SetRoadStopRandomBits(TileIndex tile, byte random_bits) { this->SetRoadStopTileData(tile, random_bits, false); }
|
||||
inline void SetRoadStopAnimationFrame(TileIndex tile, byte frame) { this->SetRoadStopTileData(tile, frame, true); }
|
||||
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); }
|
||||
void RemoveRoadStopTileData(TileIndex tile);
|
||||
|
||||
static void PostDestructor(size_t index);
|
||||
@@ -226,7 +221,7 @@ struct SpecializedStation : public BaseStation {
|
||||
* Set station type correctly
|
||||
* @param tile The base tile of the station.
|
||||
*/
|
||||
inline SpecializedStation<T, Tis_waypoint>(TileIndex tile) :
|
||||
inline SpecializedStation(TileIndex tile) :
|
||||
BaseStation(tile)
|
||||
{
|
||||
this->facilities = EXPECTED_FACIL;
|
||||
@@ -310,4 +305,14 @@ struct SpecializedStation : public BaseStation {
|
||||
static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); }
|
||||
};
|
||||
|
||||
/**
|
||||
* Get spec mapping list for each supported custom spec type.
|
||||
* @tparam T Spec type.
|
||||
* @param bst Station of custom spec list.
|
||||
* @return Speclist of custom spec type.
|
||||
*/
|
||||
template <class T> std::vector<SpecMapping<T>> &GetStationSpecList(BaseStation *bst);
|
||||
template <> inline std::vector<SpecMapping<StationSpec>> &GetStationSpecList<StationSpec>(BaseStation *bst) { return bst->speclist; }
|
||||
template <> inline std::vector<SpecMapping<RoadStopSpec>> &GetStationSpecList<RoadStopSpec>(BaseStation *bst) { return bst->roadstop_speclist; }
|
||||
|
||||
#endif /* BASE_STATION_BASE_H */
|
||||
|
@@ -34,23 +34,23 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]);
|
||||
|
||||
for (uint i = bp->skip_top; i != 0; i--) {
|
||||
src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
|
||||
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
}
|
||||
|
||||
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
|
||||
|
||||
const byte *remap = bp->remap; // store so we don't have to access it via bp every time
|
||||
const uint8_t *remap = bp->remap; // store so we don't have to access it via bp every time
|
||||
|
||||
for (int y = 0; y < bp->height; y++) {
|
||||
Colour *dst_ln = dst + bp->pitch;
|
||||
uint16_t *anim_ln = anim + this->anim_buf_pitch;
|
||||
|
||||
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
|
||||
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_px++;
|
||||
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
src_n += 2;
|
||||
|
||||
Colour *dst_end = dst + bp->skip_left;
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
void PaletteAnimate(const Palette &palette) override;
|
||||
Blitter::PaletteAnimation UsePaletteAnimation() override;
|
||||
|
||||
const char *GetName() override { return "32bpp-anim"; }
|
||||
std::string_view GetName() override { return "32bpp-anim"; }
|
||||
void PostResize() override;
|
||||
|
||||
/**
|
||||
|
@@ -31,7 +31,7 @@
|
||||
class Blitter_32bppSSE2_Anim : public Blitter_32bppAnim {
|
||||
public:
|
||||
void PaletteAnimate(const Palette &palette) override;
|
||||
const char *GetName() override { return "32bpp-sse2-anim"; }
|
||||
std::string_view GetName() override { return "32bpp-sse2-anim"; }
|
||||
};
|
||||
|
||||
/** Factory for the partially 32bpp blitter with animation. */
|
||||
|
@@ -33,7 +33,7 @@ template <BlitterMode mode, Blitter_32bppSSE2::ReadMode read_mode, Blitter_32bpp
|
||||
GNU_TARGET("sse4.1")
|
||||
inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom)
|
||||
{
|
||||
const byte * const remap = bp->remap;
|
||||
const uint8_t * const remap = bp->remap;
|
||||
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
|
||||
uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
|
||||
int effective_width = bp->width;
|
||||
@@ -42,7 +42,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
||||
const Blitter_32bppSSE_Base::SpriteData * const sd = (const Blitter_32bppSSE_Base::SpriteData *) bp->sprite;
|
||||
const SpriteInfo * const si = &sd->infos[zoom];
|
||||
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
|
||||
const Colour *src_rgba_line = (const Colour *) ((const byte *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
|
||||
const Colour *src_rgba_line = (const Colour *) ((const uint8_t *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
|
||||
|
||||
if (read_mode != RM_WITH_MARGIN) {
|
||||
src_rgba_line += bp->skip_left;
|
||||
@@ -104,20 +104,20 @@ inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom
|
||||
|
||||
if (animated) {
|
||||
/* Remap colours. */
|
||||
const byte m0 = mvX2;
|
||||
const uint8_t m0 = mvX2;
|
||||
if (m0 >= PALETTE_ANIM_START) {
|
||||
const Colour c0 = (this->LookupColourInPalette(m0).data & 0x00FFFFFF) | (src[0].data & 0xFF000000);
|
||||
InsertFirstUint32(AdjustBrightneSSE(c0, (byte) (mvX2 >> 8)).data, srcABCD);
|
||||
InsertFirstUint32(AdjustBrightneSSE(c0, (uint8_t) (mvX2 >> 8)).data, srcABCD);
|
||||
}
|
||||
const byte m1 = mvX2 >> 16;
|
||||
const uint8_t m1 = mvX2 >> 16;
|
||||
if (m1 >= PALETTE_ANIM_START) {
|
||||
const Colour c1 = (this->LookupColourInPalette(m1).data & 0x00FFFFFF) | (src[1].data & 0xFF000000);
|
||||
InsertSecondUint32(AdjustBrightneSSE(c1, (byte) (mvX2 >> 24)).data, srcABCD);
|
||||
InsertSecondUint32(AdjustBrightneSSE(c1, (uint8_t) (mvX2 >> 24)).data, srcABCD);
|
||||
}
|
||||
|
||||
/* Update anim buffer. */
|
||||
const byte a0 = src[0].a;
|
||||
const byte a1 = src[1].a;
|
||||
const uint8_t a0 = src[0].a;
|
||||
const uint8_t a1 = src[1].a;
|
||||
uint32_t anim01 = 0;
|
||||
if (a0 == 255) {
|
||||
if (a1 == 255) {
|
||||
@@ -185,9 +185,9 @@ bmno_full_transparency:
|
||||
__m128i dstABCD = _mm_loadl_epi64((__m128i*) dst);
|
||||
|
||||
/* Remap colours. */
|
||||
const uint m0 = (byte) mvX2;
|
||||
const uint m0 = (uint8_t) mvX2;
|
||||
const uint r0 = remap[m0];
|
||||
const uint m1 = (byte) (mvX2 >> 16);
|
||||
const uint m1 = (uint8_t) (mvX2 >> 16);
|
||||
const uint r1 = remap[m1];
|
||||
if (mvX2 & 0x00FF00FF) {
|
||||
#define CMOV_REMAP(m_colour, m_colour_init, m_src, m_m) \
|
||||
@@ -195,7 +195,7 @@ bmno_full_transparency:
|
||||
Colour m_colour = m_colour_init; \
|
||||
{ \
|
||||
const Colour srcm = (Colour) (m_src); \
|
||||
const uint m = (byte) (m_m); \
|
||||
const uint m = (uint8_t) (m_m); \
|
||||
const uint r = remap[m]; \
|
||||
const Colour cmap = (this->LookupColourInPalette(r).data & 0x00FFFFFF) | (srcm.data & 0xFF000000); \
|
||||
m_colour = r == 0 ? m_colour : cmap; \
|
||||
@@ -225,8 +225,8 @@ bmno_full_transparency:
|
||||
|
||||
/* Update anim buffer. */
|
||||
if (animated) {
|
||||
const byte a0 = src[0].a;
|
||||
const byte a1 = src[1].a;
|
||||
const uint8_t a0 = src[0].a;
|
||||
const uint8_t a1 = src[1].a;
|
||||
uint32_t anim01 = mvX2 & 0xFF00FF00;
|
||||
if (a0 == 255) {
|
||||
anim01 |= r0;
|
||||
@@ -368,7 +368,7 @@ bmcr_alpha_blend_single:
|
||||
|
||||
next_line:
|
||||
if (mode != BM_TRANSPARENT && mode != BM_TRANSPARENT_REMAP) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||
src_rgba_line = (const Colour*) ((const uint8_t*) src_rgba_line + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
anim_line += this->anim_buf_pitch;
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override {
|
||||
return Blitter_32bppSSE_Base::Encode(sprite, allocator);
|
||||
}
|
||||
const char *GetName() override { return "32bpp-sse4-anim"; }
|
||||
std::string_view GetName() override { return "32bpp-sse4-anim"; }
|
||||
using Blitter_32bppSSE2_Anim::LookupColourInPalette;
|
||||
};
|
||||
|
||||
|
@@ -40,26 +40,26 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
|
||||
|
||||
/* skip upper lines in src_px and src_n */
|
||||
for (uint i = bp->skip_top; i != 0; i--) {
|
||||
src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
|
||||
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
}
|
||||
|
||||
/* skip lines in dst */
|
||||
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
|
||||
|
||||
/* store so we don't have to access it via bp every time (compiler assumes pointer aliasing) */
|
||||
const byte *remap = bp->remap;
|
||||
const uint8_t *remap = bp->remap;
|
||||
|
||||
for (int y = 0; y < bp->height; y++) {
|
||||
/* next dst line begins here */
|
||||
Colour *dst_ln = dst + bp->pitch;
|
||||
|
||||
/* next src line begins here */
|
||||
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
|
||||
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_px++;
|
||||
|
||||
/* next src_n line begins here */
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
src_n += 2;
|
||||
|
||||
/* we will end this line when we reach this point */
|
||||
@@ -306,9 +306,9 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
||||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_NORMAL;
|
||||
zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite[ZOOM_LVL_MIN].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_MIN;
|
||||
zoom_max = ZOOM_LVL_MIN;
|
||||
} else {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
@@ -405,8 +405,8 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
||||
dst_n_ln = (uint32_t *)dst_n;
|
||||
}
|
||||
|
||||
lengths[z][0] = (byte *)dst_px_ln - (byte *)dst_px_orig[z]; // all are aligned to 4B boundary
|
||||
lengths[z][1] = (byte *)dst_n_ln - (byte *)dst_n_orig[z];
|
||||
lengths[z][0] = (uint8_t *)dst_px_ln - (uint8_t *)dst_px_orig[z]; // all are aligned to 4B boundary
|
||||
lengths[z][1] = (uint8_t *)dst_n_ln - (uint8_t *)dst_n_orig[z];
|
||||
}
|
||||
|
||||
uint len = 0; // total length of data
|
||||
@@ -416,10 +416,10 @@ template <bool Tpal_to_rgb> Sprite *Blitter_32bppOptimized::EncodeInternal(const
|
||||
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sizeof(SpriteData) + len);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
SpriteData *dst = (SpriteData *)dest_sprite->data;
|
||||
memset(dst, 0, sizeof(*dst));
|
||||
|
@@ -18,13 +18,13 @@ public:
|
||||
/** Data stored about a (single) sprite. */
|
||||
struct SpriteData {
|
||||
uint32_t offset[ZOOM_LVL_END][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information.
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
uint8_t data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
|
||||
const char *GetName() override { return "32bpp-optimized"; }
|
||||
std::string_view GetName() override { return "32bpp-optimized"; }
|
||||
|
||||
template <BlitterMode mode, bool Tpal_to_rgb = false> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
||||
|
||||
|
@@ -118,17 +118,17 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
|
||||
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
{
|
||||
Blitter_32bppSimple::Pixel *dst;
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite[ZOOM_LVL_NORMAL].height * (size_t)sprite[ZOOM_LVL_NORMAL].width * sizeof(*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)));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
dst = (Blitter_32bppSimple::Pixel *)dest_sprite->data;
|
||||
SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite[ZOOM_LVL_NORMAL].data;
|
||||
SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite[ZOOM_LVL_MIN].data;
|
||||
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_NORMAL].height * sprite[ZOOM_LVL_NORMAL].width; i++) {
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_MIN].height * sprite[ZOOM_LVL_MIN].width; i++) {
|
||||
if (src->m == 0) {
|
||||
dst[i].r = src->r;
|
||||
dst[i].g = src->g;
|
||||
|
@@ -28,7 +28,7 @@ public:
|
||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
|
||||
const char *GetName() override { return "32bpp-simple"; }
|
||||
std::string_view GetName() override { return "32bpp-simple"; }
|
||||
};
|
||||
|
||||
/** Factory for the simple 32 bpp blitter. */
|
||||
|
@@ -26,9 +26,9 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
* Second uint32_t of a line = the number of transparent pixels from the right.
|
||||
* Then all RGBA then all MV.
|
||||
*/
|
||||
ZoomLevel zoom_min = ZOOM_LVL_NORMAL;
|
||||
ZoomLevel zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite[ZOOM_LVL_NORMAL].type != SpriteType::Font) {
|
||||
ZoomLevel zoom_min = ZOOM_LVL_MIN;
|
||||
ZoomLevel zoom_max = ZOOM_LVL_MIN;
|
||||
if (sprite[ZOOM_LVL_MIN].type != SpriteType::Font) {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
if (zoom_max == zoom_min) zoom_max = ZOOM_LVL_MAX;
|
||||
@@ -52,10 +52,10 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
}
|
||||
|
||||
Sprite *dst_sprite = (Sprite *) allocator(sizeof(Sprite) + sizeof(SpriteData) + all_sprites_size);
|
||||
dst_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dst_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dst_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dst_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
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;
|
||||
dst_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
memcpy(dst_sprite->data, &sd, sizeof(SpriteData));
|
||||
|
||||
/* Copy colours and determine flags. */
|
||||
@@ -114,7 +114,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
(*dst_rgba_line).data = nb_pix_transp;
|
||||
|
||||
Colour *nb_right = dst_rgba_line + 1;
|
||||
dst_rgba_line = (Colour*) ((byte*) dst_rgba_line + sd.infos[z].sprite_line_size);
|
||||
dst_rgba_line = (Colour*) ((uint8_t*) dst_rgba_line + sd.infos[z].sprite_line_size);
|
||||
|
||||
/* Count the number of transparent pixels from the right. */
|
||||
dst_rgba = dst_rgba_line - 1;
|
||||
|
@@ -73,7 +73,7 @@ public:
|
||||
struct SpriteData {
|
||||
SpriteFlags flags;
|
||||
SpriteInfo infos[ZOOM_LVL_END];
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
uint8_t data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator);
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
return Blitter_32bppSSE_Base::Encode(sprite, allocator);
|
||||
}
|
||||
|
||||
const char *GetName() override { return "32bpp-sse2"; }
|
||||
std::string_view GetName() override { return "32bpp-sse2"; }
|
||||
};
|
||||
|
||||
/** Factory for the SSE2 32 bpp blitter (without palette animation). */
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
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);
|
||||
const char *GetName() override { return "32bpp-sse4"; }
|
||||
std::string_view GetName() override { return "32bpp-sse4"; }
|
||||
};
|
||||
|
||||
/** Factory for the SSE4 32 bpp blitter (without palette animation). */
|
||||
|
@@ -221,7 +221,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
#endif
|
||||
{
|
||||
const byte * const remap = bp->remap;
|
||||
const uint8_t * const remap = bp->remap;
|
||||
Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left;
|
||||
int effective_width = bp->width;
|
||||
|
||||
@@ -229,7 +229,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
const SpriteData * const sd = (const SpriteData *) bp->sprite;
|
||||
const SpriteInfo * const si = &sd->infos[zoom];
|
||||
const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width;
|
||||
const Colour *src_rgba_line = (const Colour *) ((const byte *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
|
||||
const Colour *src_rgba_line = (const Colour *) ((const uint8_t *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size);
|
||||
|
||||
if (read_mode != RM_WITH_MARGIN) {
|
||||
src_rgba_line += bp->skip_left;
|
||||
@@ -314,7 +314,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
Colour m_colour = m_colour_init; \
|
||||
{ \
|
||||
const Colour srcm = (Colour) (m_src); \
|
||||
const uint m = (byte) (m_m); \
|
||||
const uint m = (uint8_t) (m_m); \
|
||||
const uint r = remap[m]; \
|
||||
const Colour cmap = (this->LookupColourInPalette(r).data & 0x00FFFFFF) | (srcm.data & 0xFF000000); \
|
||||
m_colour = r == 0 ? m_colour : cmap; \
|
||||
@@ -442,7 +442,7 @@ bmcr_alpha_blend_single:
|
||||
|
||||
next_line:
|
||||
if (mode == BM_COLOUR_REMAP || mode == BM_CRASH_REMAP) src_mv_line += si->sprite_width;
|
||||
src_rgba_line = (const Colour*) ((const byte*) src_rgba_line + si->sprite_line_size);
|
||||
src_rgba_line = (const Colour*) ((const uint8_t*) src_rgba_line + si->sprite_line_size);
|
||||
dst_line += bp->pitch;
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@
|
||||
#endif
|
||||
|
||||
#define META_LENGTH 2 ///< Number of uint32_t inserted before each line of pixels in a sprite.
|
||||
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
|
||||
#define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_8X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL.
|
||||
#define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP.
|
||||
|
||||
#undef ALIGN
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
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);
|
||||
const char *GetName() override { return "32bpp-ssse3"; }
|
||||
std::string_view GetName() override { return "32bpp-ssse3"; }
|
||||
};
|
||||
|
||||
/** Factory for the SSSE3 32 bpp blitter (without palette animation). */
|
||||
|
@@ -104,8 +104,8 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
|
||||
/* skip upper lines in src_px and src_n */
|
||||
for (uint i = bp->skip_top; i != 0; i--) {
|
||||
src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
|
||||
src_px = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_n = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
}
|
||||
|
||||
/* skip lines in dst */
|
||||
@@ -114,7 +114,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)bp->dst - (uint32_t *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left;
|
||||
|
||||
/* store so we don't have to access it via bp everytime (compiler assumes pointer aliasing) */
|
||||
const byte *remap = bp->remap;
|
||||
const uint8_t *remap = bp->remap;
|
||||
|
||||
for (int y = 0; y < bp->height; y++) {
|
||||
/* next dst line begins here */
|
||||
@@ -122,11 +122,11 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
uint8_t *anim_ln = anim + bp->pitch;
|
||||
|
||||
/* next src line begins here */
|
||||
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px);
|
||||
const Colour *src_px_ln = (const Colour *)((const uint8_t *)src_px + *(const uint32_t *)src_px);
|
||||
src_px++;
|
||||
|
||||
/* next src_n line begins here */
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n);
|
||||
const uint16_t *src_n_ln = (const uint16_t *)((const uint8_t *)src_n + *(const uint32_t *)src_n);
|
||||
src_n += 2;
|
||||
|
||||
/* we will end this line when we reach this point */
|
||||
|
@@ -32,7 +32,7 @@ public:
|
||||
Blitter::PaletteAnimation UsePaletteAnimation() override;
|
||||
bool NeedsAnimationBuffer() override;
|
||||
|
||||
const char *GetName() override { return "40bpp-anim"; }
|
||||
std::string_view GetName() override { return "40bpp-anim"; }
|
||||
|
||||
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
||||
|
||||
|
@@ -128,9 +128,9 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
ZoomLevel zoom_min;
|
||||
ZoomLevel zoom_max;
|
||||
|
||||
if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_NORMAL;
|
||||
zoom_max = ZOOM_LVL_NORMAL;
|
||||
if (sprite[ZOOM_LVL_MIN].type == SpriteType::Font) {
|
||||
zoom_min = ZOOM_LVL_MIN;
|
||||
zoom_max = ZOOM_LVL_MIN;
|
||||
} else {
|
||||
zoom_min = _settings_client.gui.zoom_min;
|
||||
zoom_max = _settings_client.gui.zoom_max;
|
||||
@@ -147,10 +147,10 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
/* Don't allocate memory each time, but just keep some
|
||||
* memory around as this function is called quite often
|
||||
* and the memory usage is quite low. */
|
||||
static ReusableBuffer<byte> temp_buffer;
|
||||
static ReusableBuffer<uint8_t> temp_buffer;
|
||||
SpriteData *temp_dst = (SpriteData *)temp_buffer.Allocate(memory);
|
||||
memset(temp_dst, 0, sizeof(*temp_dst));
|
||||
byte *dst = temp_dst->data;
|
||||
uint8_t *dst = temp_dst->data;
|
||||
|
||||
/* Make the sprites per zoom-level */
|
||||
for (ZoomLevel i = zoom_min; i <= zoom_max; i++) {
|
||||
@@ -166,7 +166,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
uint trans = 0;
|
||||
uint pixels = 0;
|
||||
uint last_colour = 0;
|
||||
byte *count_dst = nullptr;
|
||||
uint8_t *count_dst = nullptr;
|
||||
|
||||
/* Store the scaled image */
|
||||
const SpriteLoader::CommonPixel *src = &sprite[i].data[y * sprite[i].width];
|
||||
@@ -213,7 +213,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
}
|
||||
}
|
||||
|
||||
uint size = dst - (byte *)temp_dst;
|
||||
uint size = dst - (uint8_t *)temp_dst;
|
||||
|
||||
/* Safety check, to make sure we guessed the size correctly */
|
||||
assert(size < memory);
|
||||
@@ -221,10 +221,10 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::SpriteCollection &spri
|
||||
/* Allocate the exact amount of memory we need */
|
||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + size);
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
memcpy(dest_sprite->data, temp_dst, size);
|
||||
|
||||
return dest_sprite;
|
||||
|
@@ -19,13 +19,13 @@ public:
|
||||
/** Data stored about a (single) sprite. */
|
||||
struct SpriteData {
|
||||
uint32_t offset[ZOOM_LVL_END]; ///< Offsets (from .data) to streams for different zoom levels.
|
||||
byte data[]; ///< Data, all zoomlevels.
|
||||
uint8_t data[]; ///< Data, all zoomlevels.
|
||||
};
|
||||
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
|
||||
const char *GetName() override { return "8bpp-optimized"; }
|
||||
std::string_view GetName() override { return "8bpp-optimized"; }
|
||||
};
|
||||
|
||||
/** Factory for the 8bpp blitter optimised for speed. */
|
||||
|
@@ -64,16 +64,16 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
||||
Sprite *Blitter_8bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator)
|
||||
{
|
||||
Sprite *dest_sprite;
|
||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + (size_t)sprite[ZOOM_LVL_NORMAL].height * (size_t)sprite[ZOOM_LVL_NORMAL].width);
|
||||
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->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
/* Copy over only the 'remap' channel, as that is what we care about in 8bpp */
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_NORMAL].height * sprite[ZOOM_LVL_NORMAL].width; i++) {
|
||||
dest_sprite->data[i] = sprite[ZOOM_LVL_NORMAL].data[i].m;
|
||||
for (int i = 0; i < sprite[ZOOM_LVL_MIN].height * sprite[ZOOM_LVL_MIN].width; i++) {
|
||||
dest_sprite->data[i] = sprite[ZOOM_LVL_MIN].data[i].m;
|
||||
}
|
||||
|
||||
return dest_sprite;
|
||||
|
@@ -19,7 +19,7 @@ public:
|
||||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override;
|
||||
Sprite *Encode(const SpriteLoader::SpriteCollection &sprite, AllocatorProc *allocator) override;
|
||||
|
||||
const char *GetName() override { return "8bpp-simple"; }
|
||||
std::string_view GetName() override { return "8bpp-simple"; }
|
||||
};
|
||||
|
||||
/** Factory for the most trivial 8bpp blitter. */
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
/** Parameters related to blitting. */
|
||||
struct BlitterParams {
|
||||
const void *sprite; ///< Pointer to the sprite how ever the encoder stored it
|
||||
const byte *remap; ///< XXX -- Temporary storage for remap array
|
||||
const uint8_t *remap; ///< XXX -- Temporary storage for remap array
|
||||
|
||||
int skip_left; ///< How much pixels of the source to skip on the left (based on zoom of dst)
|
||||
int skip_top; ///< How much pixels of the source to skip on the top (based on zoom of dst)
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
/**
|
||||
* Get the name of the blitter, the same as the Factory-instance returns.
|
||||
*/
|
||||
virtual const char *GetName() = 0;
|
||||
virtual std::string_view GetName() = 0;
|
||||
|
||||
/**
|
||||
* Post resize event
|
||||
|
@@ -93,7 +93,7 @@ public:
|
||||
* @param name the blitter to select.
|
||||
* @post Sets the blitter so GetCurrentBlitter() returns it too.
|
||||
*/
|
||||
static Blitter *SelectBlitter(const std::string &name)
|
||||
static Blitter *SelectBlitter(const std::string_view name)
|
||||
{
|
||||
BlitterFactory *b = GetBlitterFactory(name);
|
||||
if (b == nullptr) return nullptr;
|
||||
@@ -111,17 +111,17 @@ public:
|
||||
* @param name the blitter factory to select.
|
||||
* @return The blitter factory, or nullptr when there isn't one with the wanted name.
|
||||
*/
|
||||
static BlitterFactory *GetBlitterFactory(const std::string &name)
|
||||
static BlitterFactory *GetBlitterFactory(const std::string_view name)
|
||||
{
|
||||
#if defined(DEDICATED)
|
||||
const char *default_blitter = "null";
|
||||
const std::string_view default_blitter = "null";
|
||||
#elif defined(WITH_COCOA)
|
||||
const char *default_blitter = "32bpp-anim";
|
||||
const std::string_view default_blitter = "32bpp-anim";
|
||||
#else
|
||||
const char *default_blitter = "8bpp-optimized";
|
||||
const std::string_view default_blitter = "8bpp-optimized";
|
||||
#endif
|
||||
if (GetBlitters().empty()) return nullptr;
|
||||
const char *bname = name.empty() ? default_blitter : name.c_str();
|
||||
const std::string_view bname = name.empty() ? default_blitter : name;
|
||||
|
||||
for (auto &it : GetBlitters()) {
|
||||
BlitterFactory *b = it.second;
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
/**
|
||||
* Get the long, human readable, name for the Blitter-class.
|
||||
*/
|
||||
const std::string &GetName() const
|
||||
std::string_view GetName() const
|
||||
{
|
||||
return this->name;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
/**
|
||||
* Get a nice description of the blitter-class.
|
||||
*/
|
||||
const std::string &GetDescription() const
|
||||
std::string_view GetDescription() const
|
||||
{
|
||||
return this->description;
|
||||
}
|
||||
|
@@ -20,10 +20,10 @@ Sprite *Blitter_Null::Encode(const SpriteLoader::SpriteCollection &sprite, Alloc
|
||||
Sprite *dest_sprite;
|
||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite));
|
||||
|
||||
dest_sprite->height = sprite[ZOOM_LVL_NORMAL].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_NORMAL].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_NORMAL].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_NORMAL].y_offs;
|
||||
dest_sprite->height = sprite[ZOOM_LVL_MIN].height;
|
||||
dest_sprite->width = sprite[ZOOM_LVL_MIN].width;
|
||||
dest_sprite->x_offs = sprite[ZOOM_LVL_MIN].x_offs;
|
||||
dest_sprite->y_offs = sprite[ZOOM_LVL_MIN].y_offs;
|
||||
|
||||
return dest_sprite;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
void PaletteAnimate(const Palette &) override { };
|
||||
Blitter::PaletteAnimation UsePaletteAnimation() override { return Blitter::PALETTE_ANIMATION_NONE; };
|
||||
|
||||
const char *GetName() override { return "null"; }
|
||||
std::string_view GetName() override { return "null"; }
|
||||
};
|
||||
|
||||
/** Factory for the blitter that does nothing. */
|
||||
|
46
src/bmp.cpp
46
src/bmp.cpp
@@ -39,7 +39,7 @@ static inline bool EndOfBuffer(BmpBuffer *buffer)
|
||||
return buffer->pos == buffer->read;
|
||||
}
|
||||
|
||||
static inline byte ReadByte(BmpBuffer *buffer)
|
||||
static inline uint8_t ReadByte(BmpBuffer *buffer)
|
||||
{
|
||||
if (buffer->read < 0) return 0;
|
||||
|
||||
@@ -83,9 +83,9 @@ static inline void SetStreamOffset(BmpBuffer *buffer, int offset)
|
||||
static inline bool BmpRead1(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint x, y, i;
|
||||
byte pad = GB(4 - info->width / 8, 0, 2);
|
||||
byte *pixel_row;
|
||||
byte b;
|
||||
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];
|
||||
@@ -110,9 +110,9 @@ static inline bool BmpRead1(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead4(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint x, y;
|
||||
byte pad = GB(4 - info->width / 2, 0, 2);
|
||||
byte *pixel_row;
|
||||
byte b;
|
||||
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];
|
||||
@@ -140,12 +140,12 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint x = 0;
|
||||
uint y = info->height - 1;
|
||||
byte *pixel = &data->bitmap[y * info->width];
|
||||
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
|
||||
|
||||
byte n = ReadByte(buffer);
|
||||
byte c = ReadByte(buffer);
|
||||
uint8_t n = ReadByte(buffer);
|
||||
uint8_t c = ReadByte(buffer);
|
||||
if (n == 0) {
|
||||
switch (c) {
|
||||
case 0: // end of line
|
||||
@@ -159,8 +159,8 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
|
||||
case 2: { // delta
|
||||
if (EndOfBuffer(buffer)) return false;
|
||||
byte dx = ReadByte(buffer);
|
||||
byte dy = ReadByte(buffer);
|
||||
uint8_t dx = ReadByte(buffer);
|
||||
uint8_t dy = ReadByte(buffer);
|
||||
|
||||
/* Check for over- and underflow. */
|
||||
if (x + dx >= info->width || x + dx < x || dy > y) return false;
|
||||
@@ -175,7 +175,7 @@ static inline bool BmpRead4Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
uint i = 0;
|
||||
while (i++ < c) {
|
||||
if (EndOfBuffer(buffer) || x >= info->width) return false;
|
||||
byte b = ReadByte(buffer);
|
||||
uint8_t b = ReadByte(buffer);
|
||||
*pixel++ = GB(b, 4, 4);
|
||||
x++;
|
||||
if (i++ < c) {
|
||||
@@ -214,8 +214,8 @@ static inline bool BmpRead8(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint i;
|
||||
uint y;
|
||||
byte pad = GB(4 - info->width, 0, 2);
|
||||
byte *pixel;
|
||||
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];
|
||||
@@ -233,12 +233,12 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint x = 0;
|
||||
uint y = info->height - 1;
|
||||
byte *pixel = &data->bitmap[y * info->width];
|
||||
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
|
||||
|
||||
byte n = ReadByte(buffer);
|
||||
byte c = ReadByte(buffer);
|
||||
uint8_t n = ReadByte(buffer);
|
||||
uint8_t c = ReadByte(buffer);
|
||||
if (n == 0) {
|
||||
switch (c) {
|
||||
case 0: // end of line
|
||||
@@ -252,8 +252,8 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
|
||||
case 2: { // delta
|
||||
if (EndOfBuffer(buffer)) return false;
|
||||
byte dx = ReadByte(buffer);
|
||||
byte dy = ReadByte(buffer);
|
||||
uint8_t dx = ReadByte(buffer);
|
||||
uint8_t dy = ReadByte(buffer);
|
||||
|
||||
/* Check for over- and underflow. */
|
||||
if (x + dx >= info->width || x + dx < x || dy > y) return false;
|
||||
@@ -294,8 +294,8 @@ static inline bool BmpRead8Rle(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
static inline bool BmpRead24(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint x, y;
|
||||
byte pad = GB(4 - info->width * 3, 0, 2);
|
||||
byte *pixel_row;
|
||||
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++) {
|
||||
@@ -395,7 +395,7 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
assert(info != nullptr && data != nullptr);
|
||||
|
||||
data->bitmap = CallocT<byte>(static_cast<size_t>(info->width) * info->height * ((info->bpp == 24) ? 3 : 1));
|
||||
data->bitmap = CallocT<uint8_t>(static_cast<size_t>(info->width) * info->height * ((info->bpp == 24) ? 3 : 1));
|
||||
|
||||
/* Load image */
|
||||
SetStreamOffset(buffer, info->offset);
|
||||
|
@@ -24,13 +24,13 @@ struct BmpInfo {
|
||||
|
||||
struct BmpData {
|
||||
Colour *palette;
|
||||
byte *bitmap;
|
||||
uint8_t *bitmap;
|
||||
};
|
||||
|
||||
#define BMP_BUFFER_SIZE 1024
|
||||
|
||||
struct BmpBuffer {
|
||||
byte data[BMP_BUFFER_SIZE];
|
||||
uint8_t data[BMP_BUFFER_SIZE];
|
||||
int pos;
|
||||
int read;
|
||||
FILE *file;
|
||||
|
@@ -40,7 +40,7 @@ static constexpr NWidgetPart _background_widgets[] = {
|
||||
/**
|
||||
* Window description for the background window to prevent smearing.
|
||||
*/
|
||||
static WindowDesc _background_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _background_desc(
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_BOOTSTRAP, WC_NONE,
|
||||
WDF_NO_CLOSE,
|
||||
@@ -76,7 +76,7 @@ static constexpr NWidgetPart _nested_bootstrap_errmsg_widgets[] = {
|
||||
};
|
||||
|
||||
/** Window description for the error window. */
|
||||
static WindowDesc _bootstrap_errmsg_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _bootstrap_errmsg_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_BOOTSTRAP, WC_NONE,
|
||||
WDF_MODAL | WDF_NO_CLOSE,
|
||||
@@ -97,12 +97,12 @@ public:
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
if (widget == WID_BEM_MESSAGE) {
|
||||
*size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR);
|
||||
size->width += WidgetDimensions::scaled.frametext.Horizontal();
|
||||
size->height += WidgetDimensions::scaled.frametext.Vertical();
|
||||
size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR);
|
||||
size.width += WidgetDimensions::scaled.frametext.Horizontal();
|
||||
size.height += WidgetDimensions::scaled.frametext.Vertical();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ static constexpr NWidgetPart _nested_bootstrap_download_status_window_widgets[]
|
||||
};
|
||||
|
||||
/** Window description for the download window */
|
||||
static WindowDesc _bootstrap_download_status_window_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _bootstrap_download_status_window_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_NETWORK_STATUS_WINDOW, WC_NONE,
|
||||
WDF_MODAL | WDF_NO_CLOSE,
|
||||
@@ -185,7 +185,7 @@ static constexpr NWidgetPart _bootstrap_query_widgets[] = {
|
||||
};
|
||||
|
||||
/** The window description for the query. */
|
||||
static WindowDesc _bootstrap_query_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _bootstrap_query_desc(
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_CONFIRM_POPUP_QUERY, WC_NONE,
|
||||
WDF_NO_CLOSE,
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
/* We cache the button size. This is safe as no reinit can happen here. */
|
||||
if (this->button_size.width == 0) {
|
||||
@@ -223,13 +223,13 @@ public:
|
||||
switch (widget) {
|
||||
case WID_BAFD_QUESTION:
|
||||
/* The question is twice as wide as the buttons, and determine the height based on the width. */
|
||||
size->width = this->button_size.width * 2;
|
||||
size->height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size->width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical();
|
||||
size.width = this->button_size.width * 2;
|
||||
size.height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size.width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical();
|
||||
break;
|
||||
|
||||
case WID_BAFD_YES:
|
||||
case WID_BAFD_NO:
|
||||
*size = this->button_size;
|
||||
size = this->button_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -291,10 +291,10 @@ public:
|
||||
# include "video/video_driver.hpp"
|
||||
|
||||
class BootstrapEmscripten : public ContentCallback {
|
||||
bool downloading{false};
|
||||
uint total_files{0};
|
||||
uint total_bytes{0};
|
||||
uint downloaded_bytes{0};
|
||||
bool downloading = false;
|
||||
uint total_files = 0;
|
||||
uint total_bytes = 0;
|
||||
uint downloaded_bytes = 0;
|
||||
|
||||
public:
|
||||
BootstrapEmscripten()
|
||||
@@ -385,9 +385,9 @@ bool HandleBootstrap()
|
||||
* This way the mauve and gray colours work and we can show the user interface. */
|
||||
GfxInitPalettes();
|
||||
static const int offsets[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0, 0, 0x04, 0x08 };
|
||||
for (uint i = 0; i != 16; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
_colour_gradient[i][j] = offsets[i] + j;
|
||||
for (Colours i = COLOUR_BEGIN; i != COLOUR_END; i++) {
|
||||
for (ColourShade j = SHADE_BEGIN; j < SHADE_END; j++) {
|
||||
SetColourGradient(i, j, offsets[i] + j);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ typedef uint BridgeType; ///< Bridge spec number.
|
||||
*/
|
||||
struct BridgeSpec {
|
||||
TimerGameCalendar::Year avail_year; ///< the year where it becomes available
|
||||
byte min_length; ///< the minimum length (not counting start and end tile)
|
||||
uint8_t min_length; ///< the minimum length (not counting start and end tile)
|
||||
uint16_t max_length; ///< the maximum length (not counting start and end tile)
|
||||
uint16_t price; ///< the price multiplier
|
||||
uint16_t speed; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h)
|
||||
@@ -50,7 +50,7 @@ struct BridgeSpec {
|
||||
StringID material; ///< the string that contains the bridge description
|
||||
StringID transport_name[2]; ///< description of the bridge, when built for road or rail
|
||||
PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge
|
||||
byte flags; ///< bit 0 set: disable drawing of far pillars.
|
||||
uint8_t flags; ///< bit 0 set: disable drawing of far pillars.
|
||||
};
|
||||
|
||||
extern BridgeSpec _bridge[MAX_BRIDGES];
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include "gfx_func.h"
|
||||
#include "tunnelbridge.h"
|
||||
#include "sortlist_type.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
#include "tunnelbridge_map.h"
|
||||
#include "road_gui.h"
|
||||
@@ -54,7 +54,7 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
|
||||
* @param tile_start start tile
|
||||
* @param transport_type transport type.
|
||||
*/
|
||||
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte)
|
||||
void CcBuildBridge(Commands, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, uint8_t)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile);
|
||||
@@ -75,14 +75,18 @@ private:
|
||||
static Listing last_sorting; ///< Last setting of the sort.
|
||||
|
||||
/* Constants for sorting the bridges */
|
||||
static const StringID sorter_names[];
|
||||
static GUIBridgeList::SortFunction * const sorter_funcs[];
|
||||
static inline const StringID sorter_names[] = {
|
||||
STR_SORT_BY_NUMBER,
|
||||
STR_SORT_BY_COST,
|
||||
STR_SORT_BY_MAX_SPEED,
|
||||
};
|
||||
static const std::initializer_list<GUIBridgeList::SortFunction * const> sorter_funcs;
|
||||
|
||||
/* Internal variables */
|
||||
TileIndex start_tile;
|
||||
TileIndex end_tile;
|
||||
TransportType transport_type;
|
||||
byte road_rail_type;
|
||||
uint8_t road_rail_type;
|
||||
GUIBridgeList bridges;
|
||||
int icon_width; ///< Scaled width of the the bridge icon sprite.
|
||||
Scrollbar *vscroll;
|
||||
@@ -122,7 +126,7 @@ private:
|
||||
this->bridges.Sort();
|
||||
|
||||
/* Display the current sort variant */
|
||||
this->GetWidget<NWidgetCore>(WID_BBS_DROPDOWN_CRITERIA)->widget_data = this->sorter_names[this->bridges.SortType()];
|
||||
this->GetWidget<NWidgetCore>(WID_BBS_DROPDOWN_CRITERIA)->widget_data = BuildBridgeWindow::sorter_names[this->bridges.SortType()];
|
||||
|
||||
/* Set the modified widgets dirty */
|
||||
this->SetWidgetDirty(WID_BBS_DROPDOWN_CRITERIA);
|
||||
@@ -147,7 +151,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, TransportType transport_type, byte 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),
|
||||
@@ -161,8 +165,8 @@ public:
|
||||
this->FinishInitNested(transport_type); // Initializes 'this->icon_width'.
|
||||
|
||||
this->parent = FindWindowById(WC_BUILD_TOOLBAR, transport_type);
|
||||
this->bridges.SetListing(this->last_sorting);
|
||||
this->bridges.SetSortFuncs(this->sorter_funcs);
|
||||
this->bridges.SetListing(BuildBridgeWindow::last_sorting);
|
||||
this->bridges.SetSortFuncs(BuildBridgeWindow::sorter_funcs);
|
||||
this->bridges.NeedResort();
|
||||
this->SortBridgeList();
|
||||
|
||||
@@ -171,27 +175,24 @@ public:
|
||||
|
||||
~BuildBridgeWindow()
|
||||
{
|
||||
this->last_sorting = this->bridges.GetListing();
|
||||
BuildBridgeWindow::last_sorting = this->bridges.GetListing();
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_BBS_DROPDOWN_ORDER: {
|
||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
case WID_BBS_DROPDOWN_CRITERIA: {
|
||||
Dimension d = {0, 0};
|
||||
for (const StringID *str = this->sorter_names; *str != INVALID_STRING_ID; str++) {
|
||||
d = maxdim(d, GetStringBoundingBox(*str));
|
||||
}
|
||||
Dimension d = GetStringListBoundingBox(BuildBridgeWindow::sorter_names);
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
case WID_BBS_BRIDGE_LIST: {
|
||||
@@ -201,11 +202,11 @@ public:
|
||||
sprite_dim = maxdim(sprite_dim, GetScaledSpriteSize(bridge_data.spec->sprite));
|
||||
text_dim = maxdim(text_dim, GetStringBoundingBox(GetBridgeSelectString(bridge_data)));
|
||||
}
|
||||
resize->height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges.
|
||||
resize.height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges.
|
||||
|
||||
this->icon_width = sprite_dim.width; // Width of bridge icon.
|
||||
size->width = this->icon_width + WidgetDimensions::scaled.hsep_normal + text_dim.width + padding.width;
|
||||
size->height = 4 * resize->height; // Smallest bridge gui is 4 entries high in the matrix.
|
||||
size.width = this->icon_width + WidgetDimensions::scaled.hsep_normal + text_dim.width + padding.width;
|
||||
size.height = 4 * resize.height; // Smallest bridge gui is 4 entries high in the matrix.
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -231,11 +232,11 @@ public:
|
||||
case WID_BBS_BRIDGE_LIST: {
|
||||
Rect tr = r.WithHeight(this->resize.step_height).Shrink(WidgetDimensions::scaled.matrix);
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges.size(); i++) {
|
||||
const BuildBridgeData &bridge_data = this->bridges.at(i);
|
||||
const BridgeSpec *b = bridge_data.spec;
|
||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->bridges);
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const BridgeSpec *b = it->spec;
|
||||
DrawSpriteIgnorePadding(b->sprite, b->pal, tr.WithWidth(this->icon_width, rtl), SA_HOR_CENTER | SA_BOTTOM);
|
||||
DrawStringMultiLine(tr.Indent(this->icon_width + WidgetDimensions::scaled.hsep_normal, rtl), GetBridgeSelectString(bridge_data));
|
||||
DrawStringMultiLine(tr.Indent(this->icon_width + WidgetDimensions::scaled.hsep_normal, rtl), GetBridgeSelectString(*it));
|
||||
tr = tr.Translate(0, this->resize.step_height);
|
||||
}
|
||||
break;
|
||||
@@ -274,7 +275,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_BBS_DROPDOWN_CRITERIA:
|
||||
ShowDropDownMenu(this, this->sorter_names, this->bridges.SortType(), WID_BBS_DROPDOWN_CRITERIA, 0, 0);
|
||||
ShowDropDownMenu(this, BuildBridgeWindow::sorter_names, this->bridges.SortType(), WID_BBS_DROPDOWN_CRITERIA, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -298,20 +299,12 @@ public:
|
||||
Listing BuildBridgeWindow::last_sorting = {true, 2};
|
||||
|
||||
/** Available bridge sorting functions. */
|
||||
GUIBridgeList::SortFunction * const BuildBridgeWindow::sorter_funcs[] = {
|
||||
const std::initializer_list<GUIBridgeList::SortFunction * const> BuildBridgeWindow::sorter_funcs = {
|
||||
&BridgeIndexSorter,
|
||||
&BridgePriceSorter,
|
||||
&BridgeSpeedSorter
|
||||
};
|
||||
|
||||
/** Names of the sorting functions. */
|
||||
const StringID BuildBridgeWindow::sorter_names[] = {
|
||||
STR_SORT_BY_NUMBER,
|
||||
STR_SORT_BY_COST,
|
||||
STR_SORT_BY_MAX_SPEED,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
/** Widgets of the bridge gui. */
|
||||
static constexpr NWidgetPart _nested_build_bridge_widgets[] = {
|
||||
/* Header */
|
||||
@@ -341,7 +334,7 @@ static constexpr NWidgetPart _nested_build_bridge_widgets[] = {
|
||||
};
|
||||
|
||||
/** Window definition for the rail bridge selection window. */
|
||||
static WindowDesc _build_bridge_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _build_bridge_desc(
|
||||
WDP_AUTO, "build_bridge", 200, 114,
|
||||
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
@@ -358,7 +351,7 @@ static WindowDesc _build_bridge_desc(__FILE__, __LINE__,
|
||||
* @param transport_type The transport type
|
||||
* @param road_rail_type The road/rail type
|
||||
*/
|
||||
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
|
||||
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
|
||||
{
|
||||
CloseWindowByClass(WC_BUILD_BRIDGE);
|
||||
|
||||
|
@@ -69,10 +69,9 @@ TileIndex GetOtherBridgeEnd(TileIndex tile)
|
||||
*/
|
||||
int GetBridgeHeight(TileIndex t)
|
||||
{
|
||||
int h;
|
||||
Slope tileh = GetTileSlope(t, &h);
|
||||
auto [tileh, h] = GetTileSlopeZ(t);
|
||||
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
||||
|
||||
/* one height level extra for the ramp */
|
||||
return h + 1 + ApplyFoundationToSlope(f, &tileh);
|
||||
return h + 1 + ApplyFoundationToSlope(f, tileh);
|
||||
}
|
||||
|
@@ -25,7 +25,8 @@
|
||||
#include "window_func.h"
|
||||
#include "timer/timer_game_calendar.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
#include "dropdown_type.h"
|
||||
#include "dropdown_func.h"
|
||||
#include "engine_gui.h"
|
||||
#include "cargotype.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
@@ -95,7 +96,7 @@ static constexpr NWidgetPart _nested_build_vehicle_widgets[] = {
|
||||
|
||||
|
||||
bool _engine_sort_direction; ///< \c false = descending, \c true = ascending.
|
||||
byte _engine_sort_last_criteria[] = {0, 0, 0, 0}; ///< Last set sort criteria, for each vehicle type.
|
||||
uint8_t _engine_sort_last_criteria[] = {0, 0, 0, 0}; ///< Last set sort criteria, for each vehicle type.
|
||||
bool _engine_sort_last_order[] = {false, false, false, false}; ///< Last set direction of the sort order, for each vehicle type.
|
||||
bool _engine_sort_show_hidden_engines[] = {false, false, false, false}; ///< Last set 'show hidden engines' setting for each vehicle type.
|
||||
static CargoID _engine_sort_last_cargo_criteria[] = {CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY}; ///< Last set filter criteria, for each vehicle type.
|
||||
@@ -483,7 +484,7 @@ EngList_SortTypeFunction * const _engine_sort_functions[][11] = {{
|
||||
}};
|
||||
|
||||
/** Dropdown menu strings for the vehicle sort criteria. */
|
||||
const StringID _engine_sort_listing[][12] = {{
|
||||
const std::initializer_list<const StringID> _engine_sort_listing[] = {{
|
||||
/* Trains */
|
||||
STR_SORT_BY_ENGINE_ID,
|
||||
STR_SORT_BY_COST,
|
||||
@@ -496,7 +497,6 @@ const StringID _engine_sort_listing[][12] = {{
|
||||
STR_SORT_BY_POWER_VS_RUNNING_COST,
|
||||
STR_SORT_BY_RELIABILITY,
|
||||
STR_SORT_BY_CARGO_CAPACITY,
|
||||
INVALID_STRING_ID
|
||||
}, {
|
||||
/* Road vehicles */
|
||||
STR_SORT_BY_ENGINE_ID,
|
||||
@@ -510,7 +510,6 @@ const StringID _engine_sort_listing[][12] = {{
|
||||
STR_SORT_BY_POWER_VS_RUNNING_COST,
|
||||
STR_SORT_BY_RELIABILITY,
|
||||
STR_SORT_BY_CARGO_CAPACITY,
|
||||
INVALID_STRING_ID
|
||||
}, {
|
||||
/* Ships */
|
||||
STR_SORT_BY_ENGINE_ID,
|
||||
@@ -521,7 +520,6 @@ const StringID _engine_sort_listing[][12] = {{
|
||||
STR_SORT_BY_RUNNING_COST,
|
||||
STR_SORT_BY_RELIABILITY,
|
||||
STR_SORT_BY_CARGO_CAPACITY,
|
||||
INVALID_STRING_ID
|
||||
}, {
|
||||
/* Aircraft */
|
||||
STR_SORT_BY_ENGINE_ID,
|
||||
@@ -533,11 +531,10 @@ const StringID _engine_sort_listing[][12] = {{
|
||||
STR_SORT_BY_RELIABILITY,
|
||||
STR_SORT_BY_CARGO_CAPACITY,
|
||||
STR_SORT_BY_RANGE,
|
||||
INVALID_STRING_ID
|
||||
}};
|
||||
|
||||
/** Filters vehicles by cargo and engine (in case of rail vehicle). */
|
||||
static bool CDECL CargoAndEngineFilter(const GUIEngineListItem *item, const CargoID cid)
|
||||
static bool CargoAndEngineFilter(const GUIEngineListItem *item, const CargoID cid)
|
||||
{
|
||||
if (cid == CargoFilterCriteria::CF_ANY) {
|
||||
return true;
|
||||
@@ -549,7 +546,7 @@ static bool CDECL CargoAndEngineFilter(const GUIEngineListItem *item, const Carg
|
||||
}
|
||||
}
|
||||
|
||||
static GUIEngineList::FilterFunction * const _filter_funcs[] = {
|
||||
static GUIEngineList::FilterFunction * const _engine_filter_funcs[] = {
|
||||
&CargoAndEngineFilter,
|
||||
};
|
||||
|
||||
@@ -998,18 +995,16 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number,
|
||||
* @param type Type of vehicle (VEH_*)
|
||||
* @param r The Rect of the list
|
||||
* @param eng_list What engines to draw
|
||||
* @param min where to start in the list
|
||||
* @param max where in the list to end
|
||||
* @param sb Scrollbar of list.
|
||||
* @param selected_id what engine to highlight as selected, if any
|
||||
* @param show_count Whether to show the amount of engines or not
|
||||
* @param selected_group the group to list the engines of
|
||||
*/
|
||||
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group)
|
||||
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, const Scrollbar &sb, EngineID selected_id, bool show_count, GroupID selected_group)
|
||||
{
|
||||
static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
|
||||
|
||||
/* Obligatory sanity checks! */
|
||||
assert(max <= eng_list.size());
|
||||
auto [first, last] = sb.GetVisibleRangeIterators(eng_list);
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int step_size = GetEngineListHeight(type);
|
||||
@@ -1017,7 +1012,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
|
||||
int sprite_right = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_right;
|
||||
int sprite_width = sprite_left + sprite_right;
|
||||
int circle_width = std::max(GetScaledSpriteSize(SPR_CIRCLE_FOLDED).width, GetScaledSpriteSize(SPR_CIRCLE_UNFOLDED).width);
|
||||
int linecolour = _colour_gradient[COLOUR_ORANGE][4];
|
||||
int linecolour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL);
|
||||
|
||||
Rect ir = r.WithHeight(step_size).Shrink(WidgetDimensions::scaled.matrix);
|
||||
int sprite_y_offset = ScaleSpriteTrad(sprite_y_offsets[type]) + ir.Height() / 2;
|
||||
@@ -1028,9 +1023,8 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
|
||||
replace_icon = GetSpriteSize(SPR_GROUP_REPLACE_ACTIVE);
|
||||
|
||||
uint biggest_num_engines = 0;
|
||||
for (auto i = min; i < max; i++) {
|
||||
const auto &item = eng_list[i];
|
||||
const uint num_engines = GetGroupNumEngines(_local_company, selected_group, item.engine_id);
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const uint num_engines = GetGroupNumEngines(_local_company, selected_group, it->engine_id);
|
||||
biggest_num_engines = std::max(biggest_num_engines, num_engines);
|
||||
}
|
||||
|
||||
@@ -1047,13 +1041,31 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
|
||||
int small_text_y_offset = ir.Height() - GetCharacterHeight(FS_SMALL);
|
||||
int replace_icon_y_offset = (ir.Height() - replace_icon.height) / 2;
|
||||
|
||||
const int offset = (rtl ? -circle_width : circle_width) / 2;
|
||||
const int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
|
||||
|
||||
int y = ir.top;
|
||||
for (; min < max; min++, y += step_size) {
|
||||
const auto &item = eng_list[min];
|
||||
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;
|
||||
|
||||
if (item.indent > 0) {
|
||||
/* Draw tree continuation lines. */
|
||||
int tx = (rtl ? ir.right : ir.left) + offset;
|
||||
int ty = y - WidgetDimensions::scaled.matrix.top;
|
||||
for (uint lvl = 1; lvl <= item.indent; ++lvl) {
|
||||
if (HasBit(item.level_mask, lvl)) GfxDrawLine(tx, ty, tx, ty + step_size - 1, linecolour, WidgetDimensions::scaled.fullbevel.top);
|
||||
if (lvl < item.indent) tx += level_width;
|
||||
}
|
||||
/* Draw our node in the tree. */
|
||||
int ycentre = y + normal_text_y_offset + GetCharacterHeight(FS_NORMAL) / 2 - 1;
|
||||
if (!HasBit(item.level_mask, item.indent)) GfxDrawLine(tx, ty, tx, ycentre, linecolour, WidgetDimensions::scaled.fullbevel.top);
|
||||
GfxDrawLine(tx, ycentre, tx + offset - (rtl ? -1 : 1), ycentre, linecolour, WidgetDimensions::scaled.fullbevel.top);
|
||||
}
|
||||
|
||||
/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_company here. */
|
||||
const uint num_engines = GetGroupNumEngines(_local_company, selected_group, item.engine_id);
|
||||
|
||||
@@ -1081,14 +1093,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
|
||||
Rect fr = ir.Indent(indent, rtl).WithWidth(circle_width, rtl);
|
||||
DrawSpriteIgnorePadding(is_folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED, PAL_NONE, {fr.left, y, fr.right, y + ir.Height() - 1}, SA_CENTER);
|
||||
}
|
||||
if (indent > 0) {
|
||||
/* Draw tree lines */
|
||||
Rect fr = ir.Indent(indent - WidgetDimensions::scaled.hsep_indent, rtl).WithWidth(circle_width, rtl);
|
||||
int ycenter = y + normal_text_y_offset + GetCharacterHeight(FS_NORMAL) / 2;
|
||||
bool continues = (min + 1U) < eng_list.size() && eng_list[min + 1].indent == item.indent;
|
||||
GfxDrawLine(fr.left + circle_width / 2, y - WidgetDimensions::scaled.matrix.top, fr.left + circle_width / 2, continues ? y - WidgetDimensions::scaled.matrix.top + step_size - 1 : ycenter, linecolour, WidgetDimensions::scaled.fullbevel.top);
|
||||
GfxDrawLine(fr.left + circle_width / 2, ycenter, fr.right, ycenter, linecolour, WidgetDimensions::scaled.fullbevel.top);
|
||||
}
|
||||
y += step_size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1115,6 +1120,44 @@ void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selecte
|
||||
ShowDropDownMenu(w, _engine_sort_listing[vehicle_type], selected, button, 0, hidden_mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add children to GUI engine list to build a hierarchical tree.
|
||||
* @param dst Destination list.
|
||||
* @param src Source list.
|
||||
* @param parent Current tree parent (set by self with recursion).
|
||||
* @param indent Current tree indentation level (set by self with recursion).
|
||||
*/
|
||||
void GUIEngineListAddChildren(GUIEngineList &dst, const GUIEngineList &src, EngineID parent, uint8_t indent)
|
||||
{
|
||||
for (const auto &item : src) {
|
||||
if (item.variant_id != parent || item.engine_id == parent) continue;
|
||||
|
||||
const Engine *e = Engine::Get(item.engine_id);
|
||||
EngineDisplayFlags flags = item.flags;
|
||||
if (e->display_last_variant != INVALID_ENGINE) flags &= ~EngineDisplayFlags::Shaded;
|
||||
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) {
|
||||
/* Add this engine again as a child */
|
||||
if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) {
|
||||
dst.emplace_back(item.engine_id, item.engine_id, EngineDisplayFlags::None, indent + 1);
|
||||
}
|
||||
GUIEngineListAddChildren(dst, src, item.engine_id, indent + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (indent > 0 || dst.empty()) return;
|
||||
|
||||
/* Hierarchy is complete, traverse in reverse to find where indentation levels continue. */
|
||||
uint16_t level_mask = 0;
|
||||
for (auto it = std::rbegin(dst); std::next(it) != std::rend(dst); ++it) {
|
||||
auto next_it = std::next(it);
|
||||
SB(level_mask, it->indent, 1, it->indent <= next_it->indent);
|
||||
next_it->level_mask = level_mask;
|
||||
}
|
||||
}
|
||||
|
||||
/** Enum referring to the Hotkeys in the build vehicle window */
|
||||
enum BuildVehicleHotkeys {
|
||||
BVHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string
|
||||
@@ -1128,7 +1171,7 @@ struct BuildVehicleWindow : Window {
|
||||
RoadType roadtype; ///< Road type to show, or #INVALID_ROADTYPE.
|
||||
} filter; ///< Filter to apply.
|
||||
bool descending_sort_order; ///< Sort direction, @see _engine_sort_direction
|
||||
byte sort_criteria; ///< Current sort criterium.
|
||||
uint8_t sort_criteria; ///< Current sort criterium.
|
||||
bool show_hidden_engines; ///< State of the 'show hidden engines' button.
|
||||
bool listview_mode; ///< If set, only display the available vehicles and do not show a 'build' button.
|
||||
EngineID sel_engine; ///< Currently selected engine, or #INVALID_ENGINE
|
||||
@@ -1158,27 +1201,6 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void AddChildren(const GUIEngineList &source, EngineID parent, int indent)
|
||||
{
|
||||
for (const auto &item : source) {
|
||||
if (item.variant_id != parent || item.engine_id == parent) continue;
|
||||
|
||||
const Engine *e = Engine::Get(item.engine_id);
|
||||
EngineDisplayFlags flags = item.flags;
|
||||
if (e->display_last_variant != INVALID_ENGINE) flags &= ~EngineDisplayFlags::Shaded;
|
||||
this->eng_list.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) {
|
||||
/* Add this engine again as a child */
|
||||
if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) {
|
||||
this->eng_list.emplace_back(item.engine_id, item.engine_id, EngineDisplayFlags::None, indent + 1);
|
||||
}
|
||||
AddChildren(source, item.engine_id, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -1234,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::find_if(this->eng_list.begin(), this->eng_list.end(), [&](GUIEngineListItem &item) { return (item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None; });
|
||||
if (it != this->eng_list.end()) engine = it->engine_id;
|
||||
this->SelectEngine(engine);
|
||||
}
|
||||
@@ -1286,7 +1308,7 @@ struct BuildVehicleWindow : Window {
|
||||
this->cargo_filter_criteria = _engine_sort_last_cargo_criteria[this->vehicle_type];
|
||||
if (this->cargo_filter_criteria < NUM_CARGO && !HasBit(_standard_cargo_mask, this->cargo_filter_criteria)) this->cargo_filter_criteria = CargoFilterCriteria::CF_ANY;
|
||||
|
||||
this->eng_list.SetFilterFuncs(_filter_funcs);
|
||||
this->eng_list.SetFilterFuncs(_engine_filter_funcs);
|
||||
this->eng_list.SetFilterState(this->cargo_filter_criteria != CargoFilterCriteria::CF_ANY);
|
||||
}
|
||||
|
||||
@@ -1519,8 +1541,7 @@ struct BuildVehicleWindow : Window {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN:
|
||||
this->GenerateBuildTrainList(list);
|
||||
AddChildren(list, INVALID_ENGINE, 0);
|
||||
this->eng_list.shrink_to_fit();
|
||||
GUIEngineListAddChildren(this->eng_list, list);
|
||||
this->eng_list.RebuildDone();
|
||||
return;
|
||||
case VEH_ROAD:
|
||||
@@ -1557,8 +1578,7 @@ struct BuildVehicleWindow : Window {
|
||||
EngList_Sort(this->eng_list, _engine_sort_functions[this->vehicle_type][this->sort_criteria]);
|
||||
|
||||
this->eng_list.swap(list);
|
||||
AddChildren(list, INVALID_ENGINE, 0);
|
||||
this->eng_list.shrink_to_fit();
|
||||
GUIEngineListAddChildren(this->eng_list, list, INVALID_ENGINE, 0);
|
||||
this->eng_list.RebuildDone();
|
||||
}
|
||||
|
||||
@@ -1567,20 +1587,20 @@ struct BuildVehicleWindow : Window {
|
||||
DropDownList list;
|
||||
|
||||
/* Add item for disabling filtering. */
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(this->GetCargoFilterLabel(CargoFilterCriteria::CF_ANY), CargoFilterCriteria::CF_ANY, false));
|
||||
list.push_back(MakeDropDownListStringItem(this->GetCargoFilterLabel(CargoFilterCriteria::CF_ANY), CargoFilterCriteria::CF_ANY));
|
||||
/* Specific filters for trains. */
|
||||
if (this->vehicle_type == VEH_TRAIN) {
|
||||
/* Add item for locomotives only in case of trains. */
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(this->GetCargoFilterLabel(CargoFilterCriteria::CF_ENGINES), CargoFilterCriteria::CF_ENGINES, false));
|
||||
list.push_back(MakeDropDownListStringItem(this->GetCargoFilterLabel(CargoFilterCriteria::CF_ENGINES), CargoFilterCriteria::CF_ENGINES));
|
||||
/* Add item for vehicles not carrying anything, e.g. train engines.
|
||||
* This could also be useful for eyecandy vehicles of other types, but is likely too confusing for joe, */
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(this->GetCargoFilterLabel(CargoFilterCriteria::CF_NONE), CargoFilterCriteria::CF_NONE, false));
|
||||
list.push_back(MakeDropDownListStringItem(this->GetCargoFilterLabel(CargoFilterCriteria::CF_NONE), CargoFilterCriteria::CF_NONE));
|
||||
}
|
||||
|
||||
/* Add cargos */
|
||||
Dimension d = GetLargestCargoIconSize();
|
||||
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
|
||||
list.push_back(std::make_unique<DropDownListIconItem>(d, cs->GetCargoIcon(), PAL_NONE, cs->name, cs->Index(), false));
|
||||
list.push_back(MakeDropDownListIconItem(d, cs->GetCargoIcon(), PAL_NONE, cs->name, cs->Index()));
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -1723,7 +1743,7 @@ struct BuildVehicleWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_BV_SORT_DROPDOWN:
|
||||
SetDParam(0, _engine_sort_listing[this->vehicle_type][this->sort_criteria]);
|
||||
SetDParam(0, std::data(_engine_sort_listing[this->vehicle_type])[this->sort_criteria]);
|
||||
break;
|
||||
|
||||
case WID_BV_CARGO_FILTER_DROPDOWN:
|
||||
@@ -1742,43 +1762,43 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_BV_LIST:
|
||||
resize->height = GetEngineListHeight(this->vehicle_type);
|
||||
size->height = 3 * resize->height;
|
||||
size->width = std::max(size->width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width;
|
||||
resize.height = GetEngineListHeight(this->vehicle_type);
|
||||
size.height = 3 * resize.height;
|
||||
size.width = std::max(size.width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width;
|
||||
break;
|
||||
|
||||
case WID_BV_PANEL:
|
||||
size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
|
||||
size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
|
||||
break;
|
||||
|
||||
case WID_BV_SORT_ASCENDING_DESCENDING: {
|
||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
size = maxdim(size, d);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_BV_CARGO_FILTER_DROPDOWN:
|
||||
size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width);
|
||||
size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width);
|
||||
break;
|
||||
|
||||
case WID_BV_BUILD:
|
||||
*size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type);
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type));
|
||||
size->width += padding.width;
|
||||
size->height += padding.height;
|
||||
size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type);
|
||||
size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type));
|
||||
size.width += padding.width;
|
||||
size.height += padding.height;
|
||||
break;
|
||||
|
||||
case WID_BV_SHOW_HIDE:
|
||||
*size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type);
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type));
|
||||
size->width += padding.width;
|
||||
size->height += padding.height;
|
||||
size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type);
|
||||
size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type));
|
||||
size.width += padding.width;
|
||||
size.height += padding.height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1791,8 +1811,7 @@ struct BuildVehicleWindow : Window {
|
||||
this->vehicle_type,
|
||||
r,
|
||||
this->eng_list,
|
||||
this->vscroll->GetPosition(),
|
||||
static_cast<uint16_t>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size())),
|
||||
*this->vscroll,
|
||||
this->sel_engine,
|
||||
false,
|
||||
DEFAULT_GROUP
|
||||
@@ -1821,7 +1840,7 @@ struct BuildVehicleWindow : Window {
|
||||
int needed_height = this->details_height;
|
||||
/* Draw details panels. */
|
||||
if (this->sel_engine != INVALID_ENGINE) {
|
||||
const Rect r = this->GetWidget<NWidgetBase>(WID_BV_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
|
||||
const Rect r = this->GetWidget<NWidgetBase>(WID_BV_PANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine, this->te);
|
||||
needed_height = std::max(needed_height, (text_end - r.top) / GetCharacterHeight(FS_NORMAL));
|
||||
}
|
||||
@@ -1899,7 +1918,7 @@ struct BuildVehicleWindow : Window {
|
||||
}};
|
||||
};
|
||||
|
||||
static WindowDesc _build_vehicle_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _build_vehicle_desc(
|
||||
WDP_AUTO, "build_vehicle", 240, 268,
|
||||
WC_BUILD_VEHICLE, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
|
224
src/cachecheck.cpp
Normal file
224
src/cachecheck.cpp
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* 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 cachecheck.cpp Check caches. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "aircraft.h"
|
||||
#include "company_base.h"
|
||||
#include "debug.h"
|
||||
#include "industry.h"
|
||||
#include "roadstop_base.h"
|
||||
#include "roadveh.h"
|
||||
#include "ship.h"
|
||||
#include "station_base.h"
|
||||
#include "station_map.h"
|
||||
#include "subsidy_func.h"
|
||||
#include "town.h"
|
||||
#include "train.h"
|
||||
#include "vehicle_base.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
extern void AfterLoadCompanyStats();
|
||||
extern void RebuildTownCaches();
|
||||
|
||||
/**
|
||||
* Check the validity of some of the caches.
|
||||
* Especially in the sense of desyncs between
|
||||
* the cached value and what the value would
|
||||
* be when calculated from the 'base' data.
|
||||
*/
|
||||
void CheckCaches()
|
||||
{
|
||||
/* Return here so it is easy to add checks that are run
|
||||
* always to aid testing of caches. */
|
||||
if (_debug_desync_level <= 1) return;
|
||||
|
||||
/* Check the town caches. */
|
||||
std::vector<TownCache> old_town_caches;
|
||||
for (const Town *t : Town::Iterate()) {
|
||||
old_town_caches.push_back(t->cache);
|
||||
}
|
||||
|
||||
RebuildTownCaches();
|
||||
RebuildSubsidisedSourceAndDestinationCache();
|
||||
|
||||
uint i = 0;
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (old_town_caches[i] != t->cache) {
|
||||
Debug(desync, 2, "warning: town cache mismatch: town {}", t->index);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Check company infrastructure cache. */
|
||||
std::vector<CompanyInfrastructure> old_infrastructure;
|
||||
for (const Company *c : Company::Iterate()) old_infrastructure.push_back(c->infrastructure);
|
||||
|
||||
AfterLoadCompanyStats();
|
||||
|
||||
i = 0;
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (old_infrastructure[i] != c->infrastructure) {
|
||||
Debug(desync, 2, "warning: infrastructure cache mismatch: company {}", c->index);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Strict checking of the road stop cache entries */
|
||||
for (const RoadStop *rs : RoadStop::Iterate()) {
|
||||
if (IsBayRoadStopTile(rs->xy)) continue;
|
||||
|
||||
assert(rs->GetEntry(DIAGDIR_NE) != rs->GetEntry(DIAGDIR_NW));
|
||||
rs->GetEntry(DIAGDIR_NE)->CheckIntegrity(rs);
|
||||
rs->GetEntry(DIAGDIR_NW)->CheckIntegrity(rs);
|
||||
}
|
||||
|
||||
std::vector<NewGRFCache> grf_cache;
|
||||
std::vector<VehicleCache> veh_cache;
|
||||
std::vector<GroundVehicleCache> gro_cache;
|
||||
std::vector<TrainCache> tra_cache;
|
||||
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
if (v != v->First() || v->vehstatus & VS_CRASHED || !v->IsPrimaryVehicle()) continue;
|
||||
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
FillNewGRFVehicleCache(u);
|
||||
grf_cache.emplace_back(u->grf_cache);
|
||||
veh_cache.emplace_back(u->vcache);
|
||||
switch (u->type) {
|
||||
case VEH_TRAIN:
|
||||
gro_cache.emplace_back(Train::From(u)->gcache);
|
||||
tra_cache.emplace_back(Train::From(u)->tcache);
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
gro_cache.emplace_back(RoadVehicle::From(u)->gcache);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: Train::From(v)->ConsistChanged(CCF_TRACK); break;
|
||||
case VEH_ROAD: RoadVehUpdateCache(RoadVehicle::From(v)); break;
|
||||
case VEH_AIRCRAFT: UpdateAircraftCache(Aircraft::From(v)); break;
|
||||
case VEH_SHIP: Ship::From(v)->UpdateCache(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
uint length = 0;
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
FillNewGRFVehicleCache(u);
|
||||
if (grf_cache[length] != u->grf_cache) {
|
||||
Debug(desync, 2, "warning: newgrf cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
|
||||
}
|
||||
if (veh_cache[length] != u->vcache) {
|
||||
Debug(desync, 2, "warning: vehicle cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
|
||||
}
|
||||
switch (u->type) {
|
||||
case VEH_TRAIN:
|
||||
if (gro_cache[length] != Train::From(u)->gcache) {
|
||||
Debug(desync, 2, "warning: train ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
|
||||
}
|
||||
if (tra_cache[length] != Train::From(u)->tcache) {
|
||||
Debug(desync, 2, "warning: train cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
|
||||
}
|
||||
break;
|
||||
case VEH_ROAD:
|
||||
if (gro_cache[length] != RoadVehicle::From(u)->gcache) {
|
||||
Debug(desync, 2, "warning: road vehicle ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
length++;
|
||||
}
|
||||
|
||||
grf_cache.clear();
|
||||
veh_cache.clear();
|
||||
gro_cache.clear();
|
||||
tra_cache.clear();
|
||||
}
|
||||
|
||||
/* Check whether the caches are still valid */
|
||||
for (Vehicle *v : Vehicle::Iterate()) {
|
||||
[[maybe_unused]] const auto a = v->cargo.PeriodsInTransit();
|
||||
[[maybe_unused]] const auto b = v->cargo.TotalCount();
|
||||
[[maybe_unused]] const auto c = v->cargo.GetFeederShare();
|
||||
v->cargo.InvalidateCache();
|
||||
assert(a == v->cargo.PeriodsInTransit());
|
||||
assert(b == v->cargo.TotalCount());
|
||||
assert(c == v->cargo.GetFeederShare());
|
||||
}
|
||||
|
||||
/* Backup stations_near */
|
||||
std::vector<StationList> old_town_stations_near;
|
||||
for (Town *t : Town::Iterate()) old_town_stations_near.push_back(t->stations_near);
|
||||
|
||||
std::vector<StationList> old_industry_stations_near;
|
||||
for (Industry *ind : Industry::Iterate()) old_industry_stations_near.push_back(ind->stations_near);
|
||||
|
||||
std::vector<IndustryList> old_station_industries_near;
|
||||
for (Station *st : Station::Iterate()) old_station_industries_near.push_back(st->industries_near);
|
||||
|
||||
for (Station *st : Station::Iterate()) {
|
||||
for (GoodsEntry &ge : st->goods) {
|
||||
[[maybe_unused]] const auto a = ge.cargo.PeriodsInTransit();
|
||||
[[maybe_unused]] const auto b = ge.cargo.TotalCount();
|
||||
ge.cargo.InvalidateCache();
|
||||
assert(a == ge.cargo.PeriodsInTransit());
|
||||
assert(b == ge.cargo.TotalCount());
|
||||
}
|
||||
|
||||
/* Check docking tiles */
|
||||
TileArea ta;
|
||||
std::map<TileIndex, bool> docking_tiles;
|
||||
for (TileIndex tile : st->docking_station) {
|
||||
ta.Add(tile);
|
||||
docking_tiles[tile] = IsDockingTile(tile);
|
||||
}
|
||||
UpdateStationDockingTiles(st);
|
||||
if (ta.tile != st->docking_station.tile || ta.w != st->docking_station.w || ta.h != st->docking_station.h) {
|
||||
Debug(desync, 2, "warning: station docking mismatch: station {}, company {}", st->index, st->owner);
|
||||
}
|
||||
for (TileIndex tile : ta) {
|
||||
if (docking_tiles[tile] != IsDockingTile(tile)) {
|
||||
Debug(desync, 2, "warning: docking tile mismatch: tile {}", tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Station::RecomputeCatchmentForAll();
|
||||
|
||||
/* Check industries_near */
|
||||
i = 0;
|
||||
for (Station *st : Station::Iterate()) {
|
||||
if (st->industries_near != old_station_industries_near[i]) {
|
||||
Debug(desync, 2, "warning: station industries near mismatch: station {}", st->index);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Check stations_near */
|
||||
i = 0;
|
||||
for (Town *t : Town::Iterate()) {
|
||||
if (t->stations_near != old_town_stations_near[i]) {
|
||||
Debug(desync, 2, "warning: town stations near mismatch: town {}", t->index);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
for (Industry *ind : Industry::Iterate()) {
|
||||
if (ind->stations_near != old_industry_stations_near[i]) {
|
||||
Debug(desync, 2, "warning: industry stations near mismatch: industry {}", ind->index);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ using CargoLabel = StrongType::Typedef<uint32_t, struct CargoLabelTag, StrongTyp
|
||||
/**
|
||||
* Cargo slots to indicate a cargo type within a game.
|
||||
*/
|
||||
using CargoID = byte;
|
||||
using CargoID = uint8_t;
|
||||
|
||||
/**
|
||||
* Available types of cargo
|
||||
@@ -134,7 +134,7 @@ struct CargoArray : std::array<uint, NUM_CARGO> {
|
||||
|
||||
|
||||
/** Types of cargo source and destination */
|
||||
enum class SourceType : byte {
|
||||
enum class SourceType : uint8_t {
|
||||
Industry, ///< Source/destination is an industry
|
||||
Town, ///< Source/destination is a town
|
||||
Headquarters, ///< Source/destination are company headquarters
|
||||
|
@@ -71,8 +71,7 @@ static int32_t GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, b
|
||||
CargoMonitorMap::iterator iter = monitor_map.find(monitor);
|
||||
if (iter == monitor_map.end()) {
|
||||
if (keep_monitoring) {
|
||||
std::pair<CargoMonitorID, uint32_t> p(monitor, 0);
|
||||
monitor_map.insert(p);
|
||||
monitor_map.emplace(monitor, 0);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
|
@@ -45,23 +45,23 @@ private:
|
||||
int16_t y;
|
||||
};
|
||||
|
||||
uint16_t count{0}; ///< The amount of cargo in this packet.
|
||||
uint16_t periods_in_transit{0}; ///< Amount of cargo aging periods this packet has been in transit.
|
||||
uint16_t count = 0; ///< The amount of cargo in this packet.
|
||||
uint16_t periods_in_transit = 0; ///< Amount of cargo aging periods this packet has been in transit.
|
||||
|
||||
Money feeder_share{0}; ///< Value of feeder pickup to be paid for on delivery of cargo.
|
||||
Money feeder_share = 0; ///< Value of feeder pickup to be paid for on delivery of cargo.
|
||||
|
||||
TileIndex source_xy{INVALID_TILE}; ///< The origin of the cargo.
|
||||
TileIndex source_xy = INVALID_TILE; ///< The origin of the cargo.
|
||||
Vector travelled{0, 0}; ///< If cargo is in station: the vector from the unload tile to the source tile. If in vehicle: an intermediate value.
|
||||
|
||||
SourceID source_id{INVALID_SOURCE}; ///< Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid.
|
||||
SourceType source_type{SourceType::Industry}; ///< Type of \c source_id.
|
||||
SourceID source_id = INVALID_SOURCE; ///< Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid.
|
||||
SourceType source_type = SourceType::Industry; ///< Type of \c source_id.
|
||||
|
||||
#ifdef WITH_ASSERT
|
||||
bool in_vehicle{false}; ///< NOSAVE: Whether this cargo is in a vehicle or not.
|
||||
bool in_vehicle = false; ///< NOSAVE: Whether this cargo is in a vehicle or not.
|
||||
#endif /* WITH_ASSERT */
|
||||
|
||||
StationID first_station{INVALID_STATION}; ///< The station where the cargo came from first.
|
||||
StationID next_hop{INVALID_STATION}; ///< Station where the cargo wants to go next.
|
||||
StationID first_station = INVALID_STATION; ///< The station where the cargo came from first.
|
||||
StationID next_hop = INVALID_STATION; ///< Station where the cargo wants to go next.
|
||||
|
||||
/** The CargoList caches, thus needs to know about it. */
|
||||
template <class Tinst, class Tcont> friend class CargoList;
|
||||
|
@@ -99,7 +99,7 @@ void BuildCargoLabelMap()
|
||||
/* Label already exists, don't addd again. */
|
||||
if (CargoSpec::label_map.count(cs.label) != 0) continue;
|
||||
|
||||
CargoSpec::label_map.insert(std::make_pair(cs.label, cs.Index()));
|
||||
CargoSpec::label_map.emplace(cs.label, cs.Index());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
/** Town growth effect when delivering cargo. */
|
||||
enum TownAcceptanceEffect : byte {
|
||||
enum TownAcceptanceEffect : uint8_t {
|
||||
TAE_BEGIN = 0,
|
||||
TAE_NONE = TAE_BEGIN, ///< Cargo has no effect.
|
||||
TAE_PASSENGERS, ///< Cargo behaves passenger-like.
|
||||
@@ -31,7 +31,7 @@ enum TownAcceptanceEffect : byte {
|
||||
};
|
||||
|
||||
/** Town effect when producing cargo. */
|
||||
enum TownProductionEffect : byte {
|
||||
enum TownProductionEffect : uint8_t {
|
||||
TPE_NONE, ///< Town will not produce this cargo type.
|
||||
TPE_PASSENGERS, ///< Cargo behaves passenger-like for production.
|
||||
TPE_MAIL, ///< Cargo behaves mail-like for production.
|
||||
@@ -60,26 +60,26 @@ enum CargoClass {
|
||||
CC_SPECIAL = 1 << 15, ///< Special bit used for livery refit tricks instead of normal cargoes.
|
||||
};
|
||||
|
||||
static const byte INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
|
||||
static const uint8_t INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invalid cargo
|
||||
|
||||
static const uint TOWN_PRODUCTION_DIVISOR = 256;
|
||||
|
||||
/** Specification of a cargo type. */
|
||||
struct CargoSpec {
|
||||
CargoLabel label; ///< Unique label of the cargo type.
|
||||
uint8_t bitnum{INVALID_CARGO_BITNUM}; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec.
|
||||
uint8_t bitnum = INVALID_CARGO_BITNUM; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec.
|
||||
uint8_t legend_colour;
|
||||
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 multiplier = 0x100; ///< Capacity multiplier for vehicles. (8 fractional bits)
|
||||
uint16_t classes; ///< Classes of this cargo type. @see CargoClass
|
||||
int32_t initial_payment; ///< Initial payment rate before inflation is applied.
|
||||
uint8_t transit_periods[2];
|
||||
|
||||
bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier).
|
||||
TownAcceptanceEffect town_acceptance_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies.
|
||||
TownProductionEffect town_production_effect{INVALID_TPE}; ///< The effect on town cargo production.
|
||||
uint16_t town_production_multiplier{TOWN_PRODUCTION_DIVISOR}; ///< Town production multipler, if commanded by TownProductionEffect.
|
||||
TownProductionEffect town_production_effect = INVALID_TPE; ///< The effect on town cargo production.
|
||||
uint16_t town_production_multiplier = TOWN_PRODUCTION_DIVISOR; ///< Town production multipler, if commanded by TownProductionEffect.
|
||||
uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called
|
||||
|
||||
StringID name; ///< Name of this type of cargo.
|
||||
|
@@ -298,38 +298,37 @@ struct CheatWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
|
||||
{
|
||||
if (widget != WID_C_PANEL) return;
|
||||
|
||||
uint width = 0;
|
||||
for (int i = 0; i != lengthof(_cheats_ui); i++) {
|
||||
const CheatEntry *ce = &_cheats_ui[i];
|
||||
switch (ce->type) {
|
||||
for (const auto &ce : _cheats_ui) {
|
||||
switch (ce.type) {
|
||||
case SLE_BOOL:
|
||||
SetDParam(0, STR_CONFIG_SETTING_ON);
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width);
|
||||
width = std::max(width, GetStringBoundingBox(ce.str).width);
|
||||
SetDParam(0, STR_CONFIG_SETTING_OFF);
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width);
|
||||
width = std::max(width, GetStringBoundingBox(ce.str).width);
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (ce->str) {
|
||||
switch (ce.str) {
|
||||
/* Display date for change date cheat */
|
||||
case STR_CHEAT_CHANGE_DATE:
|
||||
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 11, 31));
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width);
|
||||
width = std::max(width, GetStringBoundingBox(ce.str).width);
|
||||
break;
|
||||
|
||||
/* Draw coloured flag for change company cheat */
|
||||
case STR_CHEAT_CHANGE_COMPANY:
|
||||
SetDParamMaxValue(0, MAX_COMPANIES);
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width + WidgetDimensions::scaled.hsep_wide);
|
||||
width = std::max(width, GetStringBoundingBox(ce.str).width + WidgetDimensions::scaled.hsep_wide);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetDParam(0, INT64_MAX);
|
||||
width = std::max(width, GetStringBoundingBox(ce->str).width);
|
||||
width = std::max(width, GetStringBoundingBox(ce.str).width);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -339,8 +338,8 @@ struct CheatWindow : Window {
|
||||
this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT);
|
||||
this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
|
||||
|
||||
size->width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
|
||||
size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
|
||||
size.width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
|
||||
size.height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
|
||||
}
|
||||
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
@@ -426,7 +425,7 @@ struct CheatWindow : Window {
|
||||
};
|
||||
|
||||
/** Window description of the cheats GUI. */
|
||||
static WindowDesc _cheats_desc(__FILE__, __LINE__,
|
||||
static WindowDesc _cheats_desc(
|
||||
WDP_AUTO, "cheats", 0, 0,
|
||||
WC_CHEATS, WC_NONE,
|
||||
0,
|
||||
|
@@ -44,7 +44,7 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags)
|
||||
return price;
|
||||
}
|
||||
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set)
|
||||
void DrawClearLandTile(const TileInfo *ti, uint8_t set)
|
||||
{
|
||||
DrawGroundSprite(SPR_FLAT_BARE_LAND + SlopeToSpriteOffset(ti->tileh) + set * 19, PAL_NONE);
|
||||
}
|
||||
@@ -129,8 +129,7 @@ static void DrawTile_Clear(TileInfo *ti)
|
||||
|
||||
static int GetSlopePixelZ_Clear(TileIndex tile, uint x, uint y, bool)
|
||||
{
|
||||
int z;
|
||||
Slope tileh = GetTilePixelSlope(tile, &z);
|
||||
auto [tileh, z] = GetTilePixelSlope(tile);
|
||||
|
||||
return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
|
||||
}
|
||||
@@ -145,25 +144,25 @@ static void UpdateFences(TileIndex tile)
|
||||
assert(IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS));
|
||||
bool dirty = false;
|
||||
|
||||
bool neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS));
|
||||
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(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CLEAR_FIELDS));
|
||||
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(TILE_ADDXY(tile, -1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, -1, 0), CLEAR_FIELDS));
|
||||
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(TILE_ADDXY(tile, 0, -1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, -1), CLEAR_FIELDS));
|
||||
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);
|
||||
dirty = true;
|
||||
|
@@ -13,6 +13,6 @@
|
||||
#include "tile_cmd.h"
|
||||
|
||||
void DrawHillyLandTile(const TileInfo *ti);
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set);
|
||||
void DrawClearLandTile(const TileInfo *ti, uint8_t set);
|
||||
|
||||
#endif /* CLEAR_FUNC_H */
|
||||
|
@@ -151,7 +151,7 @@ bool IsCommandAllowedWhilePaused(Commands cmd)
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_VEHICLE_MANAGEMENT
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_ROUTE_MANAGEMENT
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_OTHER_MANAGEMENT
|
||||
CMDPL_NO_CONSTRUCTION, ///< CMDT_COMPANY_SETTING
|
||||
CMDPL_NO_ACTIONS, ///< CMDT_COMPANY_SETTING
|
||||
CMDPL_NO_ACTIONS, ///< CMDT_SERVER_SETTING
|
||||
CMDPL_NO_ACTIONS, ///< CMDT_CHEAT
|
||||
};
|
||||
|
@@ -250,7 +250,7 @@ public:
|
||||
template <typename Tcallback>
|
||||
static Tret Unsafe(StringID err_message, Tcallback *callback, bool my_cmd, bool estimate_only, TileIndex location, std::tuple<Targs...> args)
|
||||
{
|
||||
return Execute(err_message, reinterpret_cast<CommandCallback *>(callback), my_cmd, estimate_only, false, location, std::move(args));
|
||||
return Execute(err_message, reinterpret_cast<CommandCallback *>(reinterpret_cast<void(*)()>(callback)), my_cmd, estimate_only, false, location, std::move(args));
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -301,7 +301,7 @@ protected:
|
||||
/* Only set client IDs when the command does not come from the network. */
|
||||
if (!network_command && GetCommandFlags<Tcmd>() & CMD_CLIENT_ID) SetClientIds(args, std::index_sequence_for<Targs...>{});
|
||||
|
||||
Tret res = Execute(err_message, reinterpret_cast<CommandCallback *>(callback), my_cmd, estimate_only, network_command, tile, args);
|
||||
Tret res = Execute(err_message, reinterpret_cast<CommandCallback *>(reinterpret_cast<void(*)()>(callback)), my_cmd, estimate_only, network_command, tile, args);
|
||||
InternalPostResult(ExtractCommandCost(res), tile, estimate_only, only_sending, err_message, my_cmd);
|
||||
|
||||
if (!estimate_only && !only_sending && callback != nullptr) {
|
||||
@@ -372,7 +372,7 @@ protected:
|
||||
assert(AllClientIdsSet(args, std::index_sequence_for<Targs...>{}));
|
||||
}
|
||||
|
||||
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
|
||||
Backup<CompanyID> cur_company(_current_company);
|
||||
if (!InternalExecutePrepTest(cmd_flags, tile, cur_company)) {
|
||||
cur_company.Trash();
|
||||
return MakeResult(CMD_ERROR);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user