mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-09-14 20:39:28 +00:00
Compare commits
841
Commits
1.11.1
...
12.0-beta1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b67ef1e5b8 | ||
|
|
cb9a2dec0d | ||
|
|
43c4c9d560 | ||
|
|
eca73a810c | ||
|
|
ee333a9549 | ||
|
|
2183fd4dab | ||
|
|
579f393374 | ||
|
|
1ef4d3cf19 | ||
|
|
3d55ea2d4d | ||
|
|
db13eebf29 | ||
|
|
c3d43d7b1c | ||
|
|
e599f6efb4 | ||
|
|
132c540d58 | ||
|
|
508e465b59 | ||
|
|
65b8614d26 | ||
|
|
120d216b0b | ||
|
|
26f7f592cd | ||
|
|
76b8343777 | ||
|
|
b14681891d | ||
|
|
580dd118cb | ||
|
|
4c1ea4020d | ||
|
|
8a083cd7f8 | ||
|
|
4eb368c786 | ||
|
|
8706dcd9c1 | ||
|
|
d58772ecda | ||
|
|
2dd46b964a | ||
|
|
b681935fc8 | ||
|
|
1838726985 | ||
|
|
d83647f9a7 | ||
|
|
c1d79398d5 | ||
|
|
6fce05689c | ||
|
|
8380ff8dd0 | ||
|
|
9df60a2759 | ||
|
|
dea999566d | ||
|
|
476c039332 | ||
|
|
d17e4f7d29 | ||
|
|
7409e6fea1 | ||
|
|
cab212258f | ||
|
|
333de9f15d | ||
|
|
72737a91f3 | ||
|
|
ba29edb0b3 | ||
|
|
9cc706847c | ||
|
|
99d0d9be6b | ||
|
|
6c33b4ed28 | ||
|
|
dd54e4c835 | ||
|
|
fa1e27994d | ||
|
|
8a36134003 | ||
|
|
f1dfc2f482 | ||
|
|
549a58731f | ||
|
|
e6e2a67aa1 | ||
|
|
3d0d9edafd | ||
|
|
1e439979f7 | ||
|
|
9b0bb21f3b | ||
|
|
d1cf56609d | ||
|
|
1e529e1632 | ||
|
|
9421cb1e2c | ||
|
|
386ef4dac3 | ||
|
|
3eaa470632 | ||
|
|
5dd524139f | ||
|
|
09a7825d1e | ||
|
|
3479e59eea | ||
|
|
ab601115a9 | ||
|
|
460991ecf4 | ||
|
|
16abdd5254 | ||
|
|
afea5e85ae | ||
|
|
96add9c36d | ||
|
|
29cceb59a5 | ||
|
|
8adade26ed | ||
|
|
55eed246b8 | ||
|
|
695e1493c9 | ||
|
|
c921f6d817 | ||
|
|
333cba6a61 | ||
|
|
e9b157f1f5 | ||
|
|
80f4e42627 | ||
|
|
c71f06e59b | ||
|
|
dd7f69be6e | ||
|
|
178ea3196b | ||
|
|
b6a116a247 | ||
|
|
8bb9c3f646 | ||
|
|
e4d216e44b | ||
|
|
1baec41542 | ||
|
|
cee8174d02 | ||
|
|
f4dd2d88c7 | ||
|
|
6f0c6fb2ae | ||
|
|
a498723345 | ||
|
|
f6955a304c | ||
|
|
e99134654b | ||
|
|
3e4d327451 | ||
|
|
d158eba72c | ||
|
|
de7ab2eb1c | ||
|
|
6212d0a8da | ||
|
|
8a2da49413 | ||
|
|
61fdef8457 | ||
|
|
aa93d76223 | ||
|
|
b1280fd17e | ||
|
|
e1e2212e0e | ||
|
|
cbaac5609f | ||
|
|
92cdfffbd1 | ||
|
|
8b1737f680 | ||
|
|
ddb6024bc6 | ||
|
|
85faa218ff | ||
|
|
0d0375c019 | ||
|
|
1c0c4637d2 | ||
|
|
ede3f79475 | ||
|
|
01139d3368 | ||
|
|
94881f5a34 | ||
|
|
a70aa5df49 | ||
|
|
ce813ce644 | ||
|
|
49b66ea504 | ||
|
|
a543a4b7bb | ||
|
|
89ab8b79a5 | ||
|
|
5844027eb8 | ||
|
|
87eb997be0 | ||
|
|
8f5d0ecde3 | ||
|
|
d9ca9ca555 | ||
|
|
a5add82600 | ||
|
|
c1f13e0372 | ||
|
|
852e056d6f | ||
|
|
a7fabe497c | ||
|
|
7bcc7e11ff | ||
|
|
6e627f35ac | ||
|
|
2c941cd8b3 | ||
|
|
c1a9fe6fbd | ||
|
|
f371a5ad70 | ||
|
|
7e7a4aad72 | ||
|
|
25ca6a75bc | ||
|
|
b4aedc8bee | ||
|
|
ddafc0de05 | ||
|
|
8913ae9ba8 | ||
|
|
faea943a9b | ||
|
|
511c1081af | ||
|
|
10d8c17236 | ||
|
|
05bdfadcb6 | ||
|
|
0fa2007560 | ||
|
|
d38ad7d80c | ||
|
|
979783f90e | ||
|
|
1d9912134d | ||
|
|
3e3049fd0e | ||
|
|
4e645ce749 | ||
|
|
9643a1b80a | ||
|
|
1ed2405907 | ||
|
|
3826703bc3 | ||
|
|
cdb3dd0493 | ||
|
|
7dd5fd6ed4 | ||
|
|
513641f9ba | ||
|
|
75b6051b7a | ||
|
|
4f3bf84af4 | ||
|
|
66dc0ce196 | ||
|
|
a42251fc72 | ||
|
|
9c7a7b53a1 | ||
|
|
9a7750f14e | ||
|
|
aa9818db90 | ||
|
|
df601b8559 | ||
|
|
d38079d053 | ||
|
|
b6fb020388 | ||
|
|
8336d21b25 | ||
|
|
c539343ba9 | ||
|
|
f9b4a3a5e6 | ||
|
|
883e4ea325 | ||
|
|
003b6a0c85 | ||
|
|
59e96cd56a | ||
|
|
87eb0e4fce | ||
|
|
da7621cc55 | ||
|
|
98e653dacc | ||
|
|
f35e6c1c7f | ||
|
|
c93fcbcb28 | ||
|
|
f7f1d530b8 | ||
|
|
f029fd0f3b | ||
|
|
cdf9caf8ea | ||
|
|
0013673faf | ||
|
|
74186998a2 | ||
|
|
1ed7afc0a8 | ||
|
|
95a94dcf90 | ||
|
|
37116a7575 | ||
|
|
883e21dbb7 | ||
|
|
0d5d3083bd | ||
|
|
8c1b89e107 | ||
|
|
6a05839d8d | ||
|
|
8a33e98834 | ||
|
|
052f6b5d9f | ||
|
|
ce7ef4d824 | ||
|
|
1e6a2163a5 | ||
|
|
cf865597f8 | ||
|
|
b45c006ab9 | ||
|
|
c12a152ec9 | ||
|
|
281a65b3e1 | ||
|
|
357af686dc | ||
|
|
f904aef176 | ||
|
|
a9774f3e34 | ||
|
|
3237e97b35 | ||
|
|
930bb22416 | ||
|
|
b560620eb9 | ||
|
|
8e91527251 | ||
|
|
4c4b55ecbd | ||
|
|
88edfd4ef1 | ||
|
|
b9ab9e4d05 | ||
|
|
97b94bdc9a | ||
|
|
f67af5cbe5 | ||
|
|
d5cda58158 | ||
|
|
0d2e3437e3 | ||
|
|
75e7451151 | ||
|
|
a146bcfe93 | ||
|
|
d0bcb9839a | ||
|
|
d31a535c87 | ||
|
|
05005dcdfa | ||
|
|
981cd0197a | ||
|
|
a8b3afb236 | ||
|
|
49dcf0c772 | ||
|
|
53b4786037 | ||
|
|
667301e3ec | ||
|
|
a91e29b656 | ||
|
|
36705f1dc0 | ||
|
|
9e32c618f9 | ||
|
|
7b135a8269 | ||
|
|
5cd0c65787 | ||
|
|
af3aba7a88 | ||
|
|
aa02bf27f6 | ||
|
|
0bdca02bdf | ||
|
|
af43fc3d62 | ||
|
|
0bb1d2fa8e | ||
|
|
4e4720f217 | ||
|
|
4600d289b5 | ||
|
|
909f3f25bd | ||
|
|
7385e780ac | ||
|
|
c811d42d0c | ||
|
|
721c3fdfb4 | ||
|
|
fc63432a11 | ||
|
|
75afd25e16 | ||
|
|
eb6cdadc4d | ||
|
|
d9c1d18f2b | ||
|
|
b280a3a0ed | ||
|
|
efd4ba4797 | ||
|
|
de49727ae8 | ||
|
|
121b037054 | ||
|
|
6b757c716a | ||
|
|
1e432fbd71 | ||
|
|
f86c66cbd7 | ||
|
|
7d79180040 | ||
|
|
352dbdd570 | ||
|
|
55a11710a6 | ||
|
|
a99ac62c1a | ||
|
|
662d8dfc30 | ||
|
|
845fded2a0 | ||
|
|
bf500c39c9 | ||
|
|
e588923bff | ||
|
|
ca9c50607e | ||
|
|
fed3e3305f | ||
|
|
2d0abf5a76 | ||
|
|
418e0ea85f | ||
|
|
8dd846bad4 | ||
|
|
71f3c35288 | ||
|
|
40cec34836 | ||
|
|
f1328db063 | ||
|
|
c562b4c527 | ||
|
|
16ebf7861f | ||
|
|
ee5f23382d | ||
|
|
ef25afd55a | ||
|
|
acb6348ba6 | ||
|
|
d09210e1c6 | ||
|
|
c2db408d5d | ||
|
|
d485b50813 | ||
|
|
744a9e4745 | ||
|
|
15f66329c2 | ||
|
|
00e3fddd0c | ||
|
|
b7250a42e1 | ||
|
|
2df48a78cc | ||
|
|
3ca0239985 | ||
|
|
5d05c4919b | ||
|
|
f4c7d5577e | ||
|
|
ed3946e295 | ||
|
|
076f3d26c2 | ||
|
|
2924ac48c5 | ||
|
|
bb8fd00760 | ||
|
|
ab9b937ab7 | ||
|
|
849a10520c | ||
|
|
e2417193c9 | ||
|
|
e3717ae903 | ||
|
|
df181bb641 | ||
|
|
9c424ab741 | ||
|
|
dfb89f3891 | ||
|
|
6bb3f034e4 | ||
|
|
37ae6b8ae3 | ||
|
|
174952440a | ||
|
|
8f323855b1 | ||
|
|
aa6443d57a | ||
|
|
23857af693 | ||
|
|
a2147d437e | ||
|
|
fba86f711f | ||
|
|
f899772ec2 | ||
|
|
37b285ad83 | ||
|
|
12de256b72 | ||
|
|
f997eb6ca4 | ||
|
|
1e564b333f | ||
|
|
648ee88a02 | ||
|
|
264991dfa5 | ||
|
|
414e12d26b | ||
|
|
7572603c9d | ||
|
|
d835a42c05 | ||
|
|
c27afdf3f6 | ||
|
|
3559e55b91 | ||
|
|
ea23a9cdb6 | ||
|
|
d816ff0361 | ||
|
|
5e44da3010 | ||
|
|
feb2ddbefa | ||
|
|
28e90769f7 | ||
|
|
f8dd5dd00a | ||
|
|
48ecc481ee | ||
|
|
30f5938eed | ||
|
|
c936f8b769 | ||
|
|
9fff00ba20 | ||
|
|
956d761e3e | ||
|
|
921ab68a48 | ||
|
|
043a544248 | ||
|
|
5ded596c80 | ||
|
|
4613ababd3 | ||
|
|
0c96884700 | ||
|
|
e9e4588db1 | ||
|
|
bcd7a7aafe | ||
|
|
8c273ed598 | ||
|
|
e58581f1f8 | ||
|
|
29f2bd27c4 | ||
|
|
8a918ce170 | ||
|
|
97c461d1e7 | ||
|
|
e3c9ed4d15 | ||
|
|
806f78aa04 | ||
|
|
fd95736bac | ||
|
|
f0e1cd0129 | ||
|
|
8b9f1147df | ||
|
|
d70fb74ac6 | ||
|
|
5799402f7a | ||
|
|
994bf19aef | ||
|
|
ef991b1772 | ||
|
|
2e136285e1 | ||
|
|
661728558e | ||
|
|
b4aedef848 | ||
|
|
0125ba82e8 | ||
|
|
7713c3e3cc | ||
|
|
665e3c1f45 | ||
|
|
b0f44d7eb1 | ||
|
|
e58046c947 | ||
|
|
ca9a7df752 | ||
|
|
4d74e51907 | ||
|
|
4c0e083128 | ||
|
|
4144e949ed | ||
|
|
08308d808c | ||
|
|
e2f5d9e561 | ||
|
|
ea9715d970 | ||
|
|
208952f2ba | ||
|
|
ce1c60699a | ||
|
|
7b5c0b4236 | ||
|
|
7648483364 | ||
|
|
8372c679e3 | ||
|
|
86c9ef8134 | ||
|
|
e666a962b1 | ||
|
|
860003458f | ||
|
|
72ec81325b | ||
|
|
0d6597a9e6 | ||
|
|
f58611298e | ||
|
|
f6723b53da | ||
|
|
1f8ff0e4f9 | ||
|
|
be28c95b30 | ||
|
|
024e584904 | ||
|
|
c3cd4a683d | ||
|
|
d8125fa46e | ||
|
|
91b3d697c5 | ||
|
|
cf6b91f30f | ||
|
|
3bb6ce8827 | ||
|
|
425d50372f | ||
|
|
ac99a38175 | ||
|
|
8ffb4122df | ||
|
|
db54e20825 | ||
|
|
9197de39e4 | ||
|
|
6fe4d4ad7b | ||
|
|
ed9e38221a | ||
|
|
b280f16316 | ||
|
|
b9797a81c0 | ||
|
|
b791ffc6de | ||
|
|
eaa3df1e8e | ||
|
|
35dbd53682 | ||
|
|
3ce7e31f64 | ||
|
|
c96945fa2b | ||
|
|
6b24cd2516 | ||
|
|
7607277380 | ||
|
|
886f5c104a | ||
|
|
36bcd2956a | ||
|
|
7c0762da65 | ||
|
|
e99352a5d9 | ||
|
|
64be66216c | ||
|
|
a896753ecc | ||
|
|
33d99d27f4 | ||
|
|
97722931a9 | ||
|
|
4f7d6cf1ba | ||
|
|
7b58bfaf6c | ||
|
|
08e71eed8b | ||
|
|
3477405e86 | ||
|
|
ca9f9b84d3 | ||
|
|
145f2fc43a | ||
|
|
7caceb26f7 | ||
|
|
e2dc5aa83e | ||
|
|
e2e06633c9 | ||
|
|
4d246cda73 | ||
|
|
83679c0e57 | ||
|
|
e90b2649b6 | ||
|
|
5c01f9ea52 | ||
|
|
e66e25ff71 | ||
|
|
2e43f91891 | ||
|
|
fab120ee83 | ||
|
|
ae85af98eb | ||
|
|
2e0297b0fa | ||
|
|
e6703eac68 | ||
|
|
44ca7d9377 | ||
|
|
ddaedaf32a | ||
|
|
bb9121dbd4 | ||
|
|
031e91de6e | ||
|
|
e6f0d63e25 | ||
|
|
aa5a8fe28a | ||
|
|
297d6e20bf | ||
|
|
ebe32ad912 | ||
|
|
6db52d52d0 | ||
|
|
1de5cdeab8 | ||
|
|
98283116fa | ||
|
|
1da0ba95b2 | ||
|
|
9f8d0b1bee | ||
|
|
a9ff296c3d | ||
|
|
0f062b3882 | ||
|
|
a032714dc4 | ||
|
|
95386dc2b8 | ||
|
|
77330d09fd | ||
|
|
65cbde4b30 | ||
|
|
2022e34824 | ||
|
|
16437b7c0d | ||
|
|
02fdb5b210 | ||
|
|
cc6c078dec | ||
|
|
c73d64adf9 | ||
|
|
f219354f89 | ||
|
|
423a5034ee | ||
|
|
a403653805 | ||
|
|
86741ad489 | ||
|
|
56a46f5cae | ||
|
|
6ee8690b47 | ||
|
|
187a3f20bf | ||
|
|
7755f81bb8 | ||
|
|
d7ce61f106 | ||
|
|
38c97e1492 | ||
|
|
5bd8144853 | ||
|
|
f6d5c0136e | ||
|
|
f96f113951 | ||
|
|
22567a1f43 | ||
|
|
aba239479b | ||
|
|
95abdfdef9 | ||
|
|
ba193f2e23 | ||
|
|
3e7e2d9ca3 | ||
|
|
b972ed8604 | ||
|
|
7b7dbbc935 | ||
|
|
b136e65cf9 | ||
|
|
56050fc96f | ||
|
|
3d9436bd75 | ||
|
|
c0a0d85d20 | ||
|
|
1dfc148613 | ||
|
|
d0eb3e4bc4 | ||
|
|
0968d009c8 | ||
|
|
9e7e87ce3e | ||
|
|
9841ebb0bd | ||
|
|
36e22f3a7b | ||
|
|
2e429ee485 | ||
|
|
495d73a67f | ||
|
|
296194ad36 | ||
|
|
79fc094c54 | ||
|
|
c53d9991ee | ||
|
|
8f4a612a7c | ||
|
|
b7dd602dcd | ||
|
|
583011bca0 | ||
|
|
e162d0a55c | ||
|
|
330a305c99 | ||
|
|
b9ab3bd6b3 | ||
|
|
fc91f1d1b2 | ||
|
|
1b75a29d12 | ||
|
|
664a8c3e85 | ||
|
|
de940b1dbc | ||
|
|
fa6abe1646 | ||
|
|
10e35ca8e4 | ||
|
|
fdc11a9f94 | ||
|
|
0dd339ecd8 | ||
|
|
c097bc9d7d | ||
|
|
b144e56b2c | ||
|
|
8e0b1b5d1a | ||
|
|
69e5da0b54 | ||
|
|
881e1da51d | ||
|
|
f187708b3b | ||
|
|
8c3fa2a3bf | ||
|
|
dd41de8931 | ||
|
|
d8e06e590a | ||
|
|
52b16237ad | ||
|
|
8321ef0061 | ||
|
|
e2774354b4 | ||
|
|
a879996012 | ||
|
|
b56c03b120 | ||
|
|
f7e390bdc0 | ||
|
|
f1dfa661a1 | ||
|
|
cb89d22cf2 | ||
|
|
6bca9e090d | ||
|
|
f313a539a5 | ||
|
|
3d91eee919 | ||
|
|
6c4a65eeb8 | ||
|
|
dcef3209a6 | ||
|
|
dc05917287 | ||
|
|
f94fb93779 | ||
|
|
ead30dc725 | ||
|
|
e7581fd42d | ||
|
|
72bd62fd70 | ||
|
|
24e7cb4947 | ||
|
|
605bd24674 | ||
|
|
a432009f06 | ||
|
|
fa206bf2e3 | ||
|
|
176d65b472 | ||
|
|
2feb801e56 | ||
|
|
983c7ade60 | ||
|
|
34215f7faa | ||
|
|
7bcc472f73 | ||
|
|
ba409e8c45 | ||
|
|
8228021afe | ||
|
|
6bd7f8816d | ||
|
|
08781d96ed | ||
|
|
0bc6f32346 | ||
|
|
ece9a356dc | ||
|
|
1a1def99dc | ||
|
|
20762f9117 | ||
|
|
756034fa27 | ||
|
|
a3e49178d1 | ||
|
|
bd1a20f6ee | ||
|
|
1f159f79de | ||
|
|
91b8ce073f | ||
|
|
2cf5df2a50 | ||
|
|
84aa17cea6 | ||
|
|
56aa6d0edd | ||
|
|
18651dd8b1 | ||
|
|
256dbee255 | ||
|
|
18fb1c3866 | ||
|
|
6b0b1bb3de | ||
|
|
913d8a7f28 | ||
|
|
1aeaf39954 | ||
|
|
f785a70a2b | ||
|
|
e097c83c83 | ||
|
|
22720332eb | ||
|
|
0eb17a70af | ||
|
|
67063ceeb3 | ||
|
|
520595ff87 | ||
|
|
05394d5216 | ||
|
|
83985fe26f | ||
|
|
39c51c35f4 | ||
|
|
3bd416bfdb | ||
|
|
376f2509ad | ||
|
|
282d5d302d | ||
|
|
0345f99180 | ||
|
|
2985277bec | ||
|
|
40528db993 | ||
|
|
9c6c0a0966 | ||
|
|
ce55cd0ce7 | ||
|
|
49aa392440 | ||
|
|
055067c49c | ||
|
|
254ffe9dcc | ||
|
|
957beaaefc | ||
|
|
617e85cc65 | ||
|
|
5434d63f91 | ||
|
|
af70195e44 | ||
|
|
1df510c297 | ||
|
|
09206be054 | ||
|
|
56a6f66903 | ||
|
|
63cc340dc1 | ||
|
|
d32df00b5c | ||
|
|
4791ff2862 | ||
|
|
6fe5353da2 | ||
|
|
03a43b8247 | ||
|
|
f5569763c9 | ||
|
|
2efa390a7d | ||
|
|
4f93dd95e4 | ||
|
|
4c6cca459a | ||
|
|
5153e1b6e3 | ||
|
|
3dbd6475fe | ||
|
|
665a3928e2 | ||
|
|
e162aff7a3 | ||
|
|
69118d063f | ||
|
|
f00564eeb2 | ||
|
|
f018471b36 | ||
|
|
9a8756d7ed | ||
|
|
14e92bd8e2 | ||
|
|
a61696d6c5 | ||
|
|
be37a2cab8 | ||
|
|
99f998805b | ||
|
|
a8afbe74bf | ||
|
|
0b460bf4a1 | ||
|
|
72a05921b0 | ||
|
|
356bbbb90a | ||
|
|
20ac0b4148 | ||
|
|
de81afdf4b | ||
|
|
3b3d80c8ef | ||
|
|
ae7f07de74 | ||
|
|
96dc0d04ec | ||
|
|
8e9eca6ddd | ||
|
|
267703c14b | ||
|
|
a341852cd5 | ||
|
|
31f1db2d3a | ||
|
|
b57d845e55 | ||
|
|
b3003dd163 | ||
|
|
84c75a7b9a | ||
|
|
cb2ef1ea4b | ||
|
|
8fa53f543a | ||
|
|
015e3b412e | ||
|
|
b89dba7e4e | ||
|
|
31c87ba908 | ||
|
|
0e449f20dc | ||
|
|
b54d8a49fb | ||
|
|
4880ec29e4 | ||
|
|
8c2e3a004e | ||
|
|
84985c1223 | ||
|
|
cbad518bf3 | ||
|
|
cf8c1aa860 | ||
|
|
65c5a64719 | ||
|
|
a934dfe0be | ||
|
|
8ea06128be | ||
|
|
43b6f6915b | ||
|
|
5afb090082 | ||
|
|
a3c9eca722 | ||
|
|
21f58ab437 | ||
|
|
d6000c2ec5 | ||
|
|
8b302761d4 | ||
|
|
97288bc286 | ||
|
|
224625942c | ||
|
|
27031b396f | ||
|
|
b721787c7f | ||
|
|
65818db1f4 | ||
|
|
f158957a4e | ||
|
|
9d6ff1c780 | ||
|
|
f4d5c8d99e | ||
|
|
fbc232569c | ||
|
|
fda1a590f6 | ||
|
|
a924b2ff81 | ||
|
|
c2e116a3d3 | ||
|
|
54f69deb0c | ||
|
|
ff708c2c65 | ||
|
|
5266359424 | ||
|
|
aca20092aa | ||
|
|
e62ecbff16 | ||
|
|
75386873b7 | ||
|
|
450178d780 | ||
|
|
3abefdf561 | ||
|
|
f71fb0f54a | ||
|
|
6f161f6559 | ||
|
|
38d15fc9b7 | ||
|
|
d4f027c03b | ||
|
|
98aa561cf7 | ||
|
|
a2051bad50 | ||
|
|
c545cc9d70 | ||
|
|
470d8b6637 | ||
|
|
3b9b177b36 | ||
|
|
2e39ac5ba2 | ||
|
|
888389c28d | ||
|
|
d0e40ab314 | ||
|
|
2999d301ad | ||
|
|
e1cebe0ea0 | ||
|
|
2e0f3799a8 | ||
|
|
bfb0ab3e2f | ||
|
|
5202869f0f | ||
|
|
b14f412117 | ||
|
|
dc0efd5f2e | ||
|
|
57b4cc64b7 | ||
|
|
8dda2c2c17 | ||
|
|
c52a1154ed | ||
|
|
a05bc04b63 | ||
|
|
c56fce70b4 | ||
|
|
27a956ba62 | ||
|
|
37222c3fa2 | ||
|
|
a9740cef82 | ||
|
|
d1dd997f07 | ||
|
|
ef80baf75c | ||
|
|
9fa38f5d0f | ||
|
|
994ffaa382 | ||
|
|
c361246bec | ||
|
|
9aa64b7885 | ||
|
|
51b4bd6c38 | ||
|
|
636e37d183 | ||
|
|
2a0365b3d9 | ||
|
|
96b78bc2cd | ||
|
|
69355293aa | ||
|
|
e3150d0a85 | ||
|
|
91644df491 | ||
|
|
e53313391a | ||
|
|
5ff15443e9 | ||
|
|
bf4fe19a66 | ||
|
|
b3495f1a13 | ||
|
|
d4f0b6f434 | ||
|
|
fe3cd185d7 | ||
|
|
8395c6532e | ||
|
|
ce6a744278 | ||
|
|
cd757d53ca | ||
|
|
31897eaa7d | ||
|
|
05612d60ae | ||
|
|
f4bd3fff5e | ||
|
|
17d00537a1 | ||
|
|
f757d07bb3 | ||
|
|
7c7c6cde03 | ||
|
|
e5fedcd6da | ||
|
|
4400bbfa96 | ||
|
|
3248a6c12b | ||
|
|
195cf31cb9 | ||
|
|
aade177d79 | ||
|
|
da55286c2c | ||
|
|
8e539ce293 | ||
|
|
44d1b964bf | ||
|
|
47a99bb676 | ||
|
|
6c49ae9cd7 | ||
|
|
cb9f56df0c | ||
|
|
fbef63822c | ||
|
|
837994034d | ||
|
|
a4db7c844d | ||
|
|
010d977b16 | ||
|
|
3e0a16c027 | ||
|
|
4cd9e0f41b | ||
|
|
433602b072 | ||
|
|
468b1c6c5d | ||
|
|
8562395413 | ||
|
|
64e8305874 | ||
|
|
4fb1e34b1e | ||
|
|
d2fe8c2842 | ||
|
|
7597740bff | ||
|
|
ca6b9ad8b0 | ||
|
|
c4bccd4f70 | ||
|
|
e722ea89f0 | ||
|
|
e5b960eaeb | ||
|
|
9aebfca083 | ||
|
|
31c5b8fe0f | ||
|
|
5644c00482 | ||
|
|
d50b934bb4 | ||
|
|
f0f2073006 | ||
|
|
56f982fa7f | ||
|
|
df045b92ea | ||
|
|
fdc8230dfa | ||
|
|
f9460c0c8b | ||
|
|
59b6e46bce | ||
|
|
39b7ef31f8 | ||
|
|
fbd0a2e65a | ||
|
|
c6781cbd44 | ||
|
|
0e01a7a431 | ||
|
|
d4c3d01d07 | ||
|
|
5a14bf3a6c | ||
|
|
c506263197 | ||
|
|
47c0403320 | ||
|
|
8a944c88c9 | ||
|
|
c800dcaff8 | ||
|
|
0cb99c5523 | ||
|
|
c64b0946e8 | ||
|
|
ff6924f122 | ||
|
|
e98aed8b48 | ||
|
|
96d33ab46a | ||
|
|
785e42a6f9 | ||
|
|
88c92f7b7c | ||
|
|
64c9af0991 | ||
|
|
49d370185b | ||
|
|
5233fd2751 | ||
|
|
2b86d42ddc | ||
|
|
3ede756d23 | ||
|
|
ae94b2d296 | ||
|
|
1529403584 | ||
|
|
f306d65ea3 | ||
|
|
e7cf589868 | ||
|
|
9725bd8dd0 | ||
|
|
746f1ca11a | ||
|
|
e0561dbded | ||
|
|
825867f2c5 | ||
|
|
920bf703cd | ||
|
|
42fbdda9ab | ||
|
|
f0a24e98f5 | ||
|
|
2f5035d6dc | ||
|
|
39b4a8e67e | ||
|
|
ca783d447a | ||
|
|
43c465e8f4 | ||
|
|
130a052ed5 | ||
|
|
1cd3a3b070 | ||
|
|
295d542911 | ||
|
|
e8a94dc8bb | ||
|
|
e8022a589d | ||
|
|
f481c9fc2c | ||
|
|
33c5f984f5 | ||
|
|
5b1ea0ee38 | ||
|
|
ec0c159586 | ||
|
|
799eb31ff1 | ||
|
|
e760c9fbec | ||
|
|
83ac5aa27a | ||
|
|
adb9fa3b36 | ||
|
|
bde5396d11 | ||
|
|
c56e9a546d | ||
|
|
295f34a9df | ||
|
|
dd798d688b | ||
|
|
2a9825b8de | ||
|
|
c5cb44e138 | ||
|
|
4d501655ad | ||
|
|
501087058e | ||
|
|
9639e77297 | ||
|
|
fece1c57ca | ||
|
|
9eb6c78a02 | ||
|
|
591ea9862d | ||
|
|
088964a091 | ||
|
|
086c95718d | ||
|
|
50cd6e135e | ||
|
|
49c89cb5f6 | ||
|
|
e23ccc95f5 | ||
|
|
a1230b932c | ||
|
|
2d7b34bc68 | ||
|
|
a36b286e04 | ||
|
|
76e92f6751 | ||
|
|
d0ed656fd1 | ||
|
|
13a5264438 | ||
|
|
f05e2e0d40 | ||
|
|
45c2c29c35 | ||
|
|
422e132845 | ||
|
|
1a1049bc0d | ||
|
|
23f27db8c3 | ||
|
|
70bc55cfd6 | ||
|
|
cafe4eed6e | ||
|
|
7a886cb4d4 | ||
|
|
bcaa367b68 | ||
|
|
59bfed65a1 | ||
|
|
751434ea63 | ||
|
|
0c4443667d | ||
|
|
3b3412d561 | ||
|
|
f9d24ff45e | ||
|
|
ae65ceb1a7 | ||
|
|
df958dc907 | ||
|
|
545ca3d014 | ||
|
|
0230624359 | ||
|
|
f0f96e3103 | ||
|
|
c92358527b | ||
|
|
d8dfa1613f | ||
|
|
b43cc21214 | ||
|
|
1893aef649 | ||
|
|
379b6b45e0 | ||
|
|
8ad75e4798 | ||
|
|
8b16cbaf6f | ||
|
|
9782268e17 | ||
|
|
5c73f93361 | ||
|
|
9bfa7198fd |
@@ -10,6 +10,7 @@ notifications:
|
||||
only-by:
|
||||
- DorpsGek
|
||||
commit-comment:
|
||||
discussion:
|
||||
pull-request:
|
||||
issue:
|
||||
tag-created:
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
## Version of OpenTTD
|
||||
|
||||
## Expected result
|
||||
|
||||
## Actual result
|
||||
|
||||
## Steps to reproduce
|
||||
@@ -0,0 +1,41 @@
|
||||
name: Bug Report
|
||||
description: Found a bug in OpenTTD?
|
||||
title: "[Bug]: "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Version of OpenTTD
|
||||
description: Fill in below what version of OpenTTD you are using, including your OS.
|
||||
placeholder: ex. 1.11.2, Windows 10
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected result
|
||||
description: Describe in a few words what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Actual result
|
||||
description: Describe in a few words what actually happens.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: As detailed as possible, please tell us how we can reproduce this. Feel free to attach a savegame (zip it first) to make it more clear.
|
||||
placeholder: |
|
||||
1. Loaded the attached savegame.
|
||||
2. Click on the button left of that other icon.
|
||||
3. The window doesn't open.
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Suggestions and ideas?
|
||||
url: https://www.tt-forums.net/viewforum.php?f=32
|
||||
about: Have a suggestion or an idea for a cool new feature? Post them on our forum!
|
||||
@@ -0,0 +1,37 @@
|
||||
name: Crash
|
||||
description: Did OpenTTD crash?
|
||||
title: "[Crash]: "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this crash report!
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Version of OpenTTD
|
||||
description: Fill in below what version of OpenTTD you are using, including your OS.
|
||||
placeholder: ex. 1.11.2, Windows 10
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Please spend a few words if you can reproduce this problem.
|
||||
placeholder: |
|
||||
1. Bought a new train.
|
||||
2. The game crashed.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: crashlogs
|
||||
attributes:
|
||||
label: Upload crash files
|
||||
description: With the `crash.log`, `crash.dmp`, and `crash.sav` we can analyze the crash in detail; this way you allow us to easier triage and fix the problem.
|
||||
placeholder: |
|
||||
1. Zip the `crash.log`, `crash.dmp` and `crash.sav`.
|
||||
2. Click on this field.
|
||||
3. Drag and drop the zip file in here.
|
||||
validations:
|
||||
required: true
|
||||
@@ -143,7 +143,7 @@ jobs:
|
||||
- name: Test
|
||||
run: |
|
||||
cd build
|
||||
ctest -j $(nproc)
|
||||
ctest -j $(nproc) --timeout 120
|
||||
|
||||
macos:
|
||||
name: Mac OS
|
||||
@@ -157,7 +157,7 @@ jobs:
|
||||
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.9
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.14
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -224,7 +224,7 @@ jobs:
|
||||
- name: Test
|
||||
run: |
|
||||
cd build
|
||||
ctest -j $(sysctl -n hw.logicalcpu)
|
||||
ctest -j $(sysctl -n hw.logicalcpu) --timeout 120
|
||||
|
||||
windows:
|
||||
name: Windows
|
||||
@@ -314,4 +314,93 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
cd ${GITHUB_WORKSPACE}/build
|
||||
ctest
|
||||
ctest --timeout 120
|
||||
|
||||
|
||||
msys2:
|
||||
name: msys2
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- msystem: MINGW64
|
||||
arch: x86_64
|
||||
- msystem: MINGW32
|
||||
arch: i686
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- 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
|
||||
|
||||
- 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}
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake .. -G"MSYS Makefiles"
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
echo "Running on $(nproc) cores"
|
||||
cmake --build . -j $(nproc)
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Test
|
||||
shell: msys2 {0}
|
||||
run: |
|
||||
cd build
|
||||
ctest -j $(nproc) --timeout 120
|
||||
|
||||
check_annotations:
|
||||
name: Check Annotations
|
||||
needs:
|
||||
- emscripten
|
||||
- linux
|
||||
- macos
|
||||
- windows
|
||||
- msys2
|
||||
|
||||
if: always() && github.event_name == 'pull_request'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check annotations
|
||||
uses: OpenTTD/actions/annotation-check@v2
|
||||
|
||||
@@ -15,37 +15,7 @@ jobs:
|
||||
fetch-depth: 4
|
||||
|
||||
- name: Get pull-request commits
|
||||
run: |
|
||||
set -x
|
||||
# actions/checkout did a merge checkout of the pull-request. As such, the first
|
||||
# commit is the merge commit. This means that on HEAD^ is the base branch, and
|
||||
# on HEAD^2 are the commits from the pull-request. We now check if those trees
|
||||
# have a common parent. If not, we fetch a few more commits till we do. In result,
|
||||
# the log between HEAD^ and HEAD^2 will be the commits in the pull-request.
|
||||
DEPTH=4
|
||||
while [ -z "$(git merge-base HEAD^ HEAD^2)" ]; do
|
||||
# Prevent infinite recursion
|
||||
if [ ${DEPTH} -gt 256 ]; then
|
||||
echo "No common parent between '${GITHUB_HEAD_REF}' and '${GITHUB_BASE_REF}'." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --deepen=${DEPTH} origin HEAD
|
||||
DEPTH=$(( ${DEPTH} * 4 ))
|
||||
done
|
||||
|
||||
# Just to show which commits we are going to evaluate.
|
||||
git log --oneline HEAD^..HEAD^2
|
||||
|
||||
- name: Checkout commit-checker
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: OpenTTD/OpenTTD-git-hooks
|
||||
path: git-hooks
|
||||
ref: master
|
||||
uses: OpenTTD/actions/checkout-pull-request@v2
|
||||
|
||||
- name: Check commits
|
||||
run: |
|
||||
set -x
|
||||
HOOKS_DIR=./git-hooks/hooks GIT_DIR=.git ./git-hooks/hooks/check-commits.sh HEAD^..HEAD^2
|
||||
echo "Commit checks passed"
|
||||
uses: OpenTTD/OpenTTD-git-hooks@main
|
||||
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
TZ='UTC' date +"%Y-%m-%d %H:%M UTC" > .release_date
|
||||
cat .ottdrev | cut -f 1 -d$'\t' > .version
|
||||
|
||||
if [ $(cat .ottdrev | cut -f 6 -d$'\t') = '1' ]; then
|
||||
if [ $(cat .ottdrev | cut -f 5 -d$'\t') = '1' ]; then
|
||||
# Assume that all tags are always releases. Why else make a tag?
|
||||
IS_TAG="true"
|
||||
|
||||
@@ -373,12 +373,19 @@ jobs:
|
||||
include:
|
||||
- container_image: "ubuntu:18.04"
|
||||
bundle_name: "bionic"
|
||||
compiler: "g++-8"
|
||||
- container_image: "ubuntu:20.04"
|
||||
bundle_name: "focal"
|
||||
compiler: "g++"
|
||||
- container_image: "ubuntu:20.10"
|
||||
bundle_name: "groovy"
|
||||
compiler: "g++"
|
||||
- container_image: "debian:buster"
|
||||
bundle_name: "buster"
|
||||
compiler: "g++"
|
||||
- container_image: "debian:bullseye"
|
||||
bundle_name: "bullseye"
|
||||
compiler: "g++"
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
container:
|
||||
@@ -404,7 +411,7 @@ jobs:
|
||||
apt-get install -y --no-install-recommends \
|
||||
cmake \
|
||||
debhelper \
|
||||
g++ \
|
||||
${{ matrix.compiler }} \
|
||||
git \
|
||||
make \
|
||||
openssl \
|
||||
@@ -430,7 +437,7 @@ jobs:
|
||||
cd build
|
||||
|
||||
echo "::group::CMake"
|
||||
cmake ${GITHUB_WORKSPACE} \
|
||||
CXX=${{ matrix.compiler }} cmake ${GITHUB_WORKSPACE} \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
# EOF
|
||||
@@ -468,7 +475,7 @@ jobs:
|
||||
|
||||
runs-on: macos-10.15
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.9
|
||||
MACOSX_DEPLOYMENT_TARGET: 10.14
|
||||
|
||||
steps:
|
||||
- name: Download source
|
||||
@@ -744,6 +751,21 @@ jobs:
|
||||
with:
|
||||
arch: ${{ matrix.host }}
|
||||
|
||||
- name: Import code signing certificate
|
||||
shell: powershell
|
||||
# If this is run on a fork, there may not be a certificate set up - continue in this case
|
||||
continue-on-error: true
|
||||
run: |
|
||||
$tempFile = [System.IO.Path]::GetTempFileName()
|
||||
$bytes = [System.Convert]::FromBase64String($env:WINDOWS_CERTIFICATE_P12)
|
||||
[IO.File]::WriteAllBytes($tempFile, $bytes)
|
||||
$pwd = ConvertTo-SecureString $env:WINDOWS_CERTIFICATE_PASSWORD -AsPlainText -Force
|
||||
Import-PfxCertificate -FilePath $tempFile -CertStoreLocation Cert:\CurrentUser\My -Password $pwd
|
||||
Remove-Item $tempFile
|
||||
env:
|
||||
WINDOWS_CERTIFICATE_P12: ${{ secrets.WINDOWS_CERTIFICATE_P12 }}
|
||||
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
|
||||
|
||||
- name: Build (with installer)
|
||||
if: needs.source.outputs.is_tag == 'true'
|
||||
shell: bash
|
||||
@@ -759,12 +781,15 @@ jobs:
|
||||
-DOPTION_USE_NSIS=ON \
|
||||
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DWINDOWS_CERTIFICATE_COMMON_NAME="${WINDOWS_CERTIFICATE_COMMON_NAME}" \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
|
||||
|
||||
- name: Build (without installer)
|
||||
if: needs.source.outputs.is_tag != 'true'
|
||||
@@ -780,12 +805,15 @@ jobs:
|
||||
-DCMAKE_TOOLCHAIN_FILE="c:\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
||||
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DWINDOWS_CERTIFICATE_COMMON_NAME="${WINDOWS_CERTIFICATE_COMMON_NAME}" \
|
||||
# EOF
|
||||
echo "::endgroup::"
|
||||
|
||||
echo "::group::Build"
|
||||
cmake --build .
|
||||
echo "::endgroup::"
|
||||
env:
|
||||
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
|
||||
|
||||
- name: Create bundles
|
||||
shell: bash
|
||||
@@ -807,6 +835,17 @@ jobs:
|
||||
rm -f bundles/*.sha256
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Sign installer
|
||||
if: needs.source.outputs.is_tag == 'true'
|
||||
shell: bash
|
||||
# If this is run on a fork, there may not be a certificate set up - continue in this case
|
||||
continue-on-error: true
|
||||
run: |
|
||||
cd ${GITHUB_WORKSPACE}/build/bundles
|
||||
../../os/windows/sign.bat *.exe "${WINDOWS_CERTIFICATE_COMMON_NAME}"
|
||||
env:
|
||||
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
|
||||
|
||||
- name: Store bundles
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
||||
+18
-5
@@ -4,10 +4,12 @@ if(NOT BINARY_NAME)
|
||||
set(BINARY_NAME openttd)
|
||||
endif()
|
||||
|
||||
project(${BINARY_NAME})
|
||||
project(${BINARY_NAME}
|
||||
VERSION 12.0
|
||||
)
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the bin directory")
|
||||
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the build directory. You may need to delete \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" first.")
|
||||
endif()
|
||||
|
||||
# Debug mode by default.
|
||||
@@ -20,7 +22,7 @@ if (EMSCRIPTEN)
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14)
|
||||
|
||||
# Use GNUInstallDirs to allow customisation
|
||||
# but set our own default data and bin dir
|
||||
@@ -72,6 +74,9 @@ add_custom_target(find_version
|
||||
${CMAKE_COMMAND}
|
||||
-DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
|
||||
-DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
|
||||
-DREV_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||
-DREV_MINOR=${PROJECT_VERSION_MINOR}
|
||||
-DWINDOWS=${WIN32}
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS ${GENERATED_SOURCE_FILES}
|
||||
@@ -220,6 +225,7 @@ if(MSVC)
|
||||
target_sources(openttd PRIVATE "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest")
|
||||
endif()
|
||||
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/bin)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/media)
|
||||
|
||||
@@ -235,12 +241,16 @@ target_link_libraries(openttd
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
if(HAIKU)
|
||||
target_link_libraries(openttd "be" "network" "midi")
|
||||
endif()
|
||||
|
||||
if(IPO_FOUND)
|
||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
|
||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True)
|
||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True)
|
||||
endif()
|
||||
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
|
||||
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
process_compile_flags()
|
||||
|
||||
include(LinkPackage)
|
||||
@@ -349,17 +359,20 @@ if(WIN32)
|
||||
-DUNICODE
|
||||
-D_UNICODE
|
||||
-DWITH_UNISCRIBE
|
||||
-DPSAPI_VERSION=1
|
||||
)
|
||||
|
||||
target_link_libraries(openttd
|
||||
ws2_32
|
||||
winmm
|
||||
imm32
|
||||
usp10
|
||||
psapi
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-D_SQ64)
|
||||
add_definitions(-DPOINTER_IS_64BIT)
|
||||
endif()
|
||||
|
||||
include(CreateRegression)
|
||||
|
||||
+32
-10
@@ -2,26 +2,27 @@
|
||||
|
||||
## Required/optional libraries
|
||||
|
||||
The following libraries are used by OpenTTD for:
|
||||
OpenTTD makes use of the following external libraries:
|
||||
|
||||
- zlib: (de)compressing of old (0.3.0-1.0.5) savegames, content downloads,
|
||||
- (encouraged) zlib: (de)compressing of old (0.3.0-1.0.5) savegames, content downloads,
|
||||
heightmaps
|
||||
- liblzo2: (de)compressing of old (pre 0.3.0) savegames
|
||||
- liblzma: (de)compressing of savegames (1.1.0 and later)
|
||||
- libpng: making screenshots and loading heightmaps
|
||||
- (encouraged) liblzma: (de)compressing of savegames (1.1.0 and later)
|
||||
- (encouraged) libpng: making screenshots and loading heightmaps
|
||||
- (optional) liblzo2: (de)compressing of old (pre 0.3.0) savegames
|
||||
|
||||
For Linux, the following additional libraries are used (for non-dedicated only):
|
||||
|
||||
- libSDL2: hardware access (video, sound, mouse)
|
||||
- libfreetype: loading generic fonts and rendering them
|
||||
- libfontconfig: searching for fonts, resolving font names to actual fonts
|
||||
- libicu: handling of right-to-left scripts (e.g. Arabic and Persian) and
|
||||
natural sorting of strings (Linux only)
|
||||
- libSDL2: hardware access (video, sound, mouse) (not required for Windows or macOS)
|
||||
natural sorting of strings
|
||||
|
||||
OpenTTD does not require any of the libraries to be present, but without
|
||||
liblzma you cannot open most recent savegames and without zlib you cannot
|
||||
open most older savegames or use the content downloading system.
|
||||
Without libSDL/liballegro on non-Windows and non-macOS machines you have
|
||||
no graphical user interface; you would be building a dedicated server.
|
||||
|
||||
## Windows:
|
||||
## Windows
|
||||
|
||||
You need Microsoft Visual Studio 2017 or more recent.
|
||||
|
||||
@@ -77,6 +78,8 @@ files himself via the `ZERO_CHECK` project.
|
||||
|
||||
## All other platforms
|
||||
Minimum required version of CMake is 3.9.
|
||||
By default this produces a Debug build with assertations enabled.
|
||||
This is a far slower build than release builds.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
@@ -88,6 +91,25 @@ make
|
||||
For more information on how to use CMake (including how to make Release builds),
|
||||
we urge you to read [their excellent manual](https://cmake.org/cmake/help/latest/guide/user-interaction/index.html).
|
||||
|
||||
## CMake Options
|
||||
|
||||
Via CMake, several options can be influenced to get different types of
|
||||
builds.
|
||||
|
||||
- `-DCMAKE_BUILD_TYPE=RelWithDebInfo`: build a release build. This is
|
||||
significant faster than a debug build, but has far less useful information
|
||||
in case of a crash.
|
||||
- `-DOPTION_DEDICATED=ON`: build OpenTTD without a GUI. Useful if you are
|
||||
running a headless server, as it requires less libraries to operate.
|
||||
- `-DOPTION_USE_ASSERTS=OFF`: disable asserts. Use with care, as assert
|
||||
statements capture early signs of trouble. Release builds have them
|
||||
disabled by default.
|
||||
- `-DOPTION_USE_THREADS=OFF`: disable the use of threads. This will block
|
||||
the interface in many places, and in general gives a worse experience of
|
||||
the game. Use with care.
|
||||
- `-DOPTION_TOOLS_ONLY=ON`: only build tools like `strgen`. Does not build
|
||||
the game itself. Useful for cross-compiling.
|
||||
|
||||
## Supported compilers
|
||||
|
||||
Every compiler that is supported by CMake and supports C++17, should be
|
||||
|
||||
+1
-1
@@ -14,7 +14,6 @@
|
||||
- Ingo von Borstel (planetmaker) - General coding, Support (since 1.1)
|
||||
- Remko Bijker (Rubidium) - Lead coder and way more (since 0.4.5)
|
||||
- José Soler (Terkhen) - General coding (since 1.0)
|
||||
- Leif Linse (Zuu) - AI/Game Script (since 1.2)
|
||||
|
||||
### Inactive Developers:
|
||||
|
||||
@@ -28,6 +27,7 @@
|
||||
- Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)
|
||||
- Patric Stout (TrueBrain) - NoProgrammer (0.3 - 1.2), sys op (active)
|
||||
- Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)
|
||||
- Leif Linse (Zuu) - AI/Game Script (1.2 - 1.6)
|
||||
|
||||
### Retired Developers:
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Both 'stable' and 'nightly' versions are available for download:
|
||||
- most people should choose the 'stable' version, as this has been more extensively tested
|
||||
- the 'nightly' version includes the latest changes and features, but may sometimes be less reliable
|
||||
|
||||
On some platforms OpenTTD will also be available via your OS package manager or a similar service.
|
||||
OpenTTD is also available for free on [Steam](https://store.steampowered.com/app/1536610/OpenTTD/), [GOG.com](https://www.gog.com/game/openttd), and the [Microsoft Store](https://www.microsoft.com/p/openttd-official/9ncjg5rvrr1c). On some platforms OpenTTD will be available via your OS package manager or a similar service.
|
||||
|
||||
|
||||
## 1.2) OpenTTD gameplay manual
|
||||
@@ -46,15 +46,13 @@ OpenTTD has a [community-maintained wiki](https://wiki.openttd.org/), including
|
||||
|
||||
OpenTTD has been ported to several platforms and operating systems.
|
||||
|
||||
The currently working platforms are:
|
||||
The currently supported platforms are:
|
||||
|
||||
- FreeBSD (SDL)
|
||||
- Haiku (SDL)
|
||||
- Linux (SDL)
|
||||
- macOS (universal) (Cocoa video and sound drivers)
|
||||
- OpenBSD (SDL)
|
||||
- OS/2 (SDL)
|
||||
- Windows (Win32 GDI (faster) or SDL)
|
||||
- Linux (SDL (OpenGL and non-OpenGL))
|
||||
- macOS (universal) (Cocoa)
|
||||
- Windows (Win32 GDI / OpenGL)
|
||||
|
||||
Other platforms may also work (in particular various BSD systems), but we don't actively test or maintain these.
|
||||
|
||||
### 1.3.1) Legacy support
|
||||
Platforms, languages and compilers change.
|
||||
@@ -79,9 +77,9 @@ For some platforms, you will need to refer to [the installation guide](https://w
|
||||
The free data files, split into OpenGFX for graphics, OpenSFX for sounds and
|
||||
OpenMSX for music can be found at:
|
||||
|
||||
- https://www.openttd.org/download-opengfx for OpenGFX
|
||||
- https://www.openttd.org/download-opensfx for OpenSFX
|
||||
- https://www.openttd.org/download-openmsx for OpenMSX
|
||||
- https://www.openttd.org/downloads/opengfx-releases/ for OpenGFX
|
||||
- https://www.openttd.org/downloads/opensfx-releases/ for OpenSFX
|
||||
- https://www.openttd.org/downloads/openmsx-releases/ for OpenMSX
|
||||
|
||||
Please follow the readme of these packages about the installation procedure.
|
||||
The Windows installer can optionally download and install these packages.
|
||||
@@ -207,6 +205,9 @@ See the comments in the source files in `src/3rdparty/md5` for the complete lice
|
||||
The implementations of Posix `getaddrinfo` and `getnameinfo` for OS/2 in `src/3rdparty/os2` are distributed partly under the GNU Lesser General Public License 2.1, and partly under the (3-clause) BSD license.
|
||||
The exact licensing terms can be found in `src/3rdparty/os2/getaddrinfo.c` resp. `src/3rdparty/os2/getnameinfo.c`.
|
||||
|
||||
The fmt implementation in `src/3rdparty/fmt` is licensed under the MIT license.
|
||||
See `src/3rdparty/fmt/LICENSE.rst` for the complete license text.
|
||||
|
||||
|
||||
## 4.0 Credits
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
add_subdirectory(ai)
|
||||
add_subdirectory(game)
|
||||
@@ -0,0 +1,40 @@
|
||||
set(AI_COMPAT_SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_0.7.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.0.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.1.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.2.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.3.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.4.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.5.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.6.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.7.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.8.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.9.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.10.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.11.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_12.nut
|
||||
)
|
||||
|
||||
foreach(AI_COMPAT_SOURCE_FILE IN LISTS AI_COMPAT_SOURCE_FILES)
|
||||
string(REPLACE "${CMAKE_SOURCE_DIR}/bin/" "" AI_COMPAT_SOURCE_FILE_NAME "${AI_COMPAT_SOURCE_FILE}")
|
||||
string(CONCAT AI_COMPAT_BINARY_FILE "${CMAKE_BINARY_DIR}/" "${AI_COMPAT_SOURCE_FILE_NAME}")
|
||||
|
||||
add_custom_command(OUTPUT ${AI_COMPAT_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${AI_COMPAT_SOURCE_FILE}
|
||||
${AI_COMPAT_BINARY_FILE}
|
||||
MAIN_DEPENDENCY ${AI_COMPAT_SOURCE_FILE}
|
||||
COMMENT "Copying ${AI_COMPAT_SOURCE_FILE_NAME}"
|
||||
)
|
||||
|
||||
list(APPEND AI_COMPAT_BINARY_FILES ${AI_COMPAT_BINARY_FILE})
|
||||
endforeach()
|
||||
|
||||
# Create a new target which copies all compat files
|
||||
add_custom_target(ai_compat_files
|
||||
DEPENDS ${AI_COMPAT_BINARY_FILES}
|
||||
)
|
||||
|
||||
add_dependencies(openttd
|
||||
ai_compat_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("1.11 API compatibility in effect.");
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
@@ -0,0 +1,37 @@
|
||||
set(GS_COMPAT_SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.2.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.3.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.4.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.5.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.6.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.7.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.8.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.9.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.10.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_1.11.nut
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compat_12.nut
|
||||
)
|
||||
|
||||
foreach(GS_COMPAT_SOURCE_FILE IN LISTS GS_COMPAT_SOURCE_FILES)
|
||||
string(REPLACE "${CMAKE_SOURCE_DIR}/bin/" "" GS_COMPAT_SOURCE_FILE_NAME "${GS_COMPAT_SOURCE_FILE}")
|
||||
string(CONCAT GS_COMPAT_BINARY_FILE "${CMAKE_BINARY_DIR}/" "${GS_COMPAT_SOURCE_FILE_NAME}")
|
||||
|
||||
add_custom_command(OUTPUT ${GS_COMPAT_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${GS_COMPAT_SOURCE_FILE}
|
||||
${GS_COMPAT_BINARY_FILE}
|
||||
MAIN_DEPENDENCY ${GS_COMPAT_SOURCE_FILE}
|
||||
COMMENT "Copying ${GS_COMPAT_SOURCE_FILE_NAME}"
|
||||
)
|
||||
|
||||
list(APPEND GS_COMPAT_BINARY_FILES ${GS_COMPAT_BINARY_FILE})
|
||||
endforeach()
|
||||
|
||||
# Create a new target which copies all compat files
|
||||
add_custom_target(gs_compat_files
|
||||
DEPENDS ${GS_COMPAT_BINARY_FILES}
|
||||
)
|
||||
|
||||
add_dependencies(openttd
|
||||
gs_compat_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("1.11 API compatibility in effect.");
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
+211
-7
@@ -1,3 +1,207 @@
|
||||
12.0-beta1 (2021-08-15)
|
||||
------------------------------------------------------------------------
|
||||
Feature: [Network] Remove lobby window; pressing "Join Game" now immediately joins a server (#9467)
|
||||
Feature: [Network] Synchronize server name to clients and display in Online Players window (#9472)
|
||||
Feature: [Network] Mention you are a spectator in the status bar (#9471)
|
||||
Feature: [Network] No longer require port-forwarding to host a server (#9443, #9447)
|
||||
Feature: [Network] Allow setting your server visibility to "invite-only" (#9434)
|
||||
Feature: [Network] Join servers based on their invite code (#9432)
|
||||
Feature: Raise the maximum NewGRF limit to 255 (#9428)
|
||||
Feature: Persistent rotation of numbered auto/netsave after restart (#9395, #9397)
|
||||
Feature: [NewGRF] Maximum curve speed modifier for rail vehicles (#9346)
|
||||
Feature: Move sensitive information to secrets.cfg and private information to private.cfg (#9298)
|
||||
Feature: Signed Windows builds (#9294)
|
||||
Feature: [NewGRF] Define refittability of default vehicles using cargo classes (#9148)
|
||||
Feature: Configurable subsidy duration, up to 5000 years (#9081)
|
||||
Feature: [Network] Rework in-game Online Players window (#9067)
|
||||
Feature: [Network] Show previous chat history when the chat message box is open (#9025)
|
||||
Feature: Button to reset game settings to their default values (#8958)
|
||||
Feature: Press Ctrl to build diagonal rivers in Scenario Editor (#8880)
|
||||
Feature: Set wagon replacement per group when using autoreplace (#7441)
|
||||
Add: [Network] Open Online Players window on starting/joining a server (#9479)
|
||||
Add: [Script] Basic information about loaded NewGRFs for scripts (#9464)
|
||||
Add: [AI] Get the number of vehicles in a given group (#9462)
|
||||
Add: [Network] Inform network clients what game-script a server is running (#9441)
|
||||
Add: Hindi translation (#9086)
|
||||
Add: [Network] Ensure players fill in a name instead of defaulting to "Player" (#9080)
|
||||
Change: Allow pause/unpause console command in single player (#9342)
|
||||
Change: Make savegame format self-descriptive and consistent across all objects (#9322, #9335, #9338, #9339)
|
||||
Change: By default, make "unload all" leave stations empty (#9301)
|
||||
Change: Reworked the debug levels and messages for network logs (#9230, #9251)
|
||||
Change: [Emscripten] Set default scrolling mode to non-pointer-locking (#9191)
|
||||
Change: Use neutral pronouns for various strings (#9189, #9203, #9228)
|
||||
Change: Make the town directory horizontally resizable (#9157)
|
||||
Change: Allow non-ASCII currency separators (#9121)
|
||||
Change: [NewGRF] Display a pop-up window for Errors with severity ERROR (#9119)
|
||||
Change: Treat languages as finished, if translations are 75% completed (#9019, #9086)
|
||||
Change: Disable NewGRF window apply button if no change was made (#8934)
|
||||
Fix: [Script] Crash when iterating lists of which the key is larger than 32bit (#9465)
|
||||
Fix: [Network] Desync due to use of unstable sort when distributing cargo production (#9460)
|
||||
Fix #9440: Negative cargo payments not being handled correctly (#9455)
|
||||
Fix: [Network] Crash when joining a server again after a TCP disconnect (#9453)
|
||||
Fix: Don't enable rename button for network clients in build vehicle window (#9452)
|
||||
Fix: Money could underflow and wrap around (#9451)
|
||||
Fix: Parse the console settings the same way as config settings (#9438)
|
||||
Fix: Ensure no more than the allowed number of NewGRFs are loaded from the configuration (#9430)
|
||||
Fix: [NewGRF] Overflow when determining cargo mask for string code 9A 1E (#9423)
|
||||
Fix: Integers for scripts are 64bit, but saved as 32bit (#9415)
|
||||
Fix #9392: [Script] Return a valid value with GetBuildWithRefitCapacity even when AIs are maxed out in vehicles (#9393)
|
||||
Fix #8169: Crash when autoreplacing vehicle with no orders (#9387)
|
||||
Fix: Wrong cargo line position in IndustryCargo window (#9383)
|
||||
Fix: Race-condition during startup of NewGRF scan (#9382)
|
||||
Fix: Don't propagate Shift/Ctrl state till next game-tick (#9381)
|
||||
Fix: Prevent palette updates during copying to the video driver (#9379)
|
||||
Fix: [Network] Determining GetNetworkRevisionString could overflow and underflow its buffer (#9372)
|
||||
Fix #9358: Don't skip empty files in tar archives (#9367)
|
||||
Fix: For old savegames, station bus/truck station cache was not updated (#9366)
|
||||
Fix #9353: [Script] Garbage collecting on priority queues could crash the game (#9356)
|
||||
Fix: Respect the autosave_on_exit setting for Null video driver (#9343)
|
||||
Fix: Compatible NewGRFs in crash-log reported wrong MD5 hash (#9340)
|
||||
Fix: [Script] Ensure the saved script strings are properly validated and terminated (#9336)
|
||||
Fix #9316: Town bridge length limit check incorrect above 250k inhabitants (#9318)
|
||||
Fix: Limit heightmap sizes to 8192x8192 (#9307)
|
||||
Fix #9281: Money generating exploit when buying out a company (#9300)
|
||||
Fix: Part of a tile might not be redrawn when terraforming (#9296)
|
||||
Fix: [OpenGL] Increase timeout when waiting for the GPU to be done with the drawing buffer (#9282)
|
||||
Fix: Vehicles sent in the wrong direction if there is no path to the destination (#9280)
|
||||
Fix #9264: Do not attach temporary wagons to free wagon chains when autoreplacing (#9278)
|
||||
Fix #9267: [Script] Crash during garbage collection (#9275)
|
||||
Fix: Encountering two-way red signals could prune unrelated Pathfinder branches (#9271)
|
||||
Fix #9255: [Network] Crash when hostname is not found (#9259)
|
||||
Fix #9256: Invalid read after free when replacing train chains (#9258)
|
||||
Fix: [Emscripten] Force secure WebSockets over HTTPS (#9248)
|
||||
Fix #9242: Tree tick handler did not scale by map size (#9246)
|
||||
Fix: [Network] Mark server as offline when no longer reachable (#9244)
|
||||
Fix: [Network] Don't rebuild the host-list during iterating the list (#9240)
|
||||
Fix: [Network] Don't mark the last-joined server as a manually added server (#9239)
|
||||
Fix: [Network] Clients leaving because of broken connections was not broadcasted (#9238)
|
||||
Fix: [Network] Check on CIDR for netmask check considered everything valid (#9235)
|
||||
Fix: Creating screenshots on dedicated servers failed (#9232)
|
||||
Fix: Leaking file descriptors for downloaded content (#9229)
|
||||
Fix: Spelling of several town names (#9222)
|
||||
Fix #9209: Game hangs when resizing highscore/news window if the screen is too small (#9210)
|
||||
Fix: [Network] Optimize creating network connections for clients using IPv4 and IPv6 (#9199)
|
||||
Fix #9186: Fix incorrect bounding box height causing station sprite glitch (#9187)
|
||||
Fix: Truncating strings in settings could leave invalid UTF-8 characters (#9121)
|
||||
Fix: Many issues related to window scaling (#9087, #9219)
|
||||
Fix: Invalidate cached vehicle colourmaps when changing liveries setting (#9006)
|
||||
Fix #8981: Don't attempt to re-reserve path if already entering/entered depot (#9000)
|
||||
Fix: Missing 'Town names:' colon in map gen GUI (#8986)
|
||||
Fix: Sorting and filtering industries that produce/accept many cargoes (#8468)
|
||||
Remove: [Network] COMPANY_INFO packets (#9475)
|
||||
Remove: [Network] A server can no longer set a limit to the amount of spectators allowed (#9466)
|
||||
Remove: Arbitrary limit on number of statically loaded NewGRFs (#9431)
|
||||
Remove: [Network] Language and map-name from server information (#9070)
|
||||
|
||||
|
||||
1.11.2 (2021-05-03)
|
||||
------------------------------------------------------------------------
|
||||
Change: [Win32] Limit hardware accelerated video driver to OpenGL 3.2 or higher (#9077)
|
||||
Change: More improvements to the GUI at different scales (#9075, #9102, #9107, #9133, #9174, #9183)
|
||||
Fix: Query windows could be partially drawn (#9184)
|
||||
Fix #9113: Crash when removing an airport that exists in an aircraft's orders (#9182)
|
||||
Fix #9117: [Fluidsynth] Hang when changing song (#9181)
|
||||
Fix: String validation could leave invalid UTF-8 encoded strings (#9096)
|
||||
Fix: [Network] Out-of-bounds memory access with modified servers sending too short password salts (#9176)
|
||||
Fix: Crash when extra viewport with zero height has sign in view (#9175)
|
||||
Fix #9147: Crash when taking screenshots (#9169)
|
||||
Fix #6598: [Network] Prevent crashes when (re)joining network game by falling back to main menu first (#9163)
|
||||
Fix #9152: Screenshot success popup window was treated as an error (#9159)
|
||||
Fix: Fast-forward stuttering when vsync is enabled (#9140)
|
||||
Fix: [Network, Win32] Network errors were handled badly (#9116)
|
||||
Fix: [Network] Savegame transfer could stall in rare cases (#9106)
|
||||
Fix #9097: [NewGRF] Cargo initial payment variable was being truncated (#9098)
|
||||
Fix: [NewGRF] Industry variable 66 and object variable 46 erroneously truncated the distance (#9088)
|
||||
Fix: [NewGRF] Industry variables 65 and 66 ignored the parameter, and always used the north tile (#9088)
|
||||
Fix: Do not include regression test AI in bundle (#9068, #9164)
|
||||
Fix #9062: [Win32] Version in executable was not set to current release version (#9066, #9154)
|
||||
|
||||
|
||||
1.11.1 (2021-04-18)
|
||||
------------------------------------------------------------------------
|
||||
Feature: Toggle to enable/disable vsync (#8997)
|
||||
Feature: Volume controls in the Game Options window, and better defaults (#8943)
|
||||
Add: Hotkey to focus object and rail filters (#8908)
|
||||
Add: Better plural support for Romanian (#8936)
|
||||
Change: Improve layout and spacing of several windows at different GUI scales (#9041, #9042, #9044, #9050)
|
||||
Change: [Win32] Use user UI language setting for initial language selection (#8974)
|
||||
Change: Make effect volume scale more intuitively (#8945, #8950)
|
||||
Change: Improve padding of Object & Rail station windows (#8929)
|
||||
Fix #6322: [Script] Crash when script allocates too much memory, now kills script instead (#9047)
|
||||
Fix #7513: [Script] Crash on garbage collection with misbehaving script (#9040)
|
||||
Fix #9028: [OpenGL] Crash when changing max sprite zoom level (#9032)
|
||||
Fix #8874: show a warning when a NewGRF scan is requested multiple times (#9022)
|
||||
Fix: Desync when GS unlocks railtype with wagon unlock (#9021)
|
||||
Fix #9015: [Win32] Crash on running "pwd" command in the console (#9016)
|
||||
Fix #9008: Validate starting year given on the command line (-t) (#9014)
|
||||
Fix #8878: [Network] Slow DNS queries could block the server and disconnect clients (#9013)
|
||||
Fix: Improve validation of OpenGL video driver to avoid crashes (#9007)
|
||||
Fix: Credits scrolled too slowly with larger font sizes (#8994)
|
||||
Fix #8977: Crash when altering max sprite resolution (#8993)
|
||||
Fix #8956: Industry disaster news messages showed the wrong location (#8992)
|
||||
Fix: [Win32] Font glyphs of certain widths had broken rendering (#8990)
|
||||
Fix #8930: [Win32] Duplicate text input issue for systems using IME (#8976)
|
||||
Fix: [Network] Potential stale client entries in client list (#8959)
|
||||
Fix: Graphical issues when dragging measurement tooltips (#8951)
|
||||
Fix: [Fluidsynth] Use provided default soundfont if available (#8948, #8953)
|
||||
Fix #8935: [macOS] Crash on save (#8944)
|
||||
Fix #8922: Crash when selling shared vehicles with shared vehicle window open (#8926)
|
||||
Fix: Compiling on armhf (Raspberry Pi) (#8924)
|
||||
|
||||
|
||||
1.11.0 (2021-04-01)
|
||||
------------------------------------------------------------------------
|
||||
Feature: Allow setting a custom terrain type to define highest peak (#8891)
|
||||
Feature: Auto-detect map height limit based on generated map (#8891)
|
||||
Feature: Setting to indicate desert coverage for tropic climate and snow coverage for arctic climate (replaces snow line height) (#8891)
|
||||
Add: Allow setting the highest mountain for heightmaps (#8891)
|
||||
Change: Scale exported heightmaps to highest peak and inform the user of this value (#8891)
|
||||
Change: Remove "maximum map height" from the New Game GUI (#8891)
|
||||
Fix #8803: Only auto-remove signals when rail can be built (#8904)
|
||||
Fix #8565: Stopped road vehicle displays a speed different than 0 (#8901)
|
||||
Fix #8886: Don't try to resolve folders within tars named '.' (#8893)
|
||||
Fix: Placing random trees in SE crashes the game (#8892)
|
||||
Fix #8875: Filter string in station window breaks flow in user interface (#8885)
|
||||
Fix #8871: [OpenGL] Initialize all buffers after resize and clear back buffer (#8877)
|
||||
Fix: OpenGL performance with some AMD GPUs (#8876)
|
||||
Fix: Recompute road/railtype availability after disabling the engine (#8872)
|
||||
Fix: OSK layout not scaled for 2x or 4x GUI scale (#8868)
|
||||
|
||||
|
||||
1.11.0-RC1 (2021-03-14)
|
||||
------------------------------------------------------------------------
|
||||
Feature: Option to (dis-)allow hardware accelerated video drivers (#8819)
|
||||
Feature: Option to set display refresh rate (#8813)
|
||||
Feature: Allow custom width/height of screenshot and making heightmap screenshots via console (#8804)
|
||||
Feature: Allow filtering on name in rail station window (#8706)
|
||||
Feature: Setting for highest resolution of sprites to use (#8604)
|
||||
Add: Make NewGRF Scanner / World Generation update smoother and make aborting it react faster (#8830)
|
||||
Add: Malaysia Ringgit as Currency (#8783)
|
||||
Add: "Engines only" filter in build train window (#8733)
|
||||
Change: De-limit framerate window's framerate (#8772)
|
||||
Change: Clarify what effect town interactions have (#8744)
|
||||
Change: Don't show global goals in company goal windows (#8709)
|
||||
Change: Recolour graph windows to brown (#8700)
|
||||
Fix #8855: Bootstrap could result in an empty screen when bootstrap fails (#8856)
|
||||
Fix #8851: Don't allow infinite "exec" depth in script, but limit to 10 deep (#8852)
|
||||
Fix #8647: Incorrect drawing order of tram catenary sprites (#8843)
|
||||
Fix #8711: Having gui_zoom lower than zoom_min causes a crash (#8835)
|
||||
Fix #8810: "aircraft out of fuel" news shows the wrong place (#8832)
|
||||
Fix #8833: Don't reload NewGRFs when we are shutting down (#8830)
|
||||
Fix: Scale padding between elements the same as other padding (#8829)
|
||||
Fix #8808: [OSX, OpenGL] Crash on switching blitters due to double-mapping the video buffer (#8822)
|
||||
Fix #8784: Using Alt+Enter doesn't update the fullscreen toggle visibly (#8820)
|
||||
Fix #8817: Keep NewGRF order for object class sorting (#8818)
|
||||
Fix #8809: Crash when removing airport when hangar window open (#8815)
|
||||
Fix #8799: Crash when Search Internet in Multiplayer (#8801)
|
||||
Fix #8775: [Win32] Don't create the main window when Alt-Tabbing back into fullscreen (#8792)
|
||||
Fix #8774: Black screenshots when using 40bpp-blitter (#8791)
|
||||
Fix: [OSX] Hide dock when entering fullscreen (#8789)
|
||||
Fix: Bootstrap fails to start on clean install (#8788)
|
||||
Fix: Terraform limit acts random when maxing out per_64k_frames setting (#8782)
|
||||
Fix: Max-value of fast-forward-speed-limit can be outside its storage size (#8769)
|
||||
|
||||
|
||||
1.11.0-beta2 (2021-02-28)
|
||||
------------------------------------------------------------------------
|
||||
Feature: Add setting to limit fast-forward speed (#8766)
|
||||
@@ -2186,7 +2390,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: [NewGRF] Additional text in fund industry window is NewGRF supplied and thus should have a default colour (r22631)
|
||||
- Fix: Also initialise _old_vds with newgame settings; TTD savegames do not contain these settings [FS#4622] (r22626)
|
||||
- Fix: Do not zero the orders of disaster vehicles when converting savegames [FS#4642] (r22625)
|
||||
- Fix: When closing an AI company the local player cheated to, we need to cheat him to another company [FS#4654] (r22624, r22623)
|
||||
- Fix: When closing an AI company the local player cheated to, we need to cheat them to another company [FS#4654] (r22624, r22623)
|
||||
- Fix: When closing down companies their shares in other companies must be sold even if share trading is disabled at that point of time (r22622)
|
||||
- Fix: When asking the user to confirm an unsafe unpausing, there is no need to execute a command if 'no' is chosen. This also prevents crashing when clicking unpause while the confirm window is shown (r22621)
|
||||
- Fix: Enforce refit orders to be 'always go to depot' orders; service-only and stop-in-depot orders make no sense with refitting [FS#4651] (r22620)
|
||||
@@ -2908,7 +3112,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Chat message caused glitch when rejoining a network game [FS#3757] (r19629)
|
||||
- Fix: Desync when a command is received and in the queue while a client starts joining, i.e. save the game state. This can happen in two ways: with frame_freq > 1 a command received in a previous frame might not be executed yet or when a command is received in the same frame as the join but before the savegame is made. In both cases the joining client would not get all commands to get in-sync with the server (and the other clients) (r19620)
|
||||
- Fix: Company related graphs were not updated correctly after changing the company colour [FS#3763] (r19615)
|
||||
- Fix: Possible invalid read when server moves client to spectators before he finishes joining [FS#3755] (r19613)
|
||||
- Fix: Possible invalid read when server moves client to spectators before they finish joining [FS#3755] (r19613)
|
||||
- Fix: Crash when opening a savegame with a waypoint from around 0.4.0 [FS#3756] (r19612)
|
||||
- Fix: Improve joining behaviour; kicking clients when entering passwords that was just cleared, 'connection lost' for people failing the password, access restriction circumvention [CVE-2010-0401] [FS#3754] (r19610, r19609, r19608, r19607, r19606)
|
||||
- Fix: Desync debugging; false positives in the cache validity checks and saving/loading the command stream (r19619, r19617, r19602, r19601, r19600, r19596, r19593, r19592, r19589, r19587, r19586)
|
||||
@@ -3263,7 +3467,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Do not account for path reservation costs when entering a signal block via a 'block' signal. This way you will not get double penalties, both red signals and reservation costs, for the block signalled tracks [FS#2722] (r18535)
|
||||
- Fix: [NewGRF] An industry NewGRF that defined a too small size for action0 prop 0A could cause a crash (r18527)
|
||||
- Fix: Allegro does not like to work with extmidi, so warn the user about that [FS#3272] (r18520)
|
||||
- Fix: When you pass a signal at danger, in a PBS controlled area, do not try to do the 'safe' thing and stop, but continue going; the user wanted the train to pass the signal at danger so (s)he has to suffer the consequences. Of course one can always stop the train manually [FS#2891] (r18515)
|
||||
- Fix: When you pass a signal at danger, in a PBS controlled area, do not try to do the 'safe' thing and stop, but continue going; the user wanted the train to pass the signal at danger so they have to suffer the consequences. Of course one can always stop the train manually [FS#2891] (r18515)
|
||||
- Fix: No error message was created for the first fatal NewGRF error [FS#3368] (r18506)
|
||||
- Fix: Improve airport movement on several airports [FS#3169] (r18505)
|
||||
- Fix: Autoreplace and autorenew always reset their cargo sub type to 0. Now find a sub cargo type with the exact same name and use that, otherwise fallback to 0. So cargo sub types can be maintained via autoreplace *if* the new vehicle supports the same cargo sub type [FS#3159] (r18499)
|
||||
@@ -3746,7 +3950,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Make the join/spectate command require to be connected to a network game; in SP it could lead to crashes (r15514)
|
||||
- Fix: Generating a map with the original map generator with freeform edges on resulted in a crash [FS#2641] (r15511)
|
||||
- Fix: Pre-0.5 OpenTTD stored new_nonstop and full_load_any in a different way, savegame conversion was not working for them (r15500)
|
||||
- Fix: Crash when opening the game options when the currently loaded base graphics pack has less than 2 valid graphics files. For example when someone replaces all his/her original base graphics with custom work (but keeps the name) or renames the dos ones to windows or vice versa [FS#2630] (r15476)
|
||||
- Fix: Crash when opening the game options when the currently loaded base graphics pack has less than 2 valid graphics files. For example when someone replaces all their original base graphics with custom work (but keeps the name) or renames the dos ones to windows or vice versa [FS#2630] (r15476)
|
||||
|
||||
|
||||
0.7.0-beta1 (2009-02-16)
|
||||
@@ -4508,7 +4712,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Switching players (using the cheat) crashed on Big Endian machines [FS#1150] (r11023)
|
||||
- Fix: The canal border determination did not take oil rigs into consideration (r11022)
|
||||
- Fix: Do not display income/expenses when they do not belong to a 'valid' tile, like the money cheat/giving money [FS#1175] (r11021)
|
||||
- Fix: One could not give money when (s)he had too much money or rather: when casting the amount of money to an int32 becomes negative [FS#1174] (r11020)
|
||||
- Fix: One could not give money when they had too much money or rather: when casting the amount of money to an int32 becomes negative [FS#1174] (r11020)
|
||||
- Fix: When determining the gender of a string, do not assume that the gender is in the front of the string when there can be case switching code at that location [FS#1104] (r10792)
|
||||
- Fix: Determining whether there is a tunnel going under the lowered area is only needed in two directions instead of all four, so take the directions (one for each axis) to the nearest border (along the given axis) [FS#1058] (r10686)
|
||||
- Fix: Graphical glitches when the 'link landscape toolbar' patch is turned on when opening one of the construction toolbars [FS#1076] (r10685)
|
||||
@@ -4569,7 +4773,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Do not unconditionally assume that a tile has a depot (r11027)
|
||||
- Fix: Give a more correct error when building some things on tile 0 [FS#1173] (r11024)
|
||||
- Fix: Do not display income/expenses when they do not belong to a 'valid' tile, like the money cheat and giving money [FS#1175] (r11021)
|
||||
- Fix: One could not give money when (s)he had too much money [FS#1174] (r11020)
|
||||
- Fix: One could not give money when they had too much money [FS#1174] (r11020)
|
||||
- Fix: Disallow buying/selling shares in your own company or a bankrupt company [FS#1169] (r11018)
|
||||
- Fix: Crash when quitting the game in one of the end score windows [FS#1218] (r11071)
|
||||
|
||||
@@ -5529,7 +5733,7 @@ Note: OpenTTD was migrated to GitHub for 1.9, so SVN revision and FlySpray numbe
|
||||
- Fix: Vehicles slow down under bridge if the track is on a foundation
|
||||
- Fix: You can no longer change name of waypoints whom are owned by somebody else
|
||||
- Fix: Shares are now also sold when a company goes bankrupt [SF#1090313]
|
||||
- Fix: It is no longer possible to crash trains of other companies by building a depot close to a station; trains do no longer enter tiles that do not belong to his owner [SF#1087701]
|
||||
- Fix: It is no longer possible to crash trains of other companies by building a depot close to a station; trains do no longer enter tiles that do not belong to their owner [SF#1087701]
|
||||
- Fix: Crashed trains are not reported to have too few orders any more [SF#1087403]
|
||||
- Fix: Backup-order-list was not closed with an OT_NOTHING, [SF#1086375]
|
||||
- Fix: Docks now have a button to display the catchment area [SF#1085255]
|
||||
|
||||
+19
-15
@@ -4,28 +4,32 @@
|
||||
#
|
||||
macro(compile_flags)
|
||||
if(MSVC)
|
||||
# Switch to MT (static) instead of MD (dynamic) binary
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md")
|
||||
# Switch to MT (static) instead of MD (dynamic) binary
|
||||
|
||||
# For MSVC two generators are available
|
||||
# - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the
|
||||
# configuration of the build tree
|
||||
# - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to
|
||||
# specify all configurations that will be available in the generated solution
|
||||
list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}")
|
||||
# For MSVC two generators are available
|
||||
# - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the
|
||||
# configuration of the build tree
|
||||
# - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to
|
||||
# specify all configurations that will be available in the generated solution
|
||||
list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}")
|
||||
|
||||
# Set usage of static runtime for all configurations
|
||||
foreach(MSVC_CONFIG ${MSVC_CONFIGS})
|
||||
string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS)
|
||||
string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}")
|
||||
endforeach()
|
||||
# Set usage of static runtime for all configurations
|
||||
foreach(MSVC_CONFIG ${MSVC_CONFIGS})
|
||||
string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS)
|
||||
string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# "If /Zc:rvalueCast is specified, the compiler follows section 5.4 of the
|
||||
# C++11 standard". We need C++11 for the way we use threads.
|
||||
add_compile_options(/Zc:rvalueCast)
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# Enable multi-threaded compilation.
|
||||
add_compile_options(/MP)
|
||||
add_compile_options(
|
||||
/MP # Enable multi-threaded compilation.
|
||||
/FC # Display the full path of source code files passed to the compiler in diagnostics.
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -154,7 +158,7 @@ macro(compile_flags)
|
||||
message(FATAL_ERROR "No warning flags are set for this compiler yet; please consider creating a Pull Request to add support for this compiler.")
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
if(NOT WIN32 AND NOT HAIKU)
|
||||
# rdynamic is used to get useful stack traces from crash reports.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
||||
endif()
|
||||
|
||||
@@ -35,9 +35,9 @@ function(create_grf_command)
|
||||
-DNFORENUM_EXECUTABLE=${NFORENUM_EXECUTABLE}
|
||||
-DGRFCODEC_EXECUTABLE=${GRFCODEC_EXECUTABLE}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
|
||||
MAIN_DEPENDENCY ${GRF_NFO_SOURCE_FILES}
|
||||
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
|
||||
DEPENDS ${GRF_PNG_BINARY_FILES}
|
||||
${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
|
||||
${GRF_NFO_SOURCE_FILES}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating ${GRF_SOURCE_FOLDER_NAME}.grf"
|
||||
)
|
||||
|
||||
@@ -26,11 +26,13 @@ install(TARGETS openttd
|
||||
install(DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/lang
|
||||
${CMAKE_BINARY_DIR}/baseset
|
||||
${CMAKE_SOURCE_DIR}/bin/ai
|
||||
${CMAKE_SOURCE_DIR}/bin/game
|
||||
${CMAKE_BINARY_DIR}/ai
|
||||
${CMAKE_BINARY_DIR}/game
|
||||
${CMAKE_SOURCE_DIR}/bin/scripts
|
||||
DESTINATION ${DATA_DESTINATION_DIR}
|
||||
COMPONENT language_files)
|
||||
COMPONENT language_files
|
||||
REGEX "ai/[^\.]+$" EXCLUDE # Ignore subdirs in ai dir
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_SOURCE_DIR}/COPYING.md
|
||||
@@ -136,6 +138,13 @@ elseif(WIN32)
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")
|
||||
|
||||
if(WINDOWS_CERTIFICATE_COMMON_NAME)
|
||||
add_custom_command(TARGET openttd
|
||||
POST_BUILD
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/os/windows/sign.bat" "$<TARGET_FILE:openttd>" "${WINDOWS_CERTIFICATE_COMMON_NAME}"
|
||||
)
|
||||
endif()
|
||||
elseif(UNIX)
|
||||
# With FHS, we can create deb/rpm/... Without it, they would be horribly broken
|
||||
# and not work. The other way around is also true; with FHS they are not
|
||||
|
||||
@@ -11,12 +11,13 @@ source_group("Network Core" REGULAR_EXPRESSION "src/network/core/")
|
||||
source_group("OSX" REGULAR_EXPRESSION "src/os/macosx/")
|
||||
source_group("Pathfinder" REGULAR_EXPRESSION "src/pathfinder/")
|
||||
source_group("Save/Load handlers" REGULAR_EXPRESSION "src/saveload/")
|
||||
source_group("Save/Load handlers\\Compat" REGULAR_EXPRESSION "src/saveload/compat/")
|
||||
source_group("Sound" REGULAR_EXPRESSION "src/sound/")
|
||||
source_group("Sprite loaders" REGULAR_EXPRESSION "src/spriteloader/")
|
||||
source_group("Squirrel" REGULAR_EXPRESSION "src/3rdparty/squirrel/squirrel/")
|
||||
source_group("Tables" REGULAR_EXPRESSION "src/table/")
|
||||
source_group("Video" REGULAR_EXPRESSION "src/video/")
|
||||
source_group("Video/GL" REGULAR_EXPRESSION "src/3rdparty/opengl/")
|
||||
source_group("Video\\GL" REGULAR_EXPRESSION "src/3rdparty/opengl/")
|
||||
source_group("Widgets" REGULAR_EXPRESSION "src/widgets/")
|
||||
source_group("Windows files" REGULAR_EXPRESSION "src/os/windows/|\.rc$")
|
||||
|
||||
|
||||
@@ -39,6 +39,20 @@ foreach(NFO_LINE IN LISTS NFO_LINES)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo)
|
||||
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf)
|
||||
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo RESULT_VARIABLE RESULT)
|
||||
if(RESULT)
|
||||
if(NOT RESULT MATCHES "^[0-9]*$")
|
||||
message(FATAL_ERROR "Failed to run NFORenum (${RESULT}), please check NFORENUM_EXECUTABLE variable")
|
||||
endif()
|
||||
message(FATAL_ERROR "NFORenum failed")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf RESULT_VARIABLE RESULT)
|
||||
if(RESULT)
|
||||
if(NOT RESULT MATCHES "^[0-9]*$")
|
||||
message(FATAL_ERROR "Failed to run GRFCodec (${RESULT}), please check GRFCODEC_EXECUTABLE variable")
|
||||
endif()
|
||||
message(FATAL_ERROR "GRFCodec failed")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${GRF_SOURCE_FOLDER_NAME}.grf ${GRF_BINARY_FILE})
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if(NOT REV_MAJOR)
|
||||
set(REV_MAJOR 0)
|
||||
endif()
|
||||
if(NOT REV_MINOR)
|
||||
set(REV_MINOR 0)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Finds the current version of the current folder.
|
||||
#
|
||||
@@ -83,7 +90,7 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
set(REV_ISTAG 1)
|
||||
|
||||
string(REGEX REPLACE "^[0-9.]+$" "" STABLETAG "${TAG}")
|
||||
if(NOT STABLETAG STREQUAL "")
|
||||
if(STABLETAG STREQUAL "")
|
||||
set(REV_ISSTABLETAG 1)
|
||||
else()
|
||||
set(REV_ISSTABLETAG 0)
|
||||
@@ -128,7 +135,7 @@ else()
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/rev.cpp.in"
|
||||
"${FIND_VERSION_BINARY_DIR}/rev.cpp")
|
||||
|
||||
if(WIN32)
|
||||
if(WINDOWS)
|
||||
message(STATUS "Generating ottdres.rc")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
|
||||
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
|
||||
|
||||
@@ -28,10 +28,10 @@ endmacro()
|
||||
macro(dump_class_templates NAME)
|
||||
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
||||
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} *GetParam(ForceType<${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} &GetParam(ForceType<${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} *GetParam(ForceType<const ${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} &GetParam(ForceType<const ${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} *GetParam(ForceType<${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return (${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${NAME} &GetParam(ForceType<${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return *(${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} *GetParam(ForceType<const ${NAME} *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return (${NAME} *)instance; }")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline const ${NAME} &GetParam(ForceType<const ${NAME} &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, nullptr); return *(${NAME} *)instance; }")
|
||||
if("${NAME}" STREQUAL "ScriptEvent")
|
||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
||||
elseif("${NAME}" STREQUAL "ScriptText")
|
||||
|
||||
@@ -0,0 +1,557 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
||||
<!-- derived from Iron Horse branch at https://github.com/andythenorth/iron-horse/tree/company_colour_indexes -->
|
||||
<head>
|
||||
<title>OpenTTD Company Colour Indexes</title>
|
||||
<meta charset="UTF-8" />
|
||||
<style>
|
||||
th {
|
||||
vertical-align: top;
|
||||
border-bottom: solid 1px #ddd;
|
||||
padding-top: 30px;
|
||||
padding-right: 15px;
|
||||
text-align: right;
|
||||
}
|
||||
tr.top td {
|
||||
padding-top: 20px;
|
||||
}
|
||||
tr.bottom td {
|
||||
border-bottom: solid 1px #ddd;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
td {
|
||||
text-align: right;
|
||||
}
|
||||
span {
|
||||
border: solid 1px #000;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
margin-left: 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Company Colour Indexes</h1>
|
||||
<p>Hex / dec indexes into the DOS palette</p>
|
||||
<p>
|
||||
Visual representation of values derived from <a href="https://github.com/frosch123/TTDViewer/blob/master/src/recolor.xml#L186">https://github.com/frosch123/TTDViewer/blob/master/src/recolor.xml#L186</a>
|
||||
</p>
|
||||
<table style="margin-top:30px;">
|
||||
<tbody>
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_DARK_BLUE</th>
|
||||
<td><span style="background-color:rgb( 8, 24, 88)"></span></td>
|
||||
<td><span style="background-color:rgb( 12, 36, 104)"></span></td>
|
||||
<td><span style="background-color:rgb( 20, 52, 124)"></span></td>
|
||||
<td><span style="background-color:rgb( 28, 68, 140)"></span></td>
|
||||
<td><span style="background-color:rgb( 40, 92, 164)"></span></td>
|
||||
<td><span style="background-color:rgb( 56, 120, 188)"></span></td>
|
||||
<td><span style="background-color:rgb( 72, 152, 216)"></span></td>
|
||||
<td><span style="background-color:rgb(100, 172, 224)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0xc6</td>
|
||||
<td>0xc7</td>
|
||||
<td>0xc8</td>
|
||||
<td>0xc9</td>
|
||||
<td>0xca</td>
|
||||
<td>0xcb</td>
|
||||
<td>0xcc</td>
|
||||
<td>0xcd</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>198</td>
|
||||
<td>199</td>
|
||||
<td>200</td>
|
||||
<td>201</td>
|
||||
<td>202</td>
|
||||
<td>203</td>
|
||||
<td>204</td>
|
||||
<td>205</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_PALE_GREEN</th>
|
||||
<td><span style="background-color:rgb( 16, 52, 24)"></span></td>
|
||||
<td><span style="background-color:rgb( 32, 72, 44)"></span></td>
|
||||
<td><span style="background-color:rgb( 56, 96, 72)"></span></td>
|
||||
<td><span style="background-color:rgb( 76, 116, 88)"></span></td>
|
||||
<td><span style="background-color:rgb( 96, 136, 108)"></span></td>
|
||||
<td><span style="background-color:rgb(120, 164, 136)"></span></td>
|
||||
<td><span style="background-color:rgb(152, 192, 168)"></span></td>
|
||||
<td><span style="background-color:rgb(184, 220, 200)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x60</td>
|
||||
<td>0x61</td>
|
||||
<td>0x62</td>
|
||||
<td>0x63</td>
|
||||
<td>0x64</td>
|
||||
<td>0x65</td>
|
||||
<td>0x66</td>
|
||||
<td>0x67</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>96</td>
|
||||
<td>97</td>
|
||||
<td>98</td>
|
||||
<td>99</td>
|
||||
<td>100</td>
|
||||
<td>101</td>
|
||||
<td>102</td>
|
||||
<td>103</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_PINK</th>
|
||||
<td><span style="background-color:rgb(112, 16, 32)"></span></td>
|
||||
<td><span style="background-color:rgb(136, 32, 52)"></span></td>
|
||||
<td><span style="background-color:rgb(160, 56, 76)"></span></td>
|
||||
<td><span style="background-color:rgb(188, 84, 108)"></span></td>
|
||||
<td><span style="background-color:rgb(204, 104, 124)"></span></td>
|
||||
<td><span style="background-color:rgb(220, 132, 144)"></span></td>
|
||||
<td><span style="background-color:rgb(236, 156, 164)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 188, 192)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x2a</td>
|
||||
<td>0x2b</td>
|
||||
<td>0x2c</td>
|
||||
<td>0x2d</td>
|
||||
<td>0x2e</td>
|
||||
<td>0x2f</td>
|
||||
<td>0x30</td>
|
||||
<td>0x31</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>42</td>
|
||||
<td>43</td>
|
||||
<td>44</td>
|
||||
<td>45</td>
|
||||
<td>46</td>
|
||||
<td>47</td>
|
||||
<td>48</td>
|
||||
<td>49</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_YELLOW</th>
|
||||
<td><span style="background-color:rgb(128, 68, 8)"></span></td>
|
||||
<td><span style="background-color:rgb(156, 96, 16)"></span></td>
|
||||
<td><span style="background-color:rgb(184, 120, 24)"></span></td>
|
||||
<td><span style="background-color:rgb(212, 156, 32)"></span></td>
|
||||
<td><span style="background-color:rgb(232, 184, 16)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 212, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 248, 128)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 252, 192)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x3e</td>
|
||||
<td>0x3f</td>
|
||||
<td>0x40</td>
|
||||
<td>0x41</td>
|
||||
<td>0x42</td>
|
||||
<td>0x43</td>
|
||||
<td>0x44</td>
|
||||
<td>0x45</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>62</td>
|
||||
<td>63</td>
|
||||
<td>64</td>
|
||||
<td>65</td>
|
||||
<td>66</td>
|
||||
<td>67</td>
|
||||
<td>68</td>
|
||||
<td>69</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_RED</th>
|
||||
<td><span style="background-color:rgb( 92, 0, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(128, 0, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(160, 0, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(196, 0, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(224, 0, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 52, 52)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 100, 88)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 144, 124)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0xb3</td>
|
||||
<td>0xb4</td>
|
||||
<td>0xb5</td>
|
||||
<td>0xb6</td>
|
||||
<td>0xb7</td>
|
||||
<td>0xa4</td>
|
||||
<td>0xa5</td>
|
||||
<td>0xa6</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>179</td>
|
||||
<td>180</td>
|
||||
<td>181</td>
|
||||
<td>182</td>
|
||||
<td>183</td>
|
||||
<td>164</td>
|
||||
<td>165</td>
|
||||
<td>166</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_LIGHT_BLUE</th>
|
||||
<td><span style="background-color:rgb( 16, 64, 96)"></span></td>
|
||||
<td><span style="background-color:rgb( 24, 80, 108)"></span></td>
|
||||
<td><span style="background-color:rgb( 40, 96, 120)"></span></td>
|
||||
<td><span style="background-color:rgb( 52, 112, 132)"></span></td>
|
||||
<td><span style="background-color:rgb( 80, 140, 160)"></span></td>
|
||||
<td><span style="background-color:rgb(116, 172, 192)"></span></td>
|
||||
<td><span style="background-color:rgb(156, 204, 220)"></span></td>
|
||||
<td><span style="background-color:rgb(204, 240, 252)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x9a</td>
|
||||
<td>0x9b</td>
|
||||
<td>0x9c</td>
|
||||
<td>0x9d</td>
|
||||
<td>0x9e</td>
|
||||
<td>0x9f</td>
|
||||
<td>0xa0</td>
|
||||
<td>0xa1</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>154</td>
|
||||
<td>155</td>
|
||||
<td>156</td>
|
||||
<td>157</td>
|
||||
<td>158</td>
|
||||
<td>159</td>
|
||||
<td>160</td>
|
||||
<td>161</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_GREEN</th>
|
||||
<td><span style="background-color:rgb( 32, 80, 4)"></span></td>
|
||||
<td><span style="background-color:rgb( 48, 96, 4)"></span></td>
|
||||
<td><span style="background-color:rgb( 64, 112, 12)"></span></td>
|
||||
<td><span style="background-color:rgb( 84, 132, 20)"></span></td>
|
||||
<td><span style="background-color:rgb( 92, 156, 52)"></span></td>
|
||||
<td><span style="background-color:rgb(108, 176, 64)"></span></td>
|
||||
<td><span style="background-color:rgb(124, 200, 76)"></span></td>
|
||||
<td><span style="background-color:rgb(144, 224, 92)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x52</td>
|
||||
<td>0x53</td>
|
||||
<td>0x54</td>
|
||||
<td>0x55</td>
|
||||
<td>0xce</td>
|
||||
<td>0xcf</td>
|
||||
<td>0xd0</td>
|
||||
<td>0xd1</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>82</td>
|
||||
<td>83</td>
|
||||
<td>84</td>
|
||||
<td>85</td>
|
||||
<td>206</td>
|
||||
<td>207</td>
|
||||
<td>208</td>
|
||||
<td>209</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_DARK_GREEN</th>
|
||||
<td><span style="background-color:rgb( 28, 52, 24)"></span></td>
|
||||
<td><span style="background-color:rgb( 44, 68, 32)"></span></td>
|
||||
<td><span style="background-color:rgb( 60, 88, 48)"></span></td>
|
||||
<td><span style="background-color:rgb( 80, 104, 60)"></span></td>
|
||||
<td><span style="background-color:rgb(104, 124, 76)"></span></td>
|
||||
<td><span style="background-color:rgb(128, 148, 92)"></span></td>
|
||||
<td><span style="background-color:rgb(152, 176, 108)"></span></td>
|
||||
<td><span style="background-color:rgb(180, 204, 124)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x58</td>
|
||||
<td>0x59</td>
|
||||
<td>0x5a</td>
|
||||
<td>0x5b</td>
|
||||
<td>0x5c</td>
|
||||
<td>0x5d</td>
|
||||
<td>0x5e</td>
|
||||
<td>0x5f</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>88</td>
|
||||
<td>89</td>
|
||||
<td>90</td>
|
||||
<td>91</td>
|
||||
<td>92</td>
|
||||
<td>93</td>
|
||||
<td>94</td>
|
||||
<td>95</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_BLUE</th>
|
||||
<td><span style="background-color:rgb( 0, 52, 160)"></span></td>
|
||||
<td><span style="background-color:rgb( 0, 72, 184)"></span></td>
|
||||
<td><span style="background-color:rgb( 0, 96, 212)"></span></td>
|
||||
<td><span style="background-color:rgb( 24, 120, 220)"></span></td>
|
||||
<td><span style="background-color:rgb( 56, 144, 232)"></span></td>
|
||||
<td><span style="background-color:rgb( 88, 168, 240)"></span></td>
|
||||
<td><span style="background-color:rgb(128, 196, 252)"></span></td>
|
||||
<td><span style="background-color:rgb(188, 224, 252)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x92</td>
|
||||
<td>0x93</td>
|
||||
<td>0x94</td>
|
||||
<td>0x95</td>
|
||||
<td>0x96</td>
|
||||
<td>0x97</td>
|
||||
<td>0x98</td>
|
||||
<td>0x99</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>146</td>
|
||||
<td>147</td>
|
||||
<td>148</td>
|
||||
<td>149</td>
|
||||
<td>150</td>
|
||||
<td>151</td>
|
||||
<td>152</td>
|
||||
<td>153</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_CREAM</th>
|
||||
<td><span style="background-color:rgb(116, 68, 40)"></span></td>
|
||||
<td><span style="background-color:rgb(136, 84, 56)"></span></td>
|
||||
<td><span style="background-color:rgb(164, 96, 64)"></span></td>
|
||||
<td><span style="background-color:rgb(184, 112, 80)"></span></td>
|
||||
<td><span style="background-color:rgb(204, 128, 96)"></span></td>
|
||||
<td><span style="background-color:rgb(212, 148, 112)"></span></td>
|
||||
<td><span style="background-color:rgb(224, 168, 128)"></span></td>
|
||||
<td><span style="background-color:rgb(236, 188, 148)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x72</td>
|
||||
<td>0x73</td>
|
||||
<td>0x74</td>
|
||||
<td>0x75</td>
|
||||
<td>0x76</td>
|
||||
<td>0x77</td>
|
||||
<td>0x78</td>
|
||||
<td>0x79</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>114</td>
|
||||
<td>115</td>
|
||||
<td>116</td>
|
||||
<td>117</td>
|
||||
<td>118</td>
|
||||
<td>119</td>
|
||||
<td>120</td>
|
||||
<td>121</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_MAUVE</th>
|
||||
<td><span style="background-color:rgb( 36, 40, 68)"></span></td>
|
||||
<td><span style="background-color:rgb( 48, 52, 84)"></span></td>
|
||||
<td><span style="background-color:rgb( 64, 64, 100)"></span></td>
|
||||
<td><span style="background-color:rgb( 80, 80, 116)"></span></td>
|
||||
<td><span style="background-color:rgb(100, 100, 136)"></span></td>
|
||||
<td><span style="background-color:rgb(132, 132, 164)"></span></td>
|
||||
<td><span style="background-color:rgb(172, 172, 192)"></span></td>
|
||||
<td><span style="background-color:rgb(212, 212, 224)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x80</td>
|
||||
<td>0x81</td>
|
||||
<td>0x82</td>
|
||||
<td>0x83</td>
|
||||
<td>0x84</td>
|
||||
<td>0x85</td>
|
||||
<td>0x86</td>
|
||||
<td>0x87</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>128</td>
|
||||
<td>129</td>
|
||||
<td>130</td>
|
||||
<td>131</td>
|
||||
<td>132</td>
|
||||
<td>133</td>
|
||||
<td>134</td>
|
||||
<td>135</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_PURPLE</th>
|
||||
<td><span style="background-color:rgb( 40, 20, 112)"></span></td>
|
||||
<td><span style="background-color:rgb( 64, 44, 144)"></span></td>
|
||||
<td><span style="background-color:rgb( 88, 64, 172)"></span></td>
|
||||
<td><span style="background-color:rgb(104, 76, 196)"></span></td>
|
||||
<td><span style="background-color:rgb(120, 88, 224)"></span></td>
|
||||
<td><span style="background-color:rgb(140, 104, 252)"></span></td>
|
||||
<td><span style="background-color:rgb(160, 136, 252)"></span></td>
|
||||
<td><span style="background-color:rgb(188, 168, 252)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x88</td>
|
||||
<td>0x89</td>
|
||||
<td>0x8a</td>
|
||||
<td>0x8b</td>
|
||||
<td>0x8c</td>
|
||||
<td>0x8d</td>
|
||||
<td>0x8e</td>
|
||||
<td>0x8f</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>136</td>
|
||||
<td>137</td>
|
||||
<td>138</td>
|
||||
<td>139</td>
|
||||
<td>140</td>
|
||||
<td>141</td>
|
||||
<td>142</td>
|
||||
<td>143</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_ORANGE</th>
|
||||
<td><span style="background-color:rgb(184, 120, 24)"></span></td>
|
||||
<td><span style="background-color:rgb(204, 136, 8)"></span></td>
|
||||
<td><span style="background-color:rgb(228, 144, 4)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 156, 0)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 176, 48)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 196, 100)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 216, 152)"></span></td>
|
||||
<td><span style="background-color:rgb(244, 220, 176)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x40</td>
|
||||
<td>0xc0</td>
|
||||
<td>0xc1</td>
|
||||
<td>0xc2</td>
|
||||
<td>0xc3</td>
|
||||
<td>0xc4</td>
|
||||
<td>0xc5</td>
|
||||
<td>0x27</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>64</td>
|
||||
<td>192</td>
|
||||
<td>193</td>
|
||||
<td>194</td>
|
||||
<td>195</td>
|
||||
<td>196</td>
|
||||
<td>197</td>
|
||||
<td>39</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_BROWN</th>
|
||||
<td><span style="background-color:rgb( 72, 44, 4)"></span></td>
|
||||
<td><span style="background-color:rgb( 88, 60, 20)"></span></td>
|
||||
<td><span style="background-color:rgb(104, 80, 44)"></span></td>
|
||||
<td><span style="background-color:rgb(124, 104, 72)"></span></td>
|
||||
<td><span style="background-color:rgb(152, 132, 92)"></span></td>
|
||||
<td><span style="background-color:rgb(184, 160, 120)"></span></td>
|
||||
<td><span style="background-color:rgb(212, 188, 148)"></span></td>
|
||||
<td><span style="background-color:rgb(244, 220, 176)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x20</td>
|
||||
<td>0x21</td>
|
||||
<td>0x22</td>
|
||||
<td>0x23</td>
|
||||
<td>0x24</td>
|
||||
<td>0x25</td>
|
||||
<td>0x26</td>
|
||||
<td>0x27</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>32</td>
|
||||
<td>33</td>
|
||||
<td>34</td>
|
||||
<td>35</td>
|
||||
<td>36</td>
|
||||
<td>37</td>
|
||||
<td>38</td>
|
||||
<td>39</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_GREY</th>
|
||||
<td><span style="background-color:rgb( 64, 64, 64)"></span></td>
|
||||
<td><span style="background-color:rgb( 80, 80, 80)"></span></td>
|
||||
<td><span style="background-color:rgb(100, 100, 100)"></span></td>
|
||||
<td><span style="background-color:rgb(116, 116, 116)"></span></td>
|
||||
<td><span style="background-color:rgb(132, 132, 132)"></span></td>
|
||||
<td><span style="background-color:rgb(148, 148, 148)"></span></td>
|
||||
<td><span style="background-color:rgb(168, 168, 168)"></span></td>
|
||||
<td><span style="background-color:rgb(184, 184, 184)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x4</td>
|
||||
<td>0x5</td>
|
||||
<td>0x6</td>
|
||||
<td>0x7</td>
|
||||
<td>0x8</td>
|
||||
<td>0x9</td>
|
||||
<td>0xa</td>
|
||||
<td>0xb</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>4</td>
|
||||
<td>5</td>
|
||||
<td>6</td>
|
||||
<td>7</td>
|
||||
<td>8</td>
|
||||
<td>9</td>
|
||||
<td>10</td>
|
||||
<td>11</td>
|
||||
</tr>
|
||||
|
||||
<tr class="top">
|
||||
<th rowspan="3">COLOUR_WHITE</th>
|
||||
<td><span style="background-color:rgb(132, 132, 132)"></span></td>
|
||||
<td><span style="background-color:rgb(148, 148, 148)"></span></td>
|
||||
<td><span style="background-color:rgb(168, 168, 168)"></span></td>
|
||||
<td><span style="background-color:rgb(184, 184, 184)"></span></td>
|
||||
<td><span style="background-color:rgb(200, 200, 200)"></span></td>
|
||||
<td><span style="background-color:rgb(216, 216, 216)"></span></td>
|
||||
<td><span style="background-color:rgb(232, 232, 232)"></span></td>
|
||||
<td><span style="background-color:rgb(252, 252, 252)"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>0x8</td>
|
||||
<td>0x9</td>
|
||||
<td>0xa</td>
|
||||
<td>0xb</td>
|
||||
<td>0xc</td>
|
||||
<td>0xd</td>
|
||||
<td>0xe</td>
|
||||
<td>0xf</td>
|
||||
</tr>
|
||||
<tr class="bottom">
|
||||
<td>8</td>
|
||||
<td>9</td>
|
||||
<td>10</td>
|
||||
<td>11</td>
|
||||
<td>12</td>
|
||||
<td>13</td>
|
||||
<td>14</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,83 @@
|
||||
# Game Coordinator
|
||||
|
||||
To allow two players to play together, OpenTTD uses a Game Coordinator to
|
||||
facilitate this.
|
||||
|
||||
When a server starts, it can register itself to the Game Coordinator. This
|
||||
happens when `server_game_type` is set to either `invite-only` or `public`.
|
||||
Upon registration, the Game Coordinator probes the network of the server, and
|
||||
assigns the server an unique code, called an `invite code`.
|
||||
|
||||
When a client wants to join a server, it asks the Game Coordinator to help
|
||||
with this by giving it the `invite code` of the server. The Game Coordinator
|
||||
will, in this order, attempt several ways to connect the client and server
|
||||
together:
|
||||
|
||||
## 1) Via direct IPv4 / IPv6
|
||||
|
||||
Upon registration, the Game Coordinator probes the server to see if a
|
||||
direction connection to the server is possible based on the game port. It
|
||||
tries this over the public IPv4 and IPv6, as announced by the server.
|
||||
If either (or both) are successful, a client will always be asked to try
|
||||
these direct IPs first when it wants to connect to this server.
|
||||
|
||||
- If the server is IPv4 only, the client is only asked to connect via IPv4.
|
||||
- If the server is IPv6 only, the client is only asked to connect via IPv6.
|
||||
- If the server is both IPv4 and IPv6, the client is asked to connect to to
|
||||
one of those first. If that fails, it is asked to connect to the other.
|
||||
Whether it tries IPv4 or IPv6 first, strongly depends on several network
|
||||
infrastructure related events. The biggest influence is the network
|
||||
latency over both protocols to the OpenTTD infrastructure.
|
||||
|
||||
In the end, if either the server is not reachable directly from the Internet
|
||||
or the client fails to connect to either one of them, the connection attempt
|
||||
continues with the next available method.
|
||||
|
||||
## 2) Via STUN
|
||||
|
||||
When a client wants to join a server via STUN, both the client and server
|
||||
are asked to create a connection to the STUN server (normally
|
||||
`stun.openttd.org`) via both IPv4 and IPv6. If the client or server has no
|
||||
IPv4 or IPv6, it will not make a connection attempt via that protocol.
|
||||
|
||||
The STUN server collects the public IPv4 and/or IPv6 of the client and server,
|
||||
together with the port the connection came in from. For most NAT gateways it
|
||||
holds true that as long as you use the same local IP + port, your public
|
||||
IP + port will remain the same, and allow for bi-directional communication.
|
||||
And this fact is used to later on pair the client and server.
|
||||
|
||||
The STUN server reports this information directly to the Game Coordinator
|
||||
(this in contrast to most STUN implementation, where this information is
|
||||
first reported back to the peer itself, which has to relay it back to the
|
||||
coordinator. OpenTTD skips this step, as the STUN server can directly talk to
|
||||
the Game Coordinator). When the Game Coordinator sees a matching pair (in
|
||||
terms of IPv4 / IPv6), it will ask both the client and server to connect to
|
||||
their peer based on this public IP + port.
|
||||
|
||||
As the NAT gateway forwards the traffic on the public IP + port to the local
|
||||
port, this creates a bi-directional socket between client and server. The
|
||||
connection to the STUN server can now safely be closed, and the client and
|
||||
server can continue to talk to each other.
|
||||
|
||||
Some NAT gateways do not allow this method; for those this attempt will fail,
|
||||
and this also means that it is not possible to create a connection between
|
||||
the client and server.
|
||||
|
||||
## 3) Via TURN
|
||||
|
||||
As a last resort, the Game Coordinator can decide to connect the client and
|
||||
server together via TURN. TURN is a relay service, relaying the messages
|
||||
between client and server.
|
||||
|
||||
As the client and server can already connect to the Game Coordinator, it is
|
||||
very likely this is successful.
|
||||
|
||||
It is important to note that a relay service has full view of the traffic
|
||||
send between client and server, and as such it is important that you trust
|
||||
the relay service used.
|
||||
For official binaries, this relay service is hosted by openttd.org. The relay
|
||||
service as hosted by openttd.org only validates it is relaying valid OpenTTD
|
||||
packets and does no further inspection of the payload itself.
|
||||
Although in our experience most patch-packs also use the services as offered
|
||||
by openttd.org, it is possible they use different services. Please be mindful
|
||||
about this.
|
||||
+15
-3
@@ -48,6 +48,10 @@ Last updated: 2011-02-16
|
||||
- click add server
|
||||
- type in the ip address or hostname
|
||||
- if you want to add a port use :<port>
|
||||
- If you want to play and you have the invite code of the game server you
|
||||
want connect to.
|
||||
- click add server
|
||||
- type in the invite code
|
||||
- Now you can select a company and press: "Join company", to help that company
|
||||
- Or you can press "Spectate game", to spectate the game
|
||||
- Or you can press "New company", and start your own company (if there are
|
||||
@@ -110,9 +114,10 @@ Last updated: 2011-02-16
|
||||
- You can let your server automatically restart a map when, let's say, year 2030
|
||||
is reached. See 'set restart_game_date' for detail.
|
||||
|
||||
- If you want to be on the server-list, enable Advertising. To do this, select
|
||||
'Internet (advertise)' in the Start Server menu, or type in console:
|
||||
'set server_advertise 1'.
|
||||
- If you want to be on the server-list, make your server public. You can do
|
||||
this either from the Start Server GUI, via the in-game Online Players GUI,
|
||||
or by typing in the console:
|
||||
'set server_game_type public'.
|
||||
|
||||
- You can protect your server with a password via the console: 'set server_pw',
|
||||
or via the Start Server menu.
|
||||
@@ -211,3 +216,10 @@ Last updated: 2011-02-16
|
||||
communication from an admin tool reach the programme. See section 1
|
||||
'Starting a server' further up for the ports and protocols used by OpenTTD.
|
||||
The ports can be configured in the config file.
|
||||
|
||||
- My advertising server warns a lot about getaddrinfo taking N seconds
|
||||
This could be a transient issue with your (local) DNS server, but if the
|
||||
problem persists there is likely a configuration issue in DNS resolving
|
||||
on your computer. This seems to be a common configuration issue for
|
||||
Docker instances, where the DNS resolving waits for a time out of usually
|
||||
5 seconds.
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
# OpenTTD's Savegame Format
|
||||
|
||||
Last updated: 2021-06-15
|
||||
|
||||
## Outer container
|
||||
|
||||
Savegames for OpenTTD start with an outer container, to contain the compressed data for the rest of the savegame.
|
||||
|
||||
`[0..3]` - The first four bytes indicate what compression is used.
|
||||
In ASCII, these values are possible:
|
||||
|
||||
- `OTTD` - Compressed with LZO (deprecated, only really old savegames would use this).
|
||||
- `OTTN` - No compression.
|
||||
- `OTTZ` - Compressed with zlib.
|
||||
- `OTTX` - Compressed with LZMA.
|
||||
|
||||
`[4..5]` - The next two bytes indicate which savegame version used.
|
||||
|
||||
`[6..7]` - The next two bytes can be ignored, and were only used in really old savegames.
|
||||
|
||||
`[8..N]` - Next follows a binary blob which is compressed with the indicated compression algorithm.
|
||||
|
||||
The rest of this document talks about this decompressed blob of data.
|
||||
|
||||
## Data types
|
||||
|
||||
The savegame is written in Big Endian, so when we talk about a 16-bit unsigned integer (`uint16`), we mean it is stored in Big Endian.
|
||||
|
||||
The following types are valid:
|
||||
|
||||
- `1` - `int8` / `SLE_FILE_I8` -8-bit signed integer
|
||||
- `2` - `uint8` / `SLE_FILE_U8` - 8-bit unsigned integer
|
||||
- `3` - `int16` / `SLE_FILE_I16` - 16-bit signed integer
|
||||
- `4` - `uint16` / `SLE_FILE_U16` - 16-bit unsigned integer
|
||||
- `5` - `int32` / `SLE_FILE_I32` - 32-bit signed integer
|
||||
- `6` - `uint32` / `SLE_FILE_U32` - 32-bit unsigned integer
|
||||
- `7` - `int64` / `SLE_FILE_I64` - 64-bit signed integer
|
||||
- `8` - `uint64` / `SLE_FILE_U64` - 64-bit unsigned integer
|
||||
- `9` - `StringID` / `SLE_FILE_STRINGID` - a StringID inside the OpenTTD's string table
|
||||
- `10` - `str` / `SLE_FILE_STRING` - a string (prefixed with a length-field)
|
||||
- `11` - `struct` / `SLE_FILE_STRUCT` - a struct
|
||||
|
||||
### Gamma value
|
||||
|
||||
There is also a field-type called `gamma`.
|
||||
This is most often used for length-fields, and uses as few bytes as possible to store an integer.
|
||||
For values <= 127, it uses a single byte.
|
||||
For values > 127, it uses two bytes and sets the highest bit to high.
|
||||
For values > 32767, it uses three bytes and sets the two highest bits to high.
|
||||
And this continues till the value fits.
|
||||
In a more visual approach:
|
||||
```
|
||||
0xxxxxxx
|
||||
10xxxxxx xxxxxxxx
|
||||
110xxxxx xxxxxxxx xxxxxxxx
|
||||
1110xxxx xxxxxxxx xxxxxxxx xxxxxxxx
|
||||
11110--- xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
|
||||
```
|
||||
|
||||
## Chunks
|
||||
|
||||
Savegames for OpenTTD store their data in chunks.
|
||||
Each chunk contains data for a certain part of the game, for example "Companies", "Vehicles", etc.
|
||||
|
||||
`[0..3]` - Each chunk starts with four bytes to indicate the tag.
|
||||
If the tag is `\x00\x00\x00\x00` it means the end of the savegame is reached.
|
||||
An example of a valid tag is `PLYR` when looking at it via ASCII, which contains the information of all the companies.
|
||||
|
||||
`[4..4]` - Next follows a byte where the lower 4 bits contain the type.
|
||||
The possible valid types are:
|
||||
|
||||
- `0` - `CH_RIFF` - This chunk is a binary blob.
|
||||
- `1` - `CH_ARRAY` - This chunk is a list of items.
|
||||
- `2` - `CH_SPARSE_ARRAY` - This chunk is a list of items.
|
||||
- `3` - `CH_TABLE` - This chunk is self-describing list of items.
|
||||
- `4` - `CH_SPARSE_TABLE` - This chunk is self-describing list of items.
|
||||
|
||||
Now per type the format is (slightly) different.
|
||||
|
||||
### CH_RIFF
|
||||
|
||||
(since savegame version 295, this chunk type is only used for MAP-chunks, containing bit-information about each tile on the map)
|
||||
|
||||
A `CH_RIFF` starts with an `uint24` which together with the upper-bits of the type defines the length of the chunk.
|
||||
In pseudo-code:
|
||||
|
||||
```
|
||||
type = read uint8
|
||||
if type == 0
|
||||
length = read uint24
|
||||
length |= ((type >> 4) << 24)
|
||||
```
|
||||
|
||||
The next `length` bytes are part of the chunk.
|
||||
What those bytes mean depends on the tag of the chunk; further details per chunk can be found in the source-code.
|
||||
|
||||
### CH_ARRAY / CH_SPARSE_ARRAY
|
||||
|
||||
(this chunk type is deprecated since savegame version 295 and is no longer in use)
|
||||
|
||||
`[0..G1]` - A `CH_ARRAY` / `CH_SPARSE_ARRAY` starts with a `gamma`, indicating the size of the next item plus one.
|
||||
If this size value is zero, it indicates the end of the list.
|
||||
This indicates the full length of the next item minus one.
|
||||
In psuedo-code:
|
||||
|
||||
```
|
||||
loop
|
||||
size = read gamma - 1
|
||||
if size == -1
|
||||
break loop
|
||||
read <size> bytes
|
||||
```
|
||||
|
||||
`[]` - For `CH_ARRAY` there is an implicit index.
|
||||
The loop starts at zero, and every iteration adds one to the index.
|
||||
For entries in the game that were not allocated, the `size` will be zero.
|
||||
|
||||
`[G1+1..G2]` - For `CH_SPARSE_ARRAY` there is an explicit index.
|
||||
The `gamma` following the size indicates the index.
|
||||
|
||||
The content of the item is a binary blob, and similar to `CH_RIFF`, it depends on the tag of the chunk what it means.
|
||||
Please check the source-code for further details.
|
||||
|
||||
### CH_TABLE / CH_SPARSE_TABLE
|
||||
|
||||
(this chunk type only exists since savegame version 295)
|
||||
|
||||
Both `CH_TABLE` and `CH_SPARSE_TABLE` are very similar to `CH_ARRAY` / `CH_SPARSE_ARRAY` respectively.
|
||||
The only change is that the chunk starts with a header.
|
||||
This header describes the chunk in details; with the header you know the meaning of each byte in the binary blob that follows.
|
||||
|
||||
`[0..G]` - The header starts with a `gamma` to indicate the size of all the headers in this chunk plus one.
|
||||
If this size value is zero, it means there is no header, which should never be the case.
|
||||
|
||||
Next follows a list of `(type, key)` pairs:
|
||||
|
||||
- `[0..0]` - Type of the field.
|
||||
- `[1..G]` - `gamma` to indicate length of key.
|
||||
- `[G+1..N]` - Key (in UTF-8) of the field.
|
||||
|
||||
If at any point `type` is zero, the list stops (and no `key` follows).
|
||||
|
||||
The `type`'s lower 4 bits indicate the data-type (see chapter above).
|
||||
The `type`'s 5th bit (so `0x10`) indicates if the field is a list, and if this field in every record starts with a `gamma` to indicate how many times the `type` is repeated.
|
||||
|
||||
If the `type` indicates either a `struct` or `str`, the `0x10` flag is also always set.
|
||||
|
||||
As the savegame format allows (list of) structs in structs, if any `struct` type is found, this header will be followed by a header of that struct.
|
||||
This nesting of structs is stored depth-first, so given this table:
|
||||
|
||||
```
|
||||
type | key
|
||||
-----------------
|
||||
uint8 | counter
|
||||
struct | substruct1
|
||||
struct | substruct2
|
||||
```
|
||||
|
||||
With `substruct1` being like:
|
||||
|
||||
```
|
||||
type | key
|
||||
-----------------
|
||||
uint8 | counter
|
||||
struct | substruct3
|
||||
```
|
||||
|
||||
The headers will be, in order: `table`, `substruct1`, `substruct3`, `substruct2`, each ending with a `type` is zero field.
|
||||
|
||||
After reading all the fields of all the headers, there is a list of records.
|
||||
To read this, see `CH_ARRAY` / `CH_SPARSE_ARRAY` for details.
|
||||
|
||||
As each `type` has a well defined length, you can read the records even without knowing anything about the chunk-tag yourself.
|
||||
|
||||
Do remember, that if the `type` had the `0x10` flag active, the field in the record first has a `gamma` to indicate how many times that `type` is repeated.
|
||||
|
||||
#### Guidelines for network-compatible patch-packs
|
||||
|
||||
For network-compatible patch-packs (client-side patches that can play together with unpatched clients) we advise to prefix the field-name with `__<shortname>` when introducing new fields to an existing chunk.
|
||||
|
||||
Example: you have an extra setting called `auto_destroy_rivers` you want to store in the savegame for your patched client called `mypp`.
|
||||
We advise you to call this setting `__mypp_auto_destroy_rivers` in the settings chunk.
|
||||
|
||||
Doing it this way ensures that a savegame created by these patch-packs can still safely be loaded by unpatched clients.
|
||||
They will simply ignore the field and continue loading the savegame as usual.
|
||||
The prefix is strongly advised to avoid conflicts with future-settings in an unpatched client or conflicts with other patch-packs.
|
||||
|
||||
## Scripts custom data format
|
||||
|
||||
Script chunks (`AIPL` and `GSDT`) use `CH_TABLE` chunk type.
|
||||
|
||||
At the end of each record there's an `uint8` to indicate if there's custom data (1) or not (0).
|
||||
|
||||
There are 6 data types for scripts, called `script-data-type`.
|
||||
When saving, each `script-data-type` starts with the type marker saved as `uint8` followed by the actual data.
|
||||
- `0` - `SQSL_INT`:
|
||||
- an `int64` with the actual value (`int32` before savegame version 296).
|
||||
- `1` - `SQSL_STRING`:
|
||||
- an `uint8` with the string length.
|
||||
- a list of `int8` for the string itself.
|
||||
- `2` - `SQSL_ARRAY`:
|
||||
- each element saved as `script-data-type`.
|
||||
- an `SQSL_ARRAY_TABLE_END` (0xFF) marker (`uint8`).
|
||||
- `3` - `SQSL_TABLE`:
|
||||
- for each element:
|
||||
- key saved as `script-data-type`.
|
||||
- value saved as `script-data-type`.
|
||||
- an `SQSL_ARRAY_TABLE_END` (0xFF) marker (`uint8`).
|
||||
- `4` - `SQSL_BOOL`:
|
||||
- an `uint8` with 0 (false) or 1 (true).
|
||||
- `5` - `SQSL_NULL`:
|
||||
- (no data follows)
|
||||
|
||||
The first data type is always a `SQSL_TABLE`.
|
||||
@@ -1,6 +1,4 @@
|
||||
OpenTTD's known bugs
|
||||
Last updated: 2021-02-28
|
||||
Release version: 1.11.0-beta2
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
-1 * 0 0C "OpenTTD GUI graphics"
|
||||
-1 * 3 05 15 \b 186 // OPENTTD_SPRITE_COUNT
|
||||
-1 * 3 05 15 \b 191 // OPENTTD_SPRITE_COUNT
|
||||
-1 sprites/openttdgui.png 8bpp 66 8 64 31 -31 7 normal
|
||||
-1 sprites/openttdgui.png 8bpp 146 8 64 31 -31 7 normal
|
||||
-1 sprites/openttdgui.png 8bpp 226 8 64 31 -31 7 normal
|
||||
@@ -191,3 +191,8 @@
|
||||
-1 sprites/openttdgui_convert_tram.png 8bpp 24 0 32 32 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 513 440 10 10 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 526 440 10 10 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 539 440 12 10 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 553 440 12 10 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 567 440 12 10 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 581 440 10 10 0 0 normal
|
||||
-1 sprites/openttdgui.png 8bpp 593 440 10 10 0 0 normal
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 44 KiB |
@@ -1,5 +1,5 @@
|
||||
# LibLZMA is a recent addition to the emscripten SDK, so it is possible
|
||||
# someone hasn't updated his SDK yet. Test out if the SDK supports LibLZMA.
|
||||
# someone hasn't updated their SDK yet. Test out if the SDK supports LibLZMA.
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_FLAGS "-sUSE_LIBLZMA=1")
|
||||
|
||||
|
||||
+16
-4
@@ -9,7 +9,15 @@ Module['websocket'] = { url: function(host, port, proto) {
|
||||
* If you run your own server you can setup your own WebSocket proxy in
|
||||
* front of it and let people connect to your server via the proxy. You
|
||||
* are best to add another "if" statement as above for this. */
|
||||
return null;
|
||||
|
||||
if (location.protocol === 'https:') {
|
||||
/* Insecure WebSockets do not work over HTTPS, so we force
|
||||
* secure ones. */
|
||||
return 'wss://';
|
||||
} else {
|
||||
/* Use the default provided by Emscripten. */
|
||||
return null;
|
||||
}
|
||||
} };
|
||||
|
||||
Module.preRun.push(function() {
|
||||
@@ -65,10 +73,14 @@ Module.preRun.push(function() {
|
||||
}
|
||||
|
||||
window.openttd_server_list = function() {
|
||||
add_server = Module.cwrap("em_openttd_add_server", null, ["string", "number"]);
|
||||
add_server = Module.cwrap("em_openttd_add_server", null, ["string"]);
|
||||
|
||||
/* Add servers that support WebSocket here. Example:
|
||||
* add_server("localhost", 3979); */
|
||||
/* Add servers that support WebSocket here. Examples:
|
||||
* add_server("localhost");
|
||||
* add_server("localhost:3979");
|
||||
* add_server("127.0.0.1:3979");
|
||||
* add_server("[::1]:3979");
|
||||
*/
|
||||
}
|
||||
|
||||
var leftButtonDown = false;
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
z-index: 2;
|
||||
/* OpenTTD draws the cursor itself */
|
||||
cursor: none !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
@echo off
|
||||
REM Signing script
|
||||
REM Arguments: sign.bat exe_to_sign certificate_subject_name
|
||||
|
||||
REM This is a loose wrapper around the Microsoft signtool application (included in the Windows SDK).
|
||||
REM See https://docs.microsoft.com/en-us/dotnet/framework/tools/signtool-exe for more details.
|
||||
|
||||
REM Path to signtool.exe
|
||||
IF NOT DEFINED SIGNTOOL_PATH (SET SIGNTOOL_PATH=signtool)
|
||||
|
||||
REM URL of the timestamp server
|
||||
IF NOT DEFINED SIGNTOOL_TIMESTAMP_URL (SET SIGNTOOL_TIMESTAMP_URL=http://timestamp.digicert.com)
|
||||
|
||||
REM Sign with SHA-1 for Windows 7 and below
|
||||
"%SIGNTOOL_PATH%" sign -v -n %2 -t %SIGNTOOL_TIMESTAMP_URL% %1
|
||||
|
||||
REM Sign with SHA-256 for Windows 8 and above
|
||||
"%SIGNTOOL_PATH%" sign -v -n %2 -tr %SIGNTOOL_TIMESTAMP_URL% -fd sha256 -td sha256 -as %1
|
||||
@@ -4,9 +4,10 @@ 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 "1.11"; }
|
||||
function GetAPIVersion() { return "12"; }
|
||||
function GetDate() { return "2007-03-18"; }
|
||||
function CreateInstance() { return "Regression"; }
|
||||
function UseAsRandomAI() { return false; }
|
||||
}
|
||||
|
||||
RegisterAI(Regression());
|
||||
|
||||
@@ -4,9 +4,10 @@ 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 "1.11"; }
|
||||
function GetAPIVersion() { return "12"; }
|
||||
function GetDate() { return "2007-03-18"; }
|
||||
function CreateInstance() { return "StationList"; }
|
||||
function UseAsRandomAI() { return false; }
|
||||
}
|
||||
|
||||
RegisterAI(StationList());
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
add_subdirectory(fmt)
|
||||
add_subdirectory(md5)
|
||||
add_subdirectory(squirrel)
|
||||
add_subdirectory(opengl)
|
||||
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
add_files(
|
||||
core.h
|
||||
format.h
|
||||
format-inl.h
|
||||
)
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2012 - present, Victor Zverovich
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
--- Optional exception to the license ---
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into a machine-executable object form of such
|
||||
source code, you may redistribute such embedded portions in such object form
|
||||
without including the above copyright and permission notices.
|
||||
Vendored
+2122
File diff suppressed because it is too large
Load Diff
Vendored
+2801
File diff suppressed because it is too large
Load Diff
Vendored
+3960
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -17,7 +17,7 @@ void sqstd_printcallstack(HSQUIRRELVM v)
|
||||
SQFloat f;
|
||||
const SQChar *s;
|
||||
SQInteger level=1; //1 is to skip this function that is level 0
|
||||
const SQChar *name=0;
|
||||
const SQChar *name=nullptr;
|
||||
SQInteger seq=0;
|
||||
pf(v,"\nCALLSTACK\n");
|
||||
while(SQ_SUCCEEDED(sq_stackinfos(v,level,&si)))
|
||||
@@ -116,7 +116,7 @@ static SQInteger _sqstd_aux_printerror(HSQUIRRELVM v)
|
||||
{
|
||||
SQPRINTFUNCTION pf = sq_getprintfunc(v);
|
||||
if(pf) {
|
||||
const SQChar *sErr = 0;
|
||||
const SQChar *sErr = nullptr;
|
||||
if(sq_gettop(v)>=1) {
|
||||
if(SQ_SUCCEEDED(sq_getstring(v,2,&sErr))) {
|
||||
pf(v,"\nAN ERROR HAS OCCURRED [%s]\n",sErr);
|
||||
|
||||
+2
-2
@@ -88,7 +88,7 @@ static SQRegFunction mathlib_funcs[] = {
|
||||
#endif /* EXPORT_DEFAULT_SQUIRREL_FUNCTIONS */
|
||||
_DECL_FUNC(fabs,2,".n"),
|
||||
_DECL_FUNC(abs,2,".n"),
|
||||
{0,0,0,0},
|
||||
{nullptr,nullptr,0,nullptr},
|
||||
};
|
||||
|
||||
#ifndef M_PI
|
||||
@@ -98,7 +98,7 @@ static SQRegFunction mathlib_funcs[] = {
|
||||
SQRESULT sqstd_register_mathlib(HSQUIRRELVM v)
|
||||
{
|
||||
SQInteger i=0;
|
||||
while(mathlib_funcs[i].name!=0) {
|
||||
while(mathlib_funcs[i].name!=nullptr) {
|
||||
sq_pushstring(v,mathlib_funcs[i].name,-1);
|
||||
sq_newclosure(v,mathlib_funcs[i].f,0);
|
||||
sq_setparamscheck(v,mathlib_funcs[i].nparamscheck,mathlib_funcs[i].typemask);
|
||||
|
||||
+29
-29
@@ -60,11 +60,11 @@ HSQUIRRELVM sq_open(SQInteger initialstacksize)
|
||||
v = (SQVM *)SQ_MALLOC(sizeof(SQVM));
|
||||
new (v) SQVM(ss);
|
||||
ss->_root_vm = v;
|
||||
if(v->Init(NULL, initialstacksize)) {
|
||||
if(v->Init(nullptr, initialstacksize)) {
|
||||
return v;
|
||||
} else {
|
||||
sq_delete(v, SQVM);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize)
|
||||
return v;
|
||||
} else {
|
||||
sq_delete(v, SQVM);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void sq_close(HSQUIRRELVM v)
|
||||
SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror)
|
||||
{
|
||||
SQObjectPtr o;
|
||||
if(Compile(v, read, p, sourcename, o, raiseerror?true:false, _ss(v)->_debuginfo)) {
|
||||
if(Compile(v, read, p, sourcename, o, raiseerror != 0, _ss(v)->_debuginfo)) {
|
||||
v->Push(SQClosure::Create(_ss(v), _funcproto(o)));
|
||||
return SQ_OK;
|
||||
}
|
||||
@@ -144,12 +144,12 @@ SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQCha
|
||||
|
||||
void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable)
|
||||
{
|
||||
_ss(v)->_debuginfo = enable?true:false;
|
||||
_ss(v)->_debuginfo = enable != 0;
|
||||
}
|
||||
|
||||
void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable)
|
||||
{
|
||||
_ss(v)->_notifyallexceptions = enable?true:false;
|
||||
_ss(v)->_notifyallexceptions = enable != 0;
|
||||
}
|
||||
|
||||
void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
|
||||
@@ -178,7 +178,7 @@ const SQChar *sq_objtostring(HSQOBJECT *o)
|
||||
if(sq_type(*o) == OT_STRING) {
|
||||
return _stringval(*o);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SQInteger sq_objtointeger(HSQOBJECT *o)
|
||||
@@ -224,7 +224,7 @@ void sq_pushinteger(HSQUIRRELVM v,SQInteger n)
|
||||
|
||||
void sq_pushbool(HSQUIRRELVM v,SQBool b)
|
||||
{
|
||||
v->Push(b?true:false);
|
||||
v->Push(b != 0);
|
||||
}
|
||||
|
||||
void sq_pushfloat(HSQUIRRELVM v,SQFloat n)
|
||||
@@ -256,7 +256,7 @@ void sq_newarray(HSQUIRRELVM v,SQInteger size)
|
||||
|
||||
SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase)
|
||||
{
|
||||
SQClass *baseclass = NULL;
|
||||
SQClass *baseclass = nullptr;
|
||||
if(hasbase) {
|
||||
SQObjectPtr &base = stack_get(v,-1);
|
||||
if(type(base) != OT_CLASS)
|
||||
@@ -555,7 +555,7 @@ SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b)
|
||||
|
||||
SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_STRING,o);
|
||||
*c = _stringval(*o);
|
||||
return SQ_OK;
|
||||
@@ -563,7 +563,7 @@ SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c)
|
||||
|
||||
SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_THREAD,o);
|
||||
*thread = _thread(*o);
|
||||
return SQ_OK;
|
||||
@@ -598,7 +598,7 @@ SQInteger sq_getsize(HSQUIRRELVM v, SQInteger idx)
|
||||
|
||||
SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_USERDATA,o);
|
||||
(*p) = _userdataval(*o);
|
||||
if(typetag) *typetag = _userdata(*o)->_typetag;
|
||||
@@ -637,7 +637,7 @@ SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag)
|
||||
|
||||
SQRESULT sq_getuserpointer(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_USERPOINTER,o);
|
||||
(*p) = _userpointer(*o);
|
||||
return SQ_OK;
|
||||
@@ -666,13 +666,13 @@ SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserP
|
||||
SQObjectPtr &o = stack_get(v,idx);
|
||||
if(type(o) != OT_INSTANCE) return sq_throwerror(v,"the object is not a class instance");
|
||||
(*p) = _instance(o)->_userpointer;
|
||||
if(typetag != 0) {
|
||||
if(typetag != nullptr) {
|
||||
SQClass *cl = _instance(o)->_class;
|
||||
do{
|
||||
if(cl->_typetag == typetag)
|
||||
return SQ_OK;
|
||||
cl = cl->_base;
|
||||
}while(cl != NULL);
|
||||
}while(cl != nullptr);
|
||||
return sq_throwerror(v,"invalid type tag");
|
||||
}
|
||||
return SQ_OK;
|
||||
@@ -724,7 +724,7 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
|
||||
if(type(self) == OT_TABLE || type(self) == OT_CLASS) {
|
||||
SQObjectPtr &key = v->GetUp(-2);
|
||||
if(type(key) == OT_NULL) return sq_throwerror(v, "null is not a valid key");
|
||||
v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
|
||||
v->NewSlot(self, key, v->GetUp(-1),bstatic != 0);
|
||||
v->Pop(2);
|
||||
}
|
||||
return SQ_OK;
|
||||
@@ -801,14 +801,14 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx)
|
||||
if(!_table(self)->SetDelegate(_table(mt))) return sq_throwerror(v, "delagate cycle");
|
||||
v->Pop();}
|
||||
else if(type(mt)==OT_NULL) {
|
||||
_table(self)->SetDelegate(NULL); v->Pop(); }
|
||||
_table(self)->SetDelegate(nullptr); v->Pop(); }
|
||||
else return sq_aux_invalidtype(v,type);
|
||||
break;
|
||||
case OT_USERDATA:
|
||||
if(type(mt)==OT_TABLE) {
|
||||
_userdata(self)->SetDelegate(_table(mt)); v->Pop(); }
|
||||
else if(type(mt)==OT_NULL) {
|
||||
_userdata(self)->SetDelegate(NULL); v->Pop(); }
|
||||
_userdata(self)->SetDelegate(nullptr); v->Pop(); }
|
||||
else return sq_aux_invalidtype(v, type);
|
||||
break;
|
||||
default:
|
||||
@@ -909,7 +909,7 @@ const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedIntege
|
||||
}
|
||||
SQVM::CallInfo &ci=v->_callsstack[lvl];
|
||||
if(type(ci._closure)!=OT_CLOSURE)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
SQClosure *c=_closure(ci._closure);
|
||||
SQFunctionProto *func=_funcproto(c->_function);
|
||||
if(func->_noutervalues > (SQInteger)idx) {
|
||||
@@ -919,7 +919,7 @@ const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedIntege
|
||||
idx -= func->_noutervalues;
|
||||
return func->GetLocal(v,stackbase,idx,(SQInteger)(ci._ip-func->_instructions)-1);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj)
|
||||
@@ -929,7 +929,7 @@ void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj)
|
||||
|
||||
void sq_resetobject(HSQOBJECT *po)
|
||||
{
|
||||
po->_unVal.pUserPointer=NULL;po->_type=OT_NULL;
|
||||
po->_unVal.pUserPointer=nullptr;po->_type=OT_NULL;
|
||||
}
|
||||
|
||||
SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err)
|
||||
@@ -975,7 +975,7 @@ SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror,
|
||||
v->_can_suspend = suspend >= 0;
|
||||
if (v->_can_suspend) v->_ops_till_suspend = suspend;
|
||||
|
||||
if(v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror?true:false,v->_can_suspend)){
|
||||
if(v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror != 0,v->_can_suspend)){
|
||||
if(!v->_suspended) {
|
||||
v->Pop(params);//pop closure and args
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f)
|
||||
|
||||
SQRESULT sq_writeclosure(HSQUIRRELVM v,SQWRITEFUNC w,SQUserPointer up)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, -1, OT_CLOSURE,o);
|
||||
unsigned short tag = SQ_BYTECODE_STREAM_TAG;
|
||||
if(w(up,&tag,2) != 2)
|
||||
@@ -1093,7 +1093,7 @@ SQInteger sq_collectgarbage(HSQUIRRELVM v)
|
||||
const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
|
||||
{
|
||||
SQObjectPtr &self = stack_get(v,idx);
|
||||
const SQChar *name = NULL;
|
||||
const SQChar *name = nullptr;
|
||||
if(type(self) == OT_CLOSURE) {
|
||||
if(_closure(self)->_outervalues.size()>nval) {
|
||||
v->Push(_closure(self)->_outervalues[nval]);
|
||||
@@ -1131,7 +1131,7 @@ SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
|
||||
|
||||
SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
|
||||
SQObjectPtr &key = stack_get(v,-2);
|
||||
SQObjectPtr &val = stack_get(v,-1);
|
||||
@@ -1153,7 +1153,7 @@ SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx)
|
||||
|
||||
SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
|
||||
SQObjectPtr &key = stack_get(v,-1);
|
||||
SQObjectPtr attrs;
|
||||
@@ -1173,7 +1173,7 @@ SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
|
||||
|
||||
SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
|
||||
if(_class(*o)->_base)
|
||||
v->Push(SQObjectPtr(_class(*o)->_base));
|
||||
@@ -1184,7 +1184,7 @@ SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx)
|
||||
|
||||
SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_INSTANCE,o);
|
||||
v->Push(SQObjectPtr(_instance(*o)->_class));
|
||||
return SQ_OK;
|
||||
@@ -1192,7 +1192,7 @@ SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx)
|
||||
|
||||
SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx)
|
||||
{
|
||||
SQObjectPtr *o = NULL;
|
||||
SQObjectPtr *o = nullptr;
|
||||
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
|
||||
v->Push(_class(*o)->CreateInstance());
|
||||
return SQ_OK;
|
||||
|
||||
+8
-4
@@ -17,9 +17,9 @@ public:
|
||||
return newarray;
|
||||
}
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue) override;
|
||||
#endif
|
||||
void Finalize(){
|
||||
void Finalize() override {
|
||||
_values.resize(0);
|
||||
}
|
||||
bool Get(const SQInteger nidx,SQObjectPtr &val)
|
||||
@@ -78,9 +78,13 @@ public:
|
||||
ShrinkIfNeeded();
|
||||
return true;
|
||||
}
|
||||
void Release()
|
||||
void Release() override
|
||||
{
|
||||
sq_delete(this,SQArray);
|
||||
this->_sharedstate->DelayFinalFree(this);
|
||||
}
|
||||
void FinalFree() override
|
||||
{
|
||||
sq_delete(this, SQArray);
|
||||
}
|
||||
SQObjectPtrVec _values;
|
||||
};
|
||||
|
||||
+25
-25
@@ -248,29 +248,29 @@ static SQRegFunction base_funcs[]={
|
||||
{"getconsttable",base_getconsttable,1, NULL},
|
||||
{"setconsttable",base_setconsttable,2, NULL},
|
||||
#endif
|
||||
{"assert",base_assert,2, NULL},
|
||||
{"print",base_print,2, NULL},
|
||||
{"assert",base_assert,2, nullptr},
|
||||
{"print",base_print,2, nullptr},
|
||||
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
|
||||
{"compilestring",base_compilestring,-2, ".ss"},
|
||||
{"newthread",base_newthread,2, ".c"},
|
||||
{"suspend",base_suspend,-1, NULL},
|
||||
#endif
|
||||
{"array",base_array,-2, ".n"},
|
||||
{"type",base_type,2, NULL},
|
||||
{"type",base_type,2, nullptr},
|
||||
#ifdef EXPORT_DEFAULT_SQUIRREL_FUNCTIONS
|
||||
{"dummy",base_dummy,0,NULL},
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
{"collectgarbage",base_collectgarbage,1, "t"},
|
||||
#endif
|
||||
#endif
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
void sq_base_register(HSQUIRRELVM v)
|
||||
{
|
||||
SQInteger i=0;
|
||||
sq_pushroottable(v);
|
||||
while(base_funcs[i].name!=0) {
|
||||
while(base_funcs[i].name!=nullptr) {
|
||||
sq_pushstring(v,base_funcs[i].name,-1);
|
||||
sq_newclosure(v,base_funcs[i].f,0);
|
||||
sq_setnativeclosurename(v,-1,base_funcs[i].name);
|
||||
@@ -415,10 +415,10 @@ SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
|
||||
{"rawset",table_rawset,3, "t"},
|
||||
{"rawdelete",table_rawdelete,2, "t"},
|
||||
{"rawin",container_rawexists,2, "t"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{"clear",obj_clear,1, "."},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
//ARRAY DEFAULT DELEGATE///////////////////////////////////////
|
||||
@@ -624,10 +624,10 @@ SQRegFunction SQSharedState::_array_default_delegate_funcz[]={
|
||||
{"reverse",array_reverse,1, "a"},
|
||||
{"sort",array_sort,-1, "ac"},
|
||||
{"slice",array_slice,-1, "ann"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{"clear",obj_clear,1, "."},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
//STRING DEFAULT DELEGATE//////////////////////////
|
||||
@@ -687,8 +687,8 @@ SQRegFunction SQSharedState::_string_default_delegate_funcz[]={
|
||||
{"find",string_find,-2, "s s n "},
|
||||
{"tolower",string_tolower,1, "s"},
|
||||
{"toupper",string_toupper,1, "s"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{0,0,0,0}
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
//INTEGER DEFAULT DELEGATE//////////////////////////
|
||||
@@ -697,8 +697,8 @@ SQRegFunction SQSharedState::_number_default_delegate_funcz[]={
|
||||
{"tofloat",default_delegate_tofloat,1, "n|b"},
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{"tochar",number_delegate_tochar,1, "n|b"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{0,0,0,0}
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
//CLOSURE DEFAULT DELEGATE//////////////////////////
|
||||
@@ -782,11 +782,11 @@ SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={
|
||||
{"pcall",closure_pcall,-1, "c"},
|
||||
{"acall",closure_acall,2, "ca"},
|
||||
{"pacall",closure_pacall,2, "ca"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{"bindenv",closure_bindenv,2, "c x|y|t"},
|
||||
{"getinfos",closure_getinfos,1, "c"},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
//GENERATOR DEFAULT DELEGATE
|
||||
@@ -803,9 +803,9 @@ static SQInteger generator_getstatus(HSQUIRRELVM v)
|
||||
|
||||
SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
|
||||
{"getstatus",generator_getstatus,1, "g"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
//THREAD DEFAULT DELEGATE
|
||||
@@ -889,9 +889,9 @@ SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = {
|
||||
{"call", thread_call, -1, "v"},
|
||||
{"wakeup", thread_wakeup, -1, "v"},
|
||||
{"getstatus", thread_getstatus, 1, "v"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{0,0,0,0},
|
||||
{nullptr,nullptr,0,nullptr},
|
||||
};
|
||||
|
||||
static SQInteger class_getattributes(HSQUIRRELVM v)
|
||||
@@ -919,10 +919,10 @@ SQRegFunction SQSharedState::_class_default_delegate_funcz[] = {
|
||||
{"getattributes", class_getattributes, 2, "y."},
|
||||
{"setattributes", class_setattributes, 3, "y.."},
|
||||
{"rawin",container_rawexists,2, "y"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{"instance",class_instance,1, "y"},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
static SQInteger instance_getclass(HSQUIRRELVM v)
|
||||
@@ -935,9 +935,9 @@ static SQInteger instance_getclass(HSQUIRRELVM v)
|
||||
SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = {
|
||||
{"getclass", instance_getclass, 1, "x"},
|
||||
{"rawin",container_rawexists,2, "x"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
static SQInteger weakref_ref(HSQUIRRELVM v)
|
||||
@@ -949,9 +949,9 @@ static SQInteger weakref_ref(HSQUIRRELVM v)
|
||||
|
||||
SQRegFunction SQSharedState::_weakref_default_delegate_funcz[] = {
|
||||
{"ref",weakref_ref,1, "r"},
|
||||
{"weakref",obj_delegate_weakref,1, NULL },
|
||||
{"weakref",obj_delegate_weakref,1, nullptr },
|
||||
{"tostring",default_delegate_tostring,1, "."},
|
||||
{0,0,0,0}
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+12
-6
@@ -15,8 +15,8 @@
|
||||
SQClass::SQClass(SQSharedState *ss,SQClass *base)
|
||||
{
|
||||
_base = base;
|
||||
_typetag = 0;
|
||||
_hook = NULL;
|
||||
_typetag = nullptr;
|
||||
_hook = nullptr;
|
||||
_udsize = 0;
|
||||
_metamethods.resize(MT_LAST); //size it to max size
|
||||
if(_base) {
|
||||
@@ -34,7 +34,13 @@ SQClass::SQClass(SQSharedState *ss,SQClass *base)
|
||||
|
||||
void SQClass::Finalize() {
|
||||
_attributes = _null_;
|
||||
_defaultvalues.resize(0);
|
||||
/* SQInstance's Finalize depends on the size of this sqvector, so instead of
|
||||
* resizing, all SQObjectPtrs are set to "null" so it holds no references to
|
||||
* other objects anymore. That way everything gets released properly. */
|
||||
for (SQUnsignedInteger i = 0; i < _defaultvalues.size(); i++) {
|
||||
_defaultvalues[i].val = _null_;
|
||||
_defaultvalues[i].attrs = _null_;
|
||||
}
|
||||
_methods.resize(0);
|
||||
_metamethods.resize(0);
|
||||
__ObjRelease(_members);
|
||||
@@ -133,8 +139,8 @@ bool SQClass::GetAttributes(const SQObjectPtr &key,SQObjectPtr &outval)
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
void SQInstance::Init(SQSharedState *ss)
|
||||
{
|
||||
_userpointer = NULL;
|
||||
_hook = NULL;
|
||||
_userpointer = nullptr;
|
||||
_hook = nullptr;
|
||||
__ObjAddRef(_class);
|
||||
_delegate = _class->_members;
|
||||
INIT_CHAIN();
|
||||
@@ -190,7 +196,7 @@ bool SQInstance::GetMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res)
|
||||
bool SQInstance::InstanceOf(SQClass *trg)
|
||||
{
|
||||
SQClass *parent = _class;
|
||||
while(parent != NULL) {
|
||||
while(parent != nullptr) {
|
||||
if(parent == trg)
|
||||
return true;
|
||||
parent = parent->_base;
|
||||
|
||||
+10
-8
@@ -59,7 +59,7 @@ public:
|
||||
}
|
||||
void Finalize();
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable ** );
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue);
|
||||
#endif
|
||||
SQInteger Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
|
||||
SQInstance *CreateInstance();
|
||||
@@ -126,31 +126,33 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void Release() {
|
||||
void Release() override {
|
||||
_uiRef++;
|
||||
try {
|
||||
if (_hook) { _hook(_userpointer,0);}
|
||||
} catch (...) {
|
||||
_uiRef--;
|
||||
if (_uiRef == 0) {
|
||||
SQInteger size = _memsize;
|
||||
this->~SQInstance();
|
||||
SQ_FREE(this, size);
|
||||
this->_sharedstate->DelayFinalFree(this);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
_uiRef--;
|
||||
if(_uiRef > 0) return;
|
||||
this->_sharedstate->DelayFinalFree(this);
|
||||
}
|
||||
void FinalFree() override
|
||||
{
|
||||
SQInteger size = _memsize;
|
||||
this->~SQInstance();
|
||||
SQ_FREE(this, size);
|
||||
}
|
||||
void Finalize();
|
||||
void Finalize() override;
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable ** );
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue) override;
|
||||
#endif
|
||||
bool InstanceOf(SQClass *trg);
|
||||
bool GetMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res);
|
||||
bool GetMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res) override;
|
||||
|
||||
SQClass *_class;
|
||||
SQUserPointer _userpointer;
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ public:
|
||||
bool Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
|
||||
static bool Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue);
|
||||
void Finalize(){_outervalues.resize(0); }
|
||||
#endif
|
||||
SQObjectPtr _env;
|
||||
@@ -45,7 +45,7 @@ struct SQGenerator : public CHAINABLE_OBJ
|
||||
{
|
||||
enum SQGeneratorState{eRunning,eSuspended,eDead};
|
||||
private:
|
||||
SQGenerator(SQSharedState *ss,SQClosure *closure){_closure=closure;_state=eRunning;_ci._generator=NULL;INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);}
|
||||
SQGenerator(SQSharedState *ss,SQClosure *closure){_closure=closure;_state=eRunning;_ci._generator=nullptr;INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);}
|
||||
public:
|
||||
static SQGenerator *Create(SQSharedState *ss,SQClosure *closure){
|
||||
SQGenerator *nc=(SQGenerator*)SQ_MALLOC(sizeof(SQGenerator));
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
bool Yield(SQVM *v);
|
||||
bool Resume(SQVM *v,SQInteger target);
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue);
|
||||
void Finalize(){_stack.resize(0);_closure=_null_;}
|
||||
#endif
|
||||
SQObjectPtr _closure;
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
sq_delete(this,SQNativeClosure);
|
||||
}
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue);
|
||||
void Finalize(){_outervalues.resize(0);}
|
||||
#endif
|
||||
SQInteger _nparamscheck;
|
||||
|
||||
+3
-3
@@ -57,7 +57,7 @@ typedef sqvector<ExpState> ExpStateVec;
|
||||
class SQCompiler
|
||||
{
|
||||
public:
|
||||
SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) : _token(0), _fs(NULL), _lex(_ss(v), rg, up, ThrowError, this), _debugline(0), _debugop(0)
|
||||
SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) : _token(0), _fs(nullptr), _lex(_ss(v), rg, up, ThrowError, this), _debugline(0), _debugop(0)
|
||||
{
|
||||
_vm=v;
|
||||
_sourcename = SQString::Create(_ss(v), sourcename);
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
_debugline = 1;
|
||||
_debugop = 0;
|
||||
|
||||
SQFuncState funcstate(_ss(_vm), NULL,ThrowError,this);
|
||||
SQFuncState funcstate(_ss(_vm), nullptr,ThrowError,this);
|
||||
funcstate._name = SQString::Create(_ss(_vm), "main");
|
||||
_fs = &funcstate;
|
||||
_fs->AddParameter(_fs->CreateString("this"));
|
||||
@@ -835,7 +835,7 @@ public:
|
||||
nkeys++;
|
||||
SQInteger val = _fs->PopTarget();
|
||||
SQInteger key = _fs->PopTarget();
|
||||
SQInteger attrs = hasattrs ? _fs->PopTarget():-1;
|
||||
[[maybe_unused]] SQInteger attrs = hasattrs ? _fs->PopTarget():-1;
|
||||
assert((hasattrs && attrs == key-1) || !hasattrs);
|
||||
unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0);
|
||||
SQInteger table = _fs->TopTarget(); //<<BECAUSE OF THIS NO COMMON EMIT FUNC IS POSSIBLE
|
||||
|
||||
+2
-1
@@ -79,7 +79,7 @@ SQInstructionDesc g_InstrDesc[]={
|
||||
{"_OP_NEWSLOTA"},
|
||||
{"_OP_SCOPE_END"}
|
||||
};
|
||||
#endif
|
||||
|
||||
void DumpLiteral(SQObjectPtr &o)
|
||||
{
|
||||
switch(type(o)){
|
||||
@@ -90,6 +90,7 @@ void DumpLiteral(SQObjectPtr &o)
|
||||
default: printf("(%s %p)",GetTypeName(o),(void*)_rawval(o));break; break; //shut up compiler
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed)
|
||||
{
|
||||
|
||||
+2
-2
@@ -87,7 +87,7 @@ SQLexer::SQLexer(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerE
|
||||
_prevtoken = -1;
|
||||
_curtoken = -1;
|
||||
|
||||
_svalue = NULL;
|
||||
_svalue = nullptr;
|
||||
_nvalue = 0;
|
||||
_fvalue = 0;
|
||||
|
||||
@@ -119,7 +119,7 @@ const SQChar *SQLexer::Tok2Str(SQInteger tok)
|
||||
if(((SQInteger)_integer(val)) == tok)
|
||||
return _stringval(key);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SQLexer::LexBlockComment()
|
||||
|
||||
+59
-82
@@ -41,7 +41,7 @@ const SQChar *IdType2Name(SQObjectType type)
|
||||
case _RT_INSTANCE: return "instance";
|
||||
case _RT_WEAKREF: return "weakref";
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,13 +101,13 @@ SQRefCounted::~SQRefCounted()
|
||||
{
|
||||
if(_weakref) {
|
||||
_weakref->_obj._type = OT_NULL;
|
||||
_weakref->_obj._unVal.pRefCounted = NULL;
|
||||
_weakref->_obj._unVal.pRefCounted = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SQWeakRef::Release() {
|
||||
if(ISREFCOUNTED(_obj._type)) {
|
||||
_obj._unVal.pRefCounted->_weakref = NULL;
|
||||
_obj._unVal.pRefCounted->_weakref = nullptr;
|
||||
}
|
||||
sq_delete(this,SQWeakRef);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ bool SQGenerator::Yield(SQVM *v)
|
||||
for(SQInteger j = nvargs - 1; j >= 0; j--) {
|
||||
_vargsstack.push_back(v->_vargsstack[vargsbase+j]);
|
||||
}
|
||||
_ci._generator=NULL;
|
||||
_ci._generator=nullptr;
|
||||
for(SQInteger i=0;i<_ci._etraps;i++) {
|
||||
_etraps.push_back(v->_etraps.top());
|
||||
v->_etraps.pop_back();
|
||||
@@ -204,7 +204,7 @@ void SQArray::Extend(const SQArray *a){
|
||||
const SQChar* SQFunctionProto::GetLocal(SQVM *vm,SQUnsignedInteger stackbase,SQUnsignedInteger nseq,SQUnsignedInteger nop)
|
||||
{
|
||||
SQUnsignedInteger nvars=_nlocalvarinfos;
|
||||
const SQChar *res=NULL;
|
||||
const SQChar *res=nullptr;
|
||||
if(nvars>=nseq){
|
||||
for(SQUnsignedInteger i=0;i<nvars;i++){
|
||||
if(_localvarinfos[i]._start_op<=nop && _localvarinfos[i]._end_op>=nop)
|
||||
@@ -486,104 +486,81 @@ bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr
|
||||
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
|
||||
#define START_MARK() if(!(_uiRef&MARK_FLAG)){ \
|
||||
_uiRef|=MARK_FLAG;
|
||||
|
||||
#define END_MARK() RemoveFromChain(&_sharedstate->_gc_chain, this); \
|
||||
AddToChain(chain, this); }
|
||||
|
||||
void SQVM::Mark(SQCollectable **chain)
|
||||
void SQVM::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
SQSharedState::MarkObject(_lasterror,chain);
|
||||
SQSharedState::MarkObject(_errorhandler,chain);
|
||||
SQSharedState::MarkObject(_debughook,chain);
|
||||
SQSharedState::MarkObject(_roottable, chain);
|
||||
SQSharedState::MarkObject(temp_reg, chain);
|
||||
for(SQUnsignedInteger i = 0; i < _stack.size(); i++) SQSharedState::MarkObject(_stack[i], chain);
|
||||
for(SQUnsignedInteger j = 0; j < _vargsstack.size(); j++) SQSharedState::MarkObject(_vargsstack[j], chain);
|
||||
for(SQInteger k = 0; k < _callsstacksize; k++) SQSharedState::MarkObject(_callsstack[k]._closure, chain);
|
||||
END_MARK()
|
||||
SQSharedState::EnqueueMarkObject(_lasterror,queue);
|
||||
SQSharedState::EnqueueMarkObject(_errorhandler,queue);
|
||||
SQSharedState::EnqueueMarkObject(_debughook,queue);
|
||||
SQSharedState::EnqueueMarkObject(_roottable, queue);
|
||||
SQSharedState::EnqueueMarkObject(temp_reg, queue);
|
||||
for(SQUnsignedInteger i = 0; i < _stack.size(); i++) SQSharedState::EnqueueMarkObject(_stack[i], queue);
|
||||
for(SQUnsignedInteger j = 0; j < _vargsstack.size(); j++) SQSharedState::EnqueueMarkObject(_vargsstack[j], queue);
|
||||
for(SQInteger k = 0; k < _callsstacksize; k++) SQSharedState::EnqueueMarkObject(_callsstack[k]._closure, queue);
|
||||
}
|
||||
|
||||
void SQArray::Mark(SQCollectable **chain)
|
||||
void SQArray::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
SQInteger len = _values.size();
|
||||
for(SQInteger i = 0;i < len; i++) SQSharedState::MarkObject(_values[i], chain);
|
||||
END_MARK()
|
||||
}
|
||||
void SQTable::Mark(SQCollectable **chain)
|
||||
{
|
||||
START_MARK()
|
||||
if(_delegate) _delegate->Mark(chain);
|
||||
SQInteger len = _numofnodes;
|
||||
for(SQInteger i = 0; i < len; i++){
|
||||
SQSharedState::MarkObject(_nodes[i].key, chain);
|
||||
SQSharedState::MarkObject(_nodes[i].val, chain);
|
||||
}
|
||||
END_MARK()
|
||||
SQInteger len = _values.size();
|
||||
for(SQInteger i = 0;i < len; i++) SQSharedState::EnqueueMarkObject(_values[i], queue);
|
||||
}
|
||||
|
||||
void SQClass::Mark(SQCollectable **chain)
|
||||
void SQTable::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
_members->Mark(chain);
|
||||
if(_base) _base->Mark(chain);
|
||||
SQSharedState::MarkObject(_attributes, chain);
|
||||
for(SQUnsignedInteger i =0; i< _defaultvalues.size(); i++) {
|
||||
SQSharedState::MarkObject(_defaultvalues[i].val, chain);
|
||||
SQSharedState::MarkObject(_defaultvalues[i].attrs, chain);
|
||||
}
|
||||
for(SQUnsignedInteger j =0; j< _methods.size(); j++) {
|
||||
SQSharedState::MarkObject(_methods[j].val, chain);
|
||||
SQSharedState::MarkObject(_methods[j].attrs, chain);
|
||||
}
|
||||
for(SQUnsignedInteger k =0; k< _metamethods.size(); k++) {
|
||||
SQSharedState::MarkObject(_metamethods[k], chain);
|
||||
}
|
||||
END_MARK()
|
||||
if(_delegate) queue.Enqueue(_delegate);
|
||||
SQInteger len = _numofnodes;
|
||||
for(SQInteger i = 0; i < len; i++){
|
||||
SQSharedState::EnqueueMarkObject(_nodes[i].key, queue);
|
||||
SQSharedState::EnqueueMarkObject(_nodes[i].val, queue);
|
||||
}
|
||||
}
|
||||
|
||||
void SQInstance::Mark(SQCollectable **chain)
|
||||
void SQClass::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
_class->Mark(chain);
|
||||
SQUnsignedInteger nvalues = _class->_defaultvalues.size();
|
||||
for(SQUnsignedInteger i =0; i< nvalues; i++) {
|
||||
SQSharedState::MarkObject(_values[i], chain);
|
||||
}
|
||||
END_MARK()
|
||||
queue.Enqueue(_members);
|
||||
if(_base) queue.Enqueue(_base);
|
||||
SQSharedState::EnqueueMarkObject(_attributes, queue);
|
||||
for(SQUnsignedInteger i =0; i< _defaultvalues.size(); i++) {
|
||||
SQSharedState::EnqueueMarkObject(_defaultvalues[i].val, queue);
|
||||
SQSharedState::EnqueueMarkObject(_defaultvalues[i].attrs, queue);
|
||||
}
|
||||
for(SQUnsignedInteger j =0; j< _methods.size(); j++) {
|
||||
SQSharedState::EnqueueMarkObject(_methods[j].val, queue);
|
||||
SQSharedState::EnqueueMarkObject(_methods[j].attrs, queue);
|
||||
}
|
||||
for(SQUnsignedInteger k =0; k< _metamethods.size(); k++) {
|
||||
SQSharedState::EnqueueMarkObject(_metamethods[k], queue);
|
||||
}
|
||||
}
|
||||
|
||||
void SQGenerator::Mark(SQCollectable **chain)
|
||||
void SQInstance::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
for(SQUnsignedInteger i = 0; i < _stack.size(); i++) SQSharedState::MarkObject(_stack[i], chain);
|
||||
for(SQUnsignedInteger j = 0; j < _vargsstack.size(); j++) SQSharedState::MarkObject(_vargsstack[j], chain);
|
||||
SQSharedState::MarkObject(_closure, chain);
|
||||
END_MARK()
|
||||
queue.Enqueue(_class);
|
||||
SQUnsignedInteger nvalues = _class->_defaultvalues.size();
|
||||
for(SQUnsignedInteger i =0; i< nvalues; i++) {
|
||||
SQSharedState::EnqueueMarkObject(_values[i], queue);
|
||||
}
|
||||
}
|
||||
|
||||
void SQClosure::Mark(SQCollectable **chain)
|
||||
void SQGenerator::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
for(SQUnsignedInteger i = 0; i < _outervalues.size(); i++) SQSharedState::MarkObject(_outervalues[i], chain);
|
||||
for(SQUnsignedInteger i = 0; i < _defaultparams.size(); i++) SQSharedState::MarkObject(_defaultparams[i], chain);
|
||||
END_MARK()
|
||||
for(SQUnsignedInteger i = 0; i < _stack.size(); i++) SQSharedState::EnqueueMarkObject(_stack[i], queue);
|
||||
for(SQUnsignedInteger j = 0; j < _vargsstack.size(); j++) SQSharedState::EnqueueMarkObject(_vargsstack[j], queue);
|
||||
SQSharedState::EnqueueMarkObject(_closure, queue);
|
||||
}
|
||||
|
||||
void SQNativeClosure::Mark(SQCollectable **chain)
|
||||
void SQClosure::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
START_MARK()
|
||||
for(SQUnsignedInteger i = 0; i < _outervalues.size(); i++) SQSharedState::MarkObject(_outervalues[i], chain);
|
||||
END_MARK()
|
||||
for(SQUnsignedInteger i = 0; i < _outervalues.size(); i++) SQSharedState::EnqueueMarkObject(_outervalues[i], queue);
|
||||
for(SQUnsignedInteger i = 0; i < _defaultparams.size(); i++) SQSharedState::EnqueueMarkObject(_defaultparams[i], queue);
|
||||
}
|
||||
|
||||
void SQUserData::Mark(SQCollectable **chain){
|
||||
START_MARK()
|
||||
if(_delegate) _delegate->Mark(chain);
|
||||
END_MARK()
|
||||
void SQNativeClosure::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue)
|
||||
{
|
||||
for(SQUnsignedInteger i = 0; i < _outervalues.size(); i++) SQSharedState::EnqueueMarkObject(_outervalues[i], queue);
|
||||
}
|
||||
|
||||
void SQUserData::EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue){
|
||||
if(_delegate) queue.Enqueue(_delegate);
|
||||
}
|
||||
|
||||
void SQCollectable::UnMark() { _uiRef&=~MARK_FLAG; }
|
||||
|
||||
+48
-4
@@ -2,6 +2,7 @@
|
||||
#ifndef _SQOBJECT_H_
|
||||
#define _SQOBJECT_H_
|
||||
|
||||
#include <vector>
|
||||
#include "squtils.h"
|
||||
|
||||
#define SQ_CLOSURESTREAM_HEAD (('S'<<24)|('Q'<<16)|('I'<<8)|('R'))
|
||||
@@ -55,7 +56,7 @@ enum SQMetaMethod{
|
||||
|
||||
struct SQRefCounted
|
||||
{
|
||||
SQRefCounted() { _uiRef = 0; _weakref = NULL; }
|
||||
SQRefCounted() { _uiRef = 0; _weakref = nullptr; }
|
||||
virtual ~SQRefCounted();
|
||||
SQWeakRef *GetWeakRef(SQObjectType type);
|
||||
SQUnsignedInteger _uiRef;
|
||||
@@ -133,7 +134,7 @@ struct SQObjectPtr : public SQObject
|
||||
{
|
||||
SQ_OBJECT_RAWINIT()
|
||||
_type=OT_NULL;
|
||||
_unVal.pUserPointer=NULL;
|
||||
_unVal.pUserPointer=nullptr;
|
||||
}
|
||||
SQObjectPtr(const SQObjectPtr &o)
|
||||
{
|
||||
@@ -280,7 +281,7 @@ struct SQObjectPtr : public SQObject
|
||||
tOldType = _type;
|
||||
unOldVal = _unVal;
|
||||
_type = OT_NULL;
|
||||
_unVal.pUserPointer = NULL;
|
||||
_unVal.pUserPointer = nullptr;
|
||||
__Release(tOldType,unOldVal);
|
||||
}
|
||||
inline SQObjectPtr& operator=(SQInteger i)
|
||||
@@ -344,11 +345,54 @@ struct SQCollectable : public SQRefCounted {
|
||||
SQCollectable *_prev;
|
||||
SQSharedState *_sharedstate;
|
||||
virtual void Release()=0;
|
||||
virtual void Mark(SQCollectable **chain)=0;
|
||||
virtual void EnqueueMarkObjectForChildren(class SQGCMarkerQueue &queue)=0;
|
||||
void UnMark();
|
||||
virtual void Finalize()=0;
|
||||
static void AddToChain(SQCollectable **chain,SQCollectable *c);
|
||||
static void RemoveFromChain(SQCollectable **chain,SQCollectable *c);
|
||||
|
||||
/**
|
||||
* Helper to perform the final memory freeing of this instance. Since the destructor might
|
||||
* release more objects, this can cause a very deep recursion. As such, the calls to this
|
||||
* are to be done via _sharedstate->DelayFinalFree which ensures the calls to this method
|
||||
* are done in an iterative instead of recursive approach.
|
||||
*/
|
||||
virtual void FinalFree() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper container for state to change the garbage collection from a recursive to an iterative approach.
|
||||
* The iterative approach provides effectively a depth first search approach.
|
||||
*/
|
||||
class SQGCMarkerQueue {
|
||||
std::vector<SQCollectable*> stack; ///< The elements to still process, with the most recent elements at the back.
|
||||
public:
|
||||
/** Whether there are any elements left to process. */
|
||||
bool IsEmpty() { return this->stack.empty(); }
|
||||
|
||||
/**
|
||||
* Remove the most recently added element from the queue.
|
||||
* Removal when the queue is empty results in undefined behaviour.
|
||||
*/
|
||||
SQCollectable *Pop()
|
||||
{
|
||||
SQCollectable *collectable = this->stack.back();
|
||||
this->stack.pop_back();
|
||||
return collectable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a collectable to the queue, but only when it has not been marked yet.
|
||||
* When adding it to the queue, the collectable will be marked, so subsequent calls
|
||||
* will not add it again.
|
||||
*/
|
||||
void Enqueue(SQCollectable *collectable)
|
||||
{
|
||||
if ((collectable->_uiRef & MARK_FLAG) == 0) {
|
||||
collectable->_uiRef |= MARK_FLAG;
|
||||
this->stack.push_back(collectable);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+91
-49
@@ -79,12 +79,12 @@ SQTable *CreateDefaultDelegate(SQSharedState *ss,SQRegFunction *funcz)
|
||||
{
|
||||
SQInteger i=0;
|
||||
SQTable *t=SQTable::Create(ss,0);
|
||||
while(funcz[i].name!=0){
|
||||
while(funcz[i].name!=nullptr){
|
||||
SQNativeClosure *nc = SQNativeClosure::Create(ss,funcz[i].f);
|
||||
nc->_nparamscheck = funcz[i].nparamscheck;
|
||||
nc->_name = SQString::Create(ss,funcz[i].name);
|
||||
if(funcz[i].typemask && !CompileTypemask(nc->_typecheck,funcz[i].typemask))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
t->NewSlot(SQString::Create(ss,funcz[i].name),nc);
|
||||
i++;
|
||||
}
|
||||
@@ -93,14 +93,15 @@ SQTable *CreateDefaultDelegate(SQSharedState *ss,SQRegFunction *funcz)
|
||||
|
||||
SQSharedState::SQSharedState()
|
||||
{
|
||||
_compilererrorhandler = NULL;
|
||||
_printfunc = NULL;
|
||||
_compilererrorhandler = nullptr;
|
||||
_printfunc = nullptr;
|
||||
_debuginfo = false;
|
||||
_notifyallexceptions = false;
|
||||
_scratchpad=NULL;
|
||||
_scratchpad=nullptr;
|
||||
_scratchpadsize=0;
|
||||
_collectable_free_processing = false;
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
_gc_chain=NULL;
|
||||
_gc_chain=nullptr;
|
||||
#endif
|
||||
sq_new(_stringtable,SQStringTable);
|
||||
sq_new(_metamethods,SQObjectPtrVec);
|
||||
@@ -188,7 +189,7 @@ SQSharedState::~SQSharedState()
|
||||
_refs_table.Finalize();
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
SQCollectable *t = _gc_chain;
|
||||
SQCollectable *nx = NULL;
|
||||
SQCollectable *nx = nullptr;
|
||||
if(t) {
|
||||
t->_uiRef++;
|
||||
while(t) {
|
||||
@@ -226,20 +227,48 @@ SQInteger SQSharedState::GetMetaMethodIdxByName(const SQObjectPtr &name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that is to be used instead of calling FinalFree directly on the instance,
|
||||
* so the frees can happen iteratively. This as in the FinalFree the references to any other
|
||||
* objects are released, which can cause those object to be freed yielding a potentially
|
||||
* very deep stack in case of for example a link list.
|
||||
*
|
||||
* This is done internally by a vector onto which the to be freed instances are pushed. When
|
||||
* this is called when not already processing, this method will actually call the FinalFree
|
||||
* function which might cause more elements to end up in the queue which this method then
|
||||
* picks up continueing until it has processed all instances in that queue.
|
||||
* @param collectable The collectable to (eventually) free.
|
||||
*/
|
||||
void SQSharedState::DelayFinalFree(SQCollectable *collectable)
|
||||
{
|
||||
this->_collectable_free_queue.push_back(collectable);
|
||||
|
||||
if (!this->_collectable_free_processing) {
|
||||
this->_collectable_free_processing = true;
|
||||
while (!this->_collectable_free_queue.empty()) {
|
||||
SQCollectable *collectable = this->_collectable_free_queue.back();
|
||||
this->_collectable_free_queue.pop_back();
|
||||
collectable->FinalFree();
|
||||
}
|
||||
this->_collectable_free_processing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
|
||||
void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
|
||||
void SQSharedState::EnqueueMarkObject(SQObjectPtr &o,SQGCMarkerQueue &queue)
|
||||
{
|
||||
switch(type(o)){
|
||||
case OT_TABLE:_table(o)->Mark(chain);break;
|
||||
case OT_ARRAY:_array(o)->Mark(chain);break;
|
||||
case OT_USERDATA:_userdata(o)->Mark(chain);break;
|
||||
case OT_CLOSURE:_closure(o)->Mark(chain);break;
|
||||
case OT_NATIVECLOSURE:_nativeclosure(o)->Mark(chain);break;
|
||||
case OT_GENERATOR:_generator(o)->Mark(chain);break;
|
||||
case OT_THREAD:_thread(o)->Mark(chain);break;
|
||||
case OT_CLASS:_class(o)->Mark(chain);break;
|
||||
case OT_INSTANCE:_instance(o)->Mark(chain);break;
|
||||
case OT_TABLE:queue.Enqueue(_table(o));break;
|
||||
case OT_ARRAY:queue.Enqueue(_array(o));break;
|
||||
case OT_USERDATA:queue.Enqueue(_userdata(o));break;
|
||||
case OT_CLOSURE:queue.Enqueue(_closure(o));break;
|
||||
case OT_NATIVECLOSURE:queue.Enqueue(_nativeclosure(o));break;
|
||||
case OT_GENERATOR:queue.Enqueue(_generator(o));break;
|
||||
case OT_THREAD:queue.Enqueue(_thread(o));break;
|
||||
case OT_CLASS:queue.Enqueue(_class(o));break;
|
||||
case OT_INSTANCE:queue.Enqueue(_instance(o));break;
|
||||
default: break; //shutup compiler
|
||||
}
|
||||
}
|
||||
@@ -248,28 +277,39 @@ void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
|
||||
SQInteger SQSharedState::CollectGarbage(SQVM *vm)
|
||||
{
|
||||
SQInteger n=0;
|
||||
SQCollectable *tchain=NULL;
|
||||
SQVM *vms = _thread(_root_vm);
|
||||
|
||||
vms->Mark(&tchain);
|
||||
SQGCMarkerQueue queue;
|
||||
queue.Enqueue(vms);
|
||||
#ifdef WITH_ASSERT
|
||||
SQInteger x = _table(_thread(_root_vm)->_roottable)->CountUsed();
|
||||
_refs_table.Mark(&tchain);
|
||||
MarkObject(_registry,&tchain);
|
||||
MarkObject(_consts,&tchain);
|
||||
MarkObject(_metamethodsmap,&tchain);
|
||||
MarkObject(_table_default_delegate,&tchain);
|
||||
MarkObject(_array_default_delegate,&tchain);
|
||||
MarkObject(_string_default_delegate,&tchain);
|
||||
MarkObject(_number_default_delegate,&tchain);
|
||||
MarkObject(_generator_default_delegate,&tchain);
|
||||
MarkObject(_thread_default_delegate,&tchain);
|
||||
MarkObject(_closure_default_delegate,&tchain);
|
||||
MarkObject(_class_default_delegate,&tchain);
|
||||
MarkObject(_instance_default_delegate,&tchain);
|
||||
MarkObject(_weakref_default_delegate,&tchain);
|
||||
#endif
|
||||
_refs_table.EnqueueMarkObject(queue);
|
||||
EnqueueMarkObject(_registry,queue);
|
||||
EnqueueMarkObject(_consts,queue);
|
||||
EnqueueMarkObject(_metamethodsmap,queue);
|
||||
EnqueueMarkObject(_table_default_delegate,queue);
|
||||
EnqueueMarkObject(_array_default_delegate,queue);
|
||||
EnqueueMarkObject(_string_default_delegate,queue);
|
||||
EnqueueMarkObject(_number_default_delegate,queue);
|
||||
EnqueueMarkObject(_generator_default_delegate,queue);
|
||||
EnqueueMarkObject(_thread_default_delegate,queue);
|
||||
EnqueueMarkObject(_closure_default_delegate,queue);
|
||||
EnqueueMarkObject(_class_default_delegate,queue);
|
||||
EnqueueMarkObject(_instance_default_delegate,queue);
|
||||
EnqueueMarkObject(_weakref_default_delegate,queue);
|
||||
|
||||
SQCollectable *tchain=nullptr;
|
||||
|
||||
while (!queue.IsEmpty()) {
|
||||
SQCollectable *q = queue.Pop();
|
||||
q->EnqueueMarkObjectForChildren(queue);
|
||||
SQCollectable::RemoveFromChain(&_gc_chain, q);
|
||||
SQCollectable::AddToChain(&tchain, q);
|
||||
}
|
||||
|
||||
SQCollectable *t = _gc_chain;
|
||||
SQCollectable *nx = NULL;
|
||||
SQCollectable *nx = nullptr;
|
||||
if(t) {
|
||||
t->_uiRef++;
|
||||
while(t) {
|
||||
@@ -289,8 +329,10 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
|
||||
t = t->_next;
|
||||
}
|
||||
_gc_chain = tchain;
|
||||
#ifdef WITH_ASSERT
|
||||
SQInteger z = _table(_thread(_root_vm)->_roottable)->CountUsed();
|
||||
assert(z == x);
|
||||
#endif
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
@@ -298,7 +340,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void SQCollectable::AddToChain(SQCollectable **chain,SQCollectable *c)
|
||||
{
|
||||
c->_prev = NULL;
|
||||
c->_prev = nullptr;
|
||||
c->_next = *chain;
|
||||
if(*chain) (*chain)->_prev = c;
|
||||
*chain = c;
|
||||
@@ -310,8 +352,8 @@ void SQCollectable::RemoveFromChain(SQCollectable **chain,SQCollectable *c)
|
||||
else *chain = c->_next;
|
||||
if(c->_next)
|
||||
c->_next->_prev = c->_prev;
|
||||
c->_next = NULL;
|
||||
c->_prev = NULL;
|
||||
c->_next = nullptr;
|
||||
c->_prev = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -353,12 +395,12 @@ RefTable::~RefTable()
|
||||
}
|
||||
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void RefTable::Mark(SQCollectable **chain)
|
||||
void RefTable::EnqueueMarkObject(SQGCMarkerQueue &queue)
|
||||
{
|
||||
RefNode *nodes = (RefNode *)_nodes;
|
||||
for(SQUnsignedInteger n = 0; n < _numofslots; n++) {
|
||||
if(type(nodes->obj) != OT_NULL) {
|
||||
SQSharedState::MarkObject(nodes->obj,chain);
|
||||
SQSharedState::EnqueueMarkObject(nodes->obj,queue);
|
||||
}
|
||||
nodes++;
|
||||
}
|
||||
@@ -441,16 +483,16 @@ RefTable::RefNode *RefTable::Get(SQObject &obj,SQHash &mainpos,RefNode **prev,bo
|
||||
{
|
||||
RefNode *ref;
|
||||
mainpos = ::HashObj(obj)&(_numofslots-1);
|
||||
*prev = NULL;
|
||||
*prev = nullptr;
|
||||
for (ref = _buckets[mainpos]; ref; ) {
|
||||
if(_rawval(ref->obj) == _rawval(obj) && type(ref->obj) == type(obj))
|
||||
break;
|
||||
*prev = ref;
|
||||
ref = ref->next;
|
||||
}
|
||||
if(ref == NULL && add) {
|
||||
if(ref == nullptr && add) {
|
||||
if(_numofslots == _slotused) {
|
||||
assert(_freelist == 0);
|
||||
assert(_freelist == nullptr);
|
||||
Resize(_numofslots*2);
|
||||
mainpos = ::HashObj(obj)&(_numofslots-1);
|
||||
}
|
||||
@@ -468,16 +510,16 @@ void RefTable::AllocNodes(SQUnsignedInteger size)
|
||||
RefNode *temp = nodes;
|
||||
SQUnsignedInteger n;
|
||||
for(n = 0; n < size - 1; n++) {
|
||||
bucks[n] = NULL;
|
||||
bucks[n] = nullptr;
|
||||
temp->refs = 0;
|
||||
new (&temp->obj) SQObjectPtr;
|
||||
temp->next = temp+1;
|
||||
temp++;
|
||||
}
|
||||
bucks[n] = NULL;
|
||||
bucks[n] = nullptr;
|
||||
temp->refs = 0;
|
||||
new (&temp->obj) SQObjectPtr;
|
||||
temp->next = NULL;
|
||||
temp->next = nullptr;
|
||||
_freelist = nodes;
|
||||
_nodes = nodes;
|
||||
_buckets = bucks;
|
||||
@@ -501,7 +543,7 @@ SQStringTable::SQStringTable()
|
||||
SQStringTable::~SQStringTable()
|
||||
{
|
||||
SQ_FREE(_strings,sizeof(SQString*)*_numofslots);
|
||||
_strings = NULL;
|
||||
_strings = nullptr;
|
||||
}
|
||||
|
||||
void SQStringTable::AllocNodes(SQInteger size)
|
||||
@@ -538,8 +580,8 @@ SQString::SQString(const SQChar *news, SQInteger len)
|
||||
_val[len] = '\0';
|
||||
_len = len;
|
||||
_hash = ::_hashstr(news,(size_t)len);
|
||||
_next = NULL;
|
||||
_sharedstate = NULL;
|
||||
_next = nullptr;
|
||||
_sharedstate = nullptr;
|
||||
}
|
||||
|
||||
void SQStringTable::Resize(SQInteger size)
|
||||
@@ -563,7 +605,7 @@ void SQStringTable::Resize(SQInteger size)
|
||||
void SQStringTable::Remove(SQString *bs)
|
||||
{
|
||||
SQString *s;
|
||||
SQString *prev=NULL;
|
||||
SQString *prev=nullptr;
|
||||
SQHash h = bs->_hash&(_numofslots - 1);
|
||||
|
||||
for (s = _strings[h]; s; ){
|
||||
|
||||
+7
-2
@@ -34,7 +34,7 @@ struct RefTable {
|
||||
void AddRef(SQObject &obj);
|
||||
SQBool Release(SQObject &obj);
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObject(SQGCMarkerQueue &queue);
|
||||
#endif
|
||||
void Finalize();
|
||||
private:
|
||||
@@ -61,9 +61,10 @@ struct SQSharedState
|
||||
public:
|
||||
SQChar* GetScratchPad(SQInteger size);
|
||||
SQInteger GetMetaMethodIdxByName(const SQObjectPtr &name);
|
||||
void DelayFinalFree(SQCollectable *collectable);
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
SQInteger CollectGarbage(SQVM *vm);
|
||||
static void MarkObject(SQObjectPtr &o,SQCollectable **chain);
|
||||
static void EnqueueMarkObject(SQObjectPtr &o,SQGCMarkerQueue &queue);
|
||||
#endif
|
||||
SQObjectPtrVec *_metamethods;
|
||||
SQObjectPtr _metamethodsmap;
|
||||
@@ -74,6 +75,10 @@ public:
|
||||
SQObjectPtr _registry;
|
||||
SQObjectPtr _consts;
|
||||
SQObjectPtr _constructoridx;
|
||||
/** Queue to make freeing of collectables iterative. */
|
||||
std::vector<SQCollectable *> _collectable_free_queue;
|
||||
/** Whether someone is already processing the _collectable_free_queue. */
|
||||
bool _collectable_free_processing;
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
SQCollectable *_gc_chain;
|
||||
#endif
|
||||
|
||||
+6
-6
@@ -18,7 +18,7 @@ SQTable::SQTable(SQSharedState *ss,SQInteger nInitialSize)
|
||||
while(nInitialSize>pow2size)pow2size=pow2size<<1;
|
||||
AllocNodes(pow2size);
|
||||
_usednodes = 0;
|
||||
_delegate = NULL;
|
||||
_delegate = nullptr;
|
||||
INIT_CHAIN();
|
||||
ADD_TO_CHAIN(&_sharedstate->_gc_chain,this);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ void SQTable::AllocNodes(SQInteger nSize)
|
||||
_HashNode *nodes=(_HashNode *)SQ_MALLOC(sizeof(_HashNode)*nSize);
|
||||
for(SQInteger i=0;i<nSize;i++){
|
||||
new (&nodes[i]) _HashNode;
|
||||
nodes[i].next=NULL;
|
||||
nodes[i].next=nullptr;
|
||||
}
|
||||
_numofnodes=nSize;
|
||||
_nodes=nodes;
|
||||
@@ -120,7 +120,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
||||
if (mp > n && (othern = &_nodes[mph]) != mp){
|
||||
/* yes; move colliding node into free position */
|
||||
while (othern->next != mp){
|
||||
assert(othern->next != NULL);
|
||||
assert(othern->next != nullptr);
|
||||
othern = othern->next; /* find previous */
|
||||
}
|
||||
othern->next = n; /* redo the chain with `n' in place of `mp' */
|
||||
@@ -129,7 +129,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
||||
n->next = mp->next;
|
||||
mp->key = _null_;
|
||||
mp->val = _null_;
|
||||
mp->next = NULL; /* now `mp' is free */
|
||||
mp->next = nullptr; /* now `mp' is free */
|
||||
}
|
||||
else{
|
||||
/* new node will go into free position */
|
||||
@@ -141,7 +141,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
||||
mp->key = key;
|
||||
|
||||
for (;;) { /* correct `firstfree' */
|
||||
if (type(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
|
||||
if (type(_firstfree->key) == OT_NULL && _firstfree->next == nullptr) {
|
||||
mp->val = val;
|
||||
_usednodes++;
|
||||
return true; /* OK; table still has a free place */
|
||||
@@ -190,7 +190,7 @@ void SQTable::_ClearNodes()
|
||||
void SQTable::Finalize()
|
||||
{
|
||||
_ClearNodes();
|
||||
SetDelegate(NULL);
|
||||
SetDelegate(nullptr);
|
||||
}
|
||||
|
||||
void SQTable::Clear()
|
||||
|
||||
+11
-7
@@ -27,7 +27,7 @@ struct SQTable : public SQDelegable
|
||||
private:
|
||||
struct _HashNode
|
||||
{
|
||||
_HashNode() { next = NULL; }
|
||||
_HashNode() { next = nullptr; }
|
||||
SQObjectPtr val;
|
||||
SQObjectPtr key;
|
||||
_HashNode *next;
|
||||
@@ -47,20 +47,20 @@ public:
|
||||
{
|
||||
SQTable *newtable = (SQTable*)SQ_MALLOC(sizeof(SQTable));
|
||||
new (newtable) SQTable(ss, nInitialSize);
|
||||
newtable->_delegate = NULL;
|
||||
newtable->_delegate = nullptr;
|
||||
return newtable;
|
||||
}
|
||||
void Finalize();
|
||||
void Finalize() override;
|
||||
SQTable *Clone();
|
||||
~SQTable()
|
||||
{
|
||||
SetDelegate(NULL);
|
||||
SetDelegate(nullptr);
|
||||
REMOVE_FROM_CHAIN(&_sharedstate->_gc_chain, this);
|
||||
for (SQInteger i = 0; i < _numofnodes; i++) _nodes[i].~_HashNode();
|
||||
SQ_FREE(_nodes, _numofnodes * sizeof(_HashNode));
|
||||
}
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue) override;
|
||||
#endif
|
||||
inline _HashNode *_Get(const SQObjectPtr &key,SQHash hash)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
return n;
|
||||
}
|
||||
}while((n = n->next));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
bool Get(const SQObjectPtr &key,SQObjectPtr &val);
|
||||
void Remove(const SQObjectPtr &key);
|
||||
@@ -81,7 +81,11 @@ public:
|
||||
|
||||
SQInteger CountUsed(){ return _usednodes;}
|
||||
void Clear();
|
||||
void Release()
|
||||
void Release() override
|
||||
{
|
||||
this->_sharedstate->DelayFinalFree(this);
|
||||
}
|
||||
void FinalFree() override
|
||||
{
|
||||
sq_delete(this, SQTable);
|
||||
}
|
||||
|
||||
+4
-4
@@ -4,12 +4,12 @@
|
||||
|
||||
struct SQUserData : SQDelegable
|
||||
{
|
||||
SQUserData(SQSharedState *ss, SQInteger size){ _delegate = 0; _hook = NULL; INIT_CHAIN(); ADD_TO_CHAIN(&_ss(this)->_gc_chain, this); _size = size; _typetag = 0;
|
||||
SQUserData(SQSharedState *ss, SQInteger size){ _delegate = nullptr; _hook = nullptr; INIT_CHAIN(); ADD_TO_CHAIN(&_ss(this)->_gc_chain, this); _size = size; _typetag = nullptr;
|
||||
}
|
||||
~SQUserData()
|
||||
{
|
||||
REMOVE_FROM_CHAIN(&_ss(this)->_gc_chain, this);
|
||||
SetDelegate(NULL);
|
||||
SetDelegate(nullptr);
|
||||
}
|
||||
static SQUserData* Create(SQSharedState *ss, SQInteger size)
|
||||
{
|
||||
@@ -18,8 +18,8 @@ struct SQUserData : SQDelegable
|
||||
return ud;
|
||||
}
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void Finalize(){SetDelegate(NULL);}
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue);
|
||||
void Finalize(){SetDelegate(nullptr);}
|
||||
#endif
|
||||
void Release() {
|
||||
if (_hook) _hook(_val,_size);
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ template<typename T> class sqvector
|
||||
public:
|
||||
sqvector()
|
||||
{
|
||||
_vals = NULL;
|
||||
_vals = nullptr;
|
||||
_size = 0;
|
||||
_allocated = 0;
|
||||
}
|
||||
|
||||
+18
-22
@@ -33,7 +33,7 @@ void SQVM::ClearStack(SQInteger last_top)
|
||||
tOldType = o._type;
|
||||
unOldVal = o._unVal;
|
||||
o._type = OT_NULL;
|
||||
o._unVal.pUserPointer = NULL;
|
||||
o._unVal.pUserPointer = nullptr;
|
||||
__Release(tOldType,unOldVal);
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ SQVM::SQVM(SQSharedState *ss)
|
||||
_suspended_target=-1;
|
||||
_suspended_root = SQFalse;
|
||||
_suspended_traps=0;
|
||||
_foreignptr=NULL;
|
||||
_foreignptr=nullptr;
|
||||
_nnativecalls=0;
|
||||
_lasterror = _null_;
|
||||
_errorhandler = _null_;
|
||||
@@ -115,12 +115,12 @@ SQVM::SQVM(SQSharedState *ss)
|
||||
_can_suspend = false;
|
||||
_in_stackoverflow = false;
|
||||
_ops_till_suspend = 0;
|
||||
_callsstack = NULL;
|
||||
_callsstack = nullptr;
|
||||
_callsstacksize = 0;
|
||||
_alloccallsstacksize = 0;
|
||||
_top = 0;
|
||||
_stackbase = 0;
|
||||
ci = NULL;
|
||||
ci = nullptr;
|
||||
INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
|
||||
|
||||
if (!tailcall) {
|
||||
CallInfo lc = {};
|
||||
lc._generator = NULL;
|
||||
lc._generator = nullptr;
|
||||
lc._etraps = 0;
|
||||
lc._prevstkbase = (SQInt32) ( stackbase - _stackbase );
|
||||
lc._target = (SQInt32) target;
|
||||
@@ -437,7 +437,7 @@ bool SQVM::Return(SQInteger _arg0, SQInteger _arg1, SQObjectPtr &retval)
|
||||
|
||||
while (last_top > oldstackbase) _stack._vals[last_top--].Null();
|
||||
assert(oldstackbase >= _stackbase);
|
||||
return broot?true:false;
|
||||
return broot != 0;
|
||||
}
|
||||
|
||||
#define _RET_ON_FAIL(exp) { if(!exp) return false; }
|
||||
@@ -557,7 +557,7 @@ bool SQVM::DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2)
|
||||
}
|
||||
break;
|
||||
case OT_NULL:
|
||||
_table(o1)->SetDelegate(NULL);
|
||||
_table(o1)->SetDelegate(nullptr);
|
||||
break;
|
||||
default:
|
||||
Raise_Error("using '%s' as delegate", GetTypeName(o2));
|
||||
@@ -627,7 +627,7 @@ bool SQVM::GETVARGV_OP(SQObjectPtr &target,SQObjectPtr &index,CallInfo *ci)
|
||||
|
||||
bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes)
|
||||
{
|
||||
SQClass *base = NULL;
|
||||
SQClass *base = nullptr;
|
||||
SQObjectPtr attrs;
|
||||
if(baseclass != -1) {
|
||||
if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error("trying to inherit from a %s",GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
|
||||
@@ -653,7 +653,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
|
||||
bool SQVM::IsEqual(SQObjectPtr &o1,SQObjectPtr &o2,bool &res)
|
||||
{
|
||||
if(type(o1) == type(o2)) {
|
||||
res = ((_rawval(o1) == _rawval(o2)?true:false));
|
||||
res = ((_rawval(o1) == _rawval(o2)));
|
||||
}
|
||||
else {
|
||||
if(sq_isnumeric(o1) && sq_isnumeric(o2)) {
|
||||
@@ -708,7 +708,7 @@ bool SQVM::Execute(SQObjectPtr &closure, SQInteger target, SQInteger nargs, SQIn
|
||||
temp_reg = closure;
|
||||
if(!StartCall(_closure(temp_reg), _top - nargs, nargs, stackbase, false)) {
|
||||
//call the handler if there are no calls in the stack, if not relies on the previous node
|
||||
if(ci == NULL) CallErrorHandler(_lasterror);
|
||||
if(ci == nullptr) CallErrorHandler(_lasterror);
|
||||
return false;
|
||||
}
|
||||
if (_funcproto(_closure(temp_reg)->_function)->_bgenerator) {
|
||||
@@ -1028,7 +1028,7 @@ common_call:
|
||||
case _OP_THROW: Raise_Error(TARGET); SQ_THROW();
|
||||
case _OP_CLASS: _GUARD(CLASS_OP(TARGET,arg1,arg2)); continue;
|
||||
case _OP_NEWSLOTA:
|
||||
bool bstatic = (arg0&NEW_SLOT_STATIC_FLAG)?true:false;
|
||||
bool bstatic = (arg0&NEW_SLOT_STATIC_FLAG) != 0;
|
||||
if(type(STK(arg1)) == OT_CLASS) {
|
||||
if(type(_class(STK(arg1))->_metamethods[MT_NEWMEMBER]) != OT_NULL ) {
|
||||
Push(STK(arg1)); Push(STK(arg2)); Push(STK(arg3));
|
||||
@@ -1160,7 +1160,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure,SQInteger nargs,SQInteger stackb
|
||||
_top = stackbase + nargs;
|
||||
CallInfo lci = {};
|
||||
lci._closure = nclosure;
|
||||
lci._generator = NULL;
|
||||
lci._generator = nullptr;
|
||||
lci._etraps = 0;
|
||||
lci._prevstkbase = (SQInt32) (stackbase - _stackbase);
|
||||
lci._ncalls = 1;
|
||||
@@ -1460,7 +1460,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
|
||||
}
|
||||
}
|
||||
res = t;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Raise_Error("attempt to delete a slot from a %s",GetTypeName(self));
|
||||
@@ -1471,9 +1471,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
|
||||
|
||||
bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams,SQInteger stackbase,SQObjectPtr &outres,SQBool raiseerror,SQBool can_suspend)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
SQInteger prevstackbase = _stackbase;
|
||||
#endif
|
||||
[[maybe_unused]] SQInteger prevstackbase = _stackbase;
|
||||
switch(type(closure)) {
|
||||
case OT_CLOSURE: {
|
||||
assert(!can_suspend || this->_can_suspend);
|
||||
@@ -1482,13 +1480,13 @@ SQInteger prevstackbase = _stackbase;
|
||||
bool ret = Execute(closure, _top - nparams, nparams, stackbase,outres,raiseerror);
|
||||
this->_can_suspend = backup_suspend;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OT_NATIVECLOSURE:{
|
||||
case OT_NATIVECLOSURE: {
|
||||
bool suspend;
|
||||
return CallNative(_nativeclosure(closure), nparams, stackbase, outres,suspend);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OT_CLASS: {
|
||||
SQObjectPtr constr;
|
||||
@@ -1499,16 +1497,14 @@ SQInteger prevstackbase = _stackbase;
|
||||
return Call(constr,nparams,stackbase,temp,raiseerror,false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
if(!_suspended) {
|
||||
assert(_stackbase == prevstackbase);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ public:
|
||||
#endif
|
||||
|
||||
#ifndef NO_GARBAGE_COLLECTOR
|
||||
void Mark(SQCollectable **chain);
|
||||
void EnqueueMarkObjectForChildren(SQGCMarkerQueue &queue);
|
||||
#endif
|
||||
void Finalize();
|
||||
void GrowCallStack() {
|
||||
|
||||
@@ -309,6 +309,8 @@ add_files(
|
||||
rail_gui.h
|
||||
rail_map.h
|
||||
rail_type.h
|
||||
random_access_file.cpp
|
||||
random_access_file_type.h
|
||||
rev.h
|
||||
road.cpp
|
||||
road.h
|
||||
@@ -336,6 +338,8 @@ add_files(
|
||||
settings_gui.cpp
|
||||
settings_gui.h
|
||||
settings_internal.h
|
||||
settings_table.h
|
||||
settings_table.cpp
|
||||
settings_type.h
|
||||
ship.h
|
||||
ship_cmd.cpp
|
||||
@@ -465,6 +469,7 @@ add_files(
|
||||
viewport_type.h
|
||||
void_cmd.cpp
|
||||
void_map.h
|
||||
walltime_func.h
|
||||
water.h
|
||||
water_cmd.cpp
|
||||
water_map.h
|
||||
|
||||
+3
-3
@@ -114,7 +114,7 @@
|
||||
cur_company.Restore();
|
||||
|
||||
InvalidateWindowData(WC_AI_DEBUG, 0, -1);
|
||||
DeleteWindowById(WC_AI_SETTINGS, company);
|
||||
CloseWindowById(WC_AI_SETTINGS, company);
|
||||
}
|
||||
|
||||
/* static */ void AI::Pause(CompanyID company)
|
||||
@@ -207,7 +207,7 @@
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
if (_settings_game.ai_config[c] != nullptr && _settings_game.ai_config[c]->HasScript()) {
|
||||
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
|
||||
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
||||
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
||||
_settings_game.ai_config[c]->Change(nullptr);
|
||||
if (Company::IsValidAiID(c)) {
|
||||
/* The code belonging to an already running AI was deleted. We can only do
|
||||
@@ -224,7 +224,7 @@
|
||||
}
|
||||
if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
|
||||
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
|
||||
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
||||
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
||||
_settings_newgame.ai_config[c]->Change(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
+28
-26
@@ -182,7 +182,7 @@ struct AIListWindow : public Window {
|
||||
}
|
||||
InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_AI);
|
||||
InvalidateWindowClassesData(WC_AI_SETTINGS);
|
||||
DeleteWindowByClass(WC_QUERY_STRING);
|
||||
CloseWindowByClass(WC_QUERY_STRING);
|
||||
InvalidateWindowClassesData(WC_TEXTFILE);
|
||||
}
|
||||
|
||||
@@ -190,13 +190,13 @@ struct AIListWindow : public Window {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_AIL_LIST: { // Select one of the AIs
|
||||
int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_AIL_LIST, 0, this->line_height) - 1;
|
||||
int sel = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_AIL_LIST) - 1;
|
||||
if (sel < (int)this->info_list->size()) {
|
||||
this->selected = sel;
|
||||
this->SetDirty();
|
||||
if (click_count > 1) {
|
||||
this->ChangeAI();
|
||||
delete this;
|
||||
this->Close();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -204,12 +204,12 @@ struct AIListWindow : public Window {
|
||||
|
||||
case WID_AIL_ACCEPT: {
|
||||
this->ChangeAI();
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_AIL_CANCEL:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ struct AIListWindow : public Window {
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) {
|
||||
delete this;
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ static WindowDesc _ai_list_desc(
|
||||
*/
|
||||
static void ShowAIListWindow(CompanyID slot)
|
||||
{
|
||||
DeleteWindowByClass(WC_AI_LIST);
|
||||
CloseWindowByClass(WC_AI_LIST);
|
||||
new AIListWindow(&_ai_list_desc, slot);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ struct AISettingsWindow : public Window {
|
||||
if (!this->IsEditableItem(config_item)) return;
|
||||
|
||||
if (this->clicked_row != num) {
|
||||
DeleteChildWindows(WC_QUERY_STRING);
|
||||
this->CloseChildWindows(WC_QUERY_STRING);
|
||||
HideDropDownMenu(this);
|
||||
this->clicked_row = num;
|
||||
this->clicked_dropdown = false;
|
||||
@@ -518,7 +518,7 @@ struct AISettingsWindow : public Window {
|
||||
}
|
||||
|
||||
case WID_AIS_ACCEPT:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_AIS_RESET:
|
||||
@@ -584,7 +584,7 @@ struct AISettingsWindow : public Window {
|
||||
{
|
||||
this->RebuildVisibleSettings();
|
||||
HideDropDownMenu(this);
|
||||
DeleteChildWindows(WC_QUERY_STRING);
|
||||
this->CloseChildWindows(WC_QUERY_STRING);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -628,8 +628,8 @@ static WindowDesc _ai_settings_desc(
|
||||
*/
|
||||
static void ShowAISettingsWindow(CompanyID slot)
|
||||
{
|
||||
DeleteWindowByClass(WC_AI_LIST);
|
||||
DeleteWindowByClass(WC_AI_SETTINGS);
|
||||
CloseWindowByClass(WC_AI_LIST);
|
||||
CloseWindowByClass(WC_AI_SETTINGS);
|
||||
new AISettingsWindow(&_ai_settings_desc, slot);
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
||||
{
|
||||
const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
|
||||
if (textfile == nullptr) {
|
||||
delete this;
|
||||
this->Close();
|
||||
} else {
|
||||
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
|
||||
}
|
||||
@@ -669,7 +669,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
||||
*/
|
||||
void ShowScriptTextfileWindow(TextfileType file_type, CompanyID slot)
|
||||
{
|
||||
DeleteWindowById(WC_TEXTFILE, file_type);
|
||||
CloseWindowById(WC_TEXTFILE, file_type);
|
||||
new ScriptTextfileWindow(file_type, slot);
|
||||
}
|
||||
|
||||
@@ -704,16 +704,16 @@ static const NWidgetPart _nested_ai_config_widgets[] = {
|
||||
NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIC_GAMELIST), SetMinimalSize(288, 14), SetFill(1, 0), SetMatrixDataTip(1, 1, STR_AI_CONFIG_GAMELIST_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CHANGE), SetFill(1, 0), SetMinimalSize(93, 12), SetDataTip(STR_AI_CONFIG_CHANGE, STR_AI_CONFIG_CHANGE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CONFIGURE), SetFill(1, 0), SetMinimalSize(93, 12), SetDataTip(STR_AI_CONFIG_CONFIGURE, STR_AI_CONFIG_CONFIGURE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CLOSE), SetFill(1, 0), SetMinimalSize(93, 12), SetDataTip(STR_AI_SETTINGS_CLOSE, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CHANGE), SetFill(1, 0), SetMinimalSize(93, 0), SetDataTip(STR_AI_CONFIG_CHANGE, STR_AI_CONFIG_CHANGE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CONFIGURE), SetFill(1, 0), SetMinimalSize(93, 0), SetDataTip(STR_AI_CONFIG_CONFIGURE, STR_AI_CONFIG_CONFIGURE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CLOSE), SetFill(1, 0), SetMinimalSize(93, 0), SetDataTip(STR_AI_SETTINGS_CLOSE, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CONTENT_DOWNLOAD), SetFill(1, 0), SetMinimalSize(279, 12), SetPadding(0, 7, 9, 7), SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CONTENT_DOWNLOAD), SetFill(1, 0), SetMinimalSize(279, 0), SetPadding(0, 7, 9, 7), SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
@@ -744,10 +744,11 @@ struct AIConfigWindow : public Window {
|
||||
this->OnInvalidateData(0);
|
||||
}
|
||||
|
||||
~AIConfigWindow()
|
||||
void Close() override
|
||||
{
|
||||
DeleteWindowByClass(WC_AI_LIST);
|
||||
DeleteWindowByClass(WC_AI_SETTINGS);
|
||||
CloseWindowByClass(WC_AI_LIST);
|
||||
CloseWindowByClass(WC_AI_SETTINGS);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
@@ -784,6 +785,7 @@ struct AIConfigWindow : public Window {
|
||||
|
||||
case WID_AIC_LIST:
|
||||
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
|
||||
resize->height = this->line_height;
|
||||
size->height = 8 * this->line_height;
|
||||
break;
|
||||
|
||||
@@ -895,7 +897,7 @@ struct AIConfigWindow : public Window {
|
||||
}
|
||||
|
||||
case WID_AIC_LIST: { // Select a slot
|
||||
this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
|
||||
this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
|
||||
this->InvalidateData();
|
||||
if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
|
||||
break;
|
||||
@@ -928,7 +930,7 @@ struct AIConfigWindow : public Window {
|
||||
break;
|
||||
|
||||
case WID_AIC_CLOSE:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_AIC_CONTENT_DOWNLOAD:
|
||||
@@ -970,7 +972,7 @@ struct AIConfigWindow : public Window {
|
||||
/** Open the AI config window. */
|
||||
void ShowAIConfigWindow()
|
||||
{
|
||||
DeleteWindowByClass(WC_GAME_OPTIONS);
|
||||
CloseWindowByClass(WC_GAME_OPTIONS);
|
||||
new AIConfigWindow();
|
||||
}
|
||||
|
||||
@@ -1262,7 +1264,7 @@ struct AIDebugWindow : public Window {
|
||||
this->highlight_row = -1; // The highlight of one AI make little sense for another AI.
|
||||
|
||||
/* Close AI settings window to prevent confusion */
|
||||
DeleteWindowByClass(WC_AI_SETTINGS);
|
||||
CloseWindowByClass(WC_AI_SETTINGS);
|
||||
|
||||
this->InvalidateData(-1);
|
||||
|
||||
|
||||
+4
-4
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
static bool CheckAPIVersion(const char *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" };
|
||||
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" };
|
||||
return versions.find(api_version) != versions.end();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; }
|
||||
{
|
||||
/* Get the AIInfo */
|
||||
SQUserPointer instance = nullptr;
|
||||
if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, 0)) || instance == nullptr) return sq_throwerror(vm, "Pass an instance of a child class of AIInfo to RegisterAI");
|
||||
if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, nullptr)) || instance == nullptr) return sq_throwerror(vm, "Pass an instance of a child class of AIInfo to RegisterAI");
|
||||
AIInfo *info = (AIInfo *)instance;
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, info);
|
||||
@@ -89,7 +89,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; }
|
||||
if (info->engine->MethodExists(*info->SQ_instance, "GetAPIVersion")) {
|
||||
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_OPS)) return SQ_ERROR;
|
||||
if (!CheckAPIVersion(info->api_version)) {
|
||||
DEBUG(script, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
|
||||
Debug(script, 1, "Loading info.nut from ({}.{}): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
|
||||
return SQ_ERROR;
|
||||
}
|
||||
} else {
|
||||
@@ -107,7 +107,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; }
|
||||
{
|
||||
/* Get the AIInfo */
|
||||
SQUserPointer instance;
|
||||
sq_getinstanceup(vm, 2, &instance, 0);
|
||||
sq_getinstanceup(vm, 2, &instance, nullptr);
|
||||
AIInfo *info = (AIInfo *)instance;
|
||||
info->api_version = nullptr;
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ AIInfo *AIScannerInfo::SelectRandomAI() const
|
||||
}
|
||||
|
||||
if (num_random_ais == 0) {
|
||||
DEBUG(script, 0, "No suitable AI found, loading 'dummy' AI.");
|
||||
Debug(script, 0, "No suitable AI found, loading 'dummy' AI.");
|
||||
return this->info_dummy;
|
||||
}
|
||||
|
||||
|
||||
@@ -1025,7 +1025,7 @@ static bool AircraftController(Aircraft *v)
|
||||
if (count == 0) return false;
|
||||
|
||||
/* If the plane will be a few subpixels away from the destination after
|
||||
* this movement loop, start nudging him towards the exact position for
|
||||
* this movement loop, start nudging it towards the exact position for
|
||||
* the whole loop. Otherwise, heavily depending on the speed of the plane,
|
||||
* it is possible we totally overshoot the target, causing the plane to
|
||||
* make a loop, and trying again, and again, and again .. */
|
||||
@@ -1786,7 +1786,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
|
||||
{
|
||||
/* error handling */
|
||||
if (v->pos >= apc->nofelements) {
|
||||
DEBUG(misc, 0, "[Ap] position %d is not valid for current airport. Max position is %d", v->pos, apc->nofelements-1);
|
||||
Debug(misc, 0, "[Ap] position {} is not valid for current airport. Max position is {}", v->pos, apc->nofelements-1);
|
||||
assert(v->pos < apc->nofelements);
|
||||
}
|
||||
|
||||
@@ -1825,7 +1825,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
|
||||
current = current->next;
|
||||
} while (current != nullptr);
|
||||
|
||||
DEBUG(misc, 0, "[Ap] cannot move further on Airport! (pos %d state %d) for vehicle %d", v->pos, v->state, v->index);
|
||||
Debug(misc, 0, "[Ap] cannot move further on Airport! (pos {} state {}) for vehicle {}", v->pos, v->state, v->index);
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -76,10 +76,11 @@ struct BuildAirToolbarWindow : Window {
|
||||
this->last_user_action = WIDGET_LIST_END;
|
||||
}
|
||||
|
||||
~BuildAirToolbarWindow()
|
||||
void Close() override
|
||||
{
|
||||
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
|
||||
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +97,7 @@ struct BuildAirToolbarWindow : Window {
|
||||
WID_AT_AIRPORT,
|
||||
WIDGET_LIST_END);
|
||||
if (!can_build) {
|
||||
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
||||
CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
||||
|
||||
/* Show in the tooltip why this button is disabled. */
|
||||
this->GetWidget<NWidgetCore>(WID_AT_AIRPORT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
|
||||
@@ -158,8 +159,8 @@ struct BuildAirToolbarWindow : Window {
|
||||
|
||||
this->RaiseButtons();
|
||||
|
||||
DeleteWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
||||
DeleteWindowById(WC_SELECT_STATION, 0);
|
||||
CloseWindowById(WC_BUILD_STATION, TRANSPORT_AIR);
|
||||
CloseWindowById(WC_SELECT_STATION, 0);
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
@@ -217,7 +218,7 @@ Window *ShowBuildAirToolbar()
|
||||
{
|
||||
if (!Company::IsValidID(_local_company)) return nullptr;
|
||||
|
||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||
CloseWindowByClass(WC_BUILD_TOOLBAR);
|
||||
return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
||||
}
|
||||
|
||||
@@ -276,9 +277,10 @@ public:
|
||||
if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
|
||||
}
|
||||
|
||||
virtual ~BuildAirportWindow()
|
||||
void Close() override
|
||||
{
|
||||
DeleteWindowById(WC_SELECT_STATION, 0);
|
||||
CloseWindowById(WC_SELECT_STATION, 0);
|
||||
this->PickerWindowBase::Close();
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
@@ -483,7 +485,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_AP_AIRPORT_LIST: {
|
||||
int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
|
||||
int num_clicked = this->vscroll->GetPosition() + (pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height;
|
||||
if (num_clicked >= this->vscroll->GetCount()) break;
|
||||
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
|
||||
if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@
|
||||
#include "command_func.h"
|
||||
#include "group.h"
|
||||
#include "autoreplace_base.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/pool_func.hpp"
|
||||
|
||||
#include "safeguards.h"
|
||||
@@ -64,7 +65,7 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old)
|
||||
{
|
||||
const EngineRenew *er = GetEngineReplacement(erl, engine, group);
|
||||
if (er == nullptr && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !Group::Get(group)->replace_protection))) {
|
||||
if (er == nullptr && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !HasBit(Group::Get(group)->flags, GroupFlags::GF_REPLACE_PROTECTION)))) {
|
||||
/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
|
||||
er = GetEngineReplacement(erl, engine, ALL_GROUP);
|
||||
}
|
||||
|
||||
+10
-8
@@ -207,6 +207,7 @@ static int GetIncompatibleRefitOrderIdForAutoreplace(const Vehicle *v, EngineID
|
||||
const Vehicle *u = (v->type == VEH_TRAIN) ? v->First() : v;
|
||||
|
||||
const OrderList *orders = u->orders.list;
|
||||
if (orders == nullptr) return -1;
|
||||
for (VehicleOrderID i = 0; i < orders->GetNumOrders(); i++) {
|
||||
o = orders->GetOrderAt(i);
|
||||
if (!o->IsRefit()) continue;
|
||||
@@ -596,7 +597,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
||||
assert(RailVehInfo(wagon->engine_type)->railveh_type == RAILVEH_WAGON);
|
||||
|
||||
/* Sell wagon */
|
||||
CommandCost ret = DoCommand(0, wagon->index, 0, DC_EXEC, GetCmdSellVeh(wagon));
|
||||
[[maybe_unused]] CommandCost ret = DoCommand(0, wagon->index, 0, DC_EXEC, GetCmdSellVeh(wagon));
|
||||
assert(ret.Succeeded());
|
||||
new_vehs[i] = nullptr;
|
||||
|
||||
@@ -613,6 +614,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
||||
/* Success ! */
|
||||
if ((flags & DC_EXEC) != 0 && new_head != old_head) {
|
||||
*chain = new_head;
|
||||
AI::NewEvent(old_head->owner, new ScriptEventVehicleAutoReplaced(old_head->index, new_head->index));
|
||||
}
|
||||
|
||||
/* Transfer cargo of old vehicles and sell them */
|
||||
@@ -630,10 +632,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
||||
cost.AddCost(DoCommand(0, w->index, 0, flags | DC_AUTOREPLACE, GetCmdSellVeh(w)));
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
old_vehs[i] = nullptr;
|
||||
if (i == 0) {
|
||||
AI::NewEvent(old_head->owner, new ScriptEventVehicleAutoReplaced(old_head->index, new_head->index));
|
||||
old_head = nullptr;
|
||||
}
|
||||
if (i == 0) old_head = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +650,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
||||
assert(Train::From(old_head)->GetNextUnit() == nullptr);
|
||||
|
||||
for (int i = num_units - 1; i > 0; i--) {
|
||||
CommandCost ret = CmdMoveVehicle(old_vehs[i], old_head, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
[[maybe_unused]] CommandCost ret = CmdMoveVehicle(old_vehs[i], old_head, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
assert(ret.Succeeded());
|
||||
}
|
||||
}
|
||||
@@ -715,7 +714,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(p1);
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
@@ -739,6 +738,9 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||
const Company *c = Company::Get(_current_company);
|
||||
bool wagon_removal = c->settings.renew_keep_length;
|
||||
|
||||
const Group *g = Group::GetIfValid(v->group_id);
|
||||
if (g != nullptr) wagon_removal = HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
|
||||
|
||||
/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
|
||||
Vehicle *w = v;
|
||||
bool any_replacements = false;
|
||||
@@ -805,7 +807,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
||||
+40
-9
@@ -81,7 +81,7 @@ class ReplaceVehicleWindow : public Window {
|
||||
bool replace_engines; ///< If \c true, engines are replaced, if \c false, wagons are replaced (only for trains).
|
||||
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 (found so far).
|
||||
int details_height; ///< Minimal needed height of the details panels, in text lines (found so far).
|
||||
byte sort_criteria; ///< Criteria of sorting vehicles.
|
||||
bool descending_sort_order; ///< Order of sorting vehicles.
|
||||
bool show_hidden_engines; ///< Whether to show the hidden engines.
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
this->engines[0].ForceRebuild();
|
||||
this->engines[1].ForceRebuild();
|
||||
this->reset_sel_engine = true;
|
||||
this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9);
|
||||
this->sel_engine[0] = INVALID_ENGINE;
|
||||
this->sel_engine[1] = INVALID_ENGINE;
|
||||
this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
|
||||
@@ -274,7 +274,7 @@ public:
|
||||
|
||||
case WID_RV_LEFT_DETAILS:
|
||||
case WID_RV_RIGHT_DETAILS:
|
||||
size->height = this->details_height;
|
||||
size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height;
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
@@ -375,8 +375,18 @@ public:
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
const Company *c = Company::Get(_local_company);
|
||||
SetDParam(0, c->settings.renew_keep_length ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
|
||||
bool remove_wagon;
|
||||
const Group *g = Group::GetIfValid(this->sel_group);
|
||||
if (g != nullptr) {
|
||||
remove_wagon = HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL);
|
||||
SetDParam(0, STR_GROUP_NAME);
|
||||
SetDParam(1, sel_group);
|
||||
} else {
|
||||
const Company *c = Company::Get(_local_company);
|
||||
remove_wagon = c->settings.renew_keep_length;
|
||||
SetDParam(0, STR_GROUP_DEFAULT_TRAINS + this->window_number);
|
||||
}
|
||||
SetDParam(2, remove_wagon ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -475,7 +485,7 @@ public:
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS);
|
||||
int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
|
||||
nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side], ted);
|
||||
needed_height = std::max(needed_height, text_end - (int)nwi->pos_y + WD_FRAMERECT_BOTTOM);
|
||||
needed_height = std::max(needed_height, (text_end - (int)nwi->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
}
|
||||
if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
|
||||
@@ -528,9 +538,16 @@ public:
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
|
||||
DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING);
|
||||
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
|
||||
const Group *g = Group::GetIfValid(this->sel_group);
|
||||
if (g != nullptr) {
|
||||
DoCommandP(0, this->sel_group | (GroupFlags::GF_REPLACE_WAGON_REMOVAL << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL) ? 0 : 1) | (_ctrl_pressed << 1), CMD_SET_GROUP_FLAG);
|
||||
} else {
|
||||
// toggle renew_keep_length
|
||||
DoCommandP(0, 0, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING, nullptr, "company.renew_keep_length");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_RV_START_REPLACE: { // Start replacing
|
||||
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
||||
@@ -628,6 +645,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
|
||||
{
|
||||
if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false;
|
||||
|
||||
if (Group::IsValidID(this->sel_group)) {
|
||||
uint64 params[1];
|
||||
params[0] = STR_REPLACE_REMOVE_WAGON_HELP;
|
||||
GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, 1, params, close_cond);
|
||||
} else {
|
||||
GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, 0, nullptr, close_cond);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX);
|
||||
@@ -833,7 +864,7 @@ static WindowDesc _replace_vehicle_desc(
|
||||
*/
|
||||
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
|
||||
{
|
||||
DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
|
||||
CloseWindowById(WC_REPLACE_VEHICLE, vehicletype);
|
||||
WindowDesc *desc;
|
||||
switch (vehicletype) {
|
||||
case VEH_TRAIN: desc = &_replace_rail_vehicle_desc; break;
|
||||
|
||||
+13
-13
@@ -22,8 +22,8 @@
|
||||
#define fetch_metadata(name) \
|
||||
item = metadata->GetItem(name, false); \
|
||||
if (item == nullptr || !item->value.has_value() || item->value->empty()) { \
|
||||
DEBUG(grf, 0, "Base " SET_TYPE "set detail loading: %s field missing.", name); \
|
||||
DEBUG(grf, 0, " Is %s readable for the user running OpenTTD?", full_filename); \
|
||||
Debug(grf, 0, "Base " SET_TYPE "set detail loading: {} field missing.", name); \
|
||||
Debug(grf, 0, " Is {} readable for the user running OpenTTD?", full_filename); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
/* Find the filename first. */
|
||||
item = files->GetItem(BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], false);
|
||||
if (item == nullptr || (!item->value.has_value() && !allow_empty_filename)) {
|
||||
DEBUG(grf, 0, "No " SET_TYPE " file for: %s (in %s)", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename);
|
||||
Debug(grf, 0, "No " SET_TYPE " file for: {} (in {})", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
/* Then find the MD5 checksum */
|
||||
item = md5s->GetItem(filename, false);
|
||||
if (item == nullptr || !item->value.has_value()) {
|
||||
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename, full_filename);
|
||||
Debug(grf, 0, "No MD5 checksum specified for: {} (in {})", filename, full_filename);
|
||||
return false;
|
||||
}
|
||||
const char *c = item->value->c_str();
|
||||
@@ -105,7 +105,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
} else if ('A' <= *c && *c <= 'F') {
|
||||
j = *c - 'A' + 10;
|
||||
} else {
|
||||
DEBUG(grf, 0, "Malformed MD5 checksum specified for: %s (in %s)", filename, full_filename);
|
||||
Debug(grf, 0, "Malformed MD5 checksum specified for: {} (in {})", filename, full_filename);
|
||||
return false;
|
||||
}
|
||||
if (i % 2 == 0) {
|
||||
@@ -119,7 +119,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
item = origin->GetItem(filename, false);
|
||||
if (item == nullptr) item = origin->GetItem("default", false);
|
||||
if (item == nullptr || !item->value.has_value()) {
|
||||
DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
|
||||
Debug(grf, 1, "No origin warning message specified for: {}", filename);
|
||||
file->missing_warning = stredup("");
|
||||
} else {
|
||||
file->missing_warning = stredup(item->value->c_str());
|
||||
@@ -136,12 +136,12 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
||||
break;
|
||||
|
||||
case MD5File::CR_MISMATCH:
|
||||
DEBUG(grf, 1, "MD5 checksum mismatch for: %s (in %s)", filename, full_filename);
|
||||
Debug(grf, 1, "MD5 checksum mismatch for: {} (in {})", filename, full_filename);
|
||||
this->found_files++;
|
||||
break;
|
||||
|
||||
case MD5File::CR_NO_FILE:
|
||||
DEBUG(grf, 1, "The file %s specified in %s is missing", filename, full_filename);
|
||||
Debug(grf, 1, "The file {} specified in {} is missing", filename, full_filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ template <class Tbase_set>
|
||||
bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename)
|
||||
{
|
||||
bool ret = false;
|
||||
DEBUG(grf, 1, "Checking %s for base " SET_TYPE " set", filename.c_str());
|
||||
Debug(grf, 1, "Checking {} for base " SET_TYPE " set", filename);
|
||||
|
||||
Tbase_set *set = new Tbase_set();
|
||||
IniFile *ini = new IniFile();
|
||||
@@ -179,7 +179,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
||||
/* The more complete set takes precedence over the version number. */
|
||||
if ((duplicate->valid_files == set->valid_files && duplicate->version >= set->version) ||
|
||||
duplicate->valid_files > set->valid_files) {
|
||||
DEBUG(grf, 1, "Not adding %s (%i) as base " SET_TYPE " set (duplicate, %s)", set->name.c_str(), set->version,
|
||||
Debug(grf, 1, "Not adding {} ({}) as base " SET_TYPE " set (duplicate, {})", set->name, set->version,
|
||||
duplicate->valid_files > set->valid_files ? "less valid files" : "lower version");
|
||||
set->next = BaseMedia<Tbase_set>::duplicate_sets;
|
||||
BaseMedia<Tbase_set>::duplicate_sets = set;
|
||||
@@ -195,7 +195,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
||||
* version number until a new game is started which isn't a big problem */
|
||||
if (BaseMedia<Tbase_set>::used_set == duplicate) BaseMedia<Tbase_set>::used_set = set;
|
||||
|
||||
DEBUG(grf, 1, "Removing %s (%i) as base " SET_TYPE " set (duplicate, %s)", duplicate->name.c_str(), duplicate->version,
|
||||
Debug(grf, 1, "Removing {} ({}) as base " SET_TYPE " set (duplicate, {})", duplicate->name, duplicate->version,
|
||||
duplicate->valid_files < set->valid_files ? "less valid files" : "lower version");
|
||||
duplicate->next = BaseMedia<Tbase_set>::duplicate_sets;
|
||||
BaseMedia<Tbase_set>::duplicate_sets = duplicate;
|
||||
@@ -209,7 +209,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
|
||||
ret = true;
|
||||
}
|
||||
if (ret) {
|
||||
DEBUG(grf, 1, "Adding %s (%i) as base " SET_TYPE " set", set->name.c_str(), set->version);
|
||||
Debug(grf, 1, "Adding {} ({}) as base " SET_TYPE " set", set->name, set->version);
|
||||
}
|
||||
} else {
|
||||
delete set;
|
||||
@@ -274,7 +274,7 @@ template <class Tbase_set>
|
||||
return p;
|
||||
}
|
||||
|
||||
#include "network/network_content.h"
|
||||
#include "network/core/tcp_content_type.h"
|
||||
|
||||
template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
|
||||
{
|
||||
|
||||
@@ -307,7 +307,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
|
||||
Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
|
||||
|
||||
@@ -155,6 +155,7 @@ bmno_full_transparency:
|
||||
|
||||
if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) {
|
||||
if (src->a == 0) {
|
||||
/* Complete transparency. */
|
||||
} else if (src->a == 255) {
|
||||
*anim = *(const uint16*) src_mv;
|
||||
*dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(LookupColourInPalette(src_mv->m), src_mv->v) : *src;
|
||||
@@ -197,7 +198,7 @@ bmno_full_transparency:
|
||||
m_colour = r == 0 ? m_colour : cmap; \
|
||||
m_colour = m != 0 ? m_colour : srcm; \
|
||||
}
|
||||
#ifdef _SQ64
|
||||
#ifdef POINTER_IS_64BIT
|
||||
uint64 srcs = _mm_cvtsi128_si64(srcABCD);
|
||||
uint64 dsts;
|
||||
if (animated) dsts = _mm_cvtsi128_si64(dstABCD);
|
||||
@@ -379,7 +380,7 @@ bm_normal:
|
||||
else Draw<BM_NORMAL, RM_WITH_SKIP, BT_ODD, true, true>(bp, zoom);
|
||||
}
|
||||
} else {
|
||||
#ifdef _SQ64
|
||||
#ifdef POINTER_IS_64BIT
|
||||
if (sprite_flags & SF_TRANSLUCENT) {
|
||||
if (sprite_flags & SF_NO_ANIM) Draw<BM_NORMAL, RM_WITH_MARGIN, BT_NONE, true, false>(bp, zoom);
|
||||
else Draw<BM_NORMAL, RM_WITH_MARGIN, BT_NONE, true, true>(bp, zoom);
|
||||
|
||||
@@ -106,7 +106,7 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
|
||||
Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
|
||||
}
|
||||
|
||||
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
||||
|
||||
@@ -34,7 +34,7 @@ static inline void InsertSecondUint32(const uint32 value, __m128i &into)
|
||||
|
||||
static inline void LoadUint64(const uint64 value, __m128i &into)
|
||||
{
|
||||
#ifdef _SQ64
|
||||
#ifdef POINTER_IS_64BIT
|
||||
into = _mm_cvtsi64_si128(value);
|
||||
#else
|
||||
#if (SSE_VERSION >= 4)
|
||||
@@ -297,7 +297,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||
m_colour = r == 0 ? m_colour : cmap; \
|
||||
m_colour = m != 0 ? m_colour : srcm; \
|
||||
}
|
||||
#ifdef _SQ64
|
||||
#ifdef POINTER_IS_64BIT
|
||||
uint64 srcs = _mm_cvtsi128_si64(srcABCD);
|
||||
uint64 remapped_src = 0;
|
||||
CMOV_REMAP(c0, 0, srcs, mvX2);
|
||||
|
||||
+28
-28
@@ -16,14 +16,14 @@
|
||||
#include <utility>
|
||||
|
||||
template <typename SetPixelT>
|
||||
void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, int screen_height, int width, int dash, SetPixelT set_pixel)
|
||||
void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, int screen_height, int width, int dash, SetPixelT set_pixel)
|
||||
{
|
||||
int dy;
|
||||
int dx;
|
||||
int stepx;
|
||||
int stepy;
|
||||
|
||||
dy = (y2 - y) * 2;
|
||||
dy = (y2 - y1) * 2;
|
||||
if (dy < 0) {
|
||||
dy = -dy;
|
||||
stepy = -1;
|
||||
@@ -31,7 +31,7 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
stepy = 1;
|
||||
}
|
||||
|
||||
dx = (x2 - x) * 2;
|
||||
dx = (x2 - x1) * 2;
|
||||
if (dx < 0) {
|
||||
dx = -dx;
|
||||
stepx = -1;
|
||||
@@ -41,7 +41,7 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
|
||||
if (dx == 0 && dy == 0) {
|
||||
/* The algorithm below cannot handle this special case; make it work at least for line width 1 */
|
||||
if (x >= 0 && x < screen_width && y >= 0 && y < screen_height) set_pixel(x, y);
|
||||
if (x1 >= 0 && x1 < screen_width && y1 >= 0 && y1 < screen_height) set_pixel(x1, y1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,14 +67,14 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
int dash_count = 0;
|
||||
if (dx > dy) {
|
||||
if (stepx < 0) {
|
||||
std::swap(x, x2);
|
||||
std::swap(y, y2);
|
||||
std::swap(x1, x2);
|
||||
std::swap(y1, y2);
|
||||
stepy = -stepy;
|
||||
}
|
||||
if (x2 < 0 || x >= screen_width) return;
|
||||
if (x2 < 0 || x1 >= screen_width) return;
|
||||
|
||||
int y_low = y;
|
||||
int y_high = y;
|
||||
int y_low = y1;
|
||||
int y_high = y1;
|
||||
int frac_low = dy - frac_diff / 2;
|
||||
int frac_high = dy + frac_diff / 2;
|
||||
|
||||
@@ -87,10 +87,10 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
y_high += stepy;
|
||||
}
|
||||
|
||||
if (x < 0) {
|
||||
dash_count = (-x) % (dash + gap);
|
||||
if (x1 < 0) {
|
||||
dash_count = (-x1) % (dash + gap);
|
||||
auto adjust_frac = [&](int64 frac, int &y_bound) -> int {
|
||||
frac -= ((int64) dy) * ((int64) x);
|
||||
frac -= ((int64) dy) * ((int64) x1);
|
||||
if (frac >= 0) {
|
||||
int quotient = frac / dx;
|
||||
int remainder = frac % dx;
|
||||
@@ -101,17 +101,17 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
};
|
||||
frac_low = adjust_frac(frac_low, y_low);
|
||||
frac_high = adjust_frac(frac_high, y_high);
|
||||
x = 0;
|
||||
x1 = 0;
|
||||
}
|
||||
x2++;
|
||||
if (x2 > screen_width) {
|
||||
x2 = screen_width;
|
||||
}
|
||||
|
||||
while (x != x2) {
|
||||
while (x1 != x2) {
|
||||
if (dash_count < dash) {
|
||||
for (int y = y_low; y != y_high; y += stepy) {
|
||||
if (y >= 0 && y < screen_height) set_pixel(x, y);
|
||||
if (y >= 0 && y < screen_height) set_pixel(x1, y);
|
||||
}
|
||||
}
|
||||
if (frac_low >= 0) {
|
||||
@@ -122,21 +122,21 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
y_high += stepy;
|
||||
frac_high -= dx;
|
||||
}
|
||||
x++;
|
||||
x1++;
|
||||
frac_low += dy;
|
||||
frac_high += dy;
|
||||
if (++dash_count >= dash + gap) dash_count = 0;
|
||||
}
|
||||
} else {
|
||||
if (stepy < 0) {
|
||||
std::swap(x, x2);
|
||||
std::swap(y, y2);
|
||||
std::swap(x1, x2);
|
||||
std::swap(y1, y2);
|
||||
stepx = -stepx;
|
||||
}
|
||||
if (y2 < 0 || y >= screen_height) return;
|
||||
if (y2 < 0 || y1 >= screen_height) return;
|
||||
|
||||
int x_low = x;
|
||||
int x_high = x;
|
||||
int x_low = x1;
|
||||
int x_high = x1;
|
||||
int frac_low = dx - frac_diff / 2;
|
||||
int frac_high = dx + frac_diff / 2;
|
||||
|
||||
@@ -149,10 +149,10 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
x_high += stepx;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
dash_count = (-y) % (dash + gap);
|
||||
if (y1 < 0) {
|
||||
dash_count = (-y1) % (dash + gap);
|
||||
auto adjust_frac = [&](int64 frac, int &x_bound) -> int {
|
||||
frac -= ((int64) dx) * ((int64) y);
|
||||
frac -= ((int64) dx) * ((int64) y1);
|
||||
if (frac >= 0) {
|
||||
int quotient = frac / dy;
|
||||
int remainder = frac % dy;
|
||||
@@ -163,17 +163,17 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
};
|
||||
frac_low = adjust_frac(frac_low, x_low);
|
||||
frac_high = adjust_frac(frac_high, x_high);
|
||||
y = 0;
|
||||
y1 = 0;
|
||||
}
|
||||
y2++;
|
||||
if (y2 > screen_height) {
|
||||
y2 = screen_height;
|
||||
}
|
||||
|
||||
while (y != y2) {
|
||||
while (y1 != y2) {
|
||||
if (dash_count < dash) {
|
||||
for (int x = x_low; x != x_high; x += stepx) {
|
||||
if (x >= 0 && x < screen_width) set_pixel(x, y);
|
||||
if (x >= 0 && x < screen_width) set_pixel(x, y1);
|
||||
}
|
||||
}
|
||||
if (frac_low >= 0) {
|
||||
@@ -184,7 +184,7 @@ void Blitter::DrawLineGeneric(int x, int y, int x2, int y2, int screen_width, in
|
||||
x_high += stepx;
|
||||
frac_high -= dy;
|
||||
}
|
||||
y++;
|
||||
y1++;
|
||||
frac_low += dx;
|
||||
frac_high += dx;
|
||||
if (++dash_count >= dash + gap) dash_count = 0;
|
||||
|
||||
@@ -61,15 +61,16 @@ protected:
|
||||
name(name), description(description)
|
||||
{
|
||||
if (usable) {
|
||||
Blitters &blitters = GetBlitters();
|
||||
assert(blitters.find(this->name) == blitters.end());
|
||||
/*
|
||||
* Only add when the blitter is usable. Do not bail out or
|
||||
* do more special things since the blitters are always
|
||||
* instantiated upon start anyhow and freed upon shutdown.
|
||||
*/
|
||||
std::pair<Blitters::iterator, bool> P = GetBlitters().insert(Blitters::value_type(this->name, this));
|
||||
assert(P.second);
|
||||
blitters.insert(Blitters::value_type(this->name, this));
|
||||
} else {
|
||||
DEBUG(driver, 1, "Not registering blitter %s as it is not usable", name);
|
||||
Debug(driver, 1, "Not registering blitter {} as it is not usable", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the requested blitter and return his class.
|
||||
* Find the requested blitter and return its class.
|
||||
* @param name the blitter to select.
|
||||
* @post Sets the blitter so GetCurrentBlitter() returns it too.
|
||||
*/
|
||||
@@ -103,7 +104,7 @@ public:
|
||||
delete *GetActiveBlitter();
|
||||
*GetActiveBlitter() = newb;
|
||||
|
||||
DEBUG(driver, 1, "Successfully %s blitter '%s'", name.empty() ? "probed" : "loaded", newb->GetName());
|
||||
Debug(driver, 1, "Successfully {} blitter '{}'", name.empty() ? "probed" : "loaded", newb->GetName());
|
||||
return newb;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,10 @@ public:
|
||||
this->InitNested(1);
|
||||
}
|
||||
|
||||
~BootstrapErrorWindow()
|
||||
void Close() override
|
||||
{
|
||||
_exit_game = true;
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
@@ -144,12 +145,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~BootstrapContentDownloadStatusWindow()
|
||||
void Close() override
|
||||
{
|
||||
/* If we are not set to exit the game, it means the bootstrap failed. */
|
||||
if (!_exit_game) {
|
||||
new BootstrapErrorWindow();
|
||||
}
|
||||
this->BaseNetworkContentDownloadStatusWindow::Close();
|
||||
}
|
||||
|
||||
void OnDownloadComplete(ContentID cid) override
|
||||
@@ -162,7 +164,7 @@ public:
|
||||
|
||||
/* _exit_game is used to break out of the outer video driver's MainLoop. */
|
||||
_exit_game = true;
|
||||
delete this;
|
||||
this->Close();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -201,9 +203,10 @@ public:
|
||||
}
|
||||
|
||||
/** Stop listening to the content client events. */
|
||||
~BootstrapAskForDownloadWindow()
|
||||
void Close() override
|
||||
{
|
||||
_network_content_client.RemoveCallback(this);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
@@ -264,7 +267,7 @@ public:
|
||||
/* And once the meta data is received, start downloading it. */
|
||||
_network_content_client.Select(ci->id);
|
||||
new BootstrapContentDownloadStatusWindow();
|
||||
delete this;
|
||||
this->Close();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -249,7 +249,7 @@ public:
|
||||
if (i < 9 && i < this->bridges->size()) {
|
||||
/* Build the requested bridge */
|
||||
this->BuildBridge(i);
|
||||
delete this;
|
||||
this->Close();
|
||||
return ES_HANDLED;
|
||||
}
|
||||
return ES_NOT_HANDLED;
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
uint i = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BBS_BRIDGE_LIST);
|
||||
if (i < this->bridges->size()) {
|
||||
this->BuildBridge(i);
|
||||
delete this;
|
||||
this->Close();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ static WindowDesc _build_bridge_desc(
|
||||
*/
|
||||
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
|
||||
{
|
||||
DeleteWindowByClass(WC_BUILD_BRIDGE);
|
||||
CloseWindowByClass(WC_BUILD_BRIDGE);
|
||||
|
||||
/* Data type for the bridge.
|
||||
* Bit 16,15 = transport type,
|
||||
|
||||
+12
-13
@@ -1055,7 +1055,7 @@ struct BuildVehicleWindow : Window {
|
||||
CargoID cargo_filter[NUM_CARGO + 3]; ///< Available cargo filters; CargoID or CF_ANY or CF_NONE or CF_ENGINES
|
||||
StringID cargo_filter_texts[NUM_CARGO + 4]; ///< Texts for filter_cargo, terminated by INVALID_STRING_ID
|
||||
byte cargo_filter_criteria; ///< Selected cargo filter
|
||||
int details_height; ///< Minimal needed height of the details panels (found so far).
|
||||
int details_height; ///< Minimal needed height of the details panels, in text lines (found so far).
|
||||
Scrollbar *vscroll;
|
||||
TestedEngineDetails te; ///< Tested cost and capacity after refit.
|
||||
|
||||
@@ -1097,9 +1097,6 @@ struct BuildVehicleWindow : Window {
|
||||
* So we just hide it, and enlarge the Rename button by the now vacant place. */
|
||||
if (this->listview_mode) this->GetWidget<NWidgetStacked>(WID_BV_BUILD_SEL)->SetDisplayedPlane(SZSP_NONE);
|
||||
|
||||
/* disable renaming engines in network games if you are not the server */
|
||||
this->SetWidgetDisabledState(WID_BV_RENAME, _networking && !_network_server);
|
||||
|
||||
NWidgetCore *widget = this->GetWidget<NWidgetCore>(WID_BV_LIST);
|
||||
widget->tool_tip = STR_BUY_VEHICLE_TRAIN_LIST_TOOLTIP + type;
|
||||
|
||||
@@ -1115,7 +1112,7 @@ struct BuildVehicleWindow : Window {
|
||||
widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + type;
|
||||
widget->SetLowered(this->show_hidden_engines);
|
||||
|
||||
this->details_height = ((this->vehicle_type == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
this->details_height = ((this->vehicle_type == VEH_TRAIN) ? 10 : 9);
|
||||
|
||||
this->FinishInitNested(tile == INVALID_TILE ? (int)type : tile);
|
||||
|
||||
@@ -1186,8 +1183,7 @@ struct BuildVehicleWindow : Window {
|
||||
}
|
||||
|
||||
/* Collect available cargo types for filtering. */
|
||||
const CargoSpec *cs;
|
||||
FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) {
|
||||
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
|
||||
this->cargo_filter[filter_items] = cs->Index();
|
||||
this->cargo_filter_texts[filter_items] = cs->name;
|
||||
filter_items++;
|
||||
@@ -1230,7 +1226,7 @@ struct BuildVehicleWindow : Window {
|
||||
|
||||
if (!this->listview_mode) {
|
||||
/* Query for cost and refitted capacity */
|
||||
CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type), nullptr);
|
||||
CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type));
|
||||
if (ret.Succeeded()) {
|
||||
this->te.cost = ret.GetCost() - e->GetCost();
|
||||
this->te.capacity = _returned_refit_capacity;
|
||||
@@ -1553,7 +1549,7 @@ struct BuildVehicleWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_BV_PANEL:
|
||||
size->height = this->details_height;
|
||||
size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height;
|
||||
break;
|
||||
|
||||
case WID_BV_SORT_ASCENDING_DESCENDING: {
|
||||
@@ -1609,7 +1605,10 @@ struct BuildVehicleWindow : Window {
|
||||
this->GenerateBuildList();
|
||||
this->vscroll->SetCount((uint)this->eng_list.size());
|
||||
|
||||
this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WID_BV_RENAME, WIDGET_LIST_END);
|
||||
this->SetWidgetsDisabledState(this->sel_engine == INVALID_ENGINE, WID_BV_SHOW_HIDE, WID_BV_BUILD, WIDGET_LIST_END);
|
||||
|
||||
/* Disable renaming engines in network games if you are not the server. */
|
||||
this->SetWidgetDisabledState(WID_BV_RENAME, this->sel_engine == INVALID_ENGINE || (_networking && !_network_server));
|
||||
|
||||
this->DrawWidgets();
|
||||
|
||||
@@ -1620,12 +1619,12 @@ struct BuildVehicleWindow : Window {
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_BV_PANEL);
|
||||
int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
|
||||
nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine, this->te);
|
||||
needed_height = std::max(needed_height, text_end - (int)nwi->pos_y + WD_FRAMERECT_BOTTOM);
|
||||
needed_height = std::max(needed_height, (text_end - (int)nwi->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
|
||||
int resize = needed_height - this->details_height;
|
||||
this->details_height = needed_height;
|
||||
this->ReInit(0, resize);
|
||||
this->ReInit(0, resize * FONT_HEIGHT_NORMAL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1686,7 +1685,7 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type)
|
||||
|
||||
assert(IsCompanyBuildableVehicleType(type));
|
||||
|
||||
DeleteWindowById(WC_BUILD_VEHICLE, num);
|
||||
CloseWindowById(WC_BUILD_VEHICLE, num);
|
||||
|
||||
new BuildVehicleWindow(&_build_vehicle_desc, tile, type);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ enum CargoType {
|
||||
CT_PLASTIC = 10,
|
||||
CT_FIZZY_DRINKS = 11,
|
||||
|
||||
NUM_ORIGINAL_CARGO = 12,
|
||||
NUM_CARGO = 64, ///< Maximal number of cargo types in a game.
|
||||
|
||||
CT_AUTO_REFIT = 0xFD, ///< Automatically choose cargo type when doing auto refitting.
|
||||
|
||||
+7
-6
@@ -17,6 +17,7 @@
|
||||
#include "cargo_type.h"
|
||||
#include "vehicle_type.h"
|
||||
#include "core/multimap.hpp"
|
||||
#include "saveload/saveload.h"
|
||||
#include <list>
|
||||
|
||||
/** Unique identifier for a single cargo packet. */
|
||||
@@ -32,7 +33,7 @@ struct GoodsEntry; // forward-declare for Stage() and RerouteStalePackets()
|
||||
|
||||
template <class Tinst, class Tcont> class CargoList;
|
||||
class StationCargoList; // forward-declare, so we can use it in VehicleCargoList.
|
||||
extern const struct SaveLoad *GetCargoPacketDesc();
|
||||
extern SaveLoadTable GetCargoPacketDesc();
|
||||
|
||||
typedef uint32 TileOrStationID;
|
||||
|
||||
@@ -58,7 +59,7 @@ private:
|
||||
friend class VehicleCargoList;
|
||||
friend class StationCargoList;
|
||||
/** We want this to be saved, right? */
|
||||
friend const struct SaveLoad *GetCargoPacketDesc();
|
||||
friend SaveLoadTable GetCargoPacketDesc();
|
||||
public:
|
||||
/** Maximum number of items in a single cargo packet. */
|
||||
static const uint16 MAX_COUNT = UINT16_MAX;
|
||||
@@ -304,8 +305,8 @@ public:
|
||||
friend class StationCargoList;
|
||||
/** The super class ought to know what it's doing. */
|
||||
friend class CargoList<VehicleCargoList, CargoPacketList>;
|
||||
/** The vehicles have a cargo list (and we want that saved). */
|
||||
friend const struct SaveLoad *GetVehicleDescription(VehicleType vt);
|
||||
/* So we can use private/protected variables in the saveload code */
|
||||
friend class SlVehicleCommon;
|
||||
|
||||
friend class CargoShift;
|
||||
friend class CargoTransfer;
|
||||
@@ -455,8 +456,8 @@ protected:
|
||||
public:
|
||||
/** The super class ought to know what it's doing. */
|
||||
friend class CargoList<StationCargoList, StationCargoPacketMap>;
|
||||
/** The stations, via GoodsEntry, have a CargoList. */
|
||||
friend const struct SaveLoad *GetGoodsDesc();
|
||||
/* So we can use private/protected variables in the saveload code */
|
||||
friend class SlStationGoods;
|
||||
|
||||
friend class CargoLoad;
|
||||
friend class CargoTransfer;
|
||||
|
||||
+34
-13
@@ -77,6 +77,28 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cargo ID of a default cargo, if present.
|
||||
* @param l Landscape
|
||||
* @param ct Default cargo type.
|
||||
* @return ID number if the cargo exists, else #CT_INVALID
|
||||
*/
|
||||
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct)
|
||||
{
|
||||
assert(l < lengthof(_default_climate_cargo));
|
||||
|
||||
if (ct == CT_INVALID) return CT_INVALID;
|
||||
|
||||
assert(ct < lengthof(_default_climate_cargo[0]));
|
||||
CargoLabel cl = _default_climate_cargo[l][ct];
|
||||
/* Bzzt: check if cl is just an index into the cargo table */
|
||||
if (cl < lengthof(_default_cargo)) {
|
||||
cl = _default_cargo[cl].label;
|
||||
}
|
||||
|
||||
return GetCargoIDByLabel(cl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cargo ID by cargo label.
|
||||
* @param cl Cargo type to get.
|
||||
@@ -84,8 +106,7 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
*/
|
||||
CargoID GetCargoIDByLabel(CargoLabel cl)
|
||||
{
|
||||
const CargoSpec *cs;
|
||||
FOR_ALL_CARGOSPECS(cs) {
|
||||
for (const CargoSpec *cs : CargoSpec::Iterate()) {
|
||||
if (cs->label == cl) return cs->Index();
|
||||
}
|
||||
|
||||
@@ -103,8 +124,7 @@ CargoID GetCargoIDByBitnum(uint8 bitnum)
|
||||
{
|
||||
if (bitnum == INVALID_CARGO) return CT_INVALID;
|
||||
|
||||
const CargoSpec *cs;
|
||||
FOR_ALL_CARGOSPECS(cs) {
|
||||
for (const CargoSpec *cs : CargoSpec::Iterate()) {
|
||||
if (cs->bitnum == bitnum) return cs->Index();
|
||||
}
|
||||
|
||||
@@ -129,9 +149,8 @@ SpriteID CargoSpec::GetCargoIcon() const
|
||||
return sprite;
|
||||
}
|
||||
|
||||
std::vector<const CargoSpec *> _sorted_cargo_specs; ///< Cargo specifications sorted alphabetically by name.
|
||||
uint8 _sorted_standard_cargo_specs_size; ///< Number of standard cargo specifications stored in the _sorted_cargo_specs array.
|
||||
|
||||
std::vector<const CargoSpec *> _sorted_cargo_specs; ///< Cargo specifications sorted alphabetically by name.
|
||||
span<const CargoSpec *> _sorted_standard_cargo_specs; ///< Standard cargo specifications sorted alphabetically by name.
|
||||
|
||||
/** Sort cargo specifications by their name. */
|
||||
static bool CargoSpecNameSorter(const CargoSpec * const &a, const CargoSpec * const &b)
|
||||
@@ -169,22 +188,24 @@ static bool CargoSpecClassSorter(const CargoSpec * const &a, const CargoSpec * c
|
||||
void InitializeSortedCargoSpecs()
|
||||
{
|
||||
_sorted_cargo_specs.clear();
|
||||
const CargoSpec *cargo;
|
||||
/* Add each cargo spec to the list. */
|
||||
FOR_ALL_CARGOSPECS(cargo) {
|
||||
for (const CargoSpec *cargo : CargoSpec::Iterate()) {
|
||||
_sorted_cargo_specs.push_back(cargo);
|
||||
}
|
||||
|
||||
/* Sort cargo specifications by cargo class and name. */
|
||||
std::sort(_sorted_cargo_specs.begin(), _sorted_cargo_specs.end(), &CargoSpecClassSorter);
|
||||
|
||||
/* Count the number of standard cargos and fill the mask. */
|
||||
_standard_cargo_mask = 0;
|
||||
|
||||
_sorted_standard_cargo_specs_size = 0;
|
||||
FOR_ALL_SORTED_CARGOSPECS(cargo) {
|
||||
uint8 nb_standard_cargo = 0;
|
||||
for (const auto &cargo : _sorted_cargo_specs) {
|
||||
if (cargo->classes & CC_SPECIAL) break;
|
||||
_sorted_standard_cargo_specs_size++;
|
||||
nb_standard_cargo++;
|
||||
SetBit(_standard_cargo_mask, cargo->Index());
|
||||
}
|
||||
|
||||
/* _sorted_standard_cargo_specs is a subset of _sorted_cargo_specs. */
|
||||
_sorted_standard_cargo_specs = { _sorted_cargo_specs.data(), nb_standard_cargo };
|
||||
}
|
||||
|
||||
|
||||
+49
-21
@@ -15,6 +15,8 @@
|
||||
#include "gfx_type.h"
|
||||
#include "strings_type.h"
|
||||
#include "landscape_type.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/span_type.hpp"
|
||||
#include <vector>
|
||||
|
||||
/** Globally unique label of a cargo type. */
|
||||
@@ -59,7 +61,7 @@ struct CargoSpec {
|
||||
uint8 rating_colour;
|
||||
uint8 weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
|
||||
uint16 multiplier; ///< Capacity multiplier for vehicles. (8 fractional bits)
|
||||
uint16 initial_payment;
|
||||
int32 initial_payment; ///< Initial payment rate before inflation is applied.
|
||||
uint8 transit_days[2];
|
||||
|
||||
bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier).
|
||||
@@ -122,6 +124,49 @@ struct CargoSpec {
|
||||
|
||||
SpriteID GetCargoIcon() const;
|
||||
|
||||
/**
|
||||
* Iterator to iterate all valid CargoSpec
|
||||
*/
|
||||
struct Iterator {
|
||||
typedef CargoSpec value_type;
|
||||
typedef CargoSpec *pointer;
|
||||
typedef CargoSpec &reference;
|
||||
typedef size_t difference_type;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
explicit Iterator(size_t index) : index(index)
|
||||
{
|
||||
this->ValidateIndex();
|
||||
};
|
||||
|
||||
bool operator==(const Iterator &other) const { return this->index == other.index; }
|
||||
bool operator!=(const Iterator &other) const { return !(*this == other); }
|
||||
CargoSpec * operator*() const { return CargoSpec::Get(this->index); }
|
||||
Iterator & operator++() { this->index++; this->ValidateIndex(); return *this; }
|
||||
|
||||
private:
|
||||
size_t index;
|
||||
void ValidateIndex() { while (this->index < CargoSpec::GetArraySize() && !(CargoSpec::Get(this->index)->IsValid())) this->index++; }
|
||||
};
|
||||
|
||||
/*
|
||||
* Iterable ensemble of all valid CargoSpec
|
||||
*/
|
||||
struct IterateWrapper {
|
||||
size_t from;
|
||||
IterateWrapper(size_t from = 0) : from(from) {}
|
||||
Iterator begin() { return Iterator(this->from); }
|
||||
Iterator end() { return Iterator(CargoSpec::GetArraySize()); }
|
||||
bool empty() { return this->begin() == this->end(); }
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an iterable ensemble of all valid CargoSpec
|
||||
* @param from index of the first CargoSpec to consider
|
||||
* @return an iterable ensemble of all valid CargoSpec
|
||||
*/
|
||||
static IterateWrapper Iterate(size_t from = 0) { return IterateWrapper(from); }
|
||||
|
||||
private:
|
||||
static CargoSpec array[NUM_CARGO]; ///< Array holding all CargoSpecs
|
||||
|
||||
@@ -134,10 +179,11 @@ extern CargoTypes _standard_cargo_mask;
|
||||
void SetupCargoForClimate(LandscapeID l);
|
||||
CargoID GetCargoIDByLabel(CargoLabel cl);
|
||||
CargoID GetCargoIDByBitnum(uint8 bitnum);
|
||||
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct);
|
||||
|
||||
void InitializeSortedCargoSpecs();
|
||||
extern std::vector<const CargoSpec *> _sorted_cargo_specs;
|
||||
extern uint8 _sorted_standard_cargo_specs_size;
|
||||
extern span<const CargoSpec *> _sorted_standard_cargo_specs;
|
||||
|
||||
/**
|
||||
* Does cargo \a c have cargo class \a cc?
|
||||
@@ -150,24 +196,6 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
||||
return (CargoSpec::Get(c)->classes & cc) != 0;
|
||||
}
|
||||
|
||||
#define FOR_ALL_CARGOSPECS_FROM(var, start) for (size_t cargospec_index = start; var = nullptr, cargospec_index < CargoSpec::GetArraySize(); cargospec_index++) \
|
||||
if ((var = CargoSpec::Get(cargospec_index))->IsValid())
|
||||
#define FOR_ALL_CARGOSPECS(var) FOR_ALL_CARGOSPECS_FROM(var, 0)
|
||||
|
||||
#define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, CargoTypes, cargo_bits)
|
||||
|
||||
/**
|
||||
* Loop header for iterating over cargoes, sorted by name. This includes phony cargoes like regearing cargoes.
|
||||
* @param var Reference getting the cargospec.
|
||||
* @see CargoSpec
|
||||
*/
|
||||
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_cargo_specs.size() && (var = _sorted_cargo_specs[index], true) ; index++)
|
||||
|
||||
/**
|
||||
* Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped.
|
||||
* @param var Reference getting the cargospec.
|
||||
* @see CargoSpec
|
||||
*/
|
||||
#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_standard_cargo_specs_size && (var = _sorted_cargo_specs[index], true); index++)
|
||||
using SetCargoBitIterator = SetBitIterator<CargoID, CargoTypes>;
|
||||
|
||||
#endif /* CARGOTYPE_H */
|
||||
|
||||
+13
-13
@@ -125,7 +125,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
|
||||
*/
|
||||
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
|
||||
{
|
||||
p1 = Clamp(p1, MIN_MAX_HEIGHTLEVEL, MAX_MAX_HEIGHTLEVEL);
|
||||
p1 = Clamp(p1, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
|
||||
|
||||
/* Check if at least one mountain on the map is higher than the new value.
|
||||
* If yes, disallow the change. */
|
||||
@@ -133,18 +133,18 @@ static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
|
||||
if ((int32)TileHeight(t) > p1) {
|
||||
ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
|
||||
/* Return old, unchanged value */
|
||||
return _settings_game.construction.max_heightlevel;
|
||||
return _settings_game.construction.map_height_limit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Execute the change and reload GRF Data */
|
||||
_settings_game.construction.max_heightlevel = p1;
|
||||
_settings_game.construction.map_height_limit = p1;
|
||||
ReloadNewGRFData();
|
||||
|
||||
/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
|
||||
InvalidateWindowClassesData(WC_SMALLMAP, 2);
|
||||
|
||||
return _settings_game.construction.max_heightlevel;
|
||||
return _settings_game.construction.map_height_limit;
|
||||
}
|
||||
|
||||
/** Available cheats. */
|
||||
@@ -182,14 +182,14 @@ struct CheatEntry {
|
||||
* Order matches with the values of #CheatNumbers
|
||||
*/
|
||||
static const CheatEntry _cheats_ui[] = {
|
||||
{SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
|
||||
{SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
|
||||
{SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
|
||||
{SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.max_heightlevel, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
|
||||
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
|
||||
{SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
|
||||
{SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
|
||||
{SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
|
||||
{SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
|
||||
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
|
||||
};
|
||||
|
||||
static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui));
|
||||
@@ -415,6 +415,6 @@ static WindowDesc _cheats_desc(
|
||||
/** Open cheat window. */
|
||||
void ShowCheatWindow()
|
||||
{
|
||||
DeleteWindowById(WC_CHEATS, 0);
|
||||
CloseWindowById(WC_CHEATS, 0);
|
||||
new CheatWindow(&_cheats_desc);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,9 @@ struct Cheats {
|
||||
Cheat switch_company; ///< change to another company
|
||||
Cheat money; ///< get rich or poor
|
||||
Cheat crossing_tunnels; ///< allow tunnels that cross each other
|
||||
Cheat dummy1; ///< empty cheat (build while in pause mode)
|
||||
Cheat no_jetcrash; ///< no jet will crash on small airports anymore
|
||||
Cheat dummy2; ///< empty cheat (change the climate of the map)
|
||||
Cheat change_date; ///< changes date ingame
|
||||
Cheat setup_prod; ///< setup raw-material production in game
|
||||
Cheat dummy3; ///< empty cheat (enable running el-engines on normal rail)
|
||||
Cheat edit_max_hl; ///< edit the maximum heightlevel; this is a cheat because of the fact that it needs to reset NewGRF game state and doing so as a simple configuration breaks the expectation of many
|
||||
};
|
||||
|
||||
|
||||
+7
-7
@@ -193,7 +193,7 @@ CommandProc CmdDeleteGroup;
|
||||
CommandProc CmdAddVehicleGroup;
|
||||
CommandProc CmdAddSharedVehicleGroup;
|
||||
CommandProc CmdRemoveAllVehiclesGroup;
|
||||
CommandProc CmdSetGroupReplaceProtection;
|
||||
CommandProc CmdSetGroupFlag;
|
||||
CommandProc CmdSetGroupLivery;
|
||||
|
||||
CommandProc CmdMoveOrder;
|
||||
@@ -359,7 +359,7 @@ static const Command _command_proc_table[] = {
|
||||
DEF_CMD(CmdAddVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_VEHICLE_GROUP
|
||||
DEF_CMD(CmdAddSharedVehicleGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_ADD_SHARE_VEHICLE_GROUP
|
||||
DEF_CMD(CmdRemoveAllVehiclesGroup, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_REMOVE_ALL_VEHICLES_GROUP
|
||||
DEF_CMD(CmdSetGroupReplaceProtection, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_GROUP_REPLACE_PROTECTION
|
||||
DEF_CMD(CmdSetGroupFlag, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_GROUP_FLAG
|
||||
DEF_CMD(CmdSetGroupLivery, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_GROUP_LIVERY
|
||||
DEF_CMD(CmdMoveOrder, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_MOVE_ORDER
|
||||
DEF_CMD(CmdChangeTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_CHANGE_TIMETABLE
|
||||
@@ -465,7 +465,7 @@ CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
|
||||
* @see CommandProc
|
||||
* @return the cost
|
||||
*/
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text)
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const std::string &text)
|
||||
{
|
||||
CommandCost res;
|
||||
|
||||
@@ -558,7 +558,7 @@ bool DoCommandP(const CommandContainer *container, bool my_cmd)
|
||||
* @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
|
||||
* @return \c true if the command succeeded, else \c false.
|
||||
*/
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd)
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd)
|
||||
{
|
||||
/* Cost estimation is generally only done when the
|
||||
* local user presses shift while doing something.
|
||||
@@ -631,7 +631,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
|
||||
* @param estimate_only whether to give only the estimate or also execute the command
|
||||
* @return the command cost of this function.
|
||||
*/
|
||||
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only)
|
||||
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only)
|
||||
{
|
||||
/* Prevent recursion; it gives a mess over the network */
|
||||
assert(_docommand_recursive == 0);
|
||||
@@ -696,7 +696,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
||||
if (!_networking || _generating_world || (cmd & CMD_NETWORK_COMMAND) != 0) {
|
||||
/* Log the failed command as well. Just to be able to be find
|
||||
* causes of desyncs due to bad command test implementations. */
|
||||
DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
||||
Debug(desync, 1, "cmdf: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
||||
}
|
||||
cur_company.Restore();
|
||||
return_dcpi(res);
|
||||
@@ -716,7 +716,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
||||
* reset the storages as we've not executed the command. */
|
||||
return_dcpi(CommandCost());
|
||||
}
|
||||
DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
||||
Debug(desync, 1, "cmd: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
|
||||
|
||||
/* Actually try and execute the command. If no cost-type is given
|
||||
* use the construction one */
|
||||
|
||||
+4
-4
@@ -32,15 +32,15 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
||||
*/
|
||||
#define return_cmd_error(errcode) return CommandCost(errcode);
|
||||
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = nullptr);
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const std::string &text = {});
|
||||
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
|
||||
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true);
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const std::string &text = {}, bool my_cmd = true);
|
||||
bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
|
||||
|
||||
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
|
||||
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only);
|
||||
|
||||
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
|
||||
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, CompanyID company);
|
||||
|
||||
extern Money _additional_cash_required;
|
||||
|
||||
|
||||
+3
-3
@@ -324,7 +324,7 @@ enum Commands {
|
||||
CMD_ADD_VEHICLE_GROUP, ///< add a vehicle to a group
|
||||
CMD_ADD_SHARED_VEHICLE_GROUP, ///< add all other shared vehicles to a group which are missing
|
||||
CMD_REMOVE_ALL_VEHICLES_GROUP, ///< remove all vehicles from a group
|
||||
CMD_SET_GROUP_REPLACE_PROTECTION, ///< set the autoreplace-protection for a group
|
||||
CMD_SET_GROUP_FLAG, ///< set/clear a flag for a group
|
||||
CMD_SET_GROUP_LIVERY, ///< set the livery for a group
|
||||
|
||||
CMD_MOVE_ORDER, ///< move an order
|
||||
@@ -443,7 +443,7 @@ enum CommandPauseLevel {
|
||||
* @param text Additional text
|
||||
* @return The CommandCost of the command, which can be succeeded or failed.
|
||||
*/
|
||||
typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
|
||||
typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text);
|
||||
|
||||
/**
|
||||
* Define a command with the flags which belongs to it.
|
||||
@@ -482,7 +482,7 @@ struct CommandContainer {
|
||||
uint32 p2; ///< parameter p2.
|
||||
uint32 cmd; ///< command being executed.
|
||||
CommandCallback *callback; ///< any callback function executed upon successful completion of the command.
|
||||
char text[32 * MAX_CHAR_LENGTH]; ///< possible text sent for name changes etc, in bytes including '\0'.
|
||||
std::string text; ///< possible text sent for name changes etc.
|
||||
};
|
||||
|
||||
#endif /* COMMAND_TYPE_H */
|
||||
|
||||
+7
-5
@@ -98,28 +98,30 @@ struct CompanyProperties {
|
||||
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]; ///< Economic data of the company of the last #MAX_HISTORY_QUARTERS quarters.
|
||||
byte num_valid_stat_ent; ///< Number of valid statistical entries in #old_economy.
|
||||
|
||||
Livery livery[LS_END];
|
||||
|
||||
EngineRenewList engine_renew_list; ///< Engine renewals of this company.
|
||||
CompanySettings settings; ///< settings specific for each company
|
||||
|
||||
// TODO: Change some of these member variables to use relevant INVALID_xxx constants
|
||||
CompanyProperties()
|
||||
: name_2(0), name_1(0), president_name_1(0), president_name_2(0),
|
||||
face(0), money(0), money_fraction(0), current_loan(0), colour(0), block_preview(0),
|
||||
location_of_HQ(0), last_build_coordinate(0), share_owners(), inaugurated_year(0),
|
||||
months_of_bankruptcy(0), bankrupt_asked(0), bankrupt_timeout(0), bankrupt_value(0),
|
||||
terraform_limit(0), clear_limit(0), tree_limit(0), is_ai(false) {}
|
||||
terraform_limit(0), clear_limit(0), tree_limit(0), is_ai(false), engine_renew_list(nullptr) {}
|
||||
};
|
||||
|
||||
struct Company : CompanyPool::PoolItem<&_company_pool>, CompanyProperties {
|
||||
struct Company : CompanyProperties, CompanyPool::PoolItem<&_company_pool> {
|
||||
Company(uint16 name_1 = 0, bool is_ai = false);
|
||||
~Company();
|
||||
|
||||
Livery livery[LS_END];
|
||||
RailTypes avail_railtypes; ///< Rail types available to this company.
|
||||
RoadTypes avail_roadtypes; ///< Road types available to this company.
|
||||
|
||||
class AIInstance *ai_instance;
|
||||
class AIInfo *ai_info;
|
||||
|
||||
EngineRenewList engine_renew_list; ///< Engine renewals of this company.
|
||||
CompanySettings settings; ///< settings specific for each company
|
||||
GroupStatistics group_all[VEH_COMPANY_END]; ///< NOSAVE: Statistics for the ALL_GROUP group.
|
||||
GroupStatistics group_default[VEH_COMPANY_END]; ///< NOSAVE: Statistics for the DEFAULT_GROUP group.
|
||||
|
||||
|
||||
+29
-37
@@ -67,7 +67,7 @@ Company::Company(uint16 name_1, bool is_ai)
|
||||
this->clear_limit = (uint32)_settings_game.construction.clear_frame_burst << 16;
|
||||
this->tree_limit = (uint32)_settings_game.construction.tree_frame_burst << 16;
|
||||
|
||||
for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
|
||||
for (uint j = 0; j < 4; j++) this->share_owners[j] = INVALID_OWNER;
|
||||
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ Company::~Company()
|
||||
{
|
||||
if (CleaningPool()) return;
|
||||
|
||||
DeleteCompanyWindows(this->index);
|
||||
CloseCompanyWindows(this->index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ void SetLocalCompany(CompanyID new_company)
|
||||
_current_company = _local_company = new_company;
|
||||
|
||||
/* Delete any construction windows... */
|
||||
if (switching_company) DeleteConstructionWindows();
|
||||
if (switching_company) CloseConstructionWindows();
|
||||
|
||||
/* ... and redraw the whole screen. */
|
||||
MarkWholeScreenDirty();
|
||||
@@ -376,8 +376,7 @@ set_name:;
|
||||
MarkWholeScreenDirty();
|
||||
|
||||
if (c->is_ai) {
|
||||
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
|
||||
cni->FillData(c);
|
||||
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||
SetDParam(0, STR_NEWS_COMPANY_LAUNCH_TITLE);
|
||||
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
|
||||
SetDParamStr(2, cni->company_name);
|
||||
@@ -571,8 +570,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
|
||||
GeneratePresidentName(c);
|
||||
|
||||
SetWindowDirty(WC_GRAPH_LEGEND, 0);
|
||||
SetWindowClassesDirty(WC_CLIENT_LIST_POPUP);
|
||||
SetWindowDirty(WC_CLIENT_LIST, 0);
|
||||
InvalidateWindowData(WC_CLIENT_LIST, 0);
|
||||
InvalidateWindowData(WC_LINKGRAPH_LEGEND, 0);
|
||||
BuildOwnerLegend();
|
||||
InvalidateWindowData(WC_SMALLMAP, 0, 1);
|
||||
@@ -756,21 +754,19 @@ void CompaniesYearlyLoop()
|
||||
* @param c the current company.
|
||||
* @param other the other company (use \c nullptr if not relevant).
|
||||
*/
|
||||
void CompanyNewsInformation::FillData(const Company *c, const Company *other)
|
||||
CompanyNewsInformation::CompanyNewsInformation(const Company *c, const Company *other)
|
||||
{
|
||||
SetDParam(0, c->index);
|
||||
GetString(this->company_name, STR_COMPANY_NAME, lastof(this->company_name));
|
||||
this->company_name = GetString(STR_COMPANY_NAME);
|
||||
|
||||
if (other == nullptr) {
|
||||
*this->other_company_name = '\0';
|
||||
} else {
|
||||
if (other != nullptr) {
|
||||
SetDParam(0, other->index);
|
||||
GetString(this->other_company_name, STR_COMPANY_NAME, lastof(this->other_company_name));
|
||||
this->other_company_name = GetString(STR_COMPANY_NAME);
|
||||
c = other;
|
||||
}
|
||||
|
||||
SetDParam(0, c->index);
|
||||
GetString(this->president_name, STR_PRESIDENT_NAME_MANAGER, lastof(this->president_name));
|
||||
this->president_name = GetString(STR_PRESIDENT_NAME_MANAGER);
|
||||
|
||||
this->colour = c->colour;
|
||||
this->face = c->face;
|
||||
@@ -808,7 +804,7 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason)
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
|
||||
CompanyID company_id = (CompanyID)GB(p1, 16, 8);
|
||||
@@ -825,7 +821,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
|
||||
|
||||
/* Delete multiplayer progress bar */
|
||||
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
CloseWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
|
||||
Company *c = DoStartupNewCompany(false);
|
||||
|
||||
@@ -844,7 +840,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
if (client_id == _network_own_client_id) {
|
||||
assert(_local_company == COMPANY_SPECTATOR);
|
||||
SetLocalCompany(c->index);
|
||||
if (!StrEmpty(_settings_client.network.default_company_pass)) {
|
||||
if (!_settings_client.network.default_company_pass.empty()) {
|
||||
NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass);
|
||||
}
|
||||
|
||||
@@ -888,9 +884,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
if (!(flags & DC_EXEC)) return CommandCost();
|
||||
|
||||
/* Delete any open window of the company */
|
||||
DeleteCompanyWindows(c->index);
|
||||
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
|
||||
cni->FillData(c);
|
||||
CloseCompanyWindows(c->index);
|
||||
CompanyNewsInformation *cni = new CompanyNewsInformation(c);
|
||||
|
||||
/* Show the bankrupt news */
|
||||
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
|
||||
@@ -909,6 +904,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
|
||||
|
||||
if (StoryPage::GetNumItems() == 0 || Goal::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
|
||||
InvalidateWindowData(WC_CLIENT_LIST, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -931,7 +928,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
CompanyManagerFace cmf = (CompanyManagerFace)p2;
|
||||
|
||||
@@ -955,7 +952,7 @@ CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
Colours colour = Extract<Colours, 0, 8>(p2);
|
||||
LiveryScheme scheme = Extract<LiveryScheme, 0, 8>(p1);
|
||||
@@ -1048,7 +1045,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
* @param name Name to search.
|
||||
* @return \c true if the name us unique (that is, not in use), else \c false.
|
||||
*/
|
||||
static bool IsUniqueCompanyName(const char *name)
|
||||
static bool IsUniqueCompanyName(const std::string &name)
|
||||
{
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (!c->name.empty() && c->name == name) return false;
|
||||
@@ -1066,9 +1063,9 @@ static bool IsUniqueCompanyName(const char *name)
|
||||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
bool reset = StrEmpty(text);
|
||||
bool reset = text.empty();
|
||||
|
||||
if (!reset) {
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_COMPANY_NAME_CHARS) return CMD_ERROR;
|
||||
@@ -1094,7 +1091,7 @@ CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||
* @param name Name to search.
|
||||
* @return \c true if the name us unique (that is, not in use), else \c false.
|
||||
*/
|
||||
static bool IsUniquePresidentName(const char *name)
|
||||
static bool IsUniquePresidentName(const std::string &name)
|
||||
{
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
if (!c->president_name.empty() && c->president_name == name) return false;
|
||||
@@ -1112,9 +1109,9 @@ static bool IsUniquePresidentName(const char *name)
|
||||
* @param text the new name or an empty string when resetting to the default
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
bool reset = StrEmpty(text);
|
||||
bool reset = text.empty();
|
||||
|
||||
if (!reset) {
|
||||
if (Utf8StringLength(text) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) return CMD_ERROR;
|
||||
@@ -1130,10 +1127,7 @@ CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||
c->president_name = text;
|
||||
|
||||
if (c->name_1 == STR_SV_UNNAMED && c->name.empty()) {
|
||||
char buf[80];
|
||||
|
||||
seprintf(buf, lastof(buf), "%s Transport", text);
|
||||
DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, buf);
|
||||
DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, text + " Transport");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,7 +1194,7 @@ uint32 CompanyInfrastructure::GetTramTotal() const
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (!_settings_game.economy.give_money) return CMD_ERROR;
|
||||
|
||||
@@ -1219,13 +1213,11 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
cur_company.Restore();
|
||||
|
||||
if (_networking) {
|
||||
char dest_company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
|
||||
SetDParam(0, dest_company);
|
||||
GetString(dest_company_name, STR_COMPANY_NAME, lastof(dest_company_name));
|
||||
std::string dest_company_name = GetString(STR_COMPANY_NAME);
|
||||
|
||||
char from_company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
|
||||
SetDParam(0, _current_company);
|
||||
GetString(from_company_name, STR_COMPANY_NAME, lastof(from_company_name));
|
||||
std::string from_company_name = GetString(STR_COMPANY_NAME);
|
||||
|
||||
NetworkTextMessage(NETWORK_ACTION_GIVE_MONEY, GetDrawStringCompanyColour(_current_company), false, from_company_name, dest_company_name, amount.GetCost());
|
||||
}
|
||||
|
||||
+76
-129
@@ -242,10 +242,10 @@ static const NWidgetPart _nested_company_finances_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_SPACER), SetFill(0, 0), SetMinimalSize(30, 0),
|
||||
NWidget(NWID_VERTICAL), // Vertical column with bank balance amount, loan amount, and total.
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CF_BALANCE_VALUE), SetDataTip(STR_NULL, STR_NULL),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CF_LOAN_VALUE), SetDataTip(STR_NULL, STR_NULL),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CF_BALANCE_VALUE), SetDataTip(STR_FINANCES_TOTAL_CURRENCY, STR_NULL), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CF_LOAN_VALUE), SetDataTip(STR_FINANCES_TOTAL_CURRENCY, STR_NULL), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_EMPTY, COLOUR_GREY, WID_CF_LOAN_LINE), SetMinimalSize(0, 2), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CF_TOTAL_VALUE), SetDataTip(STR_NULL, STR_NULL),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_CF_TOTAL_VALUE), SetDataTip(STR_FINANCES_TOTAL_CURRENCY, STR_NULL), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
EndContainer(),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_CF_SEL_MAXLOAN),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
@@ -292,6 +292,24 @@ struct CompanyFinancesWindow : Window {
|
||||
SetDParam(1, (CompanyID)this->window_number);
|
||||
break;
|
||||
|
||||
case WID_CF_BALANCE_VALUE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
SetDParam(0, c->money);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_LOAN_VALUE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
SetDParam(0, c->current_loan);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_TOTAL_VALUE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
SetDParam(0, c->money - c->current_loan);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_MAXLOAN_VALUE:
|
||||
SetDParam(0, _economy.max_loan);
|
||||
break;
|
||||
@@ -350,27 +368,6 @@ struct CompanyFinancesWindow : Window {
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_BALANCE_VALUE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
SetDParam(0, c->money);
|
||||
DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_LOAN_VALUE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
SetDParam(0, c->current_loan);
|
||||
DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_TOTAL_VALUE: {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
SetDParam(0, c->money - c->current_loan);
|
||||
DrawString(r.left, r.right, r.top, STR_FINANCES_TOTAL_CURRENCY, TC_FROMSTRING, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_CF_LOAN_LINE:
|
||||
GfxFillRect(r.left, r.top, r.right, r.top, PC_BLACK);
|
||||
break;
|
||||
@@ -779,11 +776,11 @@ public:
|
||||
|
||||
case WID_SCL_PRI_COL_DROPDOWN: {
|
||||
this->square = GetSpriteSize(SPR_SQUARE);
|
||||
int padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
|
||||
int string_padding = this->square.width + NWidgetScrollbar::GetVerticalDimension().width + 10;
|
||||
for (const StringID *id = _colour_dropdown; id != endof(_colour_dropdown); id++) {
|
||||
size->width = std::max(size->width, GetStringBoundingBox(*id).width + padding);
|
||||
size->width = std::max(size->width, GetStringBoundingBox(*id).width + string_padding);
|
||||
}
|
||||
size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + padding);
|
||||
size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + string_padding);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -956,7 +953,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_SCL_MATRIX: {
|
||||
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCL_MATRIX, 0, this->line_height);
|
||||
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCL_MATRIX);
|
||||
if (row >= this->rows) return;
|
||||
|
||||
if (this->livery_class < LC_GROUP_RAIL) {
|
||||
@@ -1200,70 +1197,82 @@ static const NWidgetPart _nested_select_company_manager_face_widgets[] = {
|
||||
EndContainer(),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(0, 4),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_EYECOLOUR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_HAS_MOUSTACHE_EARRING), SetDataTip(STR_EMPTY, STR_FACE_MOUSTACHE_EARRING_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_HAS_GLASSES_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAS_GLASSES_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_GLASSES, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_HAS_GLASSES), SetDataTip(STR_EMPTY, STR_FACE_GLASSES_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetFill(1, 0),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_HAIR_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_HAIR_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_HAIR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_HAIR_L), SetDataTip(AWV_DECREASE, STR_FACE_HAIR_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_HAIR), SetDataTip(STR_EMPTY, STR_FACE_HAIR_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_HAIR_R), SetDataTip(AWV_INCREASE, STR_FACE_HAIR_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_EYEBROWS_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_EYEBROWS_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_EYEBROWS, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYEBROWS_L), SetDataTip(AWV_DECREASE, STR_FACE_EYEBROWS_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_EYEBROWS), SetDataTip(STR_EMPTY, STR_FACE_EYEBROWS_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYEBROWS_R), SetDataTip(AWV_INCREASE, STR_FACE_EYEBROWS_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_EYECOLOUR_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_EYECOLOUR_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_EYECOLOUR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYECOLOUR_L), SetDataTip(AWV_DECREASE, STR_FACE_EYECOLOUR_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_EYECOLOUR), SetDataTip(STR_EMPTY, STR_FACE_EYECOLOUR_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_EYECOLOUR_R), SetDataTip(AWV_INCREASE, STR_FACE_EYECOLOUR_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_GLASSES_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_GLASSES_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_GLASSES, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_GLASSES_L), SetDataTip(AWV_DECREASE, STR_FACE_GLASSES_TOOLTIP_2),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_GLASSES), SetDataTip(STR_EMPTY, STR_FACE_GLASSES_TOOLTIP_2),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_GLASSES_R), SetDataTip(AWV_INCREASE, STR_FACE_GLASSES_TOOLTIP_2),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_NOSE_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_NOSE_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_NOSE, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_NOSE_L), SetDataTip(AWV_DECREASE, STR_FACE_NOSE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_NOSE), SetDataTip(STR_EMPTY, STR_FACE_NOSE_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_NOSE_R), SetDataTip(AWV_INCREASE, STR_FACE_NOSE_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_LIPS_MOUSTACHE_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_LIPS_MOUSTACHE_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_MOUSTACHE, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_LIPS_MOUSTACHE_L), SetDataTip(AWV_DECREASE, STR_FACE_LIPS_MOUSTACHE_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_LIPS_MOUSTACHE), SetDataTip(STR_EMPTY, STR_FACE_LIPS_MOUSTACHE_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_LIPS_MOUSTACHE_R), SetDataTip(AWV_INCREASE, STR_FACE_LIPS_MOUSTACHE_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_CHIN_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_CHIN_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_CHIN, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_CHIN_L), SetDataTip(AWV_DECREASE, STR_FACE_CHIN_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_CHIN), SetDataTip(STR_EMPTY, STR_FACE_CHIN_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_CHIN_R), SetDataTip(AWV_INCREASE, STR_FACE_CHIN_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_JACKET_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_JACKET_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_JACKET, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_JACKET_L), SetDataTip(AWV_DECREASE, STR_FACE_JACKET_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_JACKET), SetDataTip(STR_EMPTY, STR_FACE_JACKET_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_JACKET_R), SetDataTip(AWV_INCREASE, STR_FACE_JACKET_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_COLLAR_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_COLLAR_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_COLLAR, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_COLLAR_L), SetDataTip(AWV_DECREASE, STR_FACE_COLLAR_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_COLLAR), SetDataTip(STR_EMPTY, STR_FACE_COLLAR_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_COLLAR_R), SetDataTip(AWV_INCREASE, STR_FACE_COLLAR_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SCMF_TIE_EARRING_TEXT), SetFill(1, 0),
|
||||
NWidget(WWT_TEXT, INVALID_COLOUR, WID_SCMF_TIE_EARRING_TEXT), SetFill(1, 0), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT),
|
||||
SetDataTip(STR_FACE_EARRING, STR_NULL), SetTextColour(TC_GOLD), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_TIE_EARRING_L), SetDataTip(AWV_DECREASE, STR_FACE_TIE_EARRING_TOOLTIP),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCMF_TIE_EARRING), SetDataTip(STR_EMPTY, STR_FACE_TIE_EARRING_TOOLTIP),
|
||||
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_SCMF_TIE_EARRING_R), SetDataTip(AWV_INCREASE, STR_FACE_TIE_EARRING_TOOLTIP),
|
||||
@@ -1294,9 +1303,6 @@ class SelectCompanyManagerFaceWindow : public Window
|
||||
Dimension yesno_dim; ///< Dimension of a yes/no button of a part in the advanced face window.
|
||||
Dimension number_dim; ///< Dimension of a number widget of a part in the advanced face window.
|
||||
|
||||
static const StringID PART_TEXTS_IS_FEMALE[]; ///< Strings depending on #is_female, used to describe parts (2 entries for a part).
|
||||
static const StringID PART_TEXTS[]; ///< Fixed strings to describe parts of the face.
|
||||
|
||||
/**
|
||||
* Draw dynamic a label to the left of the button and a value in the button
|
||||
*
|
||||
@@ -1329,6 +1335,10 @@ class SelectCompanyManagerFaceWindow : public Window
|
||||
this->ge = (GenderEthnicity)GB(this->face, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // get the gender and ethnicity
|
||||
this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
|
||||
this->is_moust_male = !is_female && GetCompanyManagerFaceBits(this->face, CMFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
|
||||
|
||||
this->GetWidget<NWidgetCore>(WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT)->widget_data = this->is_female ? STR_FACE_EARRING : STR_FACE_MOUSTACHE;
|
||||
this->GetWidget<NWidgetCore>(WID_SCMF_TIE_EARRING_TEXT)->widget_data = this->is_female ? STR_FACE_EARRING : STR_FACE_TIE;
|
||||
this->GetWidget<NWidgetCore>(WID_SCMF_LIPS_MOUSTACHE_TEXT)->widget_data = this->is_moust_male ? STR_FACE_MOUSTACHE : STR_FACE_LIPS;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -1390,6 +1400,21 @@ public:
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT:
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING));
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE));
|
||||
break;
|
||||
|
||||
case WID_SCMF_TIE_EARRING_TEXT:
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING));
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_TIE));
|
||||
break;
|
||||
|
||||
case WID_SCMF_LIPS_MOUSTACHE_TEXT:
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_LIPS));
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE));
|
||||
break;
|
||||
|
||||
case WID_SCMF_FACE: {
|
||||
Dimension face_size = GetSpriteSize(SPR_GRADIENT);
|
||||
size->width = std::max(size->width, face_size.width);
|
||||
@@ -1397,35 +1422,6 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT:
|
||||
case WID_SCMF_TIE_EARRING_TEXT: {
|
||||
int offset = (widget - WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT) * 2;
|
||||
*size = maxdim(GetStringBoundingBox(PART_TEXTS_IS_FEMALE[offset]), GetStringBoundingBox(PART_TEXTS_IS_FEMALE[offset + 1]));
|
||||
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_SCMF_LIPS_MOUSTACHE_TEXT:
|
||||
*size = maxdim(GetStringBoundingBox(STR_FACE_LIPS), GetStringBoundingBox(STR_FACE_MOUSTACHE));
|
||||
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
break;
|
||||
|
||||
case WID_SCMF_HAS_GLASSES_TEXT:
|
||||
case WID_SCMF_HAIR_TEXT:
|
||||
case WID_SCMF_EYEBROWS_TEXT:
|
||||
case WID_SCMF_EYECOLOUR_TEXT:
|
||||
case WID_SCMF_GLASSES_TEXT:
|
||||
case WID_SCMF_NOSE_TEXT:
|
||||
case WID_SCMF_CHIN_TEXT:
|
||||
case WID_SCMF_JACKET_TEXT:
|
||||
case WID_SCMF_COLLAR_TEXT:
|
||||
*size = GetStringBoundingBox(PART_TEXTS[widget - WID_SCMF_HAS_GLASSES_TEXT]);
|
||||
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
break;
|
||||
|
||||
case WID_SCMF_HAS_MOUSTACHE_EARRING:
|
||||
case WID_SCMF_HAS_GLASSES:
|
||||
*size = this->yesno_dim;
|
||||
@@ -1510,30 +1506,6 @@ public:
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT:
|
||||
case WID_SCMF_TIE_EARRING_TEXT: {
|
||||
StringID str = PART_TEXTS_IS_FEMALE[(widget - WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT) * 2 + this->is_female];
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_GOLD, SA_RIGHT);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_SCMF_LIPS_MOUSTACHE_TEXT:
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, (this->is_moust_male) ? STR_FACE_MOUSTACHE : STR_FACE_LIPS, TC_GOLD, SA_RIGHT);
|
||||
break;
|
||||
|
||||
case WID_SCMF_HAS_GLASSES_TEXT:
|
||||
case WID_SCMF_HAIR_TEXT:
|
||||
case WID_SCMF_EYEBROWS_TEXT:
|
||||
case WID_SCMF_EYECOLOUR_TEXT:
|
||||
case WID_SCMF_GLASSES_TEXT:
|
||||
case WID_SCMF_NOSE_TEXT:
|
||||
case WID_SCMF_CHIN_TEXT:
|
||||
case WID_SCMF_JACKET_TEXT:
|
||||
case WID_SCMF_COLLAR_TEXT:
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, PART_TEXTS[widget - WID_SCMF_HAS_GLASSES_TEXT], TC_GOLD, SA_RIGHT);
|
||||
break;
|
||||
|
||||
|
||||
case WID_SCMF_HAS_MOUSTACHE_EARRING:
|
||||
if (this->is_female) { // Only for female faces
|
||||
this->DrawFaceStringLabel(WID_SCMF_HAS_MOUSTACHE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_HAS_TIE_EARRING, this->ge), true);
|
||||
@@ -1614,7 +1586,7 @@ public:
|
||||
|
||||
/* Cancel button */
|
||||
case WID_SCMF_CANCEL:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
/* Load button */
|
||||
@@ -1721,25 +1693,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** Both text values of parts of the face that depend on the #is_female boolean value. */
|
||||
const StringID SelectCompanyManagerFaceWindow::PART_TEXTS_IS_FEMALE[] = {
|
||||
STR_FACE_MOUSTACHE, STR_FACE_EARRING, // WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT
|
||||
STR_FACE_TIE, STR_FACE_EARRING, // WID_SCMF_TIE_EARRING_TEXT
|
||||
};
|
||||
|
||||
/** Textual names for parts of the face. */
|
||||
const StringID SelectCompanyManagerFaceWindow::PART_TEXTS[] = {
|
||||
STR_FACE_GLASSES, // WID_SCMF_HAS_GLASSES_TEXT
|
||||
STR_FACE_HAIR, // WID_SCMF_HAIR_TEXT
|
||||
STR_FACE_EYEBROWS, // WID_SCMF_EYEBROWS_TEXT
|
||||
STR_FACE_EYECOLOUR, // WID_SCMF_EYECOLOUR_TEXT
|
||||
STR_FACE_GLASSES, // WID_SCMF_GLASSES_TEXT
|
||||
STR_FACE_NOSE, // WID_SCMF_NOSE_TEXT
|
||||
STR_FACE_CHIN, // WID_SCMF_CHIN_TEXT
|
||||
STR_FACE_JACKET, // WID_SCMF_JACKET_TEXT
|
||||
STR_FACE_COLLAR, // WID_SCMF_COLLAR_TEXT
|
||||
};
|
||||
|
||||
/** Company manager face selection window description */
|
||||
static WindowDesc _select_company_manager_face_desc(
|
||||
WDP_AUTO, "company_face", 0, 0,
|
||||
@@ -1887,8 +1840,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
|
||||
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width);
|
||||
|
||||
RailType rt;
|
||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
||||
for (const auto &rt : _sorted_railtypes) {
|
||||
if (HasBit(this->railtypes, rt)) {
|
||||
lines++;
|
||||
SetDParam(0, GetRailTypeInfo(rt)->strings.name);
|
||||
@@ -1910,8 +1862,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
|
||||
size->width = std::max(size->width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width);
|
||||
|
||||
RoadType rt;
|
||||
FOR_ALL_SORTED_ROADTYPES(rt) {
|
||||
for (const auto &rt : _sorted_roadtypes) {
|
||||
if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) {
|
||||
lines++;
|
||||
SetDParam(0, GetRoadTypeInfo(rt)->strings.name);
|
||||
@@ -2020,8 +1971,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
|
||||
if (this->railtypes != RAILTYPES_NONE) {
|
||||
/* Draw name of each valid railtype. */
|
||||
RailType rt;
|
||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
||||
for (const auto &rt : _sorted_railtypes) {
|
||||
if (HasBit(this->railtypes, rt)) {
|
||||
SetDParam(0, GetRailTypeInfo(rt)->strings.name);
|
||||
DrawString(r.left + offs_left, r.right - offs_right, y += FONT_HEIGHT_NORMAL, STR_WHITE_STRING);
|
||||
@@ -2038,8 +1988,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
case WID_CI_RAIL_COUNT: {
|
||||
/* Draw infrastructure count for each valid railtype. */
|
||||
uint32 rail_total = c->infrastructure.GetRailTotal();
|
||||
RailType rt;
|
||||
FOR_ALL_SORTED_RAILTYPES(rt) {
|
||||
for (const auto &rt : _sorted_railtypes) {
|
||||
if (HasBit(this->railtypes, rt)) {
|
||||
this->DrawCountLine(r, y, c->infrastructure.rail[rt], RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total));
|
||||
}
|
||||
@@ -2055,8 +2004,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
DrawString(r.left, r.right, y, widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT);
|
||||
|
||||
/* Draw name of each valid roadtype. */
|
||||
RoadType rt;
|
||||
FOR_ALL_SORTED_ROADTYPES(rt) {
|
||||
for (const auto &rt : _sorted_roadtypes) {
|
||||
if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) {
|
||||
SetDParam(0, GetRoadTypeInfo(rt)->strings.name);
|
||||
DrawString(r.left + offs_left, r.right - offs_right, y += FONT_HEIGHT_NORMAL, STR_WHITE_STRING);
|
||||
@@ -2069,8 +2017,7 @@ struct CompanyInfrastructureWindow : Window
|
||||
case WID_CI_ROAD_COUNT:
|
||||
case WID_CI_TRAM_COUNT: {
|
||||
uint32 road_tram_total = widget == WID_CI_ROAD_COUNT ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal();
|
||||
RoadType rt;
|
||||
FOR_ALL_SORTED_ROADTYPES(rt) {
|
||||
for (const auto &rt : _sorted_roadtypes) {
|
||||
if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_COUNT)) {
|
||||
this->DrawCountLine(r, y, c->infrastructure.road[rt], RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_tram_total));
|
||||
}
|
||||
@@ -2820,7 +2767,7 @@ struct BuyCompanyWindow : Window {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_BC_NO:
|
||||
delete this;
|
||||
this->Close();
|
||||
break;
|
||||
|
||||
case WID_BC_YES:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user