mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-14 01:59:09 +00:00
Compare commits
396 Commits
0.6.0-beta
...
0.6.0-beta
Author | SHA1 | Date | |
---|---|---|---|
|
7def546fca | ||
|
ef112812c6 | ||
|
6891bc2011 | ||
|
576f8ad93e | ||
ab7cb0804d | |||
|
245f05a7cc | ||
932c586dfe | |||
|
26c621945d | ||
|
0078fd1699 | ||
ea6535c864 | |||
68a3df82b9 | |||
2723128ba9 | |||
|
c1108bd293 | ||
|
af59eb2543 | ||
|
8c13852373 | ||
1bcca5aae2 | |||
|
57ecf117c9 | ||
|
277ec663cb | ||
|
e789ee83ab | ||
ea808b2bfa | |||
bf0a7ae4fb | |||
e4c05f8d78 | |||
|
7beb63a93b | ||
027112e1fe | |||
|
bfc4d80c8e | ||
|
7d2d4314ec | ||
|
311c14c9f5 | ||
|
933aea42cb | ||
|
48861a9fae | ||
|
392d59f6a9 | ||
|
3ca95f2a85 | ||
|
27e5deb719 | ||
|
e281180d06 | ||
|
ef219245af | ||
|
8da51e5eb2 | ||
|
dc87b05e8c | ||
|
2f9aab3217 | ||
|
5c4150d304 | ||
|
b0c34f4d62 | ||
|
cc52a56052 | ||
|
079abbd04b | ||
|
d4e6a6bf57 | ||
|
a78d73805f | ||
|
aa1d429d7f | ||
|
853ca6386e | ||
c7debf7908 | |||
e677814a4b | |||
ab8382c0db | |||
|
a222fe2e86 | ||
|
704a75871a | ||
|
712d4b6259 | ||
|
ac528411df | ||
cbbc53e8f8 | |||
|
ed727f9a64 | ||
|
a4c1280945 | ||
|
79e0a48c42 | ||
|
cbe7e5d668 | ||
|
4d04077156 | ||
|
04f936c2c6 | ||
|
e5d33482b4 | ||
|
a1266da782 | ||
|
40ef636f43 | ||
|
1b936179ca | ||
|
3976bb987d | ||
|
930f875c51 | ||
|
0181678cde | ||
d30321d2af | |||
|
f44a9a5d5b | ||
|
6c954cad5f | ||
|
998d7644f6 | ||
82fe2885ab | |||
|
6375ea065b | ||
|
f67b5798a0 | ||
|
785572ea32 | ||
|
d133edd026 | ||
|
46650c54b6 | ||
|
b4337eba83 | ||
a27a240b87 | |||
|
ebb6259057 | ||
a01fc4c142 | |||
|
b4b3190b62 | ||
|
0e517fe023 | ||
931e6ea49d | |||
|
cd92981e9f | ||
ce2104ed47 | |||
814f47a3cc | |||
352f13dad1 | |||
4479c06e2d | |||
77717563e1 | |||
|
2832a6cafb | ||
|
eced1fb4ae | ||
|
a3ccdcea36 | ||
|
38115acf5a | ||
|
a8a3a7e3f2 | ||
|
b0ac283aec | ||
|
64fc2ade9e | ||
|
119b03ea70 | ||
|
acc7c9eb01 | ||
7be2160cfb | |||
|
fd330ce743 | ||
|
aeff6e5761 | ||
|
f7a293f074 | ||
|
f9a592cfdd | ||
|
279bfad275 | ||
|
f8f86420f8 | ||
|
e165aad4db | ||
|
91be5d7531 | ||
5d837282ee | |||
|
7302d8c88b | ||
9299f76af4 | |||
6a13067931 | |||
|
6b37ab36ea | ||
1cd2c3d517 | |||
3182cbb332 | |||
|
23fab42b2f | ||
|
c59ea520a7 | ||
|
b0ef12e0e9 | ||
|
8f94ac8f03 | ||
|
72afdb8d34 | ||
|
42bddcf723 | ||
|
aebcd80088 | ||
|
7e4b7e3ad4 | ||
|
6ce70b17ca | ||
|
ade37de6c6 | ||
|
6f7f4adffc | ||
|
19f8990f64 | ||
fa83291a76 | |||
47082fec5c | |||
|
9a2547b5a7 | ||
c94a6b8c78 | |||
47d23eb003 | |||
24784b7e0d | |||
|
f0e9c0cfc9 | ||
aab495604a | |||
|
3dd61f423a | ||
a8611311ac | |||
a967a7287f | |||
7031358cff | |||
|
d8f4a80b0a | ||
75472cbc16 | |||
|
b1be9f0137 | ||
|
8ee1faca6c | ||
|
31e2ed8b4c | ||
|
1a70eed58c | ||
|
566a24d6ee | ||
|
892e231aad | ||
|
a3b19fd50c | ||
06d578d07e | |||
|
e5e75bd8f8 | ||
|
6ae9302708 | ||
|
108ab3b910 | ||
|
c87f20ff37 | ||
|
8e1f21e29b | ||
|
e9a039b845 | ||
|
5087a6cdd7 | ||
|
e2efaaff87 | ||
|
e67ed0a808 | ||
|
6196fa01ab | ||
|
2ecb31ae3f | ||
|
6e1cae5256 | ||
|
38f0e422ac | ||
|
384503e7d3 | ||
|
4e66f5a04b | ||
|
0b1d3e43e5 | ||
|
c124792fd2 | ||
|
b9046c97fb | ||
|
2786d789a1 | ||
|
aac835171e | ||
|
6cb68b9144 | ||
|
59d6c5e157 | ||
|
0bd93f5c37 | ||
|
87bd412885 | ||
|
7963963d98 | ||
|
b3f6c0734b | ||
|
429521a7d1 | ||
|
bf98e25e43 | ||
|
e2f79f0eb5 | ||
|
17d1b522bc | ||
|
22f79df328 | ||
|
da5d3a7b3b | ||
|
451abbecb1 | ||
|
970fd6220a | ||
|
a773d45885 | ||
|
82d240e300 | ||
|
8f0e68285b | ||
|
a7d54cf946 | ||
|
6a9e77e079 | ||
|
1b53dbf9cc | ||
|
18e96ab49f | ||
|
9e9cfe6e59 | ||
|
65754b8d12 | ||
|
433a9f3c09 | ||
|
01e20c9140 | ||
|
d5c4ba8246 | ||
|
a6b1526c13 | ||
|
30c0d6da99 | ||
|
4a80cf8482 | ||
|
5b49e75453 | ||
|
d582aea639 | ||
|
8896bea306 | ||
|
a9dafdff48 | ||
|
b8196d36e7 | ||
|
7db6c7db38 | ||
|
e4ef359f47 | ||
|
df0c6eb2b9 | ||
|
f56a354d31 | ||
|
5dc1fcea04 | ||
|
c26a265f21 | ||
|
805ac40280 | ||
|
0b08f7370d | ||
|
bda9d4a236 | ||
|
61dcdbf0e0 | ||
|
6f526fd2e1 | ||
|
2885c66060 | ||
|
93c3e0d6ad | ||
|
9ecda0a97a | ||
|
85b52f6a64 | ||
|
145517fb8e | ||
|
0730b9afc1 | ||
|
3bba097bb3 | ||
|
ff7ff890f9 | ||
|
5e062d3f15 | ||
|
3cee0abdba | ||
|
ec90ce7e98 | ||
|
acf6e08f78 | ||
|
cbcfcb3bf4 | ||
|
214d25905a | ||
|
701e9d27fc | ||
|
d0ad7688f2 | ||
|
4b22e57b33 | ||
|
46724104fe | ||
|
828c242291 | ||
|
5992187a85 | ||
|
4b7f8f04a3 | ||
|
dedb15786c | ||
|
ea1ae563c7 | ||
|
2921e7482b | ||
|
a0f2366e40 | ||
|
98d18c5337 | ||
|
1a8afc5fb4 | ||
|
1d9c27e235 | ||
|
5acc147c1c | ||
|
e0646af976 | ||
|
ed54703db8 | ||
|
78ae599790 | ||
|
a5bcce4fc8 | ||
|
a85c832919 | ||
|
359c9aea3f | ||
|
fb1d768924 | ||
|
6f73382317 | ||
|
a1dbb10c26 | ||
|
ac7c79f039 | ||
|
9124331b0d | ||
|
f854b129af | ||
|
6a83f9141b | ||
|
46c0edc80b | ||
|
6aaa72c918 | ||
|
c3ea7e4dc4 | ||
|
f20e414e2e | ||
|
079c0fd66a | ||
|
5dc0e86d1b | ||
|
5cd0013e5c | ||
|
dfba33819b | ||
|
58b4a981e1 | ||
|
2a62aa1ccd | ||
|
b47bce651e | ||
|
2256d9d378 | ||
|
625a4f8e9a | ||
|
f1e4914b5f | ||
|
73c58d8a40 | ||
|
b23f824f18 | ||
|
04f0700357 | ||
|
af4d07b978 | ||
|
8c89641dbe | ||
|
6fb71047d6 | ||
|
8aaa4e7da6 | ||
|
cbb2d39860 | ||
|
c21f588a14 | ||
|
98bd772119 | ||
|
10e17c30a3 | ||
|
7159007a35 | ||
|
42dbdbb7f9 | ||
|
dd68a34e26 | ||
|
720854ed16 | ||
|
3d38b2c8ba | ||
|
2c3c6593d4 | ||
|
6c70cf2d82 | ||
|
7edf28529d | ||
|
49d632c31b | ||
|
eda5921284 | ||
|
079482f0a2 | ||
|
c65c14f06b | ||
|
8c5c0e9367 | ||
|
46441ac31c | ||
|
02c46026b3 | ||
|
ddc8f2d16f | ||
|
5f576e12aa | ||
|
5847abc9f8 | ||
|
0f43982c72 | ||
|
05fca79cf0 | ||
|
82913a2134 | ||
|
1a43c6a6f6 | ||
|
fe76841255 | ||
|
164d0a4710 | ||
|
b7d8681129 | ||
|
faf096f506 | ||
|
b5a902703e | ||
|
d9081ad3f5 | ||
|
527b72749d | ||
|
50fced3c66 | ||
|
b20b2f4ec8 | ||
|
4e574cab45 | ||
|
e2b4afaa4b | ||
|
7be55559b8 | ||
|
08ab4e1850 | ||
|
0feaee4124 | ||
|
4f030bbfff | ||
|
da9f06252b | ||
|
aa0d37854d | ||
|
6b68c6557b | ||
|
7162b8ddb3 | ||
|
5fcbb8f59b | ||
|
4704d4619b | ||
|
6e511188ae | ||
|
981865dbcc | ||
|
440608a6f0 | ||
|
34edc93f2a | ||
|
b10eea628d | ||
|
1682d5d679 | ||
|
9402d4054a | ||
|
8c5814156f | ||
|
6f7d37d3d3 | ||
|
a7d4334664 | ||
|
8e273e0f88 | ||
|
71c10f7df7 | ||
|
734b22e070 | ||
|
d736a04b59 | ||
|
77b6a2674e | ||
|
bdc7fd2d76 | ||
|
2bf2be987d | ||
|
1d5010edf9 | ||
|
9aaa455e5d | ||
|
d061d985d6 | ||
|
2cd25ed2ca | ||
|
72eb6ae278 | ||
|
a62e07b08e | ||
|
5dfead8b5c | ||
|
bd8bf99139 | ||
|
cbd1c05218 | ||
|
6cf5e4cf05 | ||
|
f27acfdf78 | ||
|
bf959f926f | ||
|
64246a2775 | ||
|
fcbfba1e17 | ||
|
221e9271c5 | ||
|
9a70ec1cb2 | ||
|
81c7ba42af | ||
|
ea072322fa | ||
|
c8add52504 | ||
|
2e0dd78ccf | ||
|
536be43411 | ||
|
ee81e00082 | ||
|
2ebf50e421 | ||
|
9d3cc5b271 | ||
|
b979995795 | ||
|
64a4ac3444 | ||
|
3ad488e98f | ||
|
2653d94bcb | ||
|
737aec4db6 | ||
|
1d56af1d33 | ||
|
83601671c7 | ||
|
d53bfd8f2f | ||
|
b168ae34be | ||
|
a91c2a4c39 | ||
|
eeaa348f8b | ||
|
b8885630aa | ||
|
5c31a973a1 | ||
|
71c4325c50 | ||
|
58bb5c7525 | ||
|
d076ea8697 | ||
|
e815dae3c6 | ||
|
a4df4728fc | ||
|
50bfe1a19d | ||
|
8be526e499 | ||
|
006acff183 | ||
|
fb0674ee2b | ||
|
51bb4a9dc8 | ||
|
2686901d84 | ||
|
6097c07e4b | ||
|
400ca1dae5 | ||
|
272a21077d | ||
|
e15a5365d1 | ||
|
96d156944f | ||
|
cd3c16d789 | ||
|
92e0bf68e3 | ||
|
dc81ea6454 |
12
BUGS
12
BUGS
@@ -1,12 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
KNOWN BUGS / PROBLEMS:
|
||||
|
||||
bridges:
|
||||
- Clearing tiles which may not have a bridge above can cause random bridge pieces to appear, which leads to crash in the long run
|
||||
|
||||
electrified rails:
|
||||
Normal and elrail depots look the same. Use 'X' (transparent buildings)
|
||||
to distinguish between them
|
||||
Missing curors / icons for construction (currently using the conventional ones)
|
||||
|
@@ -79,7 +79,7 @@ ifeq ($(shell if test -f config.cache; then echo 1; fi), 1)
|
||||
@echo " Going to reconfigure with last known settings..."
|
||||
@echo "----------------"
|
||||
# Make sure we don't lock config.cache
|
||||
@$(shell cat config.cache) || exit 1
|
||||
@$(shell cat config.cache | sed 's/\\ /\\\\ /g') || exit 1
|
||||
@echo "----------------"
|
||||
@echo "Reconfig done. Now compiling..."
|
||||
@echo "----------------"
|
||||
|
@@ -105,14 +105,14 @@ else
|
||||
# Are we a git dir?
|
||||
ifeq ($(shell if test -d $(SRC_DIR)/../.git; then echo 1; fi), 1)
|
||||
# Find the revision like: gXXXXM-branch
|
||||
REV := g$(shell if head=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`; then echo "$$head" | cut -c1-8; fi)$(shell if git diff-index HEAD | read dummy; then echo M; fi)$(shell git branch|grep '[*]' | sed 's/\* /-/;s/^-master$$//')
|
||||
REV_NR := $(shell echo `LC_ALL=C cd "$(SRC_DIR)/.." && git log --pretty=format:%s src | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/"` )
|
||||
REV := g$(shell if head=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`; then echo "$$head" | cut -c1-8; fi)$(shell if cd "$(SRC_DIR)/.." && git diff-index HEAD src | read dummy; then echo M; fi)$(shell git branch|grep '[*]' | sed 's/\* /-/;s/^-master$$//')
|
||||
REV_NR := $(shell LC_ALL=C cd "$(SRC_DIR)/.." && git log --pretty=format:%s src | grep -m 1 "^(svn r[0-9]*)" | sed "s/.*(svn r\([0-9]*\)).*/\1/" )
|
||||
else
|
||||
# Are we a hg (Mercurial) dir?
|
||||
ifeq ($(shell if test -d $(SRC_DIR)/../.hg; then echo 1; fi), 1)
|
||||
# Find the revision like: hXXXXM-branch
|
||||
REV := h$(shell if head=`LC_ALL=C hg tip 2>/dev/null`; then echo "$$head" | head -n 1 | cut -c19-26; fi)$(shell if hg status $(SRC_DIR) | grep -v '^?' | read dummy; then echo M; fi)$(shell hg branch | sed 's/^/-/;s/^-default$$//')
|
||||
REV_NR := $(shell LC_ALL=C hg log -k "svn" -l 1 --template "{desc}\n" $(SRC_DIR) | grep "^(svn r[0-9]*)" | head -n 1 | sed "s/.*(svn r\([0-9]*\)).*/\1/" )
|
||||
REV_NR := $(shell LC_ALL=C hg log -k "svn" -l 1 --template "{desc}\n" $(SRC_DIR) | grep -m 1 "^(svn r[0-9]*)" | sed "s/.*(svn r\([0-9]*\)).*/\1/" )
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,94 @@
|
||||
0.6.0-beta3 (2008-01-16)
|
||||
------------------------------------------------------------------------
|
||||
-Feature: Replaced fixed size custom name array. Names are now attached to their object directly and there is no limit to the amount of names (r11822)
|
||||
-Feature: Add drag-n-drop support to the raise/lower land tools. Land is raised/lowered at the start and the rest of the area levelled to match (r11759)
|
||||
-Feature: Add support for NewGRF's train 'tilt' flag. Trains with tilt capability (specific details are per NewGRF set) will be given a 20% speed limit bonus on curves (r11741)
|
||||
-Feature: Added sorting for cost, running costs and speed to road vehicles and ships build windows (r11710)
|
||||
-Feature: List neutral stations where the player has service in the station list too (r11670)
|
||||
-Feature: Check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen (r11646)
|
||||
-Feature: Support shore replacement via Action 5 (r11726)
|
||||
-Fix: When two NewGRFs 'fight' to define the same cargo it could happen that the strings are defined by one cargo and the 'action2' by another and when one assumes that both come from the same NewGRF [FS#1559] (r11862)
|
||||
-Fix: Recompute town population when removing a 'newhouses' grf, or when loading a game with missing 'newhouses' grfs [FS#1335] (r11855)
|
||||
-Fix: Road vehicle count was incorrect in network lobby window (r11844)
|
||||
-Fix: Mark dirty canal tile even in diagonal direction from flooded tile, draw correctly canal next to half flooded rail tile (r11843, r11838)
|
||||
-Fix: At least one instance of dmusic driver is needed for it to be registered and usable (r11826)
|
||||
-Fix: An articulated road vehicle could split up when it turned around at a corner and then would enter a drive through station at the next tile [FS#1627] (r11825)
|
||||
-Fix: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots [FS#1602] (r11813)
|
||||
-Fix: Do not crash trains when leaving depot to a very long track [FS#716] (r11802)
|
||||
-Fix: Take town rating into account when testing if a command can be executed [FS#1616] (r11795)
|
||||
-Fix: Reversing a train when loading at a station with an adjacent station in the same axis crashed [FS#1632] (r11794)
|
||||
-Fix: Group names got not deallocated in the command test run [FS#1614] (r11743)
|
||||
-Fix: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused [FS#1319] (r11742)
|
||||
-Fix: Modify and possibly discard key events for code points in the unicode private use area [FS#1610] (r11740)
|
||||
-Fix: Set the new scroll position after zooming in instead of before, as the zoom will cancel it out [FS#1609] (r11739)
|
||||
-Fix: Do not reset loading indicator IDs when only reloading NewGRFs [FS#1574] (r11735)
|
||||
-Fix: Elrail merge gave elrail, monorail & maglev unintended speed bonuses for curves, as the bonus was based on the railtype index. The bonus is now specified by a property of the railtype (r11732)
|
||||
-Fix: Clear sprite override data before performing NewGRF wagon attach callback. This stopped the callback working for autoreplace and when moving wagons from train to train in a depot [FS#1582] (r11731)
|
||||
-Fix: If there are no houses that can be build in a specific year yet, force the houses with the earliest introduction year to be available [FS#1577] (r11727)
|
||||
-Fix: Make it impossible (for users) to circumvent the length checking of the NewGRF 'allow wagon attach' callback by moving several wagons at a time (r11724)
|
||||
-Fix: Do not put more than one Random() in function calls because parameter evaluation order is not guaranteed in the c++ standard [FS#1561] (r11716)
|
||||
-Fix: Do not allow player inauguration date on scenarios to be bigger than current year [FS#1569] (r11714)
|
||||
-Fix: Add more house string id ranges to MapGRFStringID so NewGRFs use the proper string ids (r11712)
|
||||
-Fix: Do not allow refitting flooded (destroyed) vehicles (r11707)
|
||||
-Fix: Trains could have sprites with wrong direction when reversing, also was inconsistent with save/load process [FS#1557] (r11705)
|
||||
-Fix: When removing buoys, return to water or canal depending on their owner (r11666)
|
||||
-Fix: Animation informations should not be copied from original industry tile spec, while doing an action 00, industry tile, prop 08 (r11665)
|
||||
-Fix: Do not allow modifying non-uniform stations when non-uniform stations are disabled [FS#1563] (r11659)
|
||||
-Fix: 'Initialised' NewGRFs could still be deactivated in the later 'activation' pass (r11650)
|
||||
-Fix: Vehicles were still followed when sold [FS#1541] (r11632)
|
||||
-Fix: Many viewports could crash the scenario editor [FS#1527] (r11629)
|
||||
-Fix: Popping from text reference stack must be done in a precise order. But some compiler (MSVC) over optimised it and inverted this order [FS#1532] (r11627)
|
||||
-Fix: There were still some cases where one could not build a tram track, but the tram could become blocked [FS#1525] (r11621)
|
||||
-Fix: Do not make crossing red behind depot the train is entering [FS#1531] (r11619)
|
||||
-Fix: Buoys are just waypoints, so don't allow load/unload/transfert for them (r11618)
|
||||
-Fix: Sometimes large values could go off the chart [FS#1526] (r11616)
|
||||
-Fix: Temperate banks can only be built in towns (over a house) (r11615)
|
||||
|
||||
|
||||
0.6.0-beta2 (2007-12-09)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: Allow setting a default password for new companies in network games (r11556)
|
||||
- Feature: Signal selection GUI for the ones that really like to use that over CTRL (r11547)
|
||||
- Feature: Make the bridge selection window resizable (r11539)
|
||||
- Feature: [OSX] Added support for using Quartz instead of Quickdraw in windowed mode on OS X 10.4 and higher (r11496)
|
||||
- Feature: Allow to resize on creation the smallmap gui in order to show all the types industry available, allow to enable/disable individually or all at once, the industries shown on small map (r11474)
|
||||
- Codechange: Send and store the passwords a little more secure to/in the servers (r11557)
|
||||
- Fix: Wrong error messages were shown when trying to build some industries in the scenario editor [FS#1524] (r11609)
|
||||
- Fix: [NewGRF] Do not trigger industries, but only the industry's tiles (r11608)
|
||||
- Fix: Wrong count of Kirby trains when a ship was build [FS#1482] (r11605)
|
||||
- Fix: Tiles were not marked dirty in some cases when removing a lock or flooding (r11582, r11604)
|
||||
- Fix: Make price for railtype conversion more realistic; conversion should not be more expensive than removing and rebuilding [FS#1481] (r11603)
|
||||
- Fix: Do not allow changing network only patches settings from console when not in network game (r11594)
|
||||
- Fix: IsSlopeRefused() result was half wrong causing banks to be built on wrong places (r11590)
|
||||
- Fix: When ship depots got destroyed they always returned to water, even when it should have been canals [FS#1514] (r11589)
|
||||
- Fix: The one way road button wasn't reset on abort (r11587)
|
||||
- Fix: Windows could get completely missing when one resized the window to something very small [FS#1484] (r11583)
|
||||
- Fix: Invalidate 'list trains/roadvehs/ships/planes' widgets when station part is added/removed so it does not become glitchy (r11577)
|
||||
- Fix: Flood train stations when there are no trains on border tiles too (r11574, r11570)
|
||||
- Fix: Reinitialise windows system before loading a savegame because not doing so can cause crashes [FS#1494] (r11572)
|
||||
- Fix: Road vehicle getting to the wrong side of a station when trying to overtake in there [FS#1493] (r11571)
|
||||
- Fix: Full paths sometimes did not work correctly [FS#1480] (r11568)
|
||||
- Fix: Break the chain before moving a vehicle after another in the same chain instead of causing an infinite loop [FS#1512] (r11566)
|
||||
- Fix: Aircraft sometimes stopped mid-air when the airport got destroyed [FS#1503] (r11562)
|
||||
- Fix: Group list was not updated when removing the last group [FS#1504] (r11561)
|
||||
- Fix: Overflow when drawing graphics with high company values [FS#1505] (r11558)
|
||||
- Fix: If ever the air/heliport is suddenly not available while the "chopper" is descending, just go back into flying instead of stopping mid air [FS#1496] (r11546)
|
||||
- Fix: Cargo translation was sometimes done when it should not be done [FS#1501] (r11544)
|
||||
- Fix: [OSX] Detect statvfs at runtime (based on OSX version) instead of compile time. This should prevent a crash on OSX 10.3 with the precompiled binaries (in the load/save windows) (r11541)
|
||||
- Fix: [OSX] Do not try to compile the quartz video driver on OSX 10.3 as it will fail (r11540)
|
||||
- Fix: Do not do all kinds of 'updates' for town, waypoint, station and other signs when you have not converted the map to the 'current' format as that means you are going to read data in the 'old' format when you assume that it is in the 'current' format, which is eventually going to break (r11525)
|
||||
- Fix: Assertion when tram reversed at a station [FS#1485] (r11524)
|
||||
- Fix: The scrollbar of the network gui could run out of bounds (r11522)
|
||||
- Fix: [OSX] The cocoa video driver let the mouse cursor escape the window when using rmb scrolling (r11520)
|
||||
- Fix: Signs totally illegible when transparant signs is turned on and zoomed out more than one level [FS#1463] (r11507)
|
||||
- Fix: Selling vehicles could cause the window of others to scroll to that location [FS#1471] (r11506)
|
||||
- Fix: Do not do standard production change if callbacks 29/35 failed, disable smooth economy for industries using callbacks 29/35 (r11502)
|
||||
- Fix: Two small layout issues with the vehicle grouping GUI (r11478)
|
||||
- Fix: A road vehicle must not show that it is driving max speed when it is standing still waiting for the vehicle in from of it [FS#1451] (r11477)
|
||||
- Fix: OpenBSD has ALIGN already defined, causing compilation failures [FS#1450] (r11467)
|
||||
- Fix: Operator priority problem resulting in problematic autoroad placement in some cases (r11466)
|
||||
|
||||
|
||||
0.6.0-beta1 (2007-11-18)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: Make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing (r11442)
|
||||
@@ -32,7 +123,7 @@
|
||||
- Feature: New sign editor features including switching to previous/next sign (r10401)
|
||||
- Feature: Disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overridden with a patch setting [FS#669] (r10353)
|
||||
- Feature: Add the possibility of automatically filling in timetables based on the times from the first (or subsequent) run-throughs (r10331)
|
||||
- Feature: Option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map [FS#812] (r10329)
|
||||
- Feature: Option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map [FS#812] (r10329)
|
||||
- Feature: Give a better explanation why the loading of a savegame failed and do not crash on loading savegames that were altered by patches or branches [FS#917] (r10300)
|
||||
- Feature: A sticky button for the client list window [FS#885] (r10293)
|
||||
- Feature: Allow double-clicking on certain places: add NewGRF window, build-vehicle and town-action (r10265, r10267)
|
||||
@@ -384,7 +475,7 @@
|
||||
- Fix: Draw canal edges under buoys that are in a canal (r8635)
|
||||
- Fix: Buoys on canal tiles do not flood anymore (r8620)
|
||||
- Fix: Store the ownership of a water tile in the buoy tile and set the ownership of the water tile when the buoy is removed. Prevents certain abuses (r8619)
|
||||
- Fix: When the currently selected player in the performance details window is no longer active, choose the first active player instead of the first player as that may also be inactive [FS#582] (r8612)
|
||||
- Fix: When the currently selected player in the performance details window is no longer active, choose the first active player instead of the first player as that may also be inactive [FS#582] (r8612)
|
||||
- Fix: Road vehicle very close after another (slower) road vehicle gets its speed reset to 0 when entering a tunnel, which causes a traffic jam outside of the tunnel (r8609)
|
||||
- Fix: Bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge [FS#564] (r8593)
|
||||
- Fix: Road Vehicles now can obtain a slot even if the station is very spread out [FS#577] (r8536)
|
||||
@@ -1028,7 +1119,7 @@
|
||||
- Feature: scrolling credits list (in alphabetical order)
|
||||
- Feature: Train window now shows the number of vehicles per row (mpetrov)
|
||||
- Feature: [ 1039061 ] Swiss town-names (vulvulune)
|
||||
- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops (doode)
|
||||
- Feature: [ 1090950 ] Adding 16:10 resolutions for mainly laptops (doode)
|
||||
- Feature: [ 1098254 ] (dis)Allow Shares. Add patch options to allow buying/selling of shares (Hackykid)
|
||||
- Fix: [ 1031451 ] Catchment area shows when buying sign
|
||||
- Fix: [ 1040119 ] Flood and wagons in depot
|
||||
|
268
config.lib
268
config.lib
@@ -5,7 +5,7 @@ log() {
|
||||
}
|
||||
|
||||
set_default() {
|
||||
released_version="0.6.0-beta1"
|
||||
released_version="0.6.0-beta3"
|
||||
|
||||
ignore_extra_parameters="0"
|
||||
# We set all kinds of defaults for params. Later on the user can override
|
||||
@@ -30,20 +30,22 @@ set_default() {
|
||||
data_dir="share/games/openttd"
|
||||
icon_dir="share/pixmaps"
|
||||
personal_dir="1"
|
||||
shared_dir="1"
|
||||
install_dir="/"
|
||||
enable_debug="0"
|
||||
enable_desync_debug="0"
|
||||
enable_profiling="0"
|
||||
enable_dedicated="0"
|
||||
enable_network="1"
|
||||
enable_static="1"
|
||||
enable_translator="0"
|
||||
enable_unicode="1"
|
||||
enable_assert="1"
|
||||
enable_strip="1"
|
||||
enable_universal="1"
|
||||
enable_osx_g5="0"
|
||||
enable_unicode="1"
|
||||
with_distcc="1"
|
||||
with_ccache="1"
|
||||
enable_cocoa_quartz="1"
|
||||
enable_cocoa_quickdraw="1"
|
||||
with_osx_sysroot="1"
|
||||
with_application_bundle="1"
|
||||
with_sdl="1"
|
||||
@@ -61,8 +63,66 @@ set_default() {
|
||||
with_fontconfig="1"
|
||||
with_psp_config="1"
|
||||
with_threads="1"
|
||||
with_distcc="1"
|
||||
with_ccache="1"
|
||||
|
||||
save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os cpu_type revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_distcc with_osx_sysroot enable_universal enable_osx_g5 enable_unicode with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config with_threads CC CXX CFLAGS LDFLAGS"
|
||||
save_params_array="
|
||||
build
|
||||
host
|
||||
cc_build
|
||||
cc_host
|
||||
cxx_build
|
||||
cxx_host
|
||||
windres
|
||||
strip
|
||||
lipo
|
||||
awk
|
||||
os
|
||||
endian
|
||||
cpu_type
|
||||
revision
|
||||
config_log
|
||||
prefix_dir
|
||||
binary_dir
|
||||
data_dir
|
||||
icon_dir
|
||||
personal_dir
|
||||
shared_dir
|
||||
install_dir
|
||||
enable_debug
|
||||
enable_desync_debug
|
||||
enable_profiling
|
||||
enable_dedicated
|
||||
enable_network
|
||||
enable_static
|
||||
enable_translator
|
||||
enable_unicode
|
||||
enable_assert
|
||||
enable_strip
|
||||
enable_universal
|
||||
enable_osx_g5
|
||||
enable_cocoa_quartz
|
||||
enable_cocoa_quickdraw
|
||||
with_osx_sysroot
|
||||
with_application_bundle
|
||||
with_sdl
|
||||
with_cocoa
|
||||
with_zlib
|
||||
with_png
|
||||
with_makedepend
|
||||
with_direct_music
|
||||
with_sort
|
||||
with_iconv
|
||||
with_midi
|
||||
with_midi_arg
|
||||
with_libtimidity
|
||||
with_freetype
|
||||
with_fontconfig
|
||||
with_psp_config
|
||||
with_threads
|
||||
with_distcc
|
||||
with_ccache
|
||||
CC CXX CFLAGS LDFLAGS"
|
||||
}
|
||||
|
||||
detect_params() {
|
||||
@@ -135,6 +195,10 @@ detect_params() {
|
||||
--personal-dir=*) personal_dir="$optarg";;
|
||||
--without-personal-dir) personal_dir="";;
|
||||
|
||||
--shared-dir) prevp_p="shared-dir";;
|
||||
--shared-dir=*) shared_dir="$optarg";;
|
||||
--without-shared-dir) shared_dir="";;
|
||||
|
||||
--install-dir) prevp_p="install-dir";;
|
||||
--install-dir=*) install_dir="$optarg";;
|
||||
|
||||
@@ -142,6 +206,8 @@ detect_params() {
|
||||
|
||||
--enable-debug) enable_debug="1";;
|
||||
--enable-debug=*) enable_debug="$optarg";;
|
||||
--enable-desync-debug) enable_desync_debug="1";;
|
||||
--enable-desync-debug=*) enable_desync_debug="$optarg";;
|
||||
--enable-profiling) enable_profiling="1";;
|
||||
--enable-profiling=*) enable_profiling="$optarg";;
|
||||
--enable-dedicated) enable_dedicated="1";;
|
||||
@@ -170,6 +236,13 @@ detect_params() {
|
||||
--enable-unicode) enable_unicode="2";;
|
||||
--enable-unicode=*) enable_unicode="$optarg";;
|
||||
|
||||
--disable-cocoa-quartz) enable_cocoa_quartz="0";;
|
||||
--enable-cocoa-quartz) enable_cocoa_quartz="2";;
|
||||
--enable-cocoa-quartz=*) enable_cocoa_quartz="$optarg";;
|
||||
--disable-cocoa-quickdraw) enable_cocoa_quickdraw="0";;
|
||||
--enable-cocoa-quickdraw) enable_cocoa_quickdraw="2";;
|
||||
--enable-cocoa-quickdraw=*) enable_cocoa_quickdraw="$optarg";;
|
||||
|
||||
--with-sdl) with_sdl="2";;
|
||||
--without-sdl) with_sdl="0";;
|
||||
--with-sdl=*) with_sdl="$optarg";;
|
||||
@@ -337,6 +410,13 @@ check_params() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# enable_desync_debug should be between 0 and 3
|
||||
if [ -z "`echo $enable_desync_debug | egrep '^[012]$'`" ]; then
|
||||
echo "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
|
||||
echo " Available options are: --enable-desync-debug[=012]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
detect_awk
|
||||
|
||||
check_build
|
||||
@@ -376,7 +456,7 @@ check_params() {
|
||||
detect_cputype
|
||||
|
||||
if [ "$enable_static" = "1" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "OSX" ]; then
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ]; then
|
||||
enable_static="2"
|
||||
else
|
||||
enable_static="0"
|
||||
@@ -419,6 +499,17 @@ check_params() {
|
||||
log 1 "using debug level... level $enable_debug"
|
||||
fi
|
||||
|
||||
if [ "$enable_desync_debug" = "0" ]; then
|
||||
log 1 "using desync debug level... no"
|
||||
else
|
||||
log 1 "using desync debug level... level $enable_desync_debug"
|
||||
log 1 "WARNING: desync debug functions slow down the game considerably."
|
||||
log 1 "WARNING: use only when you are instructed to do so"
|
||||
log 1 " or when you know what you are doing."
|
||||
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
detect_sdl
|
||||
detect_cocoa
|
||||
|
||||
@@ -729,6 +820,15 @@ check_params() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$shared_dir" = "1" ]; then
|
||||
# we are using default values
|
||||
if [ "$os" = "OSX" ]; then
|
||||
shared_dir="/Library/Application\\\\ Support/OpenTTD"
|
||||
else
|
||||
shared_dir=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$personal_dir" ]
|
||||
then
|
||||
log 1 "personal home directory... $personal_dir"
|
||||
@@ -736,6 +836,13 @@ check_params() {
|
||||
log 1 "personal home directory... none"
|
||||
fi
|
||||
|
||||
if [ -n "$shared_dir" ]
|
||||
then
|
||||
log 1 "shared data directory... $shared_dir"
|
||||
else
|
||||
log 1 "shared data directory... none"
|
||||
fi
|
||||
|
||||
if [ -n "$install_dir" ]
|
||||
then
|
||||
log 1 "installation directory... $install_dir"
|
||||
@@ -799,60 +906,76 @@ make_cflags_and_ldflags() {
|
||||
CFLAGS="$CFLAGS -DNO_THREADS"
|
||||
fi
|
||||
|
||||
# Enable some things only for certain GCC versions
|
||||
cc_version=`$cc_host -dumpversion | cut -c 1,3`
|
||||
if [ `echo $cc_host | cut -c 1-3` = "icc" ]; then
|
||||
# Enable some things only for certain ICC versions
|
||||
cc_version=`$cc_host -dumpversion | cut -c 1-4`
|
||||
|
||||
if [ $cc_version -ge 29 ]; then
|
||||
CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
|
||||
CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
|
||||
CFLAGS="$CFLAGS -Wno-uninitialized"
|
||||
|
||||
CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
|
||||
fi
|
||||
if [ "$cc_version" = "10.1" ]; then
|
||||
CFLAGS="$CFLAGS -Wno-multichar"
|
||||
fi
|
||||
else
|
||||
# Enable some things only for certain GCC versions
|
||||
cc_version=`$cc_host -dumpversion | cut -c 1,3`
|
||||
|
||||
gcc295=""
|
||||
if [ "$cc_version" = 29 ]; then
|
||||
# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
|
||||
# need a lovely hack there to make it compile correctly.
|
||||
gcc295="1"
|
||||
fi
|
||||
if [ $cc_version -ge 29 ]; then
|
||||
CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
|
||||
CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
|
||||
CFLAGS="$CFLAGS -Wno-uninitialized"
|
||||
|
||||
if [ $cc_version -ge 30 ]; then
|
||||
CFLAGS="$CFLAGS -W -Wno-unused-parameter"
|
||||
fi
|
||||
CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
|
||||
fi
|
||||
|
||||
if [ $cc_version -ge 34 ]; then
|
||||
CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
|
||||
fi
|
||||
gcc295=""
|
||||
if [ "$cc_version" = 29 ]; then
|
||||
# Make sure we mark GCC 2.95 flag for Makefile.src.in, as we
|
||||
# need a lovely hack there to make it compile correctly.
|
||||
gcc295="1"
|
||||
fi
|
||||
|
||||
if [ "$os" = "CYGWIN" ]; then
|
||||
CFLAGS="$CFLAGS -mwin32"
|
||||
LDFLAGS="$LDFLAGS -mwin32"
|
||||
fi
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
|
||||
CFLAGS="$CFLAGS -mno-cygwin"
|
||||
LDFLAGS="$LDFLAGS -mno-cygwin"
|
||||
fi
|
||||
if [ $cc_version -ge 30 ]; then
|
||||
CFLAGS="$CFLAGS -W -Wno-unused-parameter"
|
||||
fi
|
||||
|
||||
if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
|
||||
LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
|
||||
LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
|
||||
fi
|
||||
if [ $cc_version -ge 34 ]; then
|
||||
CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition"
|
||||
fi
|
||||
|
||||
# GCC 4.0+ complains about that we break strict-aliasing.
|
||||
# On most places we don't see how to fix it, and it doesn't
|
||||
# break anything. So disable strict-aliasing to make the
|
||||
# compiler all happy.
|
||||
if [ $cc_version -ge 40 ]; then
|
||||
CFLAGS="$CFLAGS -fno-strict-aliasing"
|
||||
fi
|
||||
if [ "$os" = "CYGWIN" ]; then
|
||||
CFLAGS="$CFLAGS -mwin32"
|
||||
LDFLAGS="$LDFLAGS -mwin32"
|
||||
fi
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
|
||||
CFLAGS="$CFLAGS -mno-cygwin"
|
||||
LDFLAGS="$LDFLAGS -mno-cygwin"
|
||||
fi
|
||||
|
||||
# GCC 4.2+ automatically assumes that signed overflows do
|
||||
# not occur in signed arithmetics, whereas we are not
|
||||
# sure that they will not happen. It furthermore complains
|
||||
# about it's own optimized code in some places.
|
||||
if [ $cc_version -ge 42 ]; then
|
||||
CFLAGS="$CFLAGS -fno-strict-overflow"
|
||||
if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ]; then
|
||||
LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
|
||||
LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
|
||||
fi
|
||||
|
||||
# GCC 4.0+ complains about that we break strict-aliasing.
|
||||
# On most places we don't see how to fix it, and it doesn't
|
||||
# break anything. So disable strict-aliasing to make the
|
||||
# compiler all happy.
|
||||
if [ $cc_version -ge 40 ]; then
|
||||
CFLAGS="$CFLAGS -fno-strict-aliasing"
|
||||
fi
|
||||
|
||||
# GCC 4.2+ automatically assumes that signed overflows do
|
||||
# not occur in signed arithmetics, whereas we are not
|
||||
# sure that they will not happen. It furthermore complains
|
||||
# about it's own optimized code in some places.
|
||||
if [ $cc_version -ge 42 ]; then
|
||||
CFLAGS="$CFLAGS -fno-strict-overflow"
|
||||
fi
|
||||
|
||||
# GCC 4.3+ gives a warning about empty body of
|
||||
# loops and conditions
|
||||
if [ $cc_version -ge 43 ]; then
|
||||
CFLAGS="$CFLAGS -Wno-empty-body"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$os" != "CYGWIN" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
|
||||
@@ -922,6 +1045,14 @@ make_cflags_and_ldflags() {
|
||||
if [ "$with_cocoa" != "0" ]; then
|
||||
CFLAGS="$CFLAGS -DWITH_COCOA"
|
||||
LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit"
|
||||
|
||||
if [ "$enable_cocoa_quartz" != "0" ]; then
|
||||
CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
|
||||
fi
|
||||
|
||||
if [ "$enable_cocoa_quickdraw" != "0" ]; then
|
||||
CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$with_zlib" != "0" ]; then
|
||||
@@ -1052,6 +1183,13 @@ make_cflags_and_ldflags() {
|
||||
CFLAGS="$CFLAGS -DNDEBUG"
|
||||
fi
|
||||
|
||||
if [ "$enable_desync_debug" = "1" ]; then
|
||||
CFLAGS="$CFLAGS -DDEBUG_DUMP_COMMANDS"
|
||||
fi
|
||||
if [ "$enable_desync_debug" = "2" ]; then
|
||||
CFLAGS="$CFLAGS -DRANDOM_DEBUG"
|
||||
fi
|
||||
|
||||
if [ "$enable_osx_g5" != "0" ]; then
|
||||
CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt"
|
||||
fi
|
||||
@@ -1065,6 +1203,10 @@ make_cflags_and_ldflags() {
|
||||
CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
|
||||
fi
|
||||
|
||||
if [ -n "$shared_dir" ]; then
|
||||
CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
|
||||
|
||||
log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
|
||||
@@ -1524,6 +1666,19 @@ detect_cocoa() {
|
||||
fi
|
||||
|
||||
log 1 "checking COCOA... found"
|
||||
|
||||
|
||||
if [ "$enable_cocoa_quartz" != "0" ]; then
|
||||
log 1 "checking whether to enable the Quartz window subdriver... yes"
|
||||
else
|
||||
log 1 "checking whether to enable the Quartz window subdriver... no"
|
||||
fi
|
||||
|
||||
if [ "$enable_cocoa_quickdraw" != "0" ]; then
|
||||
log 1 "checking whether to enable the Quickdraw window subdriver... yes"
|
||||
else
|
||||
log 1 "checking whether to enable the Quickdraw window subdriver... no"
|
||||
fi
|
||||
}
|
||||
|
||||
detect_library() {
|
||||
@@ -1976,7 +2131,7 @@ make_sed() {
|
||||
ppc=`$cc_host -dumpmachine | egrep "powerpc|ppc"`
|
||||
if [ -n "$ppc" ]; then
|
||||
T_CFLAGS="$CFLAGS -DFOUR_BYTE_BOOL"
|
||||
osx_sysroot_version=10.3.9
|
||||
osx_sysroot_version=10.4u
|
||||
else
|
||||
T_CFLAGS="$CFLAGS"
|
||||
osx_sysroot_version=10.4u
|
||||
@@ -2022,6 +2177,7 @@ make_sed() {
|
||||
s#!!DATA_DIR!!#$prefix_dir/$data_dir#g;
|
||||
s#!!ICON_DIR!!#$prefix_dir/$icon_dir#g;
|
||||
s#!!PERSONAL_DIR!!#$personal_dir#g;
|
||||
s#!!SHARED_DIR!!#$shared_dir#g;
|
||||
s#!!INSTALL_DIR!!#$install_dir#g;
|
||||
s#!!STRGEN!!#$STRGEN#g;
|
||||
s#!!ENDIAN_CHECK!!#$ENDIAN_CHECK#g;
|
||||
@@ -2162,12 +2318,16 @@ showhelp() {
|
||||
echo " [share/games/openttd]"
|
||||
echo " --icon-dir=dir location of icons. Will be prefixed"
|
||||
echo " with the prefix-dir [share/pixmaps]"
|
||||
echo " --personal-dir=dir location of the personal directory [.openttd]"
|
||||
echo " --personal-dir=dir location of the personal directory"
|
||||
echo " [os-dependent default]"
|
||||
echo " --shared-dir=dir location of shared data files"
|
||||
echo " [os-dependent default]"
|
||||
echo " --install-dir=dir specifies the root to install to."
|
||||
echo " Useful to install into jails [/]"
|
||||
echo ""
|
||||
echo "Features and packages:"
|
||||
echo " --enable-debug[=LVL] enable debug-mode (LVL=[0123], 0 is release)"
|
||||
echo " --enable_desync_debug=[LVL] enable desync debug options (LVL=[012], 0 is none"
|
||||
echo " --enable-profiling enables profiling"
|
||||
echo " --enable-dedicated compile a dedicated server (without video)"
|
||||
echo " --enable-static enable static compile (doesn't work for"
|
||||
@@ -2175,6 +2335,8 @@ showhelp() {
|
||||
echo " --enable-translator enable extra output for translators"
|
||||
echo " --enable-universal enable universal builds (OSX ONLY)"
|
||||
echo " --enable-osx-g5 enables optimalizations for G5 (OSX ONLY)"
|
||||
echo " --disable-cocoa-quartz disable the quartz window mode driver for Cocoa (OSX ONLY)"
|
||||
echo " --disable-cocoa-quickdraw disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
|
||||
echo " --disable-unicode disable unicode support to build win9x"
|
||||
echo " version (Win32 ONLY)"
|
||||
echo " --disable-network disable network support"
|
||||
|
4
configure
vendored
4
configure
vendored
@@ -31,13 +31,13 @@ LANG_DIR="$SRC_DIR/lang"
|
||||
MEDIA_DIR="$ROOT_DIR/media"
|
||||
SOURCE_LIST="$ROOT_DIR/source.list"
|
||||
|
||||
if [ "$1" = "--reconfig" ]; then
|
||||
if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
|
||||
if ! [ -f "config.cache" ]; then
|
||||
echo "can't reconfigure, because never configured before"
|
||||
exit 1
|
||||
fi
|
||||
# Make sure we don't lock config.cache
|
||||
cat config.cache > cache.tmp
|
||||
cat config.cache | sed 's/\\ /\\\\ /g' > cache.tmp
|
||||
sh cache.tmp
|
||||
rm -f cache.tmp
|
||||
exit $?
|
||||
|
@@ -945,6 +945,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li>m4: Owner of the water</li>
|
||||
<li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
|
||||
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
|
||||
</ul>
|
||||
|
@@ -194,8 +194,8 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="free">OOOO OO</span>XX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XXXX XXXX</td>
|
||||
<td class="bits">XX<span class="free">OO OO</span>XX</td>
|
||||
<td class="bits"><span class="free">OOOO OOOO</span></td>
|
||||
</tr>
|
||||
|
@@ -11,20 +11,18 @@ by the number below on http://bugs.openttd.org.
|
||||
If the bug report is closed, it has been fixed, which then can be verified
|
||||
in the latest SVN version of /trunk.
|
||||
|
||||
Bugs for 0.6.0-beta1
|
||||
Bugs for 0.6.0-beta3
|
||||
------------------------------------------------------------------------
|
||||
URL: http://bugs.openttd.org
|
||||
|
||||
- 1434 Network game crashes when player builds SH40
|
||||
- 1624 Autoreplace refit fails -> crash
|
||||
- 1549 Timetable + group ID are not backed up with orders
|
||||
- 1495 Long vehicles block multistop station
|
||||
- 1487 Ending_year is never written to
|
||||
- 1473 Train not going to available platform
|
||||
- 1404 Spinner widget interprets one click as many
|
||||
- 1401 Crash while scrolling screen
|
||||
- 1386 Mac OS X fails to compile out of the box on 10.5
|
||||
- 1264 Autoreplace for multiple NewGRF DMU sets fails
|
||||
- 1200 Illegal names skip comparisons for uniquity
|
||||
- 1141 [OSX] Not smooth moving map with touchpad
|
||||
- 1109 [OSX] Choppy mouse cursor movement in fullscreen mode
|
||||
- 1094 Foundations showing on 'build on slopes'
|
||||
- 1140 [OSX] Not smooth moving map with touchpad
|
||||
- 1074 Large slowdown when building tracks
|
||||
- 1072 Text overflows in several windows
|
||||
- 716 Train crash in depot with long long tracks
|
||||
- 119 Clipping problems with vehicles on slopes
|
||||
|
@@ -4,6 +4,18 @@ openttd (0.6~svn) unstable; urgency=low
|
||||
|
||||
-- Matthijs Kooijman <m.kooijman@student.utwente.nl> Mon, 26 Feb 2007 21:07:05 +0100
|
||||
|
||||
openttd (0.6.0~beta3-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Matthijs Kooijman <m.kooijman@student.utwente.nl> Tue, 16 Jan 2008 21:40:07 +0100
|
||||
|
||||
openttd (0.6.0~beta2-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Matthijs Kooijman <m.kooijman@student.utwente.nl> Sun, 09 Dec 2007 22:05:05 +0100
|
||||
|
||||
openttd (0.6.0~beta1-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
@@ -1,9 +1,9 @@
|
||||
!define APPNAME "OpenTTD" ; Define application name
|
||||
!define APPVERSION "0.6.0" ; Define application version
|
||||
!define INSTALLERVERSION 39 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
|
||||
!define INSTALLERVERSION 41 ; NEED TO UPDATE THIS FOR EVERY RELEASE!!!
|
||||
|
||||
!define APPURLLINK "http://www.openttd.org"
|
||||
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta1"
|
||||
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}-beta3"
|
||||
!define APPVERSIONINTERNAL "${APPVERSION}.0" ; Needs to be of the format X.X.X.X
|
||||
|
||||
!define MUI_ICON "..\..\..\media\openttd.ico"
|
||||
|
@@ -41,6 +41,12 @@ Sub UpdateFiles(version)
|
||||
revision = Mid(OExec.StdOut.ReadLine(), 7)
|
||||
revision = Mid(revision, 1, InStr(revision, ")") - 1)
|
||||
End If
|
||||
Case "g" ' git
|
||||
Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../src")
|
||||
if Err.Number = 0 Then
|
||||
revision = Mid(oExec.StdOut.ReadLine(), 7)
|
||||
revision = Mid(revision, 1, InStr(revision, ")") - 1)
|
||||
End If
|
||||
End Select
|
||||
|
||||
UpdateFile revision, version, cur_date, "../src/rev.cpp"
|
||||
@@ -118,25 +124,49 @@ Function DetermineSVNVersion()
|
||||
version = version & Replace(url, "/", "-")
|
||||
End If
|
||||
Else
|
||||
' svn detection failed, reset error and try mercurial (hg)
|
||||
' svn detection failed, reset error and try git
|
||||
Err.Clear
|
||||
Set oExec = WshShell.Exec("hg tip")
|
||||
Set oExec = WshShell.Exec("git rev-parse --verify --short=8 HEAD")
|
||||
If Err.Number = 0 Then
|
||||
version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
|
||||
Set oExec = WshShell.Exec("hg status ../src")
|
||||
If Err.Number = 0 Then
|
||||
Do
|
||||
line = OExec.StdOut.ReadLine()
|
||||
If Mid(line, 1, 1) <> "?" Then
|
||||
version = version & "M"
|
||||
Exit Do
|
||||
End If
|
||||
Loop While Not OExec.StdOut.atEndOfStream
|
||||
version = "g" & oExec.StdOut.ReadLine()
|
||||
Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../src")
|
||||
Do While oExec.Status = 0 And Err.Number = 0
|
||||
Loop
|
||||
If Err.Number = 0 And oExec.ExitCode = 1 Then
|
||||
version = version & "M"
|
||||
End If
|
||||
Set oExec = WshShell.Exec("hg branch")
|
||||
|
||||
Set oExec = WshShell.Exec("git symbolic-ref HEAD")
|
||||
If Err.Number = 0 Then
|
||||
line = OExec.StdOut.ReadLine()
|
||||
If line <> "default" Then version = version & "-" & line
|
||||
line = oExec.StdOut.ReadLine()
|
||||
line = Mid(line, InStrRev(line, "/")+1)
|
||||
If line <> "master" Then
|
||||
version = version & "-" & line
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
' try mercurial (hg)
|
||||
Err.Clear
|
||||
Set oExec = WshShell.Exec("hg tip")
|
||||
If Err.Number = 0 Then
|
||||
version = "h" & Mid(OExec.StdOut.ReadLine(), 19, 8)
|
||||
Set oExec = WshShell.Exec("hg status ../src")
|
||||
If Err.Number = 0 Then
|
||||
Do
|
||||
line = OExec.StdOut.ReadLine()
|
||||
If Mid(line, 1, 1) <> "?" Then
|
||||
version = version & "M"
|
||||
Exit Do
|
||||
End If
|
||||
Loop While Not OExec.StdOut.atEndOfStream
|
||||
End If
|
||||
Set oExec = WshShell.Exec("hg branch")
|
||||
If Err.Number = 0 Then
|
||||
line = OExec.StdOut.ReadLine()
|
||||
If line <> "default" Then
|
||||
version = version & "-" & line
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -164,7 +194,7 @@ Function IsCachedVersion(version)
|
||||
End Function
|
||||
|
||||
Dim version
|
||||
version = "0.6.0-beta1"
|
||||
version = "0.6.0-beta3"
|
||||
If Not (IsCachedVersion(version) And FSO.FileExists("../src/rev.cpp") And FSO.FileExists("../src/ottdres.rc")) Then
|
||||
UpdateFiles version
|
||||
End If
|
||||
|
@@ -51,19 +51,6 @@
|
||||
Outputs="..\bin\lang\afrikaans.lng"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\american.txt">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Generating american language file"
|
||||
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
|
||||
"
|
||||
AdditionalDependencies=""
|
||||
Outputs="..\bin\lang\american.lng"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\brazilian_portuguese.txt">
|
||||
<FileConfiguration
|
||||
@@ -168,6 +155,19 @@
|
||||
Outputs="..\bin\lang\english.lng"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\english_US.txt">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Generating english_US language file"
|
||||
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
|
||||
"
|
||||
AdditionalDependencies=""
|
||||
Outputs="..\bin\lang\english_US.lng"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\esperanto.txt">
|
||||
<FileConfiguration
|
||||
|
@@ -61,21 +61,6 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\american.txt"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Generating american language file"
|
||||
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
"
|
||||
AdditionalDependencies=""
|
||||
Outputs="..\bin\lang\american.lng"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\brazilian_portuguese.txt"
|
||||
>
|
||||
@@ -196,6 +181,21 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\english_US.txt"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Generating english_US language file"
|
||||
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
"
|
||||
AdditionalDependencies=""
|
||||
Outputs="..\bin\lang\english_US.lng"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\esperanto.txt"
|
||||
>
|
||||
|
@@ -62,21 +62,6 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\american.txt"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Generating american language file"
|
||||
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
"
|
||||
AdditionalDependencies=""
|
||||
Outputs="..\bin\lang\american.lng"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\brazilian_portuguese.txt"
|
||||
>
|
||||
@@ -197,6 +182,21 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\english_US.txt"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Generating english_US language file"
|
||||
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "$(InputPath)"
"
|
||||
AdditionalDependencies=""
|
||||
Outputs="..\bin\lang\english_US.lng"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\lang\esperanto.txt"
|
||||
>
|
||||
|
@@ -30,7 +30,7 @@
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="1"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="TRUE"
|
||||
ExceptionHandling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
@@ -197,6 +197,12 @@
|
||||
<File
|
||||
RelativePath=".\..\src\console_cmds.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\bitmath_func.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\random_func.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\currency.cpp">
|
||||
</File>
|
||||
@@ -257,9 +263,6 @@
|
||||
<File
|
||||
RelativePath=".\..\src\md5.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\mersenne.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\minilzo.cpp">
|
||||
</File>
|
||||
@@ -341,6 +344,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\settings.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signs.cpp">
|
||||
</File>
|
||||
@@ -369,7 +375,7 @@
|
||||
RelativePath=".\..\src\thread.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tile.cpp">
|
||||
RelativePath=".\..\src\tile_map.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\vehicle.cpp">
|
||||
@@ -383,6 +389,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\widget.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\win32.cpp">
|
||||
</File>
|
||||
@@ -426,6 +435,15 @@
|
||||
<File
|
||||
RelativePath=".\..\src\console.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\bitmath_func.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\math_func.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\random_func.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\currency.h">
|
||||
</File>
|
||||
@@ -486,9 +504,6 @@
|
||||
<File
|
||||
RelativePath=".\..\src\heightmap.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\helpers.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\industry.h">
|
||||
</File>
|
||||
@@ -498,9 +513,6 @@
|
||||
<File
|
||||
RelativePath=".\..\src\livery.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\macros.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\map.h">
|
||||
</File>
|
||||
@@ -642,6 +654,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\signs.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal_func.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\slope.h">
|
||||
</File>
|
||||
@@ -657,6 +672,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\station.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\station_gui.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\stdafx.h">
|
||||
</File>
|
||||
@@ -717,6 +735,15 @@
|
||||
<File
|
||||
RelativePath=".\..\src\window.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown_type.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown_func.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\zoom.hpp">
|
||||
</File>
|
||||
@@ -875,6 +902,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\station_cmd.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\terraform_cmd.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\timetable_cmd.cpp">
|
||||
</File>
|
||||
@@ -1182,6 +1212,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\tunnel_map.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tunnelbridge_map.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\unmovable_map.h">
|
||||
</File>
|
||||
|
@@ -30,7 +30,7 @@
|
||||
OmitFramePointers="TRUE"
|
||||
OptimizeForProcessor="1"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="TRUE"
|
||||
ExceptionHandling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
|
@@ -61,7 +61,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
@@ -272,7 +272,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
@@ -495,6 +495,14 @@
|
||||
RelativePath=".\..\src\console_cmds.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\bitmath_func.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\random_func.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\currency.cpp"
|
||||
>
|
||||
@@ -575,10 +583,6 @@
|
||||
RelativePath=".\..\src\md5.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\mersenne.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\minilzo.cpp"
|
||||
>
|
||||
@@ -687,6 +691,10 @@
|
||||
RelativePath=".\..\src\settings.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signs.cpp"
|
||||
>
|
||||
@@ -724,7 +732,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tile.cpp"
|
||||
RelativePath=".\..\src\tile_map.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -743,6 +751,10 @@
|
||||
RelativePath=".\..\src\widget.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\win32.cpp"
|
||||
>
|
||||
@@ -799,6 +811,18 @@
|
||||
RelativePath=".\..\src\console.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\bitmath_func.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\math_func.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\random_func.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\currency.h"
|
||||
>
|
||||
@@ -879,10 +903,6 @@
|
||||
RelativePath=".\..\src\heightmap.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\helpers.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\industry.h"
|
||||
>
|
||||
@@ -895,10 +915,6 @@
|
||||
RelativePath=".\..\src\livery.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\macros.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\map.h"
|
||||
>
|
||||
@@ -1087,6 +1103,10 @@
|
||||
RelativePath=".\..\src\signs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal_func.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\slope.h"
|
||||
>
|
||||
@@ -1107,6 +1127,10 @@
|
||||
RelativePath=".\..\src\station.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\station_gui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\stdafx.h"
|
||||
>
|
||||
@@ -1187,6 +1211,18 @@
|
||||
RelativePath=".\..\src\window.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown_type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown_func.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\zoom.hpp"
|
||||
>
|
||||
@@ -1395,6 +1431,10 @@
|
||||
RelativePath=".\..\src\station_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\terraform_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\timetable_cmd.cpp"
|
||||
>
|
||||
@@ -1795,6 +1835,10 @@
|
||||
RelativePath=".\..\src\tunnel_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tunnelbridge_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\unmovable_map.h"
|
||||
>
|
||||
|
@@ -61,7 +61,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
@@ -272,7 +272,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
|
@@ -62,7 +62,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
@@ -270,7 +270,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
@@ -492,6 +492,14 @@
|
||||
RelativePath=".\..\src\console_cmds.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\bitmath_func.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\random_func.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\currency.cpp"
|
||||
>
|
||||
@@ -572,10 +580,6 @@
|
||||
RelativePath=".\..\src\md5.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\mersenne.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\minilzo.cpp"
|
||||
>
|
||||
@@ -684,6 +688,10 @@
|
||||
RelativePath=".\..\src\settings.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signs.cpp"
|
||||
>
|
||||
@@ -721,7 +729,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tile.cpp"
|
||||
RelativePath=".\..\src\tile_map.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -740,6 +748,10 @@
|
||||
RelativePath=".\..\src\widget.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\win32.cpp"
|
||||
>
|
||||
@@ -796,6 +808,18 @@
|
||||
RelativePath=".\..\src\console.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\bitmath_func.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\math_func.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\core\random_func.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\currency.h"
|
||||
>
|
||||
@@ -876,10 +900,6 @@
|
||||
RelativePath=".\..\src\heightmap.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\helpers.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\industry.h"
|
||||
>
|
||||
@@ -892,10 +912,6 @@
|
||||
RelativePath=".\..\src\livery.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\macros.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\map.h"
|
||||
>
|
||||
@@ -1084,6 +1100,10 @@
|
||||
RelativePath=".\..\src\signs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal_func.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\slope.h"
|
||||
>
|
||||
@@ -1104,6 +1124,10 @@
|
||||
RelativePath=".\..\src\station.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\station_gui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\stdafx.h"
|
||||
>
|
||||
@@ -1184,6 +1208,18 @@
|
||||
RelativePath=".\..\src\window.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown_type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown_func.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\zoom.hpp"
|
||||
>
|
||||
@@ -1392,6 +1428,10 @@
|
||||
RelativePath=".\..\src\station_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\terraform_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\timetable_cmd.cpp"
|
||||
>
|
||||
@@ -1792,6 +1832,10 @@
|
||||
RelativePath=".\..\src\tunnel_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tunnelbridge_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\unmovable_map.h"
|
||||
>
|
||||
|
@@ -62,7 +62,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
@@ -270,7 +270,7 @@
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\objs\langs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_EXCEPTION_TRACKER;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_PNG;WITH_FREETYPE;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\"OpenTTD\";WITH_ASSERT"
|
||||
StringPooling="true"
|
||||
ExceptionHandling="1"
|
||||
RuntimeLibrary="0"
|
||||
|
35
readme.txt
35
readme.txt
@@ -1,6 +1,6 @@
|
||||
OpenTTD README
|
||||
Last updated: 2007-11-18
|
||||
Release version: 0.6.0-beta1
|
||||
Last updated: 2008-01-16
|
||||
Release version: 0.6.0-beta3
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -281,30 +281,35 @@ put them in the data/ folder and you're set to go.
|
||||
X.X) Credits:
|
||||
---- --------
|
||||
The OpenTTD team (in alphabetical order):
|
||||
Jean-Francois Claeys (Belugas) - In training, not yet specialized
|
||||
Bjarni Corfitzen (Bjarni) - Mac OS X port, coder
|
||||
Matthijs Kooijman (blathijs) - Pathfinder-guru
|
||||
Victor Fischer (Celestar) - Programming everywhere you need him to
|
||||
Tamás Faragó (Darkvater) - Lead programmer
|
||||
Loïc Guilloux (glx) - In training, not yet specialized
|
||||
Jean-Francois Claeys (Belugas) - GUI, newindustries and more
|
||||
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles
|
||||
Matthijs Kooijman (blathijs) - Pathfinder-guru, pool rework
|
||||
Loïc Guilloux (glx) - General coding
|
||||
Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;)
|
||||
Kerekes Miham (MiHaMiX) - Maintainer of translator service, and host of nightlies
|
||||
Owen Rudge (orudge) - Contributor, forum host, OS/2 port
|
||||
Peter Nelson (peter1138) - Spiritual descendant from newgrf gods
|
||||
Remko Bijker (Rubidium) - THE desync hunter
|
||||
Jonathan Coome (Maedhros) - High priest of the newGRF Temple
|
||||
Attila Bán (MiHaMiX) - WebTranslator, Nightlies, Wiki and bugtracker host
|
||||
Owen Rudge (orudge) - Forum host, OS/2 port
|
||||
Peter Nelson (peter1138) - Spiritual descendant from newGRF gods
|
||||
Remko Bijker (Rubidium) - Lead coder and way more
|
||||
Benedikt Brüggemeier (skidd13) - Bug fixer and code reworker
|
||||
Zdenek Sojka (SmatZ) - Bug finder and fixer
|
||||
|
||||
Inactive Developers:
|
||||
Victor Fischer (Celestar) - Programming everywhere you need him to
|
||||
Tamás Faragó (Darkvater) - Ex-Lead coder
|
||||
Christoph Mallon (Tron) - Programmer, code correctness police
|
||||
|
||||
Retired Developers:
|
||||
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)
|
||||
Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)
|
||||
Ludvig Strigeus (ludde) - OpenTTD author, main coder (0.1 - 0.3.3)
|
||||
Serge Paquet (vurlix) - Assistant project manager, coder (0.1 - 0.3.3)
|
||||
Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3.0 - 0.3.6)
|
||||
Patric Stout (TrueLight) - Programmer, webhoster (0.3 - pre0.6)
|
||||
|
||||
Thanks to:
|
||||
Josef Drexler - For his great work on TTDPatch.
|
||||
Marcin Grzegorczyk - For his TTDPatch work and documentation of TTD internals and graphics (signals and track foundations)
|
||||
Petr Baudis (pasky) - Many patches, newgrf support, etc.
|
||||
Simon Sasburg (HackyKid) - For the many bugfixes he has blessed us with (and future PBS)
|
||||
Simon Sasburg (HackyKid) - For the many bugfixes he has blessed us with
|
||||
Stefan Meißner (sign_de) - For his work on the console
|
||||
Mike Ragsdale - OpenTTD installer
|
||||
Cian Duffy (MYOB) - BeOS port / manual writing
|
||||
|
25
source.list
25
source.list
@@ -10,6 +10,8 @@ cargotype.cpp
|
||||
command.cpp
|
||||
console.cpp
|
||||
console_cmds.cpp
|
||||
core/bitmath_func.cpp
|
||||
core/random_func.cpp
|
||||
currency.cpp
|
||||
date.cpp
|
||||
debug.cpp
|
||||
@@ -30,7 +32,6 @@ helpers.cpp
|
||||
landscape.cpp
|
||||
map.cpp
|
||||
md5.cpp
|
||||
mersenne.cpp
|
||||
minilzo.cpp
|
||||
misc.cpp
|
||||
mixer.cpp
|
||||
@@ -65,6 +66,7 @@ screenshot.cpp
|
||||
sdl.cpp
|
||||
#end
|
||||
settings.cpp
|
||||
signal.cpp
|
||||
signs.cpp
|
||||
sound.cpp
|
||||
spritecache.cpp
|
||||
@@ -74,7 +76,7 @@ strings.cpp
|
||||
texteff.cpp
|
||||
tgp.cpp
|
||||
thread.cpp
|
||||
tile.cpp
|
||||
tile_map.cpp
|
||||
#if WIN32
|
||||
#else
|
||||
#if WINCE
|
||||
@@ -91,6 +93,7 @@ vehicle.cpp
|
||||
viewport.cpp
|
||||
waypoint.cpp
|
||||
widget.cpp
|
||||
widgets/dropdown.cpp
|
||||
#if WIN32
|
||||
win32.cpp
|
||||
#end
|
||||
@@ -108,6 +111,9 @@ cargopacket.h
|
||||
cargotype.h
|
||||
command.h
|
||||
console.h
|
||||
core/bitmath_func.hpp
|
||||
core/math_func.hpp
|
||||
core/random_func.hpp
|
||||
currency.h
|
||||
date.h
|
||||
debug.h
|
||||
@@ -128,11 +134,9 @@ gfxinit.h
|
||||
group.h
|
||||
gui.h
|
||||
heightmap.h
|
||||
helpers.hpp
|
||||
industry.h
|
||||
landscape.h
|
||||
livery.h
|
||||
macros.h
|
||||
map.h
|
||||
md5.h
|
||||
mixer.h
|
||||
@@ -180,11 +184,13 @@ sound/sdl_s.h
|
||||
video/sdl_v.h
|
||||
settings.h
|
||||
signs.h
|
||||
signal_func.h
|
||||
slope.h
|
||||
sound.h
|
||||
sprite.h
|
||||
spritecache.h
|
||||
station.h
|
||||
station_gui.h
|
||||
stdafx.h
|
||||
string.h
|
||||
texteff.hpp
|
||||
@@ -205,6 +211,9 @@ music/win32_m.h
|
||||
sound/win32_s.h
|
||||
video/win32_v.h
|
||||
window.h
|
||||
widgets/dropdown.h
|
||||
widgets/dropdown_type.h
|
||||
widgets/dropdown_func.h
|
||||
zoom.hpp
|
||||
|
||||
# GUI Source Code
|
||||
@@ -259,6 +268,7 @@ road_cmd.cpp
|
||||
roadveh_cmd.cpp
|
||||
ship_cmd.cpp
|
||||
station_cmd.cpp
|
||||
terraform_cmd.cpp
|
||||
timetable_cmd.cpp
|
||||
town_cmd.cpp
|
||||
train_cmd.cpp
|
||||
@@ -368,6 +378,7 @@ town_map.h
|
||||
tree_map.h
|
||||
tunnel_map.cpp
|
||||
tunnel_map.h
|
||||
tunnelbridge_map.h
|
||||
unmovable_map.h
|
||||
void_map.h
|
||||
water_map.h
|
||||
@@ -477,7 +488,11 @@ sound/null_s.cpp
|
||||
#end
|
||||
|
||||
#if COCOA
|
||||
video/cocoa_v.mm
|
||||
video/cocoa/cocoa_v.mm
|
||||
video/cocoa/event.mm
|
||||
video/cocoa/fullscreen.mm
|
||||
video/cocoa/wnd_quartz.mm
|
||||
video/cocoa/wnd_quickdraw.mm
|
||||
sound/cocoa_s.cpp
|
||||
os/macosx/splash.cpp
|
||||
#end
|
||||
|
@@ -3,12 +3,17 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../openttd.h"
|
||||
#include "../variables.h"
|
||||
#include "../command.h"
|
||||
#include "../command_func.h"
|
||||
#include "../network/network.h"
|
||||
#include "../helpers.hpp"
|
||||
#include "../core/alloc_func.hpp"
|
||||
#include "../player_func.h"
|
||||
#include "../player_base.h"
|
||||
#include "ai.h"
|
||||
#include "default/default.h"
|
||||
|
||||
AIStruct _ai;
|
||||
AIPlayer _ai_player[MAX_PLAYERS];
|
||||
|
||||
/**
|
||||
* Dequeues commands put in the queue via AI_PutCommandInQueue.
|
||||
*/
|
||||
@@ -45,7 +50,7 @@ static void AI_DequeueCommands(PlayerID player)
|
||||
* Needed for SP; we need to delay DoCommand with 1 tick, because else events
|
||||
* will make infinite loops (AIScript).
|
||||
*/
|
||||
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCallback* callback)
|
||||
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
|
||||
{
|
||||
AICommand *com;
|
||||
|
||||
@@ -81,7 +86,7 @@ static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uin
|
||||
/**
|
||||
* Executes a raw DoCommand for the AI.
|
||||
*/
|
||||
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
|
||||
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc, CommandCallback* callback)
|
||||
{
|
||||
PlayerID old_lp;
|
||||
CommandCost res;
|
||||
@@ -104,10 +109,6 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
|
||||
/* Restore _cmd_text */
|
||||
_cmd_text = tmp_cmdtext;
|
||||
|
||||
/* If we did a DC_EXEC, and the command did not return an error, execute it
|
||||
* over the network */
|
||||
if (flags & DC_NO_WATER) procc |= CMD_NO_WATER;
|
||||
|
||||
/* NetworkSend_Command needs _local_player to be set correctly, so
|
||||
* adjust it, and put it back right after the function */
|
||||
old_lp = _local_player;
|
||||
@@ -134,7 +135,7 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
|
||||
}
|
||||
|
||||
|
||||
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
|
||||
{
|
||||
return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL);
|
||||
}
|
||||
|
14
src/ai/ai.h
14
src/ai/ai.h
@@ -1,10 +1,12 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef AI_H
|
||||
#define AI_H
|
||||
|
||||
#include "../functions.h"
|
||||
#include "../network/network.h"
|
||||
#include "../player.h"
|
||||
#include "../command.h"
|
||||
#include "../command_type.h"
|
||||
#include "../core/random_func.hpp"
|
||||
#include "../settings_type.h"
|
||||
|
||||
/* How DoCommands look like for an AI */
|
||||
struct AICommand {
|
||||
@@ -12,7 +14,7 @@ struct AICommand {
|
||||
uint32 p1;
|
||||
uint32 p2;
|
||||
uint32 procc;
|
||||
CommandCallback* callback;
|
||||
CommandCallback *callback;
|
||||
|
||||
char *text;
|
||||
uint uid;
|
||||
@@ -34,8 +36,8 @@ struct AIStruct {
|
||||
uint tick; ///< The current tick (something like _frame_counter, only for AIs)
|
||||
};
|
||||
|
||||
VARDEF AIStruct _ai;
|
||||
VARDEF AIPlayer _ai_player[MAX_PLAYERS];
|
||||
extern AIStruct _ai;
|
||||
extern AIPlayer _ai_player[MAX_PLAYERS];
|
||||
|
||||
// ai.c
|
||||
void AI_StartNewAI(PlayerID player);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,66 @@
|
||||
#ifndef DEFAULT_H
|
||||
#define DEFAULT_H
|
||||
|
||||
#include "../../direction_type.h"
|
||||
#include "../../vehicle_type.h"
|
||||
#include "../../rail_type.h"
|
||||
|
||||
void AiDoGameLoop(Player*);
|
||||
void SaveLoad_AI(PlayerID id);
|
||||
|
||||
struct AiBuildRec {
|
||||
TileIndex spec_tile;
|
||||
TileIndex use_tile;
|
||||
byte rand_rng;
|
||||
byte cur_building_rule;
|
||||
byte unk6;
|
||||
byte unk7;
|
||||
byte buildcmd_a;
|
||||
byte buildcmd_b;
|
||||
byte direction;
|
||||
CargoID cargo;
|
||||
};
|
||||
|
||||
struct PlayerAI {
|
||||
byte state;
|
||||
byte tick; ///< Used to determine how often to move
|
||||
uint32 state_counter; ///< Can hold tile index!
|
||||
uint16 timeout_counter;
|
||||
|
||||
byte state_mode;
|
||||
byte banned_tile_count;
|
||||
RailTypeByte railtype_to_use;
|
||||
|
||||
CargoID cargo_type;
|
||||
byte num_wagons;
|
||||
byte build_kind;
|
||||
byte num_build_rec;
|
||||
byte num_loco_to_build;
|
||||
byte num_want_fullload;
|
||||
|
||||
byte route_type_mask;
|
||||
|
||||
TileIndex start_tile_a;
|
||||
TileIndex cur_tile_a;
|
||||
DiagDirectionByte cur_dir_a;
|
||||
DiagDirectionByte start_dir_a;
|
||||
|
||||
TileIndex start_tile_b;
|
||||
TileIndex cur_tile_b;
|
||||
DiagDirectionByte cur_dir_b;
|
||||
DiagDirectionByte start_dir_b;
|
||||
|
||||
Vehicle *cur_veh; ///< only used by some states
|
||||
|
||||
AiBuildRec src, dst, mid1, mid2;
|
||||
|
||||
VehicleID wagon_list[9];
|
||||
byte order_list_blocks[20];
|
||||
|
||||
TileIndex banned_tiles[16];
|
||||
byte banned_val[16];
|
||||
};
|
||||
|
||||
extern PlayerAI _players_ai[MAX_PLAYERS];
|
||||
|
||||
#endif
|
||||
|
@@ -3,17 +3,17 @@
|
||||
#include "../../stdafx.h"
|
||||
#include "../../openttd.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../functions.h"
|
||||
#include "../../map.h"
|
||||
#include "../../road_map.h"
|
||||
#include "../../tile.h"
|
||||
#include "../../vehicle.h"
|
||||
#include "../../command.h"
|
||||
#include "../../command_func.h"
|
||||
#include "trolly.h"
|
||||
#include "../../engine.h"
|
||||
#include "../../station.h"
|
||||
#include "../../variables.h"
|
||||
#include "../../bridge.h"
|
||||
#include "../../vehicle_func.h"
|
||||
#include "../../vehicle_base.h"
|
||||
#include "../../player_base.h"
|
||||
#include "../../player_func.h"
|
||||
#include "../ai.h"
|
||||
|
||||
// Build HQ
|
||||
@@ -72,7 +72,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
|
||||
if (type2 == 0 && type != 0) type2 = type;
|
||||
|
||||
// Now, simply, build the bridge!
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
if (_players_ainew[p->index].tbt == AI_TRAIN) {
|
||||
return AI_DoCommand(tile_a, tile_b, (0x00 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
} else {
|
||||
return AI_DoCommand(tile_a, tile_b, ((0x80 | ROADTYPES_ROAD) << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
|
||||
@@ -146,7 +146,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
|
||||
res = AI_DoCommand(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
|
||||
if (CmdFailed(res)) {
|
||||
// Problem.. let's just abort it all!
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
_players_ainew[p->index].state = AI_STATE_NOTHING;
|
||||
return CommandCost();
|
||||
}
|
||||
cost.AddCost(res);
|
||||
@@ -202,7 +202,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
|
||||
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicleOnGround(route[part])) {
|
||||
// Problem.. let's just abort it all!
|
||||
DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]);
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
_players_ainew[p->index].state = AI_STATE_NOTHING;
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
|
||||
// It returns INVALID_ENGINE if not suitable engine is found
|
||||
EngineID AiNew_PickVehicle(Player *p)
|
||||
{
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
if (_players_ainew[p->index].tbt == AI_TRAIN) {
|
||||
// Not supported yet
|
||||
return INVALID_ENGINE;
|
||||
} else {
|
||||
@@ -246,11 +246,11 @@ EngineID AiNew_PickVehicle(Player *p)
|
||||
CommandCost ret;
|
||||
|
||||
/* Skip vehicles which can't take our cargo type */
|
||||
if (rvi->cargo_type != p->ainew.cargo && !CanRefitTo(i, p->ainew.cargo)) continue;
|
||||
if (rvi->cargo_type != _players_ainew[p->index].cargo && !CanRefitTo(i, _players_ainew[p->index].cargo)) continue;
|
||||
|
||||
// Is it availiable?
|
||||
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
|
||||
if (!HASBIT(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
|
||||
if (!HasBit(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
|
||||
|
||||
/* Rate and compare the engine by speed & capacity */
|
||||
rating = rvi->max_speed * rvi->capacity;
|
||||
@@ -274,20 +274,20 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
Player* p = GetPlayer(_current_player);
|
||||
|
||||
if (success) {
|
||||
p->ainew.state = AI_STATE_GIVE_ORDERS;
|
||||
p->ainew.veh_id = _new_vehicle_id;
|
||||
_players_ainew[p->index].state = AI_STATE_GIVE_ORDERS;
|
||||
_players_ainew[p->index].veh_id = _new_vehicle_id;
|
||||
|
||||
if (GetVehicle(p->ainew.veh_id)->cargo_type != p->ainew.cargo) {
|
||||
if (GetVehicle(_players_ainew[p->index].veh_id)->cargo_type != _players_ainew[p->index].cargo) {
|
||||
/* Cargo type doesn't match, so refit it */
|
||||
if (CmdFailed(DoCommand(tile, p->ainew.veh_id, p->ainew.cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
|
||||
if (CmdFailed(DoCommand(tile, _players_ainew[p->index].veh_id, _players_ainew[p->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
|
||||
/* Refit failed, so sell the vehicle */
|
||||
DoCommand(tile, p->ainew.veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
DoCommand(tile, _players_ainew[p->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
|
||||
_players_ainew[p->index].state = AI_STATE_NOTHING;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* XXX this should be handled more gracefully */
|
||||
p->ainew.state = AI_STATE_NOTHING;
|
||||
_players_ainew[p->index].state = AI_STATE_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
|
||||
EngineID i = AiNew_PickVehicle(p);
|
||||
|
||||
if (i == INVALID_ENGINE) return CMD_ERROR;
|
||||
if (p->ainew.tbt == AI_TRAIN) return CMD_ERROR;
|
||||
if (_players_ainew[p->index].tbt == AI_TRAIN) return CMD_ERROR;
|
||||
|
||||
if (flag & DC_EXEC) {
|
||||
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
|
||||
@@ -310,7 +310,7 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
|
||||
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
|
||||
{
|
||||
CommandCost ret, ret2;
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
if (_players_ainew[p->index].tbt == AI_TRAIN) {
|
||||
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
||||
} else {
|
||||
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||
|
@@ -4,15 +4,17 @@
|
||||
#include "../../openttd.h"
|
||||
#include "../../bridge_map.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../functions.h"
|
||||
#include "../../map.h"
|
||||
#include "../../tile.h"
|
||||
#include "../../command.h"
|
||||
#include "../../command_func.h"
|
||||
#include "trolly.h"
|
||||
#include "../../depot.h"
|
||||
#include "../../tunnel_map.h"
|
||||
#include "../../bridge.h"
|
||||
#include "../../tunnelbridge_map.h"
|
||||
#include "../ai.h"
|
||||
#include "../../variables.h"
|
||||
#include "../../player_base.h"
|
||||
#include "../../player_func.h"
|
||||
|
||||
|
||||
#define TEST_STATION_NO_DIR 0xFF
|
||||
|
||||
@@ -27,14 +29,14 @@ static bool TestCanBuildStationHere(TileIndex tile, byte dir)
|
||||
// TODO: currently we only allow spots that can be access from al 4 directions...
|
||||
// should be fixed!!!
|
||||
for (dir = 0; dir < 4; dir++) {
|
||||
ret = AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST);
|
||||
ret = AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST);
|
||||
if (CmdSucceeded(ret)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// return true if command succeeded, so the inverse of CmdFailed()
|
||||
return CmdSucceeded(AiNew_Build_Station(p, p->ainew.tbt, tile, 1, 1, dir, DC_QUERY_COST));
|
||||
return CmdSucceeded(AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +45,7 @@ static bool IsRoad(TileIndex tile)
|
||||
return
|
||||
// MP_ROAD, but not a road depot?
|
||||
(IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
|
||||
(IsTileType(tile, MP_TUNNELBRIDGE) && (
|
||||
(IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) ||
|
||||
(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD)
|
||||
));
|
||||
(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,11 +233,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
|
||||
// If the next step is a bridge, we have to enter it the right way
|
||||
if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
|
||||
if (IsTileType(atile, MP_TUNNELBRIDGE)) {
|
||||
if (IsTunnel(atile)) {
|
||||
if (GetTunnelDirection(atile) != i) continue;
|
||||
} else {
|
||||
if (GetBridgeRampDirection(atile) != i) continue;
|
||||
}
|
||||
if (GetTunnelBridgeDirection(atile) != i) continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +406,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
|
||||
if (PathFinderInfo->rail_or_road) {
|
||||
Foundation f = GetRailFoundation(parent_tileh, (TrackBits)(1 << AiNew_GetRailDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile)));
|
||||
// Maybe is BRIDGE_NO_FOUNDATION a bit strange here, but it contains just the right information..
|
||||
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HASBIT(BRIDGE_NO_FOUNDATION, parent_tileh))) {
|
||||
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HasBit(BRIDGE_NO_FOUNDATION, parent_tileh))) {
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
} else {
|
||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||
@@ -419,7 +414,7 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
|
||||
} else {
|
||||
if (!IsRoad(parent->path.node.tile) || !IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE)) {
|
||||
Foundation f = GetRoadFoundation(parent_tileh, (RoadBits)AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
|
||||
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HASBIT(BRIDGE_NO_FOUNDATION, parent_tileh))) {
|
||||
if (IsInclinedFoundation(f) || (!IsFoundation(f) && HasBit(BRIDGE_NO_FOUNDATION, parent_tileh))) {
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
} else {
|
||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||
@@ -444,13 +439,13 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
|
||||
res += AI_PATHFINDER_BRIDGE_PENALTY * GetBridgeLength(current->tile, parent->path.node.tile);
|
||||
// Check if we are going up or down, first for the starting point
|
||||
// In user_data[0] is at the 8th bit the direction
|
||||
if (!HASBIT(BRIDGE_NO_FOUNDATION, parent_tileh)) {
|
||||
if (!HasBit(BRIDGE_NO_FOUNDATION, parent_tileh)) {
|
||||
if (IsLeveledFoundation(GetBridgeFoundation(parent_tileh, (Axis)((current->user_data[0] >> 8) & 1)))) {
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
}
|
||||
// Second for the end point
|
||||
if (!HASBIT(BRIDGE_NO_FOUNDATION, tileh)) {
|
||||
if (!HasBit(BRIDGE_NO_FOUNDATION, tileh)) {
|
||||
if (IsLeveledFoundation(GetBridgeFoundation(tileh, (Axis)((current->user_data[0] >> 8) & 1)))) {
|
||||
res += AI_PATHFINDER_BRIDGE_GOES_UP_PENALTY;
|
||||
}
|
||||
|
@@ -3,9 +3,10 @@
|
||||
#include "../../stdafx.h"
|
||||
#include "../../openttd.h"
|
||||
#include "../../debug.h"
|
||||
#include "../../map.h"
|
||||
#include "../../map_func.h"
|
||||
#include "../../vehicle_base.h"
|
||||
#include "../../player_base.h"
|
||||
#include "trolly.h"
|
||||
#include "../../vehicle.h"
|
||||
|
||||
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||
{
|
||||
@@ -80,8 +81,8 @@ uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
||||
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
||||
return p->ainew.special_vehicles[i].flag;
|
||||
if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
|
||||
return _players_ainew[p->index].special_vehicles[i].flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,13 +97,13 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
||||
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
||||
p->ainew.special_vehicles[i].flag |= flag;
|
||||
if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
|
||||
_players_ainew[p->index].special_vehicles[i].flag |= flag;
|
||||
return true;
|
||||
}
|
||||
if (new_id == -1 &&
|
||||
p->ainew.special_vehicles[i].veh_id == 0 &&
|
||||
p->ainew.special_vehicles[i].flag == 0) {
|
||||
_players_ainew[p->index].special_vehicles[i].veh_id == 0 &&
|
||||
_players_ainew[p->index].special_vehicles[i].flag == 0) {
|
||||
new_id = i;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
|
||||
DEBUG(ai, 1, "special_vehicles list is too small");
|
||||
return false;
|
||||
}
|
||||
p->ainew.special_vehicles[new_id].veh_id = v->index;
|
||||
p->ainew.special_vehicles[new_id].flag = flag;
|
||||
_players_ainew[p->index].special_vehicles[new_id].veh_id = v->index;
|
||||
_players_ainew[p->index].special_vehicles[new_id].flag = flag;
|
||||
return true;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,9 @@
|
||||
#define AI_TROLLY_H
|
||||
|
||||
#include "../../aystar.h"
|
||||
#include "../../player.h"
|
||||
#include "../../player_type.h"
|
||||
#include "../../vehicle_type.h"
|
||||
#include "../../date_type.h"
|
||||
|
||||
/*
|
||||
* These defines can be altered to change the behavoir of the AI
|
||||
@@ -239,6 +241,22 @@ typedef void AiNew_StateFunction(Player *p);
|
||||
// ai_new.c
|
||||
void AiNewDoGameLoop(Player *p);
|
||||
|
||||
struct Ai_PathFinderInfo {
|
||||
TileIndex start_tile_tl; ///< tl = top-left
|
||||
TileIndex start_tile_br; ///< br = bottom-right
|
||||
TileIndex end_tile_tl; ///< tl = top-left
|
||||
TileIndex end_tile_br; ///< br = bottom-right
|
||||
DiagDirection start_direction; ///< 0 to 3 or AI_PATHFINDER_NO_DIRECTION
|
||||
DiagDirection end_direction; ///< 0 to 3 or AI_PATHFINDER_NO_DIRECTION
|
||||
|
||||
TileIndex route[500];
|
||||
byte route_extra[500]; ///< Some extra information about the route like bridge/tunnel
|
||||
int route_length;
|
||||
int position; ///< Current position in the build-path, needed to build the path
|
||||
|
||||
bool rail_or_road; ///< true = rail, false = road
|
||||
};
|
||||
|
||||
// ai_pathfinder.c
|
||||
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo);
|
||||
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo);
|
||||
@@ -259,4 +277,64 @@ EngineID AiNew_PickVehicle(Player *p);
|
||||
CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
|
||||
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
|
||||
|
||||
/* The amount of memory reserved for the AI-special-vehicles */
|
||||
#define AI_MAX_SPECIAL_VEHICLES 100
|
||||
|
||||
struct Ai_SpecialVehicle {
|
||||
VehicleID veh_id;
|
||||
uint32 flag;
|
||||
};
|
||||
|
||||
struct PlayerAiNew {
|
||||
uint8 state;
|
||||
uint tick;
|
||||
uint idle;
|
||||
|
||||
int temp; ///< A value used in more than one function, but it just temporary
|
||||
///< The use is pretty simple: with this we can 'think' about stuff
|
||||
///< in more than one tick, and more than one AI. A static will not
|
||||
///< do, because they are not saved. This way, the AI is almost human ;)
|
||||
int counter; ///< For the same reason as temp, we have counter. It can count how
|
||||
///< long we are trying something, and just abort if it takes too long
|
||||
|
||||
/* Pathfinder stuff */
|
||||
Ai_PathFinderInfo path_info;
|
||||
AyStar *pathfinder;
|
||||
|
||||
/* Route stuff */
|
||||
|
||||
CargoID cargo;
|
||||
byte tbt; ///< train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
|
||||
Money new_cost;
|
||||
|
||||
byte action;
|
||||
|
||||
int last_id; ///< here is stored the last id of the searched city/industry
|
||||
Date last_vehiclecheck_date; // Used in CheckVehicle
|
||||
Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; ///< Some vehicles have some special flags
|
||||
|
||||
TileIndex from_tile;
|
||||
TileIndex to_tile;
|
||||
|
||||
DiagDirectionByte from_direction;
|
||||
DiagDirectionByte to_direction;
|
||||
|
||||
bool from_deliver; ///< True if this is the station that GIVES cargo
|
||||
bool to_deliver;
|
||||
|
||||
TileIndex depot_tile;
|
||||
DiagDirectionByte depot_direction;
|
||||
|
||||
byte amount_veh; ///< How many vehicles we are going to build in this route
|
||||
byte cur_veh; ///< How many vehicles did we bought?
|
||||
VehicleID veh_id; ///< Used when bought a vehicle
|
||||
VehicleID veh_main_id; ///< The ID of the first vehicle, for shared copy
|
||||
|
||||
int from_ic; ///< ic = industry/city. This is the ID of them
|
||||
byte from_type; ///< AI_NO_TYPE/AI_CITY/AI_INDUSTRY
|
||||
int to_ic;
|
||||
byte to_type;
|
||||
};
|
||||
extern PlayerAiNew _players_ainew[MAX_PLAYERS];
|
||||
|
||||
#endif /* AI_TROLLY_H */
|
||||
|
@@ -6,9 +6,8 @@
|
||||
#define AIRCRAFT_H
|
||||
|
||||
#include "station_map.h"
|
||||
#include "vehicle.h"
|
||||
#include "vehicle_base.h"
|
||||
#include "engine.h"
|
||||
#include "variables.h"
|
||||
|
||||
/** An aircraft can be one ot those types */
|
||||
enum AircraftSubType {
|
||||
|
@@ -7,33 +7,38 @@
|
||||
#include "openttd.h"
|
||||
#include "aircraft.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "landscape.h"
|
||||
#include "station_map.h"
|
||||
#include "strings.h"
|
||||
#include "table/strings.h"
|
||||
#include "map.h"
|
||||
#include "tile.h"
|
||||
#include "vehicle.h"
|
||||
#include "timetable.h"
|
||||
#include "depot.h"
|
||||
#include "engine.h"
|
||||
#include "command.h"
|
||||
#include "station.h"
|
||||
#include "news.h"
|
||||
#include "sound.h"
|
||||
#include "player.h"
|
||||
#include "aircraft.h"
|
||||
#include "airport.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "table/sprites.h"
|
||||
#include "newgrf_engine.h"
|
||||
#include "newgrf_callbacks.h"
|
||||
#include "newgrf_text.h"
|
||||
#include "newgrf_sound.h"
|
||||
#include "date.h"
|
||||
#include "spritecache.h"
|
||||
#include "cargotype.h"
|
||||
#include "strings_func.h"
|
||||
#include "command_func.h"
|
||||
#include "window_func.h"
|
||||
#include "date_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "sound_func.h"
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
#include "autoreplace_func.h"
|
||||
#include "autoreplace_gui.h"
|
||||
#include "gfx_func.h"
|
||||
#include "player_func.h"
|
||||
#include "settings_type.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
|
||||
void Aircraft::UpdateDeltaXY(Direction direction)
|
||||
{
|
||||
@@ -162,7 +167,7 @@ int Aircraft::GetImage(Direction direction) const
|
||||
int sprite = GetCustomVehicleSprite(this, direction);
|
||||
|
||||
if (sprite != 0) return sprite;
|
||||
spritenum = orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index;
|
||||
spritenum = _orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index;
|
||||
}
|
||||
return direction + _aircraft_sprite[spritenum];
|
||||
}
|
||||
@@ -190,7 +195,7 @@ void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal)
|
||||
if (is_custom_sprite(spritenum)) {
|
||||
sprite = GetCustomVehicleIcon(engine, DIR_W);
|
||||
if (sprite == 0) {
|
||||
spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
|
||||
spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
|
||||
sprite = (6 + _aircraft_sprite[spritenum]);
|
||||
}
|
||||
}
|
||||
@@ -218,7 +223,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
|
||||
if (is_custom_sprite(spritenum)) {
|
||||
sprite = GetCustomVehicleIcon(engine, DIR_W);
|
||||
if (sprite == 0) {
|
||||
spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
|
||||
spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
|
||||
sprite = (6 + _aircraft_sprite[spritenum]);
|
||||
}
|
||||
}
|
||||
@@ -231,7 +236,7 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
|
||||
|
||||
static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
|
||||
{
|
||||
return CommandCost(GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
|
||||
return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,8 +284,6 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
|
||||
/* Prevent building aircraft types at places which can't handle them */
|
||||
if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
|
||||
|
||||
@@ -291,7 +294,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
||||
}
|
||||
|
||||
UnitID unit_num = HASBIT(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
|
||||
UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
|
||||
if (unit_num > _patches.max_aircraft)
|
||||
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
||||
|
||||
@@ -334,7 +337,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
v->cargo_subtype = 0;
|
||||
|
||||
v->string_id = STR_SV_AIRCRAFT_NAME;
|
||||
v->name = NULL;
|
||||
// v->next_order_param = v->next_order = 0;
|
||||
|
||||
// v->load_unload_time_rem = 0;
|
||||
@@ -364,7 +367,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
v->cargo_type = cargo;
|
||||
|
||||
if (HASBIT(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
|
||||
if (HasBit(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
|
||||
callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
|
||||
}
|
||||
|
||||
@@ -418,7 +421,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
u->random_bits = VehicleRandomBits();
|
||||
|
||||
v->vehicle_flags = 0;
|
||||
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
||||
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
||||
|
||||
UpdateAircraftCache(v);
|
||||
|
||||
@@ -489,9 +492,7 @@ CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
|
||||
CommandCost ret(-v->value);
|
||||
CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
// Invalidate depot
|
||||
@@ -568,13 +569,13 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
|
||||
if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner) || v->IsInDepot()) return CMD_ERROR;
|
||||
|
||||
if (v->current_order.type == OT_GOTO_DEPOT && !(p2 & DEPOT_LOCATE_HANGAR)) {
|
||||
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
||||
if (!!(p2 & DEPOT_SERVICE) == HasBit(v->current_order.flags, OF_HALT_IN_DEPOT)) {
|
||||
/* We called with a different DEPOT_SERVICE setting.
|
||||
* Now we change the setting to apply the new one and let the vehicle head for the same hangar.
|
||||
* Note: the if is (true for requesting service == true for ordered to stop in hangar) */
|
||||
if (flags & DC_EXEC) {
|
||||
CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
|
||||
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
||||
ClrBit(v->current_order.flags, OF_PART_OF_ORDERS);
|
||||
ToggleBit(v->current_order.flags, OF_HALT_IN_DEPOT);
|
||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||
}
|
||||
return CommandCost();
|
||||
@@ -582,7 +583,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
|
||||
|
||||
if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
|
||||
if (flags & DC_EXEC) {
|
||||
if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
|
||||
if (v->current_order.flags & OFB_UNLOAD) v->cur_order_index++;
|
||||
v->current_order.type = OT_DUMMY;
|
||||
v->current_order.flags = 0;
|
||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||
@@ -605,8 +606,8 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
|
||||
if (v->current_order.type == OT_LOADING) v->LeaveStation();
|
||||
|
||||
v->current_order.type = OT_GOTO_DEPOT;
|
||||
v->current_order.flags = OF_NON_STOP;
|
||||
if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
||||
v->current_order.flags = OFB_NON_STOP;
|
||||
if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OF_HALT_IN_DEPOT);
|
||||
v->current_order.refit_cargo = CT_INVALID;
|
||||
v->current_order.dest = next_airport_index;
|
||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||
@@ -641,16 +642,15 @@ CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
|
||||
if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||
if (!v->IsStoppedInDepot()) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
|
||||
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
|
||||
|
||||
/* Check cargo */
|
||||
CargoID new_cid = GB(p2, 0, 8);
|
||||
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
|
||||
|
||||
/* Check the refit capacity callback */
|
||||
uint16 callback = CALLBACK_FAILED;
|
||||
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
|
||||
if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
|
||||
/* Back up the existing cargo type */
|
||||
CargoID temp_cid = v->cargo_type;
|
||||
byte temp_subtype = v->cargo_subtype;
|
||||
@@ -714,7 +714,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
|
||||
// printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
|
||||
// v->u.air.targetairport = st->index;
|
||||
v->current_order.type = OT_GOTO_DEPOT;
|
||||
v->current_order.flags = OF_NON_STOP;
|
||||
v->current_order.flags = OFB_NON_STOP;
|
||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||
} else if (v->current_order.type == OT_GOTO_DEPOT) {
|
||||
v->current_order.type = OT_DUMMY;
|
||||
@@ -737,11 +737,10 @@ void OnNewDay_Aircraft(Vehicle *v)
|
||||
|
||||
if (v->vehstatus & VS_STOPPED) return;
|
||||
|
||||
CommandCost cost = CommandCost(GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
|
||||
CommandCost cost = CommandCost(EXPENSES_AIRCRAFT_RUN, GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364);
|
||||
|
||||
v->profit_this_year -= cost.GetCost() >> 8;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
|
||||
SubtractMoneyFromPlayerFract(v->owner, cost);
|
||||
|
||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||
@@ -833,12 +832,12 @@ static void SetAircraftPosition(Vehicle *v, int x, int y, int z)
|
||||
|
||||
Vehicle *u = v->Next();
|
||||
|
||||
int safe_x = clamp(x, 0, MapMaxX() * TILE_SIZE);
|
||||
int safe_y = clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
|
||||
int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
|
||||
int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
|
||||
u->x_pos = x;
|
||||
u->y_pos = y - ((v->z_pos-GetSlopeZ(safe_x, safe_y)) >> 3);;
|
||||
|
||||
safe_y = clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
|
||||
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
|
||||
u->z_pos = GetSlopeZ(safe_x, safe_y);
|
||||
u->cur_image = v->cur_image;
|
||||
|
||||
@@ -1042,7 +1041,17 @@ static bool AircraftController(Vehicle *v)
|
||||
tile = st->xy;
|
||||
|
||||
/* Jump into our "holding pattern" state machine if possible */
|
||||
if (v->u.air.pos >= afc->nofelements) v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
|
||||
if (v->u.air.pos >= afc->nofelements) {
|
||||
v->u.air.pos = v->u.air.previous_pos = AircraftGetEntryPoint(v, afc);
|
||||
} else if (v->u.air.targetairport != v->current_order.dest) {
|
||||
/* If not possible, just get out of here fast */
|
||||
v->u.air.state = FLYING;
|
||||
UpdateAircraftCache(v);
|
||||
AircraftNextAirportPos_and_Order(v);
|
||||
/* get aircraft back on running altitude */
|
||||
SetAircraftPosition(v, v->x_pos, v->y_pos, GetAircraftFlyingAltitude(v));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* get airport moving data */
|
||||
@@ -1112,7 +1121,7 @@ static bool AircraftController(Vehicle *v)
|
||||
}
|
||||
|
||||
/* Get distance from destination pos to current pos. */
|
||||
uint dist = myabs(x + amd->x - v->x_pos) + myabs(y + amd->y - v->y_pos);
|
||||
uint dist = abs(x + amd->x - v->x_pos) + abs(y + amd->y - v->y_pos);
|
||||
|
||||
/* Need exact position? */
|
||||
if (!(amd->flag & AMED_EXACTPOS) && dist <= (amd->flag & AMED_SLOWTURN ? 8U : 4U)) return true;
|
||||
@@ -1255,7 +1264,7 @@ static void HandleCrashedAircraft(Vehicle *v)
|
||||
|
||||
if (v->u.air.crashed_counter < 650) {
|
||||
uint32 r;
|
||||
if (CHANCE16R(1,32,r)) {
|
||||
if (Chance16R(1,32,r)) {
|
||||
static const DirDiff delta[] = {
|
||||
DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
|
||||
};
|
||||
@@ -1338,8 +1347,8 @@ static void ProcessAircraftOrder(Vehicle *v)
|
||||
{
|
||||
switch (v->current_order.type) {
|
||||
case OT_GOTO_DEPOT:
|
||||
if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
|
||||
if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
|
||||
if (!(v->current_order.flags & OFB_PART_OF_ORDERS)) return;
|
||||
if (v->current_order.flags & OFB_SERVICE_IF_NEEDED &&
|
||||
!VehicleNeedsService(v)) {
|
||||
UpdateVehicleTimetable(v, true);
|
||||
v->cur_order_index++;
|
||||
@@ -1680,7 +1689,7 @@ static void AircraftEventHandler_HeliTakeOff(Vehicle *v, const AirportFTAClass *
|
||||
if (v->owner == _local_player && (
|
||||
EngineHasReplacementForPlayer(p, v->engine_type, v->group_id) ||
|
||||
((p->engine_renew && v->age - v->max_age > p->engine_renew_months * 30) &&
|
||||
HASBIT(GetEngine(v->engine_type)->player_avail, _local_player))
|
||||
HasBit(GetEngine(v->engine_type)->player_avail, _local_player))
|
||||
)) {
|
||||
_current_player = _local_player;
|
||||
DoCommandP(v->tile, v->index, DEPOT_SERVICE | DEPOT_LOCATE_HANGAR, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_SHOW_NO_ERROR);
|
||||
@@ -1957,10 +1966,10 @@ static bool FreeTerminal(Vehicle *v, byte i, byte last_terminal)
|
||||
{
|
||||
Station *st = GetStation(v->u.air.targetairport);
|
||||
for (; i < last_terminal; i++) {
|
||||
if (!HASBIT(st->airport_flags, _airport_terminal_flag[i])) {
|
||||
if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
|
||||
/* TERMINAL# HELIPAD# */
|
||||
v->u.air.state = _airport_terminal_state[i]; // start moving to that terminal/helipad
|
||||
SETBIT(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
|
||||
SetBit(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -6,22 +6,17 @@
|
||||
#include "openttd.h"
|
||||
#include "aircraft.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "strings.h"
|
||||
#include "map.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "vehicle.h"
|
||||
#include "gfx.h"
|
||||
#include "command.h"
|
||||
#include "engine.h"
|
||||
#include "viewport.h"
|
||||
#include "player.h"
|
||||
#include "depot.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "newgrf_engine.h"
|
||||
#include "strings_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "gfx_func.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
/**
|
||||
* Draw the details for the given vehicle at the position (x,y)
|
||||
|
@@ -5,13 +5,12 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "map.h"
|
||||
#include "airport.h"
|
||||
#include "macros.h"
|
||||
#include "variables.h"
|
||||
#include "airport_movement.h"
|
||||
#include "date.h"
|
||||
#include "helpers.hpp"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/alloc_func.hpp"
|
||||
#include "date_func.h"
|
||||
#include "settings_type.h"
|
||||
|
||||
/* Uncomment this to print out a full report of the airport-structure
|
||||
* You should either use
|
||||
@@ -431,18 +430,6 @@ static const char* const _airport_heading_strings[] = {
|
||||
"DUMMY" // extra heading for 255
|
||||
};
|
||||
|
||||
static uint AirportBlockToString(uint32 block)
|
||||
{
|
||||
uint i = 0;
|
||||
if (block & 0xffff0000) { block >>= 16; i += 16; }
|
||||
if (block & 0x0000ff00) { block >>= 8; i += 8; }
|
||||
if (block & 0x000000f0) { block >>= 4; i += 4; }
|
||||
if (block & 0x0000000c) { block >>= 2; i += 2; }
|
||||
if (block & 0x00000002) { i += 1; }
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report)
|
||||
{
|
||||
if (!full_report) printf("(P = Current Position; NP = Next Position)\n");
|
||||
@@ -453,7 +440,7 @@ static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool ful
|
||||
byte heading = (current->heading == 255) ? MAX_HEADINGS + 1 : current->heading;
|
||||
printf("\tPos:%2d NPos:%2d Heading:%15s Block:%2d\n", current->position,
|
||||
current->next_position, _airport_heading_strings[heading],
|
||||
AirportBlockToString(current->block));
|
||||
FindLastBit(current->block));
|
||||
} else {
|
||||
printf("P:%2d NP:%2d", current->position, current->next_position);
|
||||
}
|
||||
@@ -488,14 +475,14 @@ uint32 GetValidAirports()
|
||||
{
|
||||
uint32 mask = 0;
|
||||
|
||||
if (_cur_year < 1960 || _patches.always_small_airport) SETBIT(mask, 0); // small airport
|
||||
if (_cur_year >= 1955) SETBIT(mask, 1); // city airport
|
||||
if (_cur_year >= 1963) SETBIT(mask, 2); // heliport
|
||||
if (_cur_year >= 1980) SETBIT(mask, 3); // metropolitan airport
|
||||
if (_cur_year >= 1990) SETBIT(mask, 4); // international airport
|
||||
if (_cur_year >= 1983) SETBIT(mask, 5); // commuter airport
|
||||
if (_cur_year >= 1976) SETBIT(mask, 6); // helidepot
|
||||
if (_cur_year >= 2002) SETBIT(mask, 7); // intercontinental airport
|
||||
if (_cur_year >= 1980) SETBIT(mask, 8); // helistation
|
||||
if (_cur_year < 1960 || _patches.always_small_airport) SetBit(mask, 0); // small airport
|
||||
if (_cur_year >= 1955) SetBit(mask, 1); // city airport
|
||||
if (_cur_year >= 1963) SetBit(mask, 2); // heliport
|
||||
if (_cur_year >= 1980) SetBit(mask, 3); // metropolitan airport
|
||||
if (_cur_year >= 1990) SetBit(mask, 4); // international airport
|
||||
if (_cur_year >= 1983) SetBit(mask, 5); // commuter airport
|
||||
if (_cur_year >= 1976) SetBit(mask, 6); // helidepot
|
||||
if (_cur_year >= 2002) SetBit(mask, 7); // intercontinental airport
|
||||
if (_cur_year >= 1980) SetBit(mask, 8); // helistation
|
||||
return mask;
|
||||
}
|
||||
|
@@ -5,7 +5,8 @@
|
||||
#ifndef AIRPORT_H
|
||||
#define AIRPORT_H
|
||||
|
||||
#include "direction.h"
|
||||
#include "direction_type.h"
|
||||
#include "map_type.h"
|
||||
|
||||
enum {MAX_TERMINALS = 10};
|
||||
enum {MAX_HELIPADS = 4};
|
||||
|
@@ -4,20 +4,23 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "window.h"
|
||||
#include "window_gui.h"
|
||||
#include "gui.h"
|
||||
#include "viewport.h"
|
||||
#include "gfx.h"
|
||||
#include "sound.h"
|
||||
#include "command.h"
|
||||
#include "vehicle.h"
|
||||
#include "station_gui.h"
|
||||
#include "terraform_gui.h"
|
||||
#include "command_func.h"
|
||||
#include "station.h"
|
||||
#include "airport.h"
|
||||
#include "depot.h"
|
||||
#include "sound_func.h"
|
||||
#include "window_func.h"
|
||||
#include "settings_type.h"
|
||||
#include "viewport_func.h"
|
||||
#include "gfx_func.h"
|
||||
#include "player_func.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
static byte _selected_airport_type;
|
||||
|
||||
@@ -101,7 +104,7 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
|
||||
case WE_ABORT_PLACE_OBJ:
|
||||
RaiseWindowButtons(w);
|
||||
w->RaiseButtons();
|
||||
|
||||
w = FindWindowById(WC_BUILD_STATION, 0);
|
||||
if (w != 0)
|
||||
@@ -145,9 +148,9 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_CREATE:
|
||||
SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
|
||||
SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
|
||||
LowerWindowWidget(w, _selected_airport_type + 7);
|
||||
w->SetWidgetLoweredState(16, !_station_show_coverage);
|
||||
w->SetWidgetLoweredState(17, _station_show_coverage);
|
||||
w->LowerWidget(_selected_airport_type + 7);
|
||||
break;
|
||||
|
||||
case WE_PAINT: {
|
||||
@@ -159,10 +162,10 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
avail_airports = GetValidAirports();
|
||||
|
||||
RaiseWindowWidget(w, _selected_airport_type + 7);
|
||||
if (!HASBIT(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
|
||||
if (!HASBIT(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
|
||||
LowerWindowWidget(w, _selected_airport_type + 7);
|
||||
w->RaiseWidget(_selected_airport_type + 7);
|
||||
if (!HasBit(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
|
||||
if (!HasBit(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
|
||||
w->LowerWidget(_selected_airport_type + 7);
|
||||
|
||||
/* 'Country Airport' starts at widget 7, and if its bit is set, it is
|
||||
* available, so take its opposite value to set the disabled state.
|
||||
@@ -170,7 +173,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
* XXX TODO : all airports should be held in arrays, with all relevant data.
|
||||
* This should be part of newgrf-airports, i suppose
|
||||
*/
|
||||
for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i));
|
||||
for (i = 0; i < 9; i++) w->SetWidgetDisabledState(i + 7, !HasBit(avail_airports, i));
|
||||
|
||||
// select default the coverage area to 'Off' (16)
|
||||
airport = GetAirport(_selected_airport_type);
|
||||
@@ -190,16 +193,16 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||
case WE_CLICK: {
|
||||
switch (e->we.click.widget) {
|
||||
case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
|
||||
RaiseWindowWidget(w, _selected_airport_type + 7);
|
||||
w->RaiseWidget(_selected_airport_type + 7);
|
||||
_selected_airport_type = e->we.click.widget - 7;
|
||||
LowerWindowWidget(w, _selected_airport_type + 7);
|
||||
w->LowerWidget(_selected_airport_type + 7);
|
||||
SndPlayFx(SND_15_BEEP);
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
case 16: case 17:
|
||||
_station_show_coverage = (e->we.click.widget != 16);
|
||||
SetWindowWidgetLoweredState(w, 16, !_station_show_coverage);
|
||||
SetWindowWidgetLoweredState(w, 17, _station_show_coverage);
|
||||
w->SetWidgetLoweredState(16, !_station_show_coverage);
|
||||
w->SetWidgetLoweredState(17, _station_show_coverage);
|
||||
SndPlayFx(SND_15_BEEP);
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
@@ -4,20 +4,18 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "command.h"
|
||||
#include "vehicle.h"
|
||||
#include "articulated_vehicles.h"
|
||||
#include "engine.h"
|
||||
#include "train.h"
|
||||
#include "roadveh.h"
|
||||
#include "newgrf_callbacks.h"
|
||||
#include "newgrf_engine.h"
|
||||
#include "vehicle_func.h"
|
||||
|
||||
|
||||
uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
|
||||
{
|
||||
if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
|
||||
if (!HasBit(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
|
||||
|
||||
Vehicle *v = NULL;;
|
||||
if (!purchase_window) {
|
||||
@@ -41,7 +39,7 @@ void AddArticulatedParts(Vehicle **vl, VehicleType type)
|
||||
const Vehicle *v = vl[0];
|
||||
Vehicle *u = vl[0];
|
||||
|
||||
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return;
|
||||
if (!HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return;
|
||||
|
||||
for (uint i = 1; i < MAX_UVALUE(EngineID); i++) {
|
||||
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, v->engine_type, v);
|
||||
@@ -56,7 +54,7 @@ void AddArticulatedParts(Vehicle **vl, VehicleType type)
|
||||
u = u->Next();
|
||||
|
||||
EngineID engine_type = GetFirstEngineOfType(type) + GB(callback, 0, 7);
|
||||
bool flip_image = HASBIT(callback, 7);
|
||||
bool flip_image = HasBit(callback, 7);
|
||||
|
||||
/* get common values from first engine */
|
||||
u->direction = v->direction;
|
||||
|
@@ -5,6 +5,8 @@
|
||||
#ifndef ARTICULATED_VEHICLES_H
|
||||
#define ARTICULATED_VEHICLES_H
|
||||
|
||||
#include "vehicle_type.h"
|
||||
|
||||
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
|
||||
void AddArticulatedParts(Vehicle **vl, VehicleType type);
|
||||
|
||||
|
38
src/autoreplace_base.h
Normal file
38
src/autoreplace_base.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file autoreplace_base.h Base class for autoreplaces/autorenews. */
|
||||
|
||||
#ifndef AUTOREPLACE_BASE_H
|
||||
#define AUTOREPLACE_BASE_H
|
||||
|
||||
#include "oldpool.h"
|
||||
#include "autoreplace_type.h"
|
||||
|
||||
/**
|
||||
* Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
|
||||
* placed here so the only exception to this rule, the saveload code, can use
|
||||
* it.
|
||||
*/
|
||||
DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000)
|
||||
|
||||
/**
|
||||
* Struct to store engine replacements. DO NOT USE outside of engine.c. Is
|
||||
* placed here so the only exception to this rule, the saveload code, can use
|
||||
* it.
|
||||
*/
|
||||
struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
|
||||
EngineID from;
|
||||
EngineID to;
|
||||
EngineRenew *next;
|
||||
GroupID group_id;
|
||||
|
||||
EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {}
|
||||
~EngineRenew() { this->from = INVALID_ENGINE; }
|
||||
|
||||
inline bool IsValid() const { return this->from != INVALID_ENGINE; }
|
||||
};
|
||||
|
||||
#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
|
||||
#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
|
||||
|
||||
#endif /* AUTOREPLACE_BASE_H */
|
@@ -4,11 +4,8 @@
|
||||
#include "openttd.h"
|
||||
#include "roadveh.h"
|
||||
#include "ship.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "news.h"
|
||||
#include "command.h"
|
||||
#include "player.h"
|
||||
#include "player_func.h"
|
||||
#include "engine.h"
|
||||
#include "debug.h"
|
||||
#include "vehicle_gui.h"
|
||||
@@ -17,8 +14,15 @@
|
||||
#include "aircraft.h"
|
||||
#include "cargotype.h"
|
||||
#include "group.h"
|
||||
#include "strings.h"
|
||||
#include "order.h"
|
||||
#include "strings_func.h"
|
||||
#include "command_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
#include "autoreplace_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
/*
|
||||
* move the cargo from one engine to another if possible
|
||||
@@ -131,7 +135,7 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
const UnitID cached_unitnumber = old_v->unitnumber;
|
||||
bool new_front = false;
|
||||
Vehicle *new_v = NULL;
|
||||
char vehicle_name[32];
|
||||
char *vehicle_name = NULL;
|
||||
CargoID replacement_cargo_type;
|
||||
|
||||
/* If the vehicle belongs to a group, check if the group is protected from the global autoreplace.
|
||||
@@ -158,12 +162,10 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
/* We give the player a loan of the same amount as the sell value.
|
||||
* This is needed in case he needs the income from the sale to build the new vehicle.
|
||||
* We take it back if building fails or when we really sell the old engine */
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
SubtractMoneyFromPlayer(sell_value);
|
||||
|
||||
cost = DoCommand(old_v->tile, new_engine_type, 3, flags, GetCmdBuildVeh(old_v));
|
||||
if (CmdFailed(cost)) {
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
/* Take back the money we just gave the player */
|
||||
sell_value.MultiplyCost(-1);
|
||||
SubtractMoneyFromPlayer(sell_value);
|
||||
@@ -189,9 +191,9 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
}
|
||||
}
|
||||
|
||||
if (new_v->type == VEH_TRAIN && HASBIT(old_v->u.rail.flags, VRF_REVERSE_DIRECTION) && !IsMultiheaded(new_v) && !(new_v->Next() != NULL && IsArticulatedPart(new_v->Next()))) {
|
||||
if (new_v->type == VEH_TRAIN && HasBit(old_v->u.rail.flags, VRF_REVERSE_DIRECTION) && !IsMultiheaded(new_v) && !(new_v->Next() != NULL && IsArticulatedPart(new_v->Next()))) {
|
||||
// we are autorenewing to a single engine, so we will turn it as the old one was turned as well
|
||||
SETBIT(new_v->u.rail.flags, VRF_REVERSE_DIRECTION);
|
||||
SetBit(new_v->u.rail.flags, VRF_REVERSE_DIRECTION);
|
||||
}
|
||||
|
||||
if (old_v->type == VEH_TRAIN && !IsFrontEngine(old_v)) {
|
||||
@@ -239,12 +241,7 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
MoveVehicleCargo(new_v->type == VEH_TRAIN ? new_v->First() : new_v, old_v);
|
||||
|
||||
// Get the name of the old vehicle if it has a custom name.
|
||||
if (!IsCustomName(old_v->string_id)) {
|
||||
vehicle_name[0] = '\0';
|
||||
} else {
|
||||
SetDParam(0, old_v->index);
|
||||
GetString(vehicle_name, STR_VEHICLE_NAME, lastof(vehicle_name));
|
||||
}
|
||||
if (old_v->name != NULL) vehicle_name = strdup(old_v->name);
|
||||
} else { // flags & DC_EXEC not set
|
||||
CommandCost tmp_move;
|
||||
|
||||
@@ -263,7 +260,6 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
/* Ensure that the player will not end up having negative money while autoreplacing
|
||||
* This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */
|
||||
if (CmdFailed(tmp_move) || p->player_money < (cost.GetCost() + total_cost)) {
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
/* Pay back the loan */
|
||||
sell_value.MultiplyCost(-1);
|
||||
SubtractMoneyFromPlayer(sell_value);
|
||||
@@ -273,7 +269,6 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
|
||||
/* Take back the money we just gave the player just before building the vehicle
|
||||
* The player will get the same amount now that the sale actually takes place */
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
sell_value.MultiplyCost(-1);
|
||||
SubtractMoneyFromPlayer(sell_value);
|
||||
|
||||
@@ -286,9 +281,10 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
|
||||
}
|
||||
|
||||
/* Transfer the name of the old vehicle */
|
||||
if ((flags & DC_EXEC) && vehicle_name[0] != '\0') {
|
||||
if ((flags & DC_EXEC) && vehicle_name != NULL) {
|
||||
_cmd_text = vehicle_name;
|
||||
DoCommand(0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE);
|
||||
free(vehicle_name);
|
||||
}
|
||||
|
||||
return cost;
|
||||
@@ -333,7 +329,7 @@ CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
|
||||
v->leave_depot_instantly = false;
|
||||
|
||||
for (;;) {
|
||||
cost = CommandCost();
|
||||
cost = CommandCost(EXPENSES_NEW_VEHICLES);
|
||||
w = v;
|
||||
do {
|
||||
if (w->type == VEH_TRAIN && IsRearDualheaded(w)) {
|
||||
|
103
src/autoreplace_func.h
Normal file
103
src/autoreplace_func.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file autoreplace_func.h Functions related to autoreplacing. */
|
||||
|
||||
#ifndef AUTOREPLACE_FUNC_H
|
||||
#define AUTOREPLACE_FUNC_H
|
||||
|
||||
#include "autoreplace_type.h"
|
||||
#include "player_base.h"
|
||||
|
||||
/**
|
||||
* Remove all engine replacement settings for the player.
|
||||
* @param erl The renewlist for a given player.
|
||||
* @return The new renewlist for the player.
|
||||
*/
|
||||
void RemoveAllEngineReplacement(EngineRenewList *erl);
|
||||
|
||||
/**
|
||||
* Retrieve the engine replacement in a given renewlist for an original engine type.
|
||||
* @param erl The renewlist to search in.
|
||||
* @param engine Engine type to be replaced.
|
||||
* @return The engine type to replace with, or INVALID_ENGINE if no
|
||||
* replacement is in the list.
|
||||
*/
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
|
||||
|
||||
/**
|
||||
* Add an engine replacement to the given renewlist.
|
||||
* @param erl The renewlist to add to.
|
||||
* @param old_engine The original engine type.
|
||||
* @param new_engine The replacement engine type.
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
|
||||
|
||||
/**
|
||||
* Remove an engine replacement from a given renewlist.
|
||||
* @param erl The renewlist from which to remove the replacement
|
||||
* @param engine The original engine type.
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags);
|
||||
|
||||
/**
|
||||
* Remove all engine replacement settings for the given player.
|
||||
* @param p Player.
|
||||
*/
|
||||
static inline void RemoveAllEngineReplacementForPlayer(Player *p)
|
||||
{
|
||||
RemoveAllEngineReplacement(&p->engine_renew_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the engine replacement for the given player and original engine type.
|
||||
* @param p Player.
|
||||
* @param engine Engine type.
|
||||
* @return The engine type to replace with, or INVALID_ENGINE if no
|
||||
* replacement is in the list.
|
||||
*/
|
||||
static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
|
||||
{
|
||||
return EngineReplacement(p->engine_renew_list, engine, group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has a replacement set up for the given engine.
|
||||
* @param p Player.
|
||||
* @param engine Engine type to be replaced.
|
||||
* @return true if a replacement was set up, false otherwise.
|
||||
*/
|
||||
static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group)
|
||||
{
|
||||
return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an engine replacement for the player.
|
||||
* @param p Player.
|
||||
* @param old_engine The original engine type.
|
||||
* @param new_engine The replacement engine type.
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
|
||||
{
|
||||
return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an engine replacement for the player.
|
||||
* @param p Player.
|
||||
* @param engine The original engine type.
|
||||
* @param flags The calling command flags.
|
||||
* @return 0 on success, CMD_ERROR on failure.
|
||||
*/
|
||||
static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags)
|
||||
{
|
||||
return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags);
|
||||
}
|
||||
|
||||
#endif /* AUTOREPLACE_FUNC_H */
|
@@ -5,18 +5,23 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "strings.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "command.h"
|
||||
#include "command_func.h"
|
||||
#include "variables.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "newgrf_engine.h"
|
||||
#include "group.h"
|
||||
#include "rail.h"
|
||||
#include "strings_func.h"
|
||||
#include "window_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "autoreplace_func.h"
|
||||
#include "gfx_func.h"
|
||||
#include "player_func.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
static RailType _railtype_selected_in_replace_gui;
|
||||
|
||||
@@ -31,6 +36,15 @@ static const StringID _rail_types_list[] = {
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
static int CDECL TrainEngineNumberSorter(const void *a, const void *b)
|
||||
{
|
||||
const EngineID va = *(const EngineID*)a;
|
||||
const EngineID vb = *(const EngineID*)b;
|
||||
int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* General Vehicle GUI based procedures that are independent of vehicle types */
|
||||
void InitializeVehiclesGuiList()
|
||||
{
|
||||
@@ -164,7 +178,7 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
|
||||
if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
|
||||
|
||||
/* Road vehicles can't be replaced by trams and vice-versa */
|
||||
if (type == VEH_ROAD && HASBIT(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HASBIT(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
|
||||
if (type == VEH_ROAD && HasBit(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue;
|
||||
if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
|
||||
}
|
||||
|
||||
@@ -172,6 +186,7 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
|
||||
if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
|
||||
}
|
||||
WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
|
||||
if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter);
|
||||
}
|
||||
|
||||
/** Generate the lists
|
||||
@@ -240,7 +255,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
Player *p = GetPlayer(_local_player);
|
||||
EngineID selected_id[2];
|
||||
const GroupID selected_group = WP(w,replaceveh_d).sel_group;
|
||||
const GroupID selected_group = WP(w, replaceveh_d).sel_group;
|
||||
|
||||
selected_id[0] = WP(w, replaceveh_d).sel_engine[0];
|
||||
selected_id[1] = WP(w, replaceveh_d).sel_engine[1];
|
||||
@@ -249,7 +264,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
* Either list is empty
|
||||
* or The selected replacement engine has a replacement (to prevent loops)
|
||||
* or The right list (new replacement) has the existing replacement vehicle selected */
|
||||
SetWindowWidgetDisabledState(w, 4,
|
||||
w->SetWidgetDisabledState(4,
|
||||
selected_id[0] == INVALID_ENGINE ||
|
||||
selected_id[1] == INVALID_ENGINE ||
|
||||
EngineReplacementForPlayer(p, selected_id[1], selected_group) != INVALID_ENGINE ||
|
||||
@@ -258,7 +273,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
||||
/* Disable the "Stop Replacing" button if:
|
||||
* The left list (existing vehicle) is empty
|
||||
* or The selected vehicle has no replacement set up */
|
||||
SetWindowWidgetDisabledState(w, 6,
|
||||
w->SetWidgetDisabledState(6,
|
||||
selected_id[0] == INVALID_ENGINE ||
|
||||
!EngineHasReplacementForPlayer(p, selected_id[0], selected_group));
|
||||
|
||||
|
19
src/autoreplace_gui.h
Normal file
19
src/autoreplace_gui.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file autoreplace_gui.h Functions related to the autoreplace GUIs*/
|
||||
|
||||
#ifndef AUTOREPLACE_GUI_H
|
||||
#define AUTOREPLACE_GUI_H
|
||||
|
||||
#include "vehicle_type.h"
|
||||
|
||||
/**
|
||||
* When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
|
||||
* @param type The type of engine
|
||||
*/
|
||||
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type);
|
||||
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
|
||||
void ShowReplaceVehicleWindow(VehicleType vehicletype);
|
||||
void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh);
|
||||
|
||||
#endif /* AUTOREPLACE_GUI_H */
|
15
src/autoreplace_type.h
Normal file
15
src/autoreplace_type.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file autoreplace_type.h Types related to autoreplacing. */
|
||||
|
||||
#ifndef AUTOREPLACE_TYPE_H
|
||||
#define AUTOREPLACE_TYPE_H
|
||||
|
||||
struct EngineRenew;
|
||||
|
||||
/**
|
||||
* A list to group EngineRenew directives together (such as per-player).
|
||||
*/
|
||||
typedef EngineRenew* EngineRenewList;
|
||||
|
||||
#endif /* AUTOREPLACE_TYPE_H */
|
@@ -6,6 +6,8 @@
|
||||
#define AUTOSLOPE_H
|
||||
|
||||
#include "depot.h"
|
||||
#include "settings_type.h"
|
||||
#include "player_func.h"
|
||||
|
||||
/**
|
||||
* Autoslope check for tiles with an entrance on an edge.
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "aystar.h"
|
||||
#include "helpers.hpp"
|
||||
#include "core/alloc_func.hpp"
|
||||
|
||||
int _aystar_stats_open_size;
|
||||
int _aystar_stats_closed_size;
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#define AYSTAR_H
|
||||
|
||||
#include "queue.h"
|
||||
#include "tile_type.h"
|
||||
|
||||
//#define AYSTAR_DEBUG
|
||||
enum {
|
||||
|
@@ -1,16 +1,20 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../zoom.hpp"
|
||||
#include "../gfx.h"
|
||||
#include "../core/alloc_func.hpp"
|
||||
#include "../gfx_func.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../debug.h"
|
||||
#include "../table/sprites.h"
|
||||
#include "../video/video_driver.hpp"
|
||||
#include "32bpp_anim.hpp"
|
||||
|
||||
#include "../table/sprites.h"
|
||||
|
||||
static FBlitter_32bppAnim iFBlitter_32bppAnim;
|
||||
|
||||
void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
|
||||
{
|
||||
if (bp->dst < _screen.dst_ptr || bp->dst > (uint32 *)_screen.dst_ptr + _screen.width * _screen.height) {
|
||||
if (_screen_disable_anim) {
|
||||
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
|
||||
Blitter_32bppOptimized::Draw(bp, mode, zoom);
|
||||
return;
|
||||
@@ -95,6 +99,12 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
|
||||
|
||||
void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
|
||||
{
|
||||
if (_screen_disable_anim) {
|
||||
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColorMappingRect() */
|
||||
Blitter_32bppOptimized::DrawColorMappingRect(dst, width, height, pal);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 *udst = (uint32 *)dst;
|
||||
uint8 *anim;
|
||||
|
||||
@@ -133,7 +143,9 @@ void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, i
|
||||
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
|
||||
{
|
||||
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
|
||||
/* Set the color in the anim-buffer too */
|
||||
|
||||
/* Set the color in the anim-buffer too, if we are rendering to the screen */
|
||||
if (_screen_disable_anim) return;
|
||||
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
|
||||
}
|
||||
|
||||
@@ -142,13 +154,20 @@ void Blitter_32bppAnim::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
|
||||
uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
|
||||
if (*dst == 0) {
|
||||
*dst = LookupColourInPalette(color);
|
||||
/* Set the color in the anim-buffer too */
|
||||
/* Set the color in the anim-buffer too, if we are rendering to the screen */
|
||||
if (_screen_disable_anim) return;
|
||||
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
|
||||
}
|
||||
}
|
||||
|
||||
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color)
|
||||
{
|
||||
if (_screen_disable_anim) {
|
||||
/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
|
||||
Blitter_32bppOptimized::DrawRect(video, width, height, color);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 color32 = LookupColourInPalette(color);
|
||||
uint8 *anim_line;
|
||||
|
||||
@@ -172,6 +191,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color
|
||||
|
||||
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
|
||||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
uint32 *dst = (uint32 *)video;
|
||||
uint32 *usrc = (uint32 *)src;
|
||||
@@ -195,6 +215,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
|
||||
|
||||
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
|
||||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
uint32 *udst = (uint32 *)dst;
|
||||
uint32 *src = (uint32 *)video;
|
||||
@@ -217,6 +238,8 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
|
||||
|
||||
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
|
||||
{
|
||||
assert(!_screen_disable_anim);
|
||||
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
|
||||
uint8 *dst, *src;
|
||||
|
||||
/* We need to scroll the anim-buffer too */
|
||||
@@ -265,6 +288,7 @@ int Blitter_32bppAnim::BufferSize(int width, int height)
|
||||
|
||||
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
|
||||
{
|
||||
assert(!_screen_disable_anim);
|
||||
uint8 *anim = this->anim_buf;
|
||||
|
||||
/* Never repaint the transparency pixel */
|
||||
|
@@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../gfx.h"
|
||||
#include "../gfx_func.h"
|
||||
#include "32bpp_base.hpp"
|
||||
|
||||
void *Blitter_32bppBase::MoveTo(const void *video, int x, int y)
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#define BLITTER_32BPP_BASE_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
#include "../core/bitmath_func.hpp"
|
||||
|
||||
class Blitter_32bppBase : public Blitter {
|
||||
public:
|
||||
|
@@ -1,8 +1,9 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../zoom.hpp"
|
||||
#include "../gfx.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../gfx_func.h"
|
||||
#include "../debug.h"
|
||||
#include "../table/sprites.h"
|
||||
#include "32bpp_optimized.hpp"
|
||||
|
||||
static FBlitter_32bppOptimized iFBlitter_32bppOptimized;
|
||||
|
@@ -1,10 +1,13 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../zoom.hpp"
|
||||
#include "../gfx.h"
|
||||
#include "../gfx_func.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../debug.h"
|
||||
#include "../table/sprites.h"
|
||||
#include "32bpp_simple.hpp"
|
||||
|
||||
#include "../table/sprites.h"
|
||||
|
||||
static FBlitter_32bppSimple iFBlitter_32bppSimple;
|
||||
|
||||
void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
|
||||
|
@@ -1,5 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../gfx.h"
|
||||
#include "../gfx_func.h"
|
||||
#include "8bpp_base.hpp"
|
||||
|
||||
void Blitter_8bppBase::DrawColorMappingRect(void *dst, int width, int height, int pal)
|
||||
|
@@ -3,9 +3,8 @@
|
||||
/** @file 8bpp_debug.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../zoom.hpp"
|
||||
#include "../gfx.h"
|
||||
#include "../functions.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../core/random_func.hpp"
|
||||
#include "8bpp_debug.hpp"
|
||||
|
||||
static FBlitter_8bppDebug iFBlitter_8bppDebug;
|
||||
|
@@ -3,9 +3,9 @@
|
||||
/** @file 8bpp_optimized.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../zoom.hpp"
|
||||
#include "../gfx.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../debug.h"
|
||||
#include "../core/alloc_func.hpp"
|
||||
#include "8bpp_optimized.hpp"
|
||||
|
||||
static FBlitter_8bppOptimized iFBlitter_8bppOptimized;
|
||||
@@ -17,7 +17,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
||||
uint offset = 0;
|
||||
|
||||
/* Find the offset of this zoom-level */
|
||||
offset = ((const uint8 *)bp->sprite)[(int)zoom * 2] | ((const byte *)bp->sprite)[(int)zoom * 2 + 1] << 8;
|
||||
offset = ((const uint8 *)bp->sprite)[(int)(zoom - ZOOM_LVL_BEGIN) * 2] | ((const byte *)bp->sprite)[(int)(zoom - ZOOM_LVL_BEGIN) * 2 + 1] << 8;
|
||||
|
||||
/* Find where to start reading in the source sprite */
|
||||
src = (const uint8 *)bp->sprite + offset;
|
||||
@@ -110,9 +110,9 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::All
|
||||
uint index = 0;
|
||||
|
||||
/* Make memory for all zoom-levels */
|
||||
memory += (int)ZOOM_LVL_END * sizeof(uint16);
|
||||
for (int i = 0; i < (int)ZOOM_LVL_END; i++) {
|
||||
memory += UnScaleByZoom(sprite->height, (ZoomLevel)i) * UnScaleByZoom(sprite->width, (ZoomLevel)i);
|
||||
memory += (int)(ZOOM_LVL_END - ZOOM_LVL_BEGIN) * sizeof(uint16);
|
||||
for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) {
|
||||
memory += UnScaleByZoom(sprite->height, i) * UnScaleByZoom(sprite->width, i);
|
||||
index += 2;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::All
|
||||
temp_dst = MallocT<byte>(memory);
|
||||
|
||||
/* Make the sprites per zoom-level */
|
||||
for (int i = 0; i < (int)ZOOM_LVL_END; i++) {
|
||||
for (ZoomLevel i = ZOOM_LVL_BEGIN; i < ZOOM_LVL_END; i++) {
|
||||
/* Store the scaled image */
|
||||
const SpriteLoader::CommonPixel *src;
|
||||
|
||||
@@ -131,19 +131,19 @@ Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, Blitter::All
|
||||
|
||||
byte *dst = &temp_dst[index];
|
||||
|
||||
for (int y = 0; y < UnScaleByZoom(sprite->height, (ZoomLevel)i); y++) {
|
||||
for (int y = 0; y < UnScaleByZoom(sprite->height, i); y++) {
|
||||
uint trans = 0;
|
||||
uint pixels = 0;
|
||||
uint last_color = 0;
|
||||
uint count_index = 0;
|
||||
uint rx = 0;
|
||||
src = &sprite->data[ScaleByZoom(y, (ZoomLevel)i) * sprite->width];
|
||||
src = &sprite->data[ScaleByZoom(y, i) * sprite->width];
|
||||
|
||||
for (int x = 0; x < UnScaleByZoom(sprite->width, (ZoomLevel)i); x++) {
|
||||
for (int x = 0; x < UnScaleByZoom(sprite->width, i); x++) {
|
||||
uint color = 0;
|
||||
|
||||
/* Get the color keeping in mind the zoom-level */
|
||||
for (int j = 0; j < ScaleByZoom(1, (ZoomLevel)i); j++) {
|
||||
for (int j = 0; j < ScaleByZoom(1, i); j++) {
|
||||
if (src->m != 0) color = src->m;
|
||||
src++;
|
||||
rx++;
|
||||
|
@@ -3,8 +3,7 @@
|
||||
/** @file 8bpp_simple.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../zoom.hpp"
|
||||
#include "../gfx.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "8bpp_simple.hpp"
|
||||
|
||||
static FBlitter_8bppSimple iFBlitter_8bppSimple;
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "../spritecache.h"
|
||||
#include "../spriteloader/spriteloader.hpp"
|
||||
#include "../zoom_type.h"
|
||||
|
||||
enum BlitterMode {
|
||||
BM_NORMAL,
|
||||
|
@@ -4,8 +4,8 @@
|
||||
#define BLITTER_FACTORY_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
#include "../string.h"
|
||||
#include "../debug.h"
|
||||
#include "../string_func.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
if (name == NULL) return;
|
||||
|
||||
this->name = strdup(name);
|
||||
#if !defined(NDEBUG)
|
||||
#if !defined(NDEBUG) || defined(WITH_ASSERT)
|
||||
/* NDEBUG disables asserts and gives a warning: unused variable 'P' */
|
||||
std::pair<Blitters::iterator, bool> P =
|
||||
#endif /* !NDEBUG */
|
||||
@@ -130,4 +130,6 @@ public:
|
||||
const char *GetName();
|
||||
};
|
||||
|
||||
extern char _ini_blitter[32];
|
||||
|
||||
#endif /* BLITTER_FACTORY_HPP */
|
||||
|
@@ -1,5 +1,8 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file null.cpp A blitter that doesn't blit. */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../variables.h"
|
||||
#include "null.hpp"
|
||||
|
||||
static FBlitter_Null iFBlitter_Null;
|
||||
|
@@ -3,11 +3,9 @@
|
||||
/** @file bmp.cpp */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "gfx.h"
|
||||
#include "bmp.h"
|
||||
#include "macros.h"
|
||||
#include "helpers.hpp"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/alloc_func.hpp"
|
||||
|
||||
void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file)
|
||||
{
|
||||
@@ -354,7 +352,7 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
assert(info != NULL && data != NULL);
|
||||
|
||||
data->bitmap = (byte*)calloc(info->width * info->height, ((info->bpp == 24) ? 3 : 1) * sizeof(byte));
|
||||
data->bitmap = CallocT<byte>(info->width * info->height * ((info->bpp == 24) ? 3 : 1));
|
||||
if (data->bitmap == NULL) return false;
|
||||
|
||||
/* Load image */
|
||||
|
@@ -5,6 +5,8 @@
|
||||
#ifndef BMP_H
|
||||
#define BMP_H
|
||||
|
||||
#include "gfx_type.h"
|
||||
|
||||
struct BmpInfo {
|
||||
uint32 offset; ///< offset of bitmap data from .bmp file begining
|
||||
uint32 width; ///< bitmap width
|
||||
|
@@ -5,6 +5,10 @@
|
||||
#ifndef BRIDGE_H
|
||||
#define BRIDGE_H
|
||||
|
||||
#include "gfx_type.h"
|
||||
#include "direction_type.h"
|
||||
#include "tile_cmd.h"
|
||||
|
||||
enum {
|
||||
MAX_BRIDGES = 13
|
||||
};
|
||||
@@ -37,4 +41,8 @@ static inline const Bridge *GetBridge(uint i)
|
||||
|
||||
void DrawBridgeMiddle(const TileInfo *ti);
|
||||
|
||||
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
|
||||
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
|
||||
int CalcBridgeLenCostFactor(int x);
|
||||
|
||||
#endif /* BRIDGE_H */
|
||||
|
@@ -4,26 +4,34 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "viewport.h"
|
||||
#include "gfx.h"
|
||||
#include "command.h"
|
||||
#include "sound.h"
|
||||
#include "window_gui.h"
|
||||
#include "command_func.h"
|
||||
#include "economy_func.h"
|
||||
#include "variables.h"
|
||||
#include "bridge.h"
|
||||
#include "strings_func.h"
|
||||
#include "window_func.h"
|
||||
#include "sound_func.h"
|
||||
#include "map_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "gfx_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
static struct BridgeData {
|
||||
uint8 last_size;
|
||||
uint count;
|
||||
TileIndex start_tile;
|
||||
TileIndex end_tile;
|
||||
byte type;
|
||||
byte indexes[MAX_BRIDGES];
|
||||
uint8 type;
|
||||
uint8 indexes[MAX_BRIDGES];
|
||||
Money costs[MAX_BRIDGES];
|
||||
|
||||
BridgeData()
|
||||
: last_size(4)
|
||||
, count(0)
|
||||
{};
|
||||
} _bridgedata;
|
||||
|
||||
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||
@@ -39,26 +47,52 @@ static void BuildBridge(Window *w, int i)
|
||||
CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
|
||||
}
|
||||
|
||||
/* Names of the build bridge selection window */
|
||||
enum BuildBridgeSelectionWidgets {
|
||||
BBSW_CLOSEBOX = 0,
|
||||
BBSW_CAPTION,
|
||||
BBSW_BRIDGE_LIST,
|
||||
BBSW_SCROLLBAR,
|
||||
BBSW_RESIZEBOX
|
||||
};
|
||||
|
||||
static void BuildBridgeWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT:
|
||||
case WE_CREATE:
|
||||
w->resize.step_height = 22;
|
||||
w->vscroll.count = _bridgedata.count;
|
||||
|
||||
if (_bridgedata.last_size <= 4) {
|
||||
w->vscroll.cap = 4;
|
||||
} else {
|
||||
/* Resize the bridge selection window if we used a bigger one the last time */
|
||||
w->vscroll.cap = (w->vscroll.count > _bridgedata.last_size) ? _bridgedata.last_size : w->vscroll.count;
|
||||
ResizeWindow(w, 0, (w->vscroll.cap - 4) * w->resize.step_height);
|
||||
w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_PAINT: {
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
for (uint i = 0; i < 4 && i + w->vscroll.pos < _bridgedata.count; i++) {
|
||||
uint y = 15;
|
||||
for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) {
|
||||
const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]];
|
||||
|
||||
SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
|
||||
SetDParam(1, b->speed * 10 / 16);
|
||||
SetDParam(0, b->material);
|
||||
DrawSprite(b->sprite, b->pal, 3, 15 + i * 22);
|
||||
|
||||
DrawString(44, 15 + i * 22 , STR_500D, TC_FROMSTRING);
|
||||
DrawSprite(b->sprite, b->pal, 3, y);
|
||||
DrawString(44, y, STR_500D, TC_FROMSTRING);
|
||||
y += w->resize.step_height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WE_KEYPRESS: {
|
||||
uint i = e->we.keypress.keycode - '1';
|
||||
const uint8 i = e->we.keypress.keycode - '1';
|
||||
if (i < 9 && i < _bridgedata.count) {
|
||||
e->we.keypress.cont = false;
|
||||
BuildBridge(w, i);
|
||||
@@ -68,44 +102,61 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
|
||||
case WE_CLICK:
|
||||
if (e->we.click.widget == 2) {
|
||||
uint ind = ((int)e->we.click.pt.y - 14) / 22;
|
||||
if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count)
|
||||
BuildBridge(w, ind);
|
||||
if (e->we.click.widget == BBSW_BRIDGE_LIST) {
|
||||
uint ind = ((int)e->we.click.pt.y - 14) / w->resize.step_height;
|
||||
if (ind < w->vscroll.cap) {
|
||||
ind += w->vscroll.pos;
|
||||
if (ind < _bridgedata.count) {
|
||||
BuildBridge(w, ind);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_RESIZE:
|
||||
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
|
||||
w->widget[BBSW_BRIDGE_LIST].data = (w->vscroll.cap << 8) + 1;
|
||||
SetVScrollCount(w, _bridgedata.count);
|
||||
|
||||
_bridgedata.last_size = w->vscroll.cap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Widget definition for the rail bridge selection window */
|
||||
static const Widget _build_bridge_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
|
||||
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BBSW_CLOSEBOX
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_100D_SELECT_RAIL_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BBSW_CAPTION
|
||||
{ WWT_MATRIX, RESIZE_BOTTOM, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK}, // BBSW_BRIDGE_LIST
|
||||
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 7, 188, 199, 14, 89, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
|
||||
{ WWT_RESIZEBOX, RESIZE_TB, 7, 188, 199, 90, 101, 0x0, STR_RESIZE_BUTTON}, // BBSW_RESIZEBOX
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
/* Window definition for the rail bridge selection window */
|
||||
static const WindowDesc _build_bridge_desc = {
|
||||
WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
|
||||
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
||||
_build_bridge_widgets,
|
||||
BuildBridgeWndProc
|
||||
};
|
||||
|
||||
|
||||
/* Widget definition for the road bridge selection window */
|
||||
static const Widget _build_road_bridge_widgets[] = {
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||
{ WWT_MATRIX, RESIZE_NONE, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK},
|
||||
{ WWT_SCROLLBAR, RESIZE_NONE, 7, 188, 199, 14, 101, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // BBSW_CLOSEBOX
|
||||
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 199, 0, 13, STR_1803_SELECT_ROAD_BRIDGE, STR_018C_WINDOW_TITLE_DRAG_THIS}, // BBSW_CAPTION
|
||||
{ WWT_MATRIX, RESIZE_BOTTOM, 7, 0, 187, 14, 101, 0x401, STR_101F_BRIDGE_SELECTION_CLICK}, // BBSW_BRIDGE_LIST
|
||||
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 7, 188, 199, 14, 89, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // BBSW_SCROLLBAR
|
||||
{ WWT_RESIZEBOX, RESIZE_TB, 7, 188, 199, 90, 101, 0x0, STR_RESIZE_BUTTON}, // BBSW_RESIZEBOX
|
||||
{ WIDGETS_END},
|
||||
};
|
||||
|
||||
/* Window definition for the road bridge selection window */
|
||||
static const WindowDesc _build_road_bridge_desc = {
|
||||
WDP_AUTO, WDP_AUTO, 200, 102, 200, 102,
|
||||
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
||||
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
||||
_build_road_bridge_widgets,
|
||||
BuildBridgeWndProc
|
||||
};
|
||||
@@ -113,52 +164,46 @@ static const WindowDesc _build_road_bridge_desc = {
|
||||
|
||||
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
|
||||
{
|
||||
uint j = 0;
|
||||
CommandCost ret;
|
||||
StringID errmsg;
|
||||
|
||||
DeleteWindowById(WC_BUILD_BRIDGE, 0);
|
||||
|
||||
_bridgedata.type = bridge_type;
|
||||
_bridgedata.start_tile = start;
|
||||
_bridgedata.end_tile = end;
|
||||
|
||||
errmsg = INVALID_STRING_ID;
|
||||
|
||||
// only query bridge building possibility once, result is the same for all bridges!
|
||||
// returns CMD_ERROR on failure, and price on success
|
||||
ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
|
||||
/* only query bridge building possibility once, result is the same for all bridges!
|
||||
* returns CMD_ERROR on failure, and price on success */
|
||||
StringID errmsg = INVALID_STRING_ID;
|
||||
CommandCost ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
|
||||
|
||||
uint8 j = 0;
|
||||
if (CmdFailed(ret)) {
|
||||
errmsg = _error_message;
|
||||
} else {
|
||||
// check which bridges can be built
|
||||
// get absolute bridge length
|
||||
// length of the middle parts of the bridge
|
||||
int bridge_len = GetBridgeLength(start, end);
|
||||
// total length of bridge
|
||||
int tot_bridgedata_len = bridge_len + 2;
|
||||
/* check which bridges can be built
|
||||
* get absolute bridge length
|
||||
* length of the middle parts of the bridge */
|
||||
const uint bridge_len = GetBridgeLength(start, end);
|
||||
/* total length of bridge */
|
||||
const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
|
||||
|
||||
tot_bridgedata_len = CalcBridgeLenCostFactor(tot_bridgedata_len);
|
||||
|
||||
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) { // loop for all bridgetypes
|
||||
/* loop for all bridgetypes */
|
||||
for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) {
|
||||
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
|
||||
/* bridge is accepted, add to list */
|
||||
const Bridge *b = &_bridge[bridge_type];
|
||||
// bridge is accepted, add to list
|
||||
// add to terraforming & bulldozing costs the cost of the bridge itself (not computed with DC_QUERY_COST)
|
||||
/* Add to terraforming & bulldozing costs the cost of the
|
||||
* bridge itself (not computed with DC_QUERY_COST) */
|
||||
_bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
|
||||
_bridgedata.indexes[j] = bridge_type;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
_bridgedata.count = j;
|
||||
}
|
||||
|
||||
_bridgedata.count = j;
|
||||
|
||||
if (j != 0) {
|
||||
Window *w = AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
|
||||
w->vscroll.cap = 4;
|
||||
w->vscroll.count = (byte)j;
|
||||
AllocateWindowDesc((_bridgedata.type & 0x80) ? &_build_road_bridge_desc : &_build_bridge_desc);
|
||||
} else {
|
||||
ShowErrorMessage(errmsg, STR_5015_CAN_T_BUILD_BRIDGE_HERE, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE);
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include "bridge.h"
|
||||
#include "variables.h"
|
||||
#include "landscape.h"
|
||||
#include "tunnelbridge_map.h"
|
||||
|
||||
|
||||
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
|
||||
@@ -17,7 +18,7 @@ TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
|
||||
dir = ReverseDiagDir(dir);
|
||||
do {
|
||||
tile += delta;
|
||||
} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir);
|
||||
} while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
|
||||
|
||||
return tile;
|
||||
}
|
||||
@@ -38,14 +39,14 @@ TileIndex GetSouthernBridgeEnd(TileIndex t)
|
||||
TileIndex GetOtherBridgeEnd(TileIndex tile)
|
||||
{
|
||||
assert(IsBridgeTile(tile));
|
||||
return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
|
||||
return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
|
||||
}
|
||||
|
||||
uint GetBridgeHeight(TileIndex t)
|
||||
{
|
||||
uint h;
|
||||
Slope tileh = GetTileSlope(t, &h);
|
||||
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
|
||||
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
||||
|
||||
/* one height level extra for the ramp */
|
||||
return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);
|
||||
|
@@ -5,12 +5,9 @@
|
||||
#ifndef BRIDGE_MAP_H
|
||||
#define BRIDGE_MAP_H
|
||||
|
||||
#include "direction.h"
|
||||
#include "macros.h"
|
||||
#include "map.h"
|
||||
#include "rail.h"
|
||||
#include "direction_func.h"
|
||||
#include "rail_type.h"
|
||||
#include "road_map.h"
|
||||
#include "tile.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -22,7 +19,7 @@
|
||||
static inline bool IsBridge(TileIndex t)
|
||||
{
|
||||
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
||||
return HASBIT(_m[t].m5, 7);
|
||||
return HasBit(_m[t].m5, 7);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +61,6 @@ static inline bool IsBridgeAbove(TileIndex t)
|
||||
return GB(_m[t].m6, 6, 2) != 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines the type of bridge on a tile
|
||||
* @param t The tile to analyze
|
||||
@@ -77,20 +73,6 @@ static inline uint GetBridgeType(TileIndex t)
|
||||
return GB(_m[t].m2, 4, 4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the direction pointing onto the bridge
|
||||
* @param t The tile to analyze
|
||||
* @pre IsBridgeTile(t)
|
||||
* @return the above mentionned direction
|
||||
*/
|
||||
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeTile(t));
|
||||
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
|
||||
* @param t The tile to analyze
|
||||
@@ -103,45 +85,6 @@ static inline Axis GetBridgeAxis(TileIndex t)
|
||||
return (Axis)(GB(_m[t].m6, 6, 2) - 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the transport type of the bridge's ramp.
|
||||
* @param t The ramp tile to analyze
|
||||
* @pre IsBridgeTile(t)
|
||||
* @return the transport type of the bridge
|
||||
*/
|
||||
static inline TransportType GetBridgeTransportType(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeTile(t));
|
||||
return (TransportType)GB(_m[t].m5, 2, 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does the bridge ramp lie in a snow or desert area?
|
||||
* @param t The ramp tile to analyze
|
||||
* @pre IsBridgeTile(t)
|
||||
* @return true if and only if in a snow or desert area
|
||||
*/
|
||||
static inline bool HasBridgeSnowOrDesert(TileIndex t)
|
||||
{
|
||||
assert(IsBridgeTile(t));
|
||||
return HASBIT(_m[t].m4, 7);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether the bridge ramp lies in a snow or desert area.
|
||||
* @param t The ramp tile to set (un)make a snow/desert area
|
||||
* @param snow_or_desert Make (true) or unmake the tile a snow/desert area
|
||||
* @pre IsBridgeTile(t)
|
||||
*/
|
||||
static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
|
||||
{
|
||||
assert(IsBridgeTile(t));
|
||||
SB(_m[t].m4, 7, 1, snow_or_desert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the end of a bridge in the specified direction starting at a middle tile
|
||||
* @param t the bridge tile to find the bridge ramp for
|
||||
@@ -184,10 +127,9 @@ uint GetBridgeHeight(TileIndex tile);
|
||||
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
|
||||
{
|
||||
assert(MayHaveBridgeAbove(t));
|
||||
CLRBIT(_m[t].m6, 6 + a);
|
||||
ClrBit(_m[t].m6, 6 + a);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes bridges from the given, that is bridges along the X and Y axis.
|
||||
* @param t the tile to remove the bridge from
|
||||
@@ -208,7 +150,7 @@ static inline void ClearBridgeMiddle(TileIndex t)
|
||||
static inline void SetBridgeMiddle(TileIndex t, Axis a)
|
||||
{
|
||||
assert(MayHaveBridgeAbove(t));
|
||||
SETBIT(_m[t].m6, 6 + a);
|
||||
SetBit(_m[t].m6, 6 + a);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,28 +9,47 @@
|
||||
#include "ship.h"
|
||||
#include "aircraft.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "vehicle.h"
|
||||
#include "articulated_vehicles.h"
|
||||
#include "gfx.h"
|
||||
#include "textbuf_gui.h"
|
||||
#include "station.h"
|
||||
#include "command.h"
|
||||
#include "command_func.h"
|
||||
#include "engine.h"
|
||||
#include "player.h"
|
||||
#include "player_func.h"
|
||||
#include "depot.h"
|
||||
#include "airport.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "newgrf_engine.h"
|
||||
#include "date.h"
|
||||
#include "strings.h"
|
||||
#include "cargotype.h"
|
||||
#include "group.h"
|
||||
#include "road_map.h"
|
||||
#include "strings_func.h"
|
||||
#include "window_func.h"
|
||||
#include "date_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "settings_type.h"
|
||||
#include "gfx_func.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
struct buildvehicle_d {
|
||||
VehicleType vehicle_type;
|
||||
union {
|
||||
RailTypeByte railtype;
|
||||
AirportFTAClass::Flags flags;
|
||||
RoadTypes roadtypes;
|
||||
} filter;
|
||||
byte sel_index; ///< deprecated value, used for 'unified' ship and road
|
||||
bool descending_sort_order;
|
||||
byte sort_criteria;
|
||||
bool regenerate_list;
|
||||
EngineID sel_engine;
|
||||
EngineID rename_engine;
|
||||
EngineList eng_list;
|
||||
};
|
||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d));
|
||||
|
||||
enum BuildVehicleWidgets {
|
||||
BUILD_VEHICLE_WIDGET_CLOSEBOX = 0,
|
||||
@@ -269,6 +288,38 @@ static int CDECL TrainEnginesThenWagonsSorter(const void *a, const void *b)
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
/* Road vehicle sorting functions */
|
||||
static int CDECL RoadVehEngineCostSorter(const void *a, const void *b)
|
||||
{
|
||||
int va = RoadVehInfo(*(const EngineID*)a)->base_cost;
|
||||
int vb = RoadVehInfo(*(const EngineID*)b)->base_cost;
|
||||
int r = va - vb;
|
||||
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
static int CDECL RoadVehEngineSpeedSorter(const void *a, const void *b)
|
||||
{
|
||||
int va = RoadVehInfo(*(const EngineID*)a)->max_speed;
|
||||
int vb = RoadVehInfo(*(const EngineID*)b)->max_speed;
|
||||
int r = va - vb;
|
||||
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
static int CDECL RoadVehEngineRunningCostSorter(const void *a, const void *b)
|
||||
{
|
||||
const int va = RoadVehInfo(*(const EngineID*)a)->running_cost;
|
||||
const int vb = RoadVehInfo(*(const EngineID*)b)->running_cost;
|
||||
const int r = va - vb;
|
||||
|
||||
if (r == 0) {
|
||||
/* Use EngineID to sort instead since we want consistent sorting */
|
||||
return EngineNumberSorter(a, b);
|
||||
}
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b)
|
||||
{
|
||||
int va = RoadVehInfo(*(const EngineID*)a)->capacity;
|
||||
@@ -282,6 +333,38 @@ static int CDECL RoadVehEngineCapacitySorter(const void *a, const void *b)
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
/* Road vehicle sorting functions */
|
||||
static int CDECL ShipEngineCostSorter(const void *a, const void *b)
|
||||
{
|
||||
int va = ShipVehInfo(*(const EngineID*)a)->base_cost;
|
||||
int vb = ShipVehInfo(*(const EngineID*)b)->base_cost;
|
||||
int r = va - vb;
|
||||
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
static int CDECL ShipEngineSpeedSorter(const void *a, const void *b)
|
||||
{
|
||||
int va = ShipVehInfo(*(const EngineID*)a)->max_speed;
|
||||
int vb = ShipVehInfo(*(const EngineID*)b)->max_speed;
|
||||
int r = va - vb;
|
||||
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
static int CDECL ShipEngineRunningCostSorter(const void *a, const void *b)
|
||||
{
|
||||
const int va = ShipVehInfo(*(const EngineID*)a)->running_cost;
|
||||
const int vb = ShipVehInfo(*(const EngineID*)b)->running_cost;
|
||||
const int r = va - vb;
|
||||
|
||||
if (r == 0) {
|
||||
/* Use EngineID to sort instead since we want consistent sorting */
|
||||
return EngineNumberSorter(a, b);
|
||||
}
|
||||
return _internal_sort_order ? -r : r;
|
||||
}
|
||||
|
||||
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
|
||||
{
|
||||
int va = ShipVehInfo(*(const EngineID*)a)->capacity;
|
||||
@@ -367,15 +450,21 @@ static EngList_SortTypeFunction * const _sorter[][10] = {{
|
||||
}, {
|
||||
/* Road vehicles */
|
||||
&EngineNumberSorter,
|
||||
&RoadVehEngineCostSorter,
|
||||
&RoadVehEngineSpeedSorter,
|
||||
&EngineIntroDateSorter,
|
||||
&EngineNameSorter,
|
||||
&RoadVehEngineRunningCostSorter,
|
||||
&EngineReliabilitySorter,
|
||||
&RoadVehEngineCapacitySorter,
|
||||
}, {
|
||||
/* Ships */
|
||||
&EngineNumberSorter,
|
||||
&ShipEngineCostSorter,
|
||||
&ShipEngineSpeedSorter,
|
||||
&EngineIntroDateSorter,
|
||||
&EngineNameSorter,
|
||||
&ShipEngineRunningCostSorter,
|
||||
&EngineReliabilitySorter,
|
||||
&ShipEngineCapacitySorter,
|
||||
}, {
|
||||
@@ -406,16 +495,22 @@ static const StringID _sort_listing[][11] = {{
|
||||
}, {
|
||||
/* Road vehicles */
|
||||
STR_ENGINE_SORT_ENGINE_ID,
|
||||
STR_ENGINE_SORT_COST,
|
||||
STR_SORT_BY_MAX_SPEED,
|
||||
STR_ENGINE_SORT_INTRO_DATE,
|
||||
STR_SORT_BY_DROPDOWN_NAME,
|
||||
STR_ENGINE_SORT_RUNNING_COST,
|
||||
STR_SORT_BY_RELIABILITY,
|
||||
STR_ENGINE_SORT_CARGO_CAPACITY,
|
||||
INVALID_STRING_ID
|
||||
}, {
|
||||
/* Ships */
|
||||
STR_ENGINE_SORT_ENGINE_ID,
|
||||
STR_ENGINE_SORT_COST,
|
||||
STR_SORT_BY_MAX_SPEED,
|
||||
STR_ENGINE_SORT_INTRO_DATE,
|
||||
STR_SORT_BY_DROPDOWN_NAME,
|
||||
STR_ENGINE_SORT_RUNNING_COST,
|
||||
STR_SORT_BY_RELIABILITY,
|
||||
STR_ENGINE_SORT_CARGO_CAPACITY,
|
||||
INVALID_STRING_ID
|
||||
@@ -667,7 +762,7 @@ int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
|
||||
/* Figure out what train EngineIDs to put in the list */
|
||||
static void GenerateBuildTrainList(Window *w)
|
||||
{
|
||||
EngineID eid, sel_id;
|
||||
EngineID sel_id = INVALID_ENGINE;
|
||||
int num_engines = 0;
|
||||
int num_wagons = 0;
|
||||
buildvehicle_d *bv = &WP(w, buildvehicle_d);
|
||||
@@ -680,7 +775,7 @@ static void GenerateBuildTrainList(Window *w)
|
||||
* Also check to see if the previously selected engine is still available,
|
||||
* and if not, reset selection to INVALID_ENGINE. This could be the case
|
||||
* when engines become obsolete and are removed */
|
||||
for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
|
||||
for (EngineID eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
|
||||
const RailVehicleInfo *rvi = RailVehInfo(eid);
|
||||
|
||||
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue;
|
||||
@@ -713,16 +808,14 @@ static void GenerateBuildTrainList(Window *w)
|
||||
/* Figure out what road vehicle EngineIDs to put in the list */
|
||||
static void GenerateBuildRoadVehList(Window *w)
|
||||
{
|
||||
EngineID eid, sel_id;
|
||||
EngineID sel_id = INVALID_ENGINE;
|
||||
buildvehicle_d *bv = &WP(w, buildvehicle_d);
|
||||
|
||||
EngList_RemoveAll(&bv->eng_list);
|
||||
|
||||
sel_id = INVALID_ENGINE;
|
||||
|
||||
for (eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
|
||||
for (EngineID eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
|
||||
if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
|
||||
if (!HASBIT(bv->filter.roadtypes, HASBIT(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
|
||||
if (!HasBit(bv->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
|
||||
EngList_Add(&bv->eng_list, eid);
|
||||
|
||||
if (eid == bv->sel_engine) sel_id = eid;
|
||||
@@ -733,14 +826,12 @@ static void GenerateBuildRoadVehList(Window *w)
|
||||
/* Figure out what ship EngineIDs to put in the list */
|
||||
static void GenerateBuildShipList(Window *w)
|
||||
{
|
||||
EngineID eid, sel_id;
|
||||
EngineID sel_id = INVALID_ENGINE;
|
||||
buildvehicle_d *bv = &WP(w, buildvehicle_d);
|
||||
|
||||
EngList_RemoveAll(&bv->eng_list);
|
||||
|
||||
sel_id = INVALID_ENGINE;
|
||||
|
||||
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
|
||||
for (EngineID eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
|
||||
if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
|
||||
EngList_Add(&bv->eng_list, eid);
|
||||
|
||||
@@ -752,7 +843,7 @@ static void GenerateBuildShipList(Window *w)
|
||||
/* Figure out what aircraft EngineIDs to put in the list */
|
||||
static void GenerateBuildAircraftList(Window *w)
|
||||
{
|
||||
EngineID eid, sel_id;
|
||||
EngineID sel_id = INVALID_ENGINE;
|
||||
buildvehicle_d *bv = &WP(w, buildvehicle_d);
|
||||
|
||||
EngList_RemoveAll(&bv->eng_list);
|
||||
@@ -761,8 +852,7 @@ static void GenerateBuildAircraftList(Window *w)
|
||||
* Also check to see if the previously selected plane is still available,
|
||||
* and if not, reset selection to INVALID_ENGINE. This could be the case
|
||||
* when planes become obsolete and are removed */
|
||||
sel_id = INVALID_ENGINE;
|
||||
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
|
||||
for (EngineID eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
|
||||
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
|
||||
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
|
||||
if (w->window_number > VEH_END && !CanAircraftUseStation(eid, w->window_number)) continue;
|
||||
@@ -888,7 +978,7 @@ static void DrawBuildVehicleWindow(Window *w)
|
||||
const buildvehicle_d *bv = &WP(w, buildvehicle_d);
|
||||
uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
|
||||
|
||||
SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
|
||||
w->SetWidgetDisabledState(BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
|
||||
|
||||
SetVScrollCount(w, EngList_Count(&bv->eng_list));
|
||||
SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "callback_table.h"
|
||||
#include "functions.h"
|
||||
|
||||
/* If you add a callback for DoCommandP, also add the callback in here
|
||||
* see below for the full list!
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#ifndef CALLBACK_TABLE_H
|
||||
#define CALLBACK_TABLE_H
|
||||
|
||||
#include "command.h"
|
||||
#include "command_type.h"
|
||||
|
||||
extern CommandCallback *_callback_table[];
|
||||
extern const int _callback_table_count;
|
||||
|
59
src/cargo_type.h
Normal file
59
src/cargo_type.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file cargo_type.h Types related to cargos... */
|
||||
|
||||
#ifndef CARGO_TYPE_H
|
||||
#define CARGO_TYPE_H
|
||||
|
||||
typedef byte CargoID;
|
||||
|
||||
enum {
|
||||
// Temperate
|
||||
CT_PASSENGERS = 0,
|
||||
CT_COAL = 1,
|
||||
CT_MAIL = 2,
|
||||
CT_OIL = 3,
|
||||
CT_LIVESTOCK = 4,
|
||||
CT_GOODS = 5,
|
||||
CT_GRAIN = 6,
|
||||
CT_WOOD = 7,
|
||||
CT_IRON_ORE = 8,
|
||||
CT_STEEL = 9,
|
||||
CT_VALUABLES = 10,
|
||||
|
||||
// Arctic
|
||||
CT_WHEAT = 6,
|
||||
CT_HILLY_UNUSED = 8,
|
||||
CT_PAPER = 9,
|
||||
CT_GOLD = 10,
|
||||
CT_FOOD = 11,
|
||||
|
||||
// Tropic
|
||||
CT_RUBBER = 1,
|
||||
CT_FRUIT = 4,
|
||||
CT_MAIZE = 6,
|
||||
CT_COPPER_ORE = 8,
|
||||
CT_WATER = 9,
|
||||
CT_DIAMONDS = 10,
|
||||
|
||||
// Toyland
|
||||
CT_SUGAR = 1,
|
||||
CT_TOYS = 3,
|
||||
CT_BATTERIES = 4,
|
||||
CT_CANDY = 5,
|
||||
CT_TOFFEE = 6,
|
||||
CT_COLA = 7,
|
||||
CT_COTTON_CANDY = 8,
|
||||
CT_BUBBLES = 9,
|
||||
CT_PLASTIC = 10,
|
||||
CT_FIZZY_DRINKS = 11,
|
||||
|
||||
NUM_CARGO = 32,
|
||||
|
||||
CT_NO_REFIT = 0xFE,
|
||||
CT_INVALID = 0xFF
|
||||
};
|
||||
|
||||
typedef uint AcceptedCargo[NUM_CARGO];
|
||||
|
||||
#endif /* OPENTTD_H */
|
@@ -5,6 +5,8 @@
|
||||
#ifndef CARGOPACKET_H
|
||||
#define CARGOPACKET_H
|
||||
|
||||
#include "economy_type.h"
|
||||
#include "tile_type.h"
|
||||
#include <list>
|
||||
|
||||
typedef uint32 CargoPacketID;
|
||||
|
@@ -4,12 +4,12 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "macros.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "newgrf_cargo.h"
|
||||
#include "cargotype.h"
|
||||
#include "core/bitmath_func.hpp"
|
||||
|
||||
#include "table/sprites.h"
|
||||
#include "table/strings.h"
|
||||
#include "table/cargo_const.h"
|
||||
|
||||
CargoSpec _cargo[NUM_CARGO];
|
||||
@@ -37,7 +37,7 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
if (cl < lengthof(_default_cargo)) {
|
||||
/* Copy the indexed cargo */
|
||||
_cargo[i] = _default_cargo[cl];
|
||||
SETBIT(_cargo_mask, i);
|
||||
if (_cargo[i].bitnum != INVALID_CARGO) SetBit(_cargo_mask, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void SetupCargoForClimate(LandscapeID l)
|
||||
_cargo[i] = _default_cargo[j];
|
||||
|
||||
/* Populate the available cargo mask */
|
||||
SETBIT(_cargo_mask, i);
|
||||
SetBit(_cargo_mask, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,9 @@
|
||||
#ifndef CARGOTYPE_H
|
||||
#define CARGOTYPE_H
|
||||
|
||||
#include "cargo_type.h"
|
||||
#include "gfx_type.h"
|
||||
#include "newgrf_string_type.h"
|
||||
|
||||
typedef uint32 CargoLabel;
|
||||
|
||||
@@ -33,11 +36,11 @@ struct CargoSpec {
|
||||
uint16 multipliertowngrowth;
|
||||
uint8 callback_mask;
|
||||
|
||||
StringID name;
|
||||
StringID name_single;
|
||||
StringID units_volume;
|
||||
StringID quantifier;
|
||||
StringID abbrev;
|
||||
GRFMappedStringID name;
|
||||
GRFMappedStringID name_single;
|
||||
GRFMappedStringID units_volume;
|
||||
GRFMappedStringID quantifier;
|
||||
GRFMappedStringID abbrev;
|
||||
|
||||
SpriteID sprite;
|
||||
|
||||
|
@@ -5,455 +5,35 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "clear_map.h"
|
||||
#include "rail_map.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "map.h"
|
||||
#include "player.h"
|
||||
#include "tile.h"
|
||||
#include "viewport.h"
|
||||
#include "command.h"
|
||||
#include "tunnel_map.h"
|
||||
#include "bridge_map.h"
|
||||
#include "command_func.h"
|
||||
#include "bridge.h"
|
||||
#include "landscape.h"
|
||||
#include "variables.h"
|
||||
#include "table/sprites.h"
|
||||
#include "unmovable_map.h"
|
||||
#include "genworld.h"
|
||||
#include "industry.h"
|
||||
#include "water_map.h"
|
||||
|
||||
/*
|
||||
* In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player).
|
||||
* The maximal amount of height modifications is archieved when raising a complete flat land from sea level to MAX_TILE_HEIGHT or vice versa.
|
||||
* This affects all corners with a manhatten distance smaller than MAX_TILE_HEIGHT to one of the initial 4 corners.
|
||||
* Their maximal amount is computed to 4 * \sum_{i=1}^{h_max} i = 2 * h_max * (h_max + 1).
|
||||
*/
|
||||
static const int TERRAFORMER_MODHEIGHT_SIZE = 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 1);
|
||||
|
||||
/*
|
||||
* The maximal amount of affected tiles (i.e. the tiles that incident with one of the corners above, is computed similiar to
|
||||
* 1 + 4 * \sum_{i=1}^{h_max} (i+1) = 1 + 2 * h_max + (h_max + 3).
|
||||
*/
|
||||
static const int TERRAFORMER_TILE_TABLE_SIZE = 1 + 2 * MAX_TILE_HEIGHT * (MAX_TILE_HEIGHT + 3);
|
||||
|
||||
struct TerraformerHeightMod {
|
||||
TileIndex tile; ///< Referenced tile.
|
||||
byte height; ///< New TileHeight (height of north corner) of the tile.
|
||||
};
|
||||
|
||||
struct TerraformerState {
|
||||
int modheight_count; ///< amount of entries in "modheight".
|
||||
int tile_table_count; ///< amount of entries in "tile_table".
|
||||
|
||||
/**
|
||||
* Dirty tiles, i.e.\ at least one corner changed.
|
||||
*
|
||||
* This array contains the tiles which are or will be marked as dirty.
|
||||
*
|
||||
* @ingroup dirty
|
||||
*/
|
||||
TileIndex tile_table[TERRAFORMER_TILE_TABLE_SIZE];
|
||||
TerraformerHeightMod modheight[TERRAFORMER_MODHEIGHT_SIZE]; ///< Height modifications.
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the TileHeight (height of north corner) of a tile as of current terraforming progress.
|
||||
*
|
||||
* @param ts TerraformerState.
|
||||
* @param tile Tile.
|
||||
* @return TileHeight.
|
||||
*/
|
||||
static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
|
||||
{
|
||||
TerraformerHeightMod *mod = ts->modheight;
|
||||
int count;
|
||||
|
||||
for (count = ts->modheight_count; count != 0; count--, mod++) {
|
||||
if (mod->tile == tile) return mod->height;
|
||||
}
|
||||
|
||||
/* TileHeight unchanged so far, read value from map. */
|
||||
return TileHeight(tile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the TileHeight (height of north corner) of a tile in a TerraformerState.
|
||||
*
|
||||
* @param ts TerraformerState.
|
||||
* @param tile Tile.
|
||||
* @param height New TileHeight.
|
||||
*/
|
||||
static void TerraformSetHeightOfTile(TerraformerState *ts, TileIndex tile, int height)
|
||||
{
|
||||
/* Find tile in the "modheight" table.
|
||||
* Note: In a normal user-terraform command the tile will not be found in the "modheight" table.
|
||||
* But during house- or industry-construction multiple corners can be terraformed at once. */
|
||||
TerraformerHeightMod *mod = ts->modheight;
|
||||
int count = ts->modheight_count;
|
||||
while ((count > 0) && (mod->tile != tile)) {
|
||||
mod++;
|
||||
count--;
|
||||
}
|
||||
|
||||
/* New entry? */
|
||||
if (count == 0) {
|
||||
assert(ts->modheight_count < TERRAFORMER_MODHEIGHT_SIZE);
|
||||
ts->modheight_count++;
|
||||
}
|
||||
|
||||
/* Finally store the new value */
|
||||
mod->tile = tile;
|
||||
mod->height = (byte)height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tile to the "tile_table" in a TerraformerState.
|
||||
*
|
||||
* @param ts TerraformerState.
|
||||
* @param tile Tile.
|
||||
* @ingroup dirty
|
||||
*/
|
||||
static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
|
||||
{
|
||||
int count;
|
||||
TileIndex *t;
|
||||
|
||||
count = ts->tile_table_count;
|
||||
|
||||
for (t = ts->tile_table; count != 0; count--, t++) {
|
||||
if (*t == tile) return;
|
||||
}
|
||||
|
||||
assert(ts->tile_table_count < TERRAFORMER_TILE_TABLE_SIZE);
|
||||
|
||||
ts->tile_table[ts->tile_table_count++] = tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all tiles that incident with the north corner of a specific tile to the "tile_table" in a TerraformerState.
|
||||
*
|
||||
* @param ts TerraformerState.
|
||||
* @param tile Tile.
|
||||
* @ingroup dirty
|
||||
*/
|
||||
static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
|
||||
{
|
||||
TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
|
||||
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
|
||||
TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, 0));
|
||||
TerraformAddDirtyTile(ts, tile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Terraform the north corner of a tile to a specific height.
|
||||
*
|
||||
* @param ts TerraformerState.
|
||||
* @param tile Tile.
|
||||
* @param height Aimed height.
|
||||
* @param return Error code or cost.
|
||||
*/
|
||||
static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
|
||||
{
|
||||
CommandCost total_cost = CommandCost();
|
||||
|
||||
assert(tile < MapSize());
|
||||
|
||||
/* Check range of destination height */
|
||||
if (height < 0) return_cmd_error(STR_1003_ALREADY_AT_SEA_LEVEL);
|
||||
if (height > MAX_TILE_HEIGHT) return_cmd_error(STR_1004_TOO_HIGH);
|
||||
|
||||
/*
|
||||
* Check if the terraforming has any effect.
|
||||
* This can only be true, if multiple corners of the start-tile are terraformed (i.e. the terraforming is done by towns/industries etc.).
|
||||
* In this case the terraforming should fail. (Don't know why.)
|
||||
*/
|
||||
if (height == TerraformGetHeightOfTile(ts, tile)) return CMD_ERROR;
|
||||
|
||||
/* Check "too close to edge of map" */
|
||||
uint x = TileX(tile);
|
||||
uint y = TileY(tile);
|
||||
if ((x <= 1) || (y <= 1) || (x >= MapMaxX() - 1) || (y >= MapMaxY() - 1)) {
|
||||
/*
|
||||
* Determine a sensible error tile
|
||||
* Note: If x and y are both zero this will disable the error tile. (Tile 0 cannot be highlighted :( )
|
||||
*/
|
||||
if ((x == 1) && (y != 0)) x = 0;
|
||||
if ((y == 1) && (x != 0)) y = 0;
|
||||
_terraform_err_tile = TileXY(x, y);
|
||||
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
|
||||
}
|
||||
|
||||
/* Mark incident tiles, that are involved in the terraforming */
|
||||
TerraformAddDirtyTileAround(ts, tile);
|
||||
|
||||
/* Store the height modification */
|
||||
TerraformSetHeightOfTile(ts, tile, height);
|
||||
|
||||
/* Increment cost */
|
||||
total_cost.AddCost(_price.terraform);
|
||||
|
||||
/* Recurse to neighboured corners if height difference is larger than 1 */
|
||||
{
|
||||
const TileIndexDiffC *ttm;
|
||||
|
||||
static const TileIndexDiffC _terraform_tilepos[] = {
|
||||
{ 1, 0}, // move to tile in SE
|
||||
{-2, 0}, // undo last move, and move to tile in NW
|
||||
{ 1, 1}, // undo last move, and move to tile in SW
|
||||
{ 0, -2} // undo last move, and move to tile in NE
|
||||
};
|
||||
|
||||
for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
|
||||
tile += ToTileIndexDiff(*ttm);
|
||||
|
||||
/* Get TileHeight of neighboured tile as of current terraform progress */
|
||||
int r = TerraformGetHeightOfTile(ts, tile);
|
||||
int height_diff = height - r;
|
||||
|
||||
/* Is the height difference to the neighboured corner greater than 1? */
|
||||
if (abs(height_diff) > 1) {
|
||||
/* Terraform the neighboured corner. The resulting height difference should be 1. */
|
||||
height_diff += (height_diff < 0 ? 1 : -1);
|
||||
CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
|
||||
if (CmdFailed(cost)) return cost;
|
||||
total_cost.AddCost(cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return total_cost;
|
||||
}
|
||||
|
||||
/** Terraform land
|
||||
* @param tile tile to terraform
|
||||
* @param flags for this command type
|
||||
* @param p1 corners to terraform (SLOPE_xxx)
|
||||
* @param p2 direction; eg up (non-zero) or down (zero)
|
||||
* @return error or cost of terraforming
|
||||
*/
|
||||
CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
TerraformerState ts;
|
||||
CommandCost total_cost = CommandCost();
|
||||
int direction = (p2 != 0 ? 1 : -1);
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
_terraform_err_tile = 0;
|
||||
|
||||
ts.modheight_count = ts.tile_table_count = 0;
|
||||
|
||||
/* Make an extra check for map-bounds cause we add tiles to the originating tile */
|
||||
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
|
||||
|
||||
/* Compute the costs and the terraforming result in a model of the landscape */
|
||||
if ((p1 & SLOPE_W) != 0) {
|
||||
TileIndex t = tile + TileDiffXY(1, 0);
|
||||
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
|
||||
if (CmdFailed(cost)) return cost;
|
||||
total_cost.AddCost(cost);
|
||||
}
|
||||
|
||||
if ((p1 & SLOPE_S) != 0) {
|
||||
TileIndex t = tile + TileDiffXY(1, 1);
|
||||
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
|
||||
if (CmdFailed(cost)) return cost;
|
||||
total_cost.AddCost(cost);
|
||||
}
|
||||
|
||||
if ((p1 & SLOPE_E) != 0) {
|
||||
TileIndex t = tile + TileDiffXY(0, 1);
|
||||
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
|
||||
if (CmdFailed(cost)) return cost;
|
||||
total_cost.AddCost(cost);
|
||||
}
|
||||
|
||||
if ((p1 & SLOPE_N) != 0) {
|
||||
TileIndex t = tile + TileDiffXY(0, 0);
|
||||
CommandCost cost = TerraformTileHeight(&ts, t, TileHeight(t) + direction);
|
||||
if (CmdFailed(cost)) return cost;
|
||||
total_cost.AddCost(cost);
|
||||
}
|
||||
|
||||
/* Check if the terraforming is valid wrt. tunnels, bridges and objects on the surface */
|
||||
{
|
||||
int count;
|
||||
TileIndex *ti = ts.tile_table;
|
||||
|
||||
for (count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
TileIndex tile = *ti;
|
||||
|
||||
/* Find new heights of tile corners */
|
||||
uint z_N = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
|
||||
uint z_W = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
|
||||
uint z_S = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
|
||||
uint z_E = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
|
||||
|
||||
/* Find min and max height of tile */
|
||||
uint z_min = min(min(z_N, z_W), min(z_S, z_E));
|
||||
uint z_max = max(max(z_N, z_W), max(z_S, z_E));
|
||||
|
||||
/* Compute tile slope */
|
||||
uint tileh = (z_max > z_min + 1 ? SLOPE_STEEP : SLOPE_FLAT);
|
||||
if (z_W > z_min) tileh += SLOPE_W;
|
||||
if (z_S > z_min) tileh += SLOPE_S;
|
||||
if (z_E > z_min) tileh += SLOPE_E;
|
||||
if (z_N > z_min) tileh += SLOPE_N;
|
||||
|
||||
/* Check if bridge would take damage */
|
||||
if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) &&
|
||||
GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) {
|
||||
_terraform_err_tile = tile; // highlight the tile under the bridge
|
||||
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
}
|
||||
/* Check if tunnel would take damage */
|
||||
if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
|
||||
_terraform_err_tile = tile; // highlight the tile above the tunnel
|
||||
return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
|
||||
}
|
||||
/* Check tiletype-specific things, and add extra-cost */
|
||||
CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, (Slope) tileh);
|
||||
if (CmdFailed(cost)) {
|
||||
_terraform_err_tile = tile;
|
||||
return cost;
|
||||
}
|
||||
total_cost.AddCost(cost);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
/* change the height */
|
||||
{
|
||||
int count;
|
||||
TerraformerHeightMod *mod;
|
||||
|
||||
mod = ts.modheight;
|
||||
for (count = ts.modheight_count; count != 0; count--, mod++) {
|
||||
TileIndex til = mod->tile;
|
||||
|
||||
SetTileHeight(til, mod->height);
|
||||
}
|
||||
}
|
||||
|
||||
/* finally mark the dirty tiles dirty */
|
||||
{
|
||||
int count;
|
||||
TileIndex *ti = ts.tile_table;
|
||||
for (count = ts.tile_table_count; count != 0; count--, ti++) {
|
||||
MarkTileDirtyByTile(*ti);
|
||||
}
|
||||
}
|
||||
}
|
||||
return total_cost;
|
||||
}
|
||||
|
||||
|
||||
/** Levels a selected (rectangle) area of land
|
||||
* @param tile end tile of area-drag
|
||||
* @param flags for this command type
|
||||
* @param p1 start tile of area drag
|
||||
* @param p2 unused
|
||||
* @return error or cost of terraforming
|
||||
*/
|
||||
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
int size_x, size_y;
|
||||
int ex;
|
||||
int ey;
|
||||
int sx, sy;
|
||||
uint h, curh;
|
||||
CommandCost money;
|
||||
CommandCost ret;
|
||||
CommandCost cost;
|
||||
|
||||
if (p1 >= MapSize()) return CMD_ERROR;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
/* remember level height */
|
||||
h = TileHeight(p1);
|
||||
|
||||
/* make sure sx,sy are smaller than ex,ey */
|
||||
ex = TileX(tile);
|
||||
ey = TileY(tile);
|
||||
sx = TileX(p1);
|
||||
sy = TileY(p1);
|
||||
if (ex < sx) Swap(ex, sx);
|
||||
if (ey < sy) Swap(ey, sy);
|
||||
tile = TileXY(sx, sy);
|
||||
|
||||
size_x = ex - sx + 1;
|
||||
size_y = ey - sy + 1;
|
||||
|
||||
money.AddCost(GetAvailableMoneyForCommand());
|
||||
|
||||
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
|
||||
curh = TileHeight(tile2);
|
||||
while (curh != h) {
|
||||
ret = DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
|
||||
if (CmdFailed(ret)) break;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
money.AddCost(-ret.GetCost());
|
||||
if (money.GetCost() < 0) {
|
||||
_additional_cash_required = ret.GetCost();
|
||||
return cost;
|
||||
}
|
||||
DoCommand(tile2, SLOPE_N, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
|
||||
}
|
||||
|
||||
cost.AddCost(ret);
|
||||
curh += (curh > h) ? -1 : 1;
|
||||
}
|
||||
} END_TILE_LOOP(tile2, size_x, size_y, tile)
|
||||
|
||||
return (cost.GetCost() == 0) ? CMD_ERROR : cost;
|
||||
}
|
||||
|
||||
/** Purchase a land area. Actually you only purchase one tile, so
|
||||
* the name is a bit confusing ;p
|
||||
* @param tile the tile the player is purchasing
|
||||
* @param flags for this command type
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
* @return error of cost of operation
|
||||
*/
|
||||
CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
CommandCost cost;
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
|
||||
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
|
||||
}
|
||||
|
||||
cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||
if (CmdFailed(cost)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
MakeOwnedLand(tile, _current_player);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
return cost.AddCost(_price.purchase_land * 10);
|
||||
}
|
||||
|
||||
#include "tile_cmd.h"
|
||||
#include "functions.h"
|
||||
#include "economy_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "settings_type.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
#include "table/clear_land.h"
|
||||
|
||||
static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
|
||||
{
|
||||
static const Money* clear_price_table[] = {
|
||||
&_price.clear_1,
|
||||
&_price.purchase_land,
|
||||
&_price.clear_2,
|
||||
&_price.clear_3,
|
||||
&_price.purchase_land,
|
||||
&_price.purchase_land,
|
||||
&_price.clear_2, // XXX unused?
|
||||
&_price.clear_grass,
|
||||
&_price.clear_roughland,
|
||||
&_price.clear_rocks,
|
||||
&_price.clear_fields,
|
||||
&_price.clear_roughland,
|
||||
&_price.clear_roughland,
|
||||
};
|
||||
CommandCost price;
|
||||
CommandCost price(EXPENSES_CONSTRUCTION);
|
||||
|
||||
if (!IsClearGround(tile, CLEAR_GRASS) || GetClearDensity(tile) != 0) {
|
||||
price.AddCost(*clear_price_table[GetClearGround(tile)]);
|
||||
@@ -464,33 +44,6 @@ static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
|
||||
return price;
|
||||
}
|
||||
|
||||
/** Sell a land area. Actually you only sell one tile, so
|
||||
* the name is a bit confusing ;p
|
||||
* @param tile the tile the player is selling
|
||||
* @param flags for this command type
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
* @return error or cost of operation
|
||||
*/
|
||||
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
||||
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
|
||||
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
|
||||
|
||||
|
||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) DoClearSquare(tile);
|
||||
|
||||
return CommandCost(- _price.purchase_land * 2);
|
||||
}
|
||||
|
||||
|
||||
#include "table/clear_land.h"
|
||||
|
||||
|
||||
void DrawClearLandTile(const TileInfo *ti, byte set)
|
||||
{
|
||||
DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19, PAL_NONE);
|
||||
|
@@ -5,9 +5,8 @@
|
||||
#ifndef CLEAR_MAP_H
|
||||
#define CLEAR_MAP_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "tile.h"
|
||||
#include "bridge_map.h"
|
||||
#include "industry_type.h"
|
||||
|
||||
/**
|
||||
* Ground types. Valid densities in comments after the enum.
|
||||
|
@@ -3,13 +3,12 @@
|
||||
#ifndef CMD_HELPER_H
|
||||
#define CMD_HELPER_H
|
||||
|
||||
#include "direction.h"
|
||||
#include "macros.h"
|
||||
#include "road.h"
|
||||
#include "direction_type.h"
|
||||
#include "road_type.h"
|
||||
|
||||
|
||||
template<uint N> static inline void ExtractValid();
|
||||
template<> static inline void ExtractValid<1>() {}
|
||||
template<> inline void ExtractValid<1>() {}
|
||||
|
||||
|
||||
template<typename T> struct ExtractBits;
|
||||
|
@@ -4,20 +4,27 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "strings.h"
|
||||
#include "functions.h"
|
||||
#include "landscape.h"
|
||||
#include "map.h"
|
||||
#include "tile_map.h"
|
||||
#include "gui.h"
|
||||
#include "command.h"
|
||||
#include "player.h"
|
||||
#include "command_func.h"
|
||||
#include "network/network.h"
|
||||
#include "variables.h"
|
||||
#include "genworld.h"
|
||||
#include "newgrf_storage.h"
|
||||
#include "strings_func.h"
|
||||
#include "gfx_func.h"
|
||||
#include "functions.h"
|
||||
#include "town.h"
|
||||
#include "date_func.h"
|
||||
#include "debug.h"
|
||||
#include "player_func.h"
|
||||
#include "player_base.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
const char *_cmd_text = NULL;
|
||||
StringID _error_message;
|
||||
|
||||
/**
|
||||
* Helper macro to define the header of all command handler macros.
|
||||
@@ -387,7 +394,7 @@ byte GetCommandFlags(uint cmd)
|
||||
return _command_proc_table[cmd & 0xFF].flags;
|
||||
}
|
||||
|
||||
static int _docommand_recursive;
|
||||
static int _docommand_recursive = 0;
|
||||
|
||||
/*!
|
||||
* This function executes a given command with the parameters from the #CommandProc parameter list.
|
||||
@@ -400,7 +407,7 @@ static int _docommand_recursive;
|
||||
* @param procc The command-id to execute (a value of the CMD_* enums)
|
||||
* @see CommandProc
|
||||
*/
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
|
||||
{
|
||||
CommandCost res;
|
||||
CommandProc *proc;
|
||||
@@ -419,7 +426,9 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint p
|
||||
|
||||
/* only execute the test call if it's toplevel, or we're not execing. */
|
||||
if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
|
||||
SetTownRatingTestMode(true);
|
||||
res = proc(tile, flags & ~DC_EXEC, p1, p2);
|
||||
SetTownRatingTestMode(false);
|
||||
if (CmdFailed(res)) {
|
||||
res.SetGlobalErrorMessage();
|
||||
goto error;
|
||||
@@ -440,7 +449,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint p
|
||||
}
|
||||
|
||||
/* Execute the command here. All cost-relevant functions set the expenses type
|
||||
* themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
|
||||
* themselves to the cost object at some point */
|
||||
res = proc(tile, flags, p1, p2);
|
||||
if (CmdFailed(res)) {
|
||||
res.SetGlobalErrorMessage();
|
||||
@@ -539,7 +548,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
* e.g.: if you demolish a whole town, the dryrun would say okay.
|
||||
* but by really destroying, your rating drops and at a certain point
|
||||
* it will fail. so res and res2 are different
|
||||
* CMD_REMOVE_ROAD: This command has special local authority
|
||||
* CMD_REMOVE_LONG_ROAD: This command has special local authority
|
||||
* restrictions which may cause the test run to fail (the previous
|
||||
* road fragments still stay there and the town won't let you
|
||||
* disconnect the road system), but the exec will succeed and this
|
||||
@@ -549,9 +558,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
* estimate the cost of cloning a vehicle. */
|
||||
notest =
|
||||
(cmd & 0xFF) == CMD_CLEAR_AREA ||
|
||||
(cmd & 0xFF) == CMD_CONVERT_RAIL ||
|
||||
(cmd & 0xFF) == CMD_LEVEL_LAND ||
|
||||
(cmd & 0xFF) == CMD_REMOVE_ROAD ||
|
||||
(cmd & 0xFF) == CMD_REMOVE_LONG_ROAD ||
|
||||
(cmd & 0xFF) == CMD_CLONE_VEHICLE;
|
||||
|
||||
@@ -581,7 +588,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
|
||||
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
|
||||
/* first test if the command can be executed. */
|
||||
SetTownRatingTestMode(true);
|
||||
res = proc(tile, flags, p1, p2);
|
||||
SetTownRatingTestMode(false);
|
||||
if (CmdFailed(res)) {
|
||||
res.SetGlobalErrorMessage();
|
||||
goto show_error;
|
||||
@@ -609,6 +618,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
return true;
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
|
||||
|
||||
/* update last build coordinate of player. */
|
||||
if (tile != 0 && IsValidPlayer(_current_player)) {
|
||||
@@ -617,7 +627,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
|
||||
/* Actually try and execute the command. If no cost-type is given
|
||||
* use the construction one */
|
||||
_yearly_expenses_type = EXPENSES_CONSTRUCTION;
|
||||
res2 = proc(tile, flags | DC_EXEC, p1, p2);
|
||||
|
||||
/* If notest is on, it means the result of the test can be different than
|
||||
@@ -692,6 +701,11 @@ Money CommandCost::GetCost() const
|
||||
return this->cost;
|
||||
}
|
||||
|
||||
ExpensesType CommandCost::GetExpensesType() const
|
||||
{
|
||||
return this->expense_type;
|
||||
}
|
||||
|
||||
void CommandCost::SetGlobalErrorMessage() const
|
||||
{
|
||||
extern StringID _error_message;
|
||||
|
95
src/command_func.h
Normal file
95
src/command_func.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file command_func.h Functions related to commands. */
|
||||
|
||||
#ifndef COMMAND_FUNC_H
|
||||
#define COMMAND_FUNC_H
|
||||
|
||||
#include "command_type.h"
|
||||
|
||||
/**
|
||||
* Checks if a command failes.
|
||||
*
|
||||
* As you see the parameter is not a command but the return value of a command,
|
||||
* the CommandCost class. This function checks if the command executed by
|
||||
* the CommandProc function failed and returns true if it does.
|
||||
*
|
||||
* @param cost The return value of a CommandProc call
|
||||
* @return true if the command failes
|
||||
* @see CmdSucceded
|
||||
*/
|
||||
static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
|
||||
|
||||
/**
|
||||
* Checks if a command succeeded.
|
||||
*
|
||||
* As #CmdFailed this function checks if a command succeeded
|
||||
*
|
||||
* @param cost The return value of a CommandProc call
|
||||
* @return true if the command succeeded
|
||||
* @see CmdSucceeded
|
||||
*/
|
||||
static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
|
||||
|
||||
/**
|
||||
* Define a default return value for a failed command.
|
||||
*
|
||||
* This variable contains a CommandCost object with is declared as "failed".
|
||||
* Other functions just need to return this error if there is an error,
|
||||
* which doesn't need to specific by a StringID.
|
||||
*/
|
||||
static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
||||
|
||||
/**
|
||||
* Returns from a function with a specific StringID as error.
|
||||
*
|
||||
* This macro is used to return from a function. The parameter contains the
|
||||
* StringID which will be returned.
|
||||
*
|
||||
* @param errcode The StringID to return
|
||||
*/
|
||||
#define return_cmd_error(errcode) return CommandCost(errcode);
|
||||
|
||||
/**
|
||||
* Execute a command
|
||||
*/
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc);
|
||||
|
||||
/**
|
||||
* Execute a network safe DoCommand function
|
||||
*/
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
/**
|
||||
* Send a command over the network
|
||||
*/
|
||||
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
/**
|
||||
* Text, which gets sent with a command
|
||||
*
|
||||
* This variable contains a string (be specific a pointer of the first
|
||||
* char of this string) which will be send with a command. This is
|
||||
* used for user input data like names or chat messages.
|
||||
*/
|
||||
extern const char *_cmd_text;
|
||||
extern Money _additional_cash_required;
|
||||
extern StringID _error_message;
|
||||
|
||||
/**
|
||||
* Checks if a integer value belongs to a command.
|
||||
*/
|
||||
bool IsValidCommand(uint32 cmd);
|
||||
/**
|
||||
* Returns the flags from a given command.
|
||||
*/
|
||||
byte GetCommandFlags(uint32 cmd);
|
||||
/**
|
||||
* Returns the current money available which can be used for a command.
|
||||
*/
|
||||
Money GetAvailableMoneyForCommand();
|
||||
|
||||
#endif /* COMMAND_FUNC_H */
|
@@ -1,9 +1,99 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file command.h */
|
||||
/** @file command_type.h Types related to commands. */
|
||||
|
||||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
#ifndef COMMAND_TYPE_H
|
||||
#define COMMAND_TYPE_H
|
||||
|
||||
#include "economy_type.h"
|
||||
#include "strings_type.h"
|
||||
#include "tile_type.h"
|
||||
|
||||
/**
|
||||
* Common return value for all commands. Wraps the cost and
|
||||
* a possible error message/state together.
|
||||
*/
|
||||
class CommandCost {
|
||||
ExpensesType expense_type; ///< the type of expence as shown on the finances view
|
||||
Money cost; ///< The cost of this action
|
||||
StringID message; ///< Warning message for when success is unset
|
||||
bool success; ///< Whether the comment went fine up to this moment
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a command cost return with no cost and no error
|
||||
*/
|
||||
CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {}
|
||||
|
||||
/**
|
||||
* Creates a command return value the is failed with the given message
|
||||
*/
|
||||
CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {}
|
||||
|
||||
/**
|
||||
* Creates a command cost with given expense type and start cost of 0
|
||||
* @param ex_t the expense type
|
||||
*/
|
||||
CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {}
|
||||
|
||||
/**
|
||||
* Creates a command return value with the given start cost and expense type
|
||||
* @param ex_t the expense type
|
||||
* @param cst the initial cost of this command
|
||||
*/
|
||||
CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
|
||||
|
||||
/**
|
||||
* Adds the cost of the given command return value to this cost.
|
||||
* Also takes a possible error message when it is set.
|
||||
* @param ret the command to add the cost of.
|
||||
* @return this class.
|
||||
*/
|
||||
CommandCost AddCost(CommandCost ret);
|
||||
|
||||
/**
|
||||
* Adds the given cost to the cost of the command.
|
||||
* @param cost the cost to add
|
||||
* @return this class.
|
||||
*/
|
||||
CommandCost AddCost(Money cost);
|
||||
|
||||
/**
|
||||
* Multiplies the cost of the command by the given factor.
|
||||
* @param cost factor to multiply the costs with
|
||||
* @return this class
|
||||
*/
|
||||
CommandCost MultiplyCost(int factor);
|
||||
|
||||
/**
|
||||
* The costs as made up to this moment
|
||||
* @return the costs
|
||||
*/
|
||||
Money GetCost() const;
|
||||
|
||||
/**
|
||||
* The expense type of the cost
|
||||
* @return the expense type
|
||||
*/
|
||||
ExpensesType GetExpensesType() const;
|
||||
|
||||
/**
|
||||
* Sets the global error message *if* this class has one.
|
||||
*/
|
||||
void SetGlobalErrorMessage() const;
|
||||
|
||||
/**
|
||||
* Did this command succeed?
|
||||
* @return true if and only if it succeeded
|
||||
*/
|
||||
bool Succeeded() const;
|
||||
|
||||
/**
|
||||
* Did this command fail?
|
||||
* @return true if and only if it failed
|
||||
*/
|
||||
bool Failed() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* List of commands.
|
||||
@@ -248,50 +338,6 @@ struct Command {
|
||||
byte flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a command failes.
|
||||
*
|
||||
* As you see the parameter is not a command but the return value of a command,
|
||||
* the CommandCost class. This function checks if the command executed by
|
||||
* the CommandProc function failed and returns true if it does.
|
||||
*
|
||||
* @param cost The return value of a CommandProc call
|
||||
* @return true if the command failes
|
||||
* @see CmdSucceded
|
||||
*/
|
||||
static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
|
||||
|
||||
/**
|
||||
* Checks if a command succeeded.
|
||||
*
|
||||
* As #CmdFailed this function checks if a command succeeded
|
||||
*
|
||||
* @param cost The return value of a CommandProc call
|
||||
* @return true if the command succeeded
|
||||
* @see CmdSucceeded
|
||||
*/
|
||||
static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
|
||||
|
||||
/**
|
||||
* Define a default return value for a failed command.
|
||||
*
|
||||
* This variable contains a CommandCost object with is declared as "failed".
|
||||
* Other functions just need to return this error if there is an error,
|
||||
* which doesn't need to specific by a StringID.
|
||||
*/
|
||||
static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
||||
|
||||
/**
|
||||
* Returns from a function with a specific StringID as error.
|
||||
*
|
||||
* This macro is used to return from a function. The parameter contains the
|
||||
* StringID which will be returned.
|
||||
*
|
||||
* @param errcode The StringID to return
|
||||
*/
|
||||
#define return_cmd_error(errcode) return CommandCost(errcode);
|
||||
|
||||
/* command.cpp */
|
||||
/**
|
||||
* Define a callback function for the client, after the command is finished.
|
||||
*
|
||||
@@ -307,44 +353,4 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
||||
*/
|
||||
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||
|
||||
/**
|
||||
* Execute a command
|
||||
*/
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
|
||||
|
||||
/**
|
||||
* Execute a network safe DoCommand function
|
||||
*/
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
/**
|
||||
* Send a command over the network
|
||||
*/
|
||||
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
/**
|
||||
* Text, which gets sent with a command
|
||||
*
|
||||
* This variable contains a string (be specific a pointer of the first
|
||||
* char of this string) which will be send with a command. This is
|
||||
* used for user input data like names or chat messages.
|
||||
*/
|
||||
extern const char *_cmd_text;
|
||||
|
||||
/**
|
||||
* Checks if a integer value belongs to a command.
|
||||
*/
|
||||
bool IsValidCommand(uint cmd);
|
||||
/**
|
||||
* Returns the flags from a given command.
|
||||
*/
|
||||
byte GetCommandFlags(uint cmd);
|
||||
/**
|
||||
* Returns the current money available which can be used for a command.
|
||||
*/
|
||||
Money GetAvailableMoneyForCommand();
|
||||
|
||||
#endif /* COMMAND_H */
|
||||
#endif /* COMMAND_TYPE_H */
|
@@ -4,21 +4,22 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "table/strings.h"
|
||||
#include "functions.h"
|
||||
#include "window.h"
|
||||
#include "gui.h"
|
||||
#include "gfx.h"
|
||||
#include "player.h"
|
||||
#include "textbuf_gui.h"
|
||||
#include "window_gui.h"
|
||||
#include "variables.h"
|
||||
#include "string.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "console.h"
|
||||
#include "helpers.hpp"
|
||||
#include "network/network.h"
|
||||
#include "network/network_data.h"
|
||||
#include "network/network_server.h"
|
||||
#include "core/alloc_func.hpp"
|
||||
#include "window_func.h"
|
||||
#include "string_func.h"
|
||||
#include "gfx_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
#define ICON_BUFFER 79
|
||||
#define ICON_HISTORY_SIZE 20
|
||||
@@ -28,6 +29,19 @@
|
||||
#define ICON_MAX_ALIAS_LINES 40
|
||||
#define ICON_TOKEN_COUNT 20
|
||||
|
||||
/* console parser */
|
||||
IConsoleCmd *_iconsole_cmds; ///< list of registred commands
|
||||
IConsoleVar *_iconsole_vars; ///< list of registred vars
|
||||
IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
|
||||
|
||||
/* console colors/modes */
|
||||
byte _icolour_def;
|
||||
byte _icolour_err;
|
||||
byte _icolour_warn;
|
||||
byte _icolour_dbg;
|
||||
byte _icolour_cmd;
|
||||
IConsoleModes _iconsole_mode;
|
||||
|
||||
/* ** main console ** */
|
||||
static char *_iconsole_buffer[ICON_BUFFER + 1];
|
||||
static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
|
||||
@@ -305,12 +319,12 @@ void IConsoleSwitch()
|
||||
w->height = _screen.height / 3;
|
||||
w->width = _screen.width;
|
||||
_iconsole_mode = ICONSOLE_OPENED;
|
||||
SETBIT(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
|
||||
SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
|
||||
} break;
|
||||
case ICONSOLE_OPENED: case ICONSOLE_FULL:
|
||||
DeleteWindowById(WC_CONSOLE, 0);
|
||||
_iconsole_mode = ICONSOLE_CLOSED;
|
||||
CLRBIT(_no_scroll, SCROLL_CON);
|
||||
ClrBit(_no_scroll, SCROLL_CON);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -356,7 +370,7 @@ static void IConsoleHistoryNavigate(int direction)
|
||||
_iconsole_historypos = i;
|
||||
IConsoleClearCommand();
|
||||
/* copy history to 'command prompt / bash' */
|
||||
assert(_iconsole_history[i] != NULL && IS_INT_INSIDE(i, 0, ICON_HISTORY_SIZE));
|
||||
assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
|
||||
ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
|
||||
UpdateTextBufferSize(&_iconsole_cmdline);
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include "window_type.h"
|
||||
|
||||
/* maximum length of a typed in command */
|
||||
#define ICON_CMDLN_SIZE 255
|
||||
/* maximum length of a totally expanded command */
|
||||
@@ -101,17 +103,17 @@ struct IConsoleAlias {
|
||||
};
|
||||
|
||||
/* console parser */
|
||||
VARDEF IConsoleCmd *_iconsole_cmds; ///< list of registred commands
|
||||
VARDEF IConsoleVar *_iconsole_vars; ///< list of registred vars
|
||||
VARDEF IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
|
||||
extern IConsoleCmd *_iconsole_cmds; ///< list of registred commands
|
||||
extern IConsoleVar *_iconsole_vars; ///< list of registred vars
|
||||
extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
|
||||
|
||||
/* console colors/modes */
|
||||
VARDEF byte _icolour_def;
|
||||
VARDEF byte _icolour_err;
|
||||
VARDEF byte _icolour_warn;
|
||||
VARDEF byte _icolour_dbg;
|
||||
VARDEF byte _icolour_cmd;
|
||||
VARDEF IConsoleModes _iconsole_mode;
|
||||
extern byte _icolour_def;
|
||||
extern byte _icolour_err;
|
||||
extern byte _icolour_warn;
|
||||
extern byte _icolour_dbg;
|
||||
extern byte _icolour_cmd;
|
||||
extern IConsoleModes _iconsole_mode;
|
||||
|
||||
/* console functions */
|
||||
void IConsoleInit();
|
||||
|
@@ -7,26 +7,36 @@
|
||||
#include "console.h"
|
||||
#include "debug.h"
|
||||
#include "engine.h"
|
||||
#include "functions.h"
|
||||
#include "landscape.h"
|
||||
#include "saveload.h"
|
||||
#include "string.h"
|
||||
#include "variables.h"
|
||||
#include "network/network_data.h"
|
||||
#include "network/network_client.h"
|
||||
#include "network/network_server.h"
|
||||
#include "network/network_udp.h"
|
||||
#include "command.h"
|
||||
#include "settings.h"
|
||||
#include "command_func.h"
|
||||
#include "settings_func.h"
|
||||
#include "fios.h"
|
||||
#include "fileio.h"
|
||||
#include "vehicle.h"
|
||||
#include "station.h"
|
||||
#include "strings.h"
|
||||
#include "screenshot.h"
|
||||
#include "genworld.h"
|
||||
#include "date.h"
|
||||
#include "network/network.h"
|
||||
#include "strings_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "window_func.h"
|
||||
#include "functions.h"
|
||||
#include "map_func.h"
|
||||
#include "date_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "string_func.h"
|
||||
#include "player_func.h"
|
||||
#include "player_base.h"
|
||||
#include "settings_type.h"
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
#include "table/strings.h"
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
// ** scriptfile handling ** //
|
||||
static FILE *_script_file;
|
||||
@@ -134,19 +144,12 @@ DEF_CONSOLE_CMD(ConResetTile)
|
||||
|
||||
DEF_CONSOLE_CMD(ConStopAllVehicles)
|
||||
{
|
||||
Vehicle* v;
|
||||
if (argc == 0) {
|
||||
IConsoleHelp("Stops all vehicles in the game. For debugging only! Use at your own risk... Usage: 'stopall'");
|
||||
return true;
|
||||
}
|
||||
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
/* Code ripped from CmdStartStopTrain. Can't call it, because of
|
||||
* ownership problems, so we'll duplicate some code, for now */
|
||||
v->vehstatus |= VS_STOPPED;
|
||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||
}
|
||||
StopAllVehicles();
|
||||
return true;
|
||||
}
|
||||
#endif /* _DEBUG */
|
||||
@@ -233,7 +236,7 @@ static const FiosItem* GetFiosItem(const char* file)
|
||||
if (file == endptr || *endptr != '\0') i = -1;
|
||||
}
|
||||
|
||||
return IS_INT_INSIDE(i, 0, _fios_num) ? &_fios_list[i] : NULL;
|
||||
return IsInsideMM(i, 0, _fios_num) ? &_fios_list[i] : NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1226,10 +1229,6 @@ DEF_CONSOLE_CMD(ConSay)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
#include "table/strings.h"
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
DEF_CONSOLE_CMD(ConPlayers)
|
||||
{
|
||||
Player *p;
|
||||
@@ -1326,6 +1325,8 @@ DEF_CONSOLE_HOOK(ConHookRconPW)
|
||||
return true;
|
||||
}
|
||||
|
||||
extern void HashCurrentCompanyPassword();
|
||||
|
||||
/* Also use from within player_gui to change the password graphically */
|
||||
bool NetworkChangeCompanyPassword(byte argc, char *argv[])
|
||||
{
|
||||
@@ -1346,8 +1347,11 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
|
||||
|
||||
ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password));
|
||||
|
||||
if (!_network_server)
|
||||
if (!_network_server) {
|
||||
SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
|
||||
} else {
|
||||
HashCurrentCompanyPassword();
|
||||
}
|
||||
|
||||
IConsolePrintF(_icolour_warn, "'company_pw' changed to: %s", _network_player_info[_local_player].password);
|
||||
|
||||
@@ -1649,6 +1653,8 @@ void IConsoleStdLibRegister()
|
||||
IConsoleVarRegister("min_players", &_network_min_players, ICONSOLE_VAR_BYTE, "Automatically pause the game when the number of active players passes below the given amount");
|
||||
IConsoleVarHookAdd("min_players", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
|
||||
IConsoleVarHookAdd("min_players", ICONSOLE_HOOK_POST_ACTION, ConHookCheckMinPlayers);
|
||||
IConsoleVarRegister("reload_cfg", &_network_reload_cfg, ICONSOLE_VAR_BOOLEAN, "reload the entire config file between the end of this game, and starting the next new game - dedicated servers");
|
||||
IConsoleVarHookAdd("reload_cfg", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
|
84
src/core/alloc_func.hpp
Normal file
84
src/core/alloc_func.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file alloc_func.hpp Functions related to the allocation of memory */
|
||||
|
||||
#ifndef ALLOC_FUNC_HPP
|
||||
#define ALLOC_FUNC_HPP
|
||||
|
||||
/**
|
||||
* Simplified allocation function that allocates the specified number of
|
||||
* elements of the given type. It also explicitly casts it to the requested
|
||||
* type.
|
||||
* @note throws an error when there is no memory anymore.
|
||||
* @note the memory contains garbage data (i.e. possibly non-zero values).
|
||||
* @param T the type of the variable(s) to allocation.
|
||||
* @param num_elements the number of elements to allocate of the given type.
|
||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||
*/
|
||||
template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
* returns NULL. So we do that for *all* allocations, thus causing it
|
||||
* to behave the same on all OSes.
|
||||
*/
|
||||
if (num_elements == 0) return NULL;
|
||||
|
||||
T *t_ptr = (T*)malloc(num_elements * sizeof(T));
|
||||
if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified allocation function that allocates the specified number of
|
||||
* elements of the given type. It also explicitly casts it to the requested
|
||||
* type.
|
||||
* @note throws an error when there is no memory anymore.
|
||||
* @note the memory contains all zero values.
|
||||
* @param T the type of the variable(s) to allocation.
|
||||
* @param num_elements the number of elements to allocate of the given type.
|
||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||
*/
|
||||
template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
* returns NULL. So we do that for *all* allocations, thus causing it
|
||||
* to behave the same on all OSes.
|
||||
*/
|
||||
if (num_elements == 0) return NULL;
|
||||
|
||||
T *t_ptr = (T*)calloc(num_elements, sizeof(T));
|
||||
if (t_ptr == NULL) error("Out of memory. Cannot allocate %i bytes", num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified reallocation function that allocates the specified number of
|
||||
* elements of the given type. It also explicitly casts it to the requested
|
||||
* type. It extends/shrinks the memory allocation given in t_ptr.
|
||||
* @note throws an error when there is no memory anymore.
|
||||
* @note the memory contains all zero values.
|
||||
* @param T the type of the variable(s) to allocation.
|
||||
* @param t_ptr the previous allocation to extend/shrink.
|
||||
* @param num_elements the number of elements to allocate of the given type.
|
||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||
*/
|
||||
template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
* returns NULL. So we do that for *all* allocations, thus causing it
|
||||
* to behave the same on all OSes.
|
||||
*/
|
||||
if (num_elements == 0) {
|
||||
free(t_ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
|
||||
if (t_ptr == NULL) error("Out of memory. Cannot reallocate %i bytes", num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
#endif /* ALLOC_FUNC_HPP */
|
72
src/core/bitmath_func.cpp
Normal file
72
src/core/bitmath_func.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file bitmath_func.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "bitmath_func.hpp"
|
||||
|
||||
const uint8 _ffb_64[64] = {
|
||||
0, 0, 1, 0, 2, 0, 1, 0,
|
||||
3, 0, 1, 0, 2, 0, 1, 0,
|
||||
4, 0, 1, 0, 2, 0, 1, 0,
|
||||
3, 0, 1, 0, 2, 0, 1, 0,
|
||||
5, 0, 1, 0, 2, 0, 1, 0,
|
||||
3, 0, 1, 0, 2, 0, 1, 0,
|
||||
4, 0, 1, 0, 2, 0, 1, 0,
|
||||
3, 0, 1, 0, 2, 0, 1, 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Search the first set bit in a 32 bit variable.
|
||||
*
|
||||
* This algorithm is a static implementation of a log
|
||||
* conguence search algorithm. It checks the first half
|
||||
* if there is a bit set search there further. And this
|
||||
* way further. If no bit is set return 0.
|
||||
*
|
||||
* @param x The value to search
|
||||
* @return The position of the first bit set
|
||||
*/
|
||||
uint8 FindFirstBit(uint32 x)
|
||||
{
|
||||
if (x == 0) return 0;
|
||||
/* The macro FIND_FIRST_BIT is better to use when your x is
|
||||
not more than 128. */
|
||||
|
||||
uint8 pos = 0;
|
||||
|
||||
if ((x & 0x0000ffff) == 0) { x >>= 16; pos += 16; }
|
||||
if ((x & 0x000000ff) == 0) { x >>= 8; pos += 8; }
|
||||
if ((x & 0x0000000f) == 0) { x >>= 4; pos += 4; }
|
||||
if ((x & 0x00000003) == 0) { x >>= 2; pos += 2; }
|
||||
if ((x & 0x00000001) == 0) { pos += 1; }
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the last set bit in a 64 bit variable.
|
||||
*
|
||||
* This algorithm is a static implementation of a log
|
||||
* conguence search algorithm. It checks the second half
|
||||
* if there is a bit set search there further. And this
|
||||
* way further. If no bit is set return 0.
|
||||
*
|
||||
* @param x The value to search
|
||||
* @return The position of the last bit set
|
||||
*/
|
||||
uint8 FindLastBit(uint64 x)
|
||||
{
|
||||
if (x == 0) return 0;
|
||||
|
||||
uint8 pos = 0;
|
||||
|
||||
if ((x & 0xffffffff00000000ULL) != 0) { x >>= 32; pos += 32; }
|
||||
if ((x & 0x00000000ffff0000ULL) != 0) { x >>= 16; pos += 16; }
|
||||
if ((x & 0x000000000000ff00ULL) != 0) { x >>= 8; pos += 8; }
|
||||
if ((x & 0x00000000000000f0ULL) != 0) { x >>= 4; pos += 4; }
|
||||
if ((x & 0x000000000000000cULL) != 0) { x >>= 2; pos += 2; }
|
||||
if ((x & 0x0000000000000002ULL) != 0) { pos += 1; }
|
||||
|
||||
return pos;
|
||||
}
|
324
src/core/bitmath_func.hpp
Normal file
324
src/core/bitmath_func.hpp
Normal file
@@ -0,0 +1,324 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file bitmath_func.hpp */
|
||||
|
||||
#ifndef BITMATH_FUNC_HPP
|
||||
#define BITMATH_FUNC_HPP
|
||||
|
||||
/**
|
||||
* Fetch n bits from x, started at bit s.
|
||||
*
|
||||
* This function can be used to fetch n bits from the value x. The
|
||||
* s value set the startposition to read. The startposition is
|
||||
* count from the LSB and starts at 0. The result starts at a
|
||||
* LSB, as this isn't just an and-bitmask but also some
|
||||
* bit-shifting operations. GB(0xFF, 2, 1) will so
|
||||
* return 0x01 (0000 0001) instead of
|
||||
* 0x04 (0000 0100).
|
||||
*
|
||||
* @param x The value to read some bits.
|
||||
* @param s The startposition to read some bits.
|
||||
* @param n The number of bits to read.
|
||||
* @return The selected bits, aligned to a LSB.
|
||||
*/
|
||||
template<typename T> static inline uint GB(const T x, const uint8 s, const uint8 n)
|
||||
{
|
||||
return (x >> s) & ((1U << n) - 1);
|
||||
}
|
||||
|
||||
/** Set n bits from x starting at bit s to d
|
||||
*
|
||||
* This function sets n bits from x which started as bit s to the value of
|
||||
* d. The parameters x, s and n works the same as the parameters of
|
||||
* #GB. The result is saved in x again. Unused bits in the window
|
||||
* provided by n are set to 0 if the value of b isn't "big" enough.
|
||||
* This is not a bug, its a feature.
|
||||
*
|
||||
* @note Parameter x must be a variable as the result is saved there.
|
||||
* @note To avoid unexpecting results the value of b should not use more
|
||||
* space as the provided space of n bits (log2)
|
||||
* @param x The variable to change some bits
|
||||
* @param s The startposition for the new bits
|
||||
* @param n The size/window for the new bits
|
||||
* @param d The actually new bits to save in the defined position.
|
||||
* @return The new value of x
|
||||
*/
|
||||
template<typename T, typename U> static inline T SB(T& x, const uint8 s, const uint8 n, const U d)
|
||||
{
|
||||
x &= (T)(~(((1U << n) - 1) << s));
|
||||
x |= (T)(d << s);
|
||||
return x;
|
||||
}
|
||||
|
||||
/** Add i to n bits of x starting at bit s.
|
||||
*
|
||||
* This add the value of i on n bits of x starting at bit s. The parameters x,
|
||||
* s, i are similar to #GB besides x must be a variable as the result are
|
||||
* saved there. An overflow does not affect the following bits of the given
|
||||
* bit window and is simply ignored.
|
||||
*
|
||||
* @note Parameter x must be a variable as the result is saved there.
|
||||
* @param x The variable to add some bits at some position
|
||||
* @param s The startposition of the addition
|
||||
* @param n The size/window for the addition
|
||||
* @param i The value to add at the given startposition in the given window.
|
||||
* @return The new value of x
|
||||
*/
|
||||
template<typename T, typename U> static inline T AB(T& x, const uint8 s, const uint8 n, const U i)
|
||||
{
|
||||
const T mask = (T)(((1U << n) - 1) << s);
|
||||
x = (T)((x & ~mask) | ((x + (i << s)) & mask));
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a bit in a value is set.
|
||||
*
|
||||
* This function checks if a bit inside a value is set or not.
|
||||
* The y value specific the position of the bit, started at the
|
||||
* LSB and count from 0.
|
||||
*
|
||||
* @param x The value to check
|
||||
* @param y The position of the bit to check, started from the LSB
|
||||
* @return True if the bit is set, false else.
|
||||
*/
|
||||
template<typename T> static inline bool HasBit(const T x, const uint8 y)
|
||||
{
|
||||
return (x & ((T)1U << y)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check several bits in a value.
|
||||
*
|
||||
* This macro checks if a value contains at least one bit of an other
|
||||
* value.
|
||||
*
|
||||
* @param x The first value
|
||||
* @param y The second value
|
||||
* @return True if at least one bit is set in both values, false else.
|
||||
*/
|
||||
#define HASBITS(x, y) ((x) & (y))
|
||||
|
||||
/**
|
||||
* Set a bit in a variable.
|
||||
*
|
||||
* This function sets a bit in a variable. The variable is changed
|
||||
* and the value is also returned. Parameter y defines the bit and
|
||||
* starts at the LSB with 0.
|
||||
*
|
||||
* @param x The variable to set a bit
|
||||
* @param y The bit position to set
|
||||
* @return The new value of the old value with the bit set
|
||||
*/
|
||||
template<typename T> static inline T SetBit(T& x, const uint8 y)
|
||||
{
|
||||
return x = (T)(x | (T)(1U << y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets several bits in a variable.
|
||||
*
|
||||
* This macro sets several bits in a variable. The bits to set are provided
|
||||
* by a value. The new value is also returned.
|
||||
*
|
||||
* @param x The variable to set some bits
|
||||
* @param y The value with set bits for setting them in the variable
|
||||
* @return The new value of x
|
||||
*/
|
||||
#define SETBITS(x, y) ((x) |= (y))
|
||||
|
||||
/**
|
||||
* Clears a bit in a variable.
|
||||
*
|
||||
* This function clears a bit in a variable. The variable is
|
||||
* changed and the value is also returned. Parameter y defines the bit
|
||||
* to clear and starts at the LSB with 0.
|
||||
*
|
||||
* @param x The variable to clear the bit
|
||||
* @param y The bit position to clear
|
||||
* @return The new value of the old value with the bit cleared
|
||||
*/
|
||||
template<typename T> static inline T ClrBit(T& x, const uint8 y)
|
||||
{
|
||||
return x = (T)(x & ~((T)1U << y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears several bits in a variable.
|
||||
*
|
||||
* This macro clears several bits in a variable. The bits to clear are
|
||||
* provided by a value. The new value is also returned.
|
||||
*
|
||||
* @param x The variable to clear some bits
|
||||
* @param y The value with set bits for clearing them in the variable
|
||||
* @return The new value of x
|
||||
*/
|
||||
#define CLRBITS(x, y) ((x) &= ~(y))
|
||||
|
||||
/**
|
||||
* Toggles a bit in a variable.
|
||||
*
|
||||
* This function toggles a bit in a variable. The variable is
|
||||
* changed and the value is also returned. Parameter y defines the bit
|
||||
* to toggle and starts at the LSB with 0.
|
||||
*
|
||||
* @param x The varliable to toggle the bit
|
||||
* @param y The bit position to toggle
|
||||
* @return The new value of the old value with the bit toggled
|
||||
*/
|
||||
template<typename T> static inline T ToggleBit(T& x, const uint8 y)
|
||||
{
|
||||
return x = (T)(x ^ (T)(1U << y));
|
||||
}
|
||||
|
||||
|
||||
/** Lookup table to check which bit is set in a 6 bit variable */
|
||||
extern const uint8 _ffb_64[64];
|
||||
|
||||
/**
|
||||
* Returns the first occure of a bit in a 6-bit value (from right).
|
||||
*
|
||||
* Returns the position of the first bit that is not zero, counted from the
|
||||
* LSB. Ie, 110100 returns 2, 000001 returns 0, etc. When x == 0 returns
|
||||
* 0.
|
||||
*
|
||||
* @param x The 6-bit value to check the first zero-bit
|
||||
* @return The first position of a bit started from the LSB or 0 if x is 0.
|
||||
*/
|
||||
#define FIND_FIRST_BIT(x) _ffb_64[(x)]
|
||||
|
||||
/**
|
||||
* Finds the position of the first bit in an integer.
|
||||
*
|
||||
* This function returns the position of the first bit set in the
|
||||
* integer. It does only check the bits of the bitmask
|
||||
* 0x3F3F (0011111100111111) and checks only the
|
||||
* bits of the bitmask 0x3F00 if and only if the
|
||||
* lower part 0x00FF is 0. This results the bits at 0x00C0 must
|
||||
* be also zero to check the bits at 0x3F00.
|
||||
*
|
||||
* @param value The value to check the first bits
|
||||
* @return The position of the first bit which is set
|
||||
* @see FIND_FIRST_BIT
|
||||
*/
|
||||
static inline uint8 FindFirstBit2x64(const int value)
|
||||
{
|
||||
if ((value & 0xFF) == 0) {
|
||||
return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
|
||||
} else {
|
||||
return FIND_FIRST_BIT(value & 0x3F);
|
||||
}
|
||||
}
|
||||
|
||||
uint8 FindFirstBit(uint32 x);
|
||||
uint8 FindLastBit(uint64 x);
|
||||
|
||||
/**
|
||||
* Clear the first bit in an integer.
|
||||
*
|
||||
* This function returns a value where the first bit (from LSB)
|
||||
* is cleared.
|
||||
* So, 110100 returns 110000, 000001 returns 000000, etc.
|
||||
*
|
||||
* @param value The value to clear the first bit
|
||||
* @return The new value with the first bit cleared
|
||||
*/
|
||||
template<typename T> static inline T KillFirstBit(T value)
|
||||
{
|
||||
return value &= (T)(value - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of set bits in a variable.
|
||||
*
|
||||
* @param value the value to count the number of bits in.
|
||||
* @return the number of bits.
|
||||
*/
|
||||
template<typename T> static inline uint CountBits(T value)
|
||||
{
|
||||
uint num;
|
||||
|
||||
/* This loop is only called once for every bit set by clearing the lowest
|
||||
* bit in each loop. The number of bits is therefore equal to the number of
|
||||
* times the loop was called. It was found at the following website:
|
||||
* http://graphics.stanford.edu/~seander/bithacks.html */
|
||||
|
||||
for (num = 0; value != 0; num++) {
|
||||
value &= (T)(value - 1);
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* ROtate x Left by n
|
||||
*
|
||||
* @note Assumes a byte has 8 bits
|
||||
* @param x The value which we want to rotate
|
||||
* @param n The number how many we waht to rotate
|
||||
* @return A bit rotated number
|
||||
*/
|
||||
template<typename T> static inline T ROL(const T x, const uint8 n)
|
||||
{
|
||||
return (T)(x << n | x >> (sizeof(x) * 8 - n));
|
||||
}
|
||||
|
||||
/**
|
||||
* ROtate x Right by n
|
||||
*
|
||||
* @note Assumes a byte has 8 bits
|
||||
* @param x The value which we want to rotate
|
||||
* @param n The number how many we waht to rotate
|
||||
* @return A bit rotated number
|
||||
*/
|
||||
template<typename T> static inline T ROR(const T x, const uint8 n)
|
||||
{
|
||||
return (T)(x >> n | x << (sizeof(x) * 8 - n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Do an operation for each set set bit in a value.
|
||||
*
|
||||
* This macros is used to do an operation for each set
|
||||
* bit in a variable. The first variable can be reused
|
||||
* in the operation due to it's the bit position counter.
|
||||
* The second variable will be cleared during the usage
|
||||
*
|
||||
* @param i The position counter
|
||||
* @param b The value which we check for set bits
|
||||
*/
|
||||
#define FOR_EACH_SET_BIT(i, b) \
|
||||
for (i = 0; b != 0; i++, b >>= 1) \
|
||||
if (b & 1)
|
||||
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* Make endian swapping use Apple's macros to increase speed
|
||||
* (since it will use hardware swapping if available).
|
||||
* Even though they should return uint16 and uint32, we get
|
||||
* warnings if we don't cast those (why?) */
|
||||
#define BSWAP32(x) ((uint32)Endian32_Swap(x))
|
||||
#define BSWAP16(x) ((uint16)Endian16_Swap(x))
|
||||
#else
|
||||
/**
|
||||
* Perform a 32 bits endianness bitswap on x.
|
||||
* @param x the variable to bitswap
|
||||
* @return the bitswapped value.
|
||||
*/
|
||||
static inline uint32 BSWAP32(uint32 x)
|
||||
{
|
||||
return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a 16 bits endianness bitswap on x.
|
||||
* @param x the variable to bitswap
|
||||
* @return the bitswapped value.
|
||||
*/
|
||||
static inline uint16 BSWAP16(uint16 x)
|
||||
{
|
||||
return (x >> 8) | (x << 8);
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#endif /* BITMATH_FUNC_HPP */
|
65
src/core/endian_func.hpp
Normal file
65
src/core/endian_func.hpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file endian_func.hpp */
|
||||
|
||||
#ifndef ENDIAN_FUNC_H
|
||||
#define ENDIAN_FUNC_H
|
||||
|
||||
#include "bitmath_func.hpp"
|
||||
|
||||
#if defined(ARM) || defined(__arm__) || defined(__alpha__)
|
||||
#define OTTD_ALIGNMENT
|
||||
#endif
|
||||
|
||||
/* Windows has always LITTLE_ENDIAN */
|
||||
#if defined(WIN32) || defined(__OS2__) || defined(WIN64)
|
||||
#define TTD_LITTLE_ENDIAN
|
||||
#elif !defined(TESTING)
|
||||
/* Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile */
|
||||
#if defined(STRGEN)
|
||||
#include "endian_host.h"
|
||||
#else
|
||||
#include "endian_target.h"
|
||||
#endif
|
||||
#endif /* WIN32 || __OS2__ || WIN64 */
|
||||
|
||||
/* Setup alignment and conversion macros */
|
||||
#if defined(TTD_BIG_ENDIAN)
|
||||
#define FROM_BE16(x) (x)
|
||||
#define FROM_BE32(x) (x)
|
||||
#define TO_BE16(x) (x)
|
||||
#define TO_BE32(x) (x)
|
||||
#define TO_BE32X(x) (x)
|
||||
#define FROM_LE16(x) BSWAP16(x)
|
||||
#define FROM_LE32(x) BSWAP32(x)
|
||||
#define TO_LE16(x) BSWAP16(x)
|
||||
#define TO_LE32(x) BSWAP32(x)
|
||||
#define TO_LE32X(x) BSWAP32(x)
|
||||
#else
|
||||
#define FROM_BE16(x) BSWAP16(x)
|
||||
#define FROM_BE32(x) BSWAP32(x)
|
||||
#define TO_BE16(x) BSWAP16(x)
|
||||
#define TO_BE32(x) BSWAP32(x)
|
||||
#define TO_BE32X(x) BSWAP32(x)
|
||||
#define FROM_LE16(x) (x)
|
||||
#define FROM_LE32(x) (x)
|
||||
#define TO_LE16(x) (x)
|
||||
#define TO_LE32(x) (x)
|
||||
#define TO_LE32X(x) (x)
|
||||
#endif /* TTD_BIG_ENDIAN */
|
||||
|
||||
static inline uint16 ReadLE16Aligned(const void *x)
|
||||
{
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
}
|
||||
|
||||
static inline uint16 ReadLE16Unaligned(const void *x)
|
||||
{
|
||||
#ifdef OTTD_ALIGNMENT
|
||||
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
|
||||
#else
|
||||
return FROM_LE16(*(const uint16*)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ENDIAN_FUNC_HPP */
|
115
src/core/enum_type.hpp
Normal file
115
src/core/enum_type.hpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file enum_type.hpp Type (helpers) for enums */
|
||||
|
||||
#ifndef ENUM_TYPE_HPP
|
||||
#define ENUM_TYPE_HPP
|
||||
|
||||
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
|
||||
#define DECLARE_POSTFIX_INCREMENT(type) \
|
||||
FORCEINLINE type operator ++(type& e, int) \
|
||||
{ \
|
||||
type e_org = e; \
|
||||
e = (type)((int)e + 1); \
|
||||
return e_org; \
|
||||
} \
|
||||
FORCEINLINE type operator --(type& e, int) \
|
||||
{ \
|
||||
type e_org = e; \
|
||||
e = (type)((int)e - 1); \
|
||||
return e_org; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Operators to allow to work with enum as with type safe bit set in C++ */
|
||||
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
|
||||
FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
|
||||
FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
|
||||
FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
|
||||
FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
|
||||
FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
|
||||
FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
|
||||
FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
|
||||
|
||||
|
||||
/** Informative template class exposing basic enumeration properties used by several
|
||||
* other templates below. Here we have only forward declaration. For each enum type
|
||||
* we will create specialization derived from MakeEnumPropsT<>.
|
||||
* i.e.:
|
||||
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
|
||||
* followed by:
|
||||
* typedef TinyEnumT<Track> TrackByte;
|
||||
*/
|
||||
template <typename Tenum_t> struct EnumPropsT;
|
||||
|
||||
/** Helper template class that makes basic properties of given enumeration type visible
|
||||
* from outsize. It is used as base class of several EnumPropsT specializations each
|
||||
* dedicated to one of commonly used enumeration types.
|
||||
* @param Tenum_t enumeration type that you want to describe
|
||||
* @param Tstorage_t what storage type would be sufficient (i.e. byte)
|
||||
* @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
|
||||
* @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
|
||||
* @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
|
||||
*/
|
||||
template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
|
||||
struct MakeEnumPropsT {
|
||||
typedef Tenum_t type; ///< enum type (i.e. Trackdir)
|
||||
typedef Tstorage_t storage; ///< storage type (i.e. byte)
|
||||
static const Tenum_t begin = Tbegin; ///< lowest valid value (i.e. TRACKDIR_BEGIN)
|
||||
static const Tenum_t end = Tend; ///< one after the last valid value (i.e. TRACKDIR_END)
|
||||
static const Tenum_t invalid = Tinvalid; ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** In some cases we use byte or uint16 to store values that are defined as enum. It is
|
||||
* necessary in order to control the sizeof() such values. Some compilers make enum
|
||||
* the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
|
||||
* compiler type-checking causes errors like:
|
||||
* 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
|
||||
* u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
|
||||
* to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
|
||||
template <typename Tenum_t> struct TinyEnumT;
|
||||
|
||||
/** The general declaration of TinyEnumT<> (above) */
|
||||
template <typename Tenum_t> struct TinyEnumT
|
||||
{
|
||||
typedef Tenum_t enum_type; ///< expose our enumeration type (i.e. Trackdir) to outside
|
||||
typedef EnumPropsT<Tenum_t> Props; ///< make easier access to our enumeration propeties
|
||||
typedef typename Props::storage storage_type; ///< small storage type
|
||||
static const enum_type begin = Props::begin; ///< enum beginning (i.e. TRACKDIR_BEGIN)
|
||||
static const enum_type end = Props::end; ///< enum end (i.e. TRACKDIR_END)
|
||||
static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
|
||||
|
||||
storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form
|
||||
|
||||
/** Cast operator - invoked then the value is assigned to the Tenum_t type */
|
||||
FORCEINLINE operator enum_type () const
|
||||
{
|
||||
return (enum_type)m_val;
|
||||
}
|
||||
|
||||
/** Assignment operator (from Tenum_t type) */
|
||||
FORCEINLINE TinyEnumT& operator = (enum_type e)
|
||||
{
|
||||
m_val = (storage_type)e; return *this;
|
||||
}
|
||||
|
||||
/** postfix ++ operator on tiny type */
|
||||
FORCEINLINE TinyEnumT operator ++ (int)
|
||||
{
|
||||
TinyEnumT org = *this;
|
||||
if (++m_val >= end) m_val -= (storage_type)(end - begin);
|
||||
return org;
|
||||
}
|
||||
|
||||
/** prefix ++ operator on tiny type */
|
||||
FORCEINLINE TinyEnumT& operator ++ ()
|
||||
{
|
||||
if (++m_val >= end) m_val -= (storage_type)(end - begin);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HELPERS_HPP */
|
49
src/core/geometry_type.hpp
Normal file
49
src/core/geometry_type.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file geometry_type.hpp All geometry types in OpenTTD. */
|
||||
|
||||
#ifndef GEOMETRY_TYPE_HPP
|
||||
#define GEOMETRY_TYPE_HPP
|
||||
|
||||
#if defined(__AMIGA__)
|
||||
/* AmigaOS already has a Point declared */
|
||||
#define Point OTTD_Point
|
||||
#endif /* __AMIGA__ */
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* Mac OS X already has both Rect and Point declared */
|
||||
#define Rect OTTD_Rect
|
||||
#define Point OTTD_Point
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
|
||||
struct Point {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct Dimension {
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
int left;
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
};
|
||||
|
||||
struct PointDimension {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
||||
struct Pair {
|
||||
int a;
|
||||
int b;
|
||||
};
|
||||
|
||||
#endif /* GEOMETRY_TYPE_HPP */
|
226
src/core/math_func.hpp
Normal file
226
src/core/math_func.hpp
Normal file
@@ -0,0 +1,226 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file math_func.hpp Integer math functions */
|
||||
|
||||
#ifndef MATH_FUNC_HPP
|
||||
#define MATH_FUNC_HPP
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the maximum of two values.
|
||||
*
|
||||
* This function returns the greater value of two given values.
|
||||
* If they are equal the value of a is returned.
|
||||
*
|
||||
* @param a The first value
|
||||
* @param b The second value
|
||||
* @return The greater value or a if equals
|
||||
*/
|
||||
template<typename T> static inline T max(const T a, const T b)
|
||||
{
|
||||
return (a >= b) ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum of two values.
|
||||
*
|
||||
* This function returns the smaller value of two given values.
|
||||
* If they are equal the value of b is returned.
|
||||
*
|
||||
* @param a The first value
|
||||
* @param b The second value
|
||||
* @return The smaller value or b if equals
|
||||
*/
|
||||
template<typename T> static inline T min(const T a, const T b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum of two integer.
|
||||
*
|
||||
* This function returns the smaller value of two given integers.
|
||||
*
|
||||
* @param a The first integer
|
||||
* @param b The second integer
|
||||
* @return The smaller value
|
||||
*/
|
||||
static inline int min(const int a, const int b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum of two unsigned integers.
|
||||
*
|
||||
* This function returns the smaller value of two given unsigned integers.
|
||||
*
|
||||
* @param a The first unsigned integer
|
||||
* @param b The second unsigned integer
|
||||
* @return The smaller value
|
||||
*/
|
||||
static inline uint minu(const uint a, const uint b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute value of (scalar) variable.
|
||||
*
|
||||
* @note assumes variable to be signed
|
||||
* @param a The value we want to unsign
|
||||
* @return The unsigned value
|
||||
*/
|
||||
template <typename T> static inline T abs(const T a)
|
||||
{
|
||||
return (a < (T)0) ? -a : a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the smallest multiple of n equal or greater than x
|
||||
*
|
||||
* @note n must be a power of 2
|
||||
* @param x The min value
|
||||
* @param n The base of the number we are searching
|
||||
* @return The smallest multiple of n equal or greater than x
|
||||
*/
|
||||
template<typename T> static inline T Align(const T x, uint n)
|
||||
{
|
||||
n--;
|
||||
return (T)((x + n) & ~(n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp an integer between an interval.
|
||||
*
|
||||
* This function returns a value which is between the given interval of
|
||||
* min and max. If the given value is in this interval the value itself
|
||||
* is returned otherwise the border of the interval is returned, according
|
||||
* which side of the interval was 'left'.
|
||||
*
|
||||
* @note The min value must be less or equal of max or you get some
|
||||
* unexpected results.
|
||||
* @param a The value to clamp/truncate.
|
||||
* @param min The minimum of the interval.
|
||||
* @param max the maximum of the interval.
|
||||
* @returns A value between min and max which is closest to a.
|
||||
* @see ClampU(uint, uint, uint)
|
||||
*/
|
||||
static inline int Clamp(const int a, const int min, const int max)
|
||||
{
|
||||
if (a <= min) return min;
|
||||
if (a >= max) return max;
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp an unsigned integer between an interval.
|
||||
*
|
||||
* This function returns a value which is between the given interval of
|
||||
* min and max. If the given value is in this interval the value itself
|
||||
* is returned otherwise the border of the interval is returned, according
|
||||
* which side of the interval was 'left'.
|
||||
*
|
||||
* @note The min value must be less or equal of max or you get some
|
||||
* unexpected results.
|
||||
* @param a The value to clamp/truncate.
|
||||
* @param min The minimum of the interval.
|
||||
* @param max the maximum of the interval.
|
||||
* @returns A value between min and max which is closest to a.
|
||||
* @see Clamp(int, int, int)
|
||||
*/
|
||||
static inline uint ClampU(const uint a, const uint min, const uint max)
|
||||
{
|
||||
if (a <= min) return min;
|
||||
if (a >= max) return max;
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce a signed 64-bit int to a signed 32-bit one
|
||||
*
|
||||
* This function clamps a 64-bit integer to a 32-bit integer.
|
||||
* If the 64-bit value is smaller than the smallest 32-bit integer
|
||||
* value 0x80000000 this value is returned (the left one bit is the sign bit).
|
||||
* If the 64-bit value is greater than the greatest 32-bit integer value 0x7FFFFFFF
|
||||
* this value is returned. In all other cases the 64-bit value 'fits' in a
|
||||
* 32-bits integer field and so the value is casted to int32 and returned.
|
||||
*
|
||||
* @param a The 64-bit value to clamps
|
||||
* @return The 64-bit value reduced to a 32-bit value
|
||||
* @see Clamp(int, int, int)
|
||||
*/
|
||||
static inline int32 ClampToI32(const int64 a)
|
||||
{
|
||||
if (a <= (int32)0x80000000) return 0x80000000;
|
||||
if (a >= (int32)0x7FFFFFFF) return 0x7FFFFFFF;
|
||||
return (int32)a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the (absolute) difference between two (scalar) variables
|
||||
*
|
||||
* @param a The first scalar
|
||||
* @param b The second scalar
|
||||
* @return The absolute difference between the given scalars
|
||||
*/
|
||||
template <typename T> static inline T Delta(const T a, const T b) {
|
||||
return (a < b) ? b - a : a - b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a value is between a window started at some base point.
|
||||
*
|
||||
* This function checks if the value x is between the value of base
|
||||
* and base+size. If x equals base this returns true. If x equals
|
||||
* base+size this returns false.
|
||||
*
|
||||
* @param x The value to check
|
||||
* @param base The base value of the interval
|
||||
* @param size The size of the interval
|
||||
* @return True if the value is in the interval, false else.
|
||||
*/
|
||||
template<typename T> static inline bool IsInsideBS(const T x, const uint base, const uint size)
|
||||
{
|
||||
return (uint)(x - base) < size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a value is in an interval.
|
||||
*
|
||||
* Returns true if a value is in the interval of [min, max).
|
||||
*
|
||||
* @param a The value to check
|
||||
* @param min The minimum of the interval
|
||||
* @param max The maximum of the interval
|
||||
* @see IsInsideBS()
|
||||
*/
|
||||
template<typename T> static inline bool IsInsideMM(const T x, const uint min, const uint max)
|
||||
{
|
||||
return (uint)(x - min) < (max - min);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type safe swap operation
|
||||
* @param a variable to swap with b
|
||||
* @param b variable to swap with a
|
||||
*/
|
||||
template<typename T> void Swap(T& a, T& b)
|
||||
{
|
||||
T t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
#endif /* MATH_FUNC_HPP */
|
@@ -1,170 +1,11 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file helpers.hpp */
|
||||
/** @file overflowsafe_type.hpp An overflow safe integer-like type. */
|
||||
|
||||
#ifndef HELPERS_HPP
|
||||
#define HELPERS_HPP
|
||||
#ifndef OVERFLOWSAFE_TYPE_HPP
|
||||
#define OVERFLOWSAFE_TYPE_HPP
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
|
||||
* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
|
||||
template <typename T> FORCEINLINE T* MallocT(size_t num_elements)
|
||||
{
|
||||
T *t_ptr = (T*)malloc(num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
|
||||
* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
|
||||
template <typename T> FORCEINLINE T* CallocT(size_t num_elements)
|
||||
{
|
||||
T *t_ptr = (T*)calloc(num_elements, sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
/** When allocating using malloc/calloc in C++ it is usually needed to cast the return value
|
||||
* from void* to the proper pointer type. Another alternative would be MallocT<> as follows */
|
||||
template <typename T> FORCEINLINE T* ReallocT(T* t_ptr, size_t num_elements)
|
||||
{
|
||||
t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
|
||||
/** type safe swap operation */
|
||||
template<typename T> void Swap(T& a, T& b)
|
||||
{
|
||||
T t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
|
||||
/** returns the absolute value of (scalar) variable. @note assumes variable to be signed */
|
||||
template <typename T> static inline T myabs(T a) { return a < (T)0 ? -a : a; }
|
||||
/** returns the (absolute) difference between two (scalar) variables */
|
||||
template <typename T> static inline T delta(T a, T b) { return a < b ? b - a : a - b; }
|
||||
|
||||
/** Some enums need to have allowed incrementing (i.e. StationClassID) */
|
||||
#define DECLARE_POSTFIX_INCREMENT(type) \
|
||||
FORCEINLINE type operator ++(type& e, int) \
|
||||
{ \
|
||||
type e_org = e; \
|
||||
e = (type)((int)e + 1); \
|
||||
return e_org; \
|
||||
} \
|
||||
FORCEINLINE type operator --(type& e, int) \
|
||||
{ \
|
||||
type e_org = e; \
|
||||
e = (type)((int)e - 1); \
|
||||
return e_org; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Operators to allow to work with enum as with type safe bit set in C++ */
|
||||
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \
|
||||
FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \
|
||||
FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \
|
||||
FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \
|
||||
FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \
|
||||
FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \
|
||||
FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \
|
||||
FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);}
|
||||
|
||||
|
||||
/** Informative template class exposing basic enumeration properties used by several
|
||||
* other templates below. Here we have only forward declaration. For each enum type
|
||||
* we will create specialization derived from MakeEnumPropsT<>.
|
||||
* i.e.:
|
||||
* template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {};
|
||||
* followed by:
|
||||
* typedef TinyEnumT<Track> TrackByte;
|
||||
*/
|
||||
template <typename Tenum_t> struct EnumPropsT;
|
||||
|
||||
/** Helper template class that makes basic properties of given enumeration type visible
|
||||
* from outsize. It is used as base class of several EnumPropsT specializations each
|
||||
* dedicated to one of commonly used enumeration types.
|
||||
* @param Tenum_t enumeration type that you want to describe
|
||||
* @param Tstorage_t what storage type would be sufficient (i.e. byte)
|
||||
* @param Tbegin first valid value from the contiguous range (i.e. TRACK_BEGIN)
|
||||
* @param Tend one past the last valid value from the contiguous range (i.e. TRACK_END)
|
||||
* @param Tinvalid value used as invalid value marker (i.e. INVALID_TRACK)
|
||||
*/
|
||||
template <typename Tenum_t, typename Tstorage_t, Tenum_t Tbegin, Tenum_t Tend, Tenum_t Tinvalid>
|
||||
struct MakeEnumPropsT {
|
||||
typedef Tenum_t type; ///< enum type (i.e. Trackdir)
|
||||
typedef Tstorage_t storage; ///< storage type (i.e. byte)
|
||||
static const Tenum_t begin = Tbegin; ///< lowest valid value (i.e. TRACKDIR_BEGIN)
|
||||
static const Tenum_t end = Tend; ///< one after the last valid value (i.e. TRACKDIR_END)
|
||||
static const Tenum_t invalid = Tinvalid; ///< what value is used as invalid value (i.e. INVALID_TRACKDIR)
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** In some cases we use byte or uint16 to store values that are defined as enum. It is
|
||||
* necessary in order to control the sizeof() such values. Some compilers make enum
|
||||
* the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
|
||||
* compiler type-checking causes errors like:
|
||||
* 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
|
||||
* u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
|
||||
* to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
|
||||
template <typename Tenum_t> struct TinyEnumT;
|
||||
|
||||
/** The general declaration of TinyEnumT<> (above) */
|
||||
template <typename Tenum_t> struct TinyEnumT
|
||||
{
|
||||
typedef Tenum_t enum_type; ///< expose our enumeration type (i.e. Trackdir) to outside
|
||||
typedef EnumPropsT<Tenum_t> Props; ///< make easier access to our enumeration propeties
|
||||
typedef typename Props::storage storage_type; ///< small storage type
|
||||
static const enum_type begin = Props::begin; ///< enum beginning (i.e. TRACKDIR_BEGIN)
|
||||
static const enum_type end = Props::end; ///< enum end (i.e. TRACKDIR_END)
|
||||
static const enum_type invalid = Props::invalid;///< invalid value (i.e. INVALID_TRACKDIR)
|
||||
|
||||
storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form
|
||||
|
||||
/** Cast operator - invoked then the value is assigned to the Tenum_t type */
|
||||
FORCEINLINE operator enum_type () const
|
||||
{
|
||||
return (enum_type)m_val;
|
||||
}
|
||||
|
||||
/** Assignment operator (from Tenum_t type) */
|
||||
FORCEINLINE TinyEnumT& operator = (enum_type e)
|
||||
{
|
||||
m_val = (storage_type)e; return *this;
|
||||
}
|
||||
|
||||
/** postfix ++ operator on tiny type */
|
||||
FORCEINLINE TinyEnumT operator ++ (int)
|
||||
{
|
||||
TinyEnumT org = *this;
|
||||
if (++m_val >= end) m_val -= (storage_type)(end - begin);
|
||||
return org;
|
||||
}
|
||||
|
||||
/** prefix ++ operator on tiny type */
|
||||
FORCEINLINE TinyEnumT& operator ++ ()
|
||||
{
|
||||
if (++m_val >= end) m_val -= (storage_type)(end - begin);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> void ClrBitT(T &t, int bit_index)
|
||||
{
|
||||
t = (T)(t & ~((T)1 << bit_index));
|
||||
}
|
||||
|
||||
template <typename T> void SetBitT(T &t, int bit_index)
|
||||
{
|
||||
t = (T)(t | ((T)1 << bit_index));
|
||||
}
|
||||
|
||||
template <typename T> void ToggleBitT(T &t, int bit_index)
|
||||
{
|
||||
t = (T)(t ^ ((T)1 << bit_index));
|
||||
}
|
||||
#include "math_func.hpp"
|
||||
|
||||
/**
|
||||
* Overflow safe template for integers, i.e. integers that will never overflow
|
||||
@@ -198,7 +39,7 @@ public:
|
||||
*/
|
||||
FORCEINLINE OverflowSafeInt& operator += (const OverflowSafeInt& other)
|
||||
{
|
||||
if ((T_MAX - myabs(other.m_value)) < myabs(this->m_value) &&
|
||||
if ((T_MAX - abs(other.m_value)) < abs(this->m_value) &&
|
||||
(this->m_value < 0) == (other.m_value < 0)) {
|
||||
this->m_value = (this->m_value < 0) ? T_MIN : T_MAX ;
|
||||
} else {
|
||||
@@ -229,7 +70,7 @@ public:
|
||||
*/
|
||||
FORCEINLINE OverflowSafeInt& operator *= (const int factor)
|
||||
{
|
||||
if (factor != 0 && (T_MAX / myabs(factor)) < myabs(this->m_value)) {
|
||||
if (factor != 0 && (T_MAX / abs(factor)) < abs(this->m_value)) {
|
||||
this->m_value = ((this->m_value < 0) == (factor < 0)) ? T_MAX : T_MIN ;
|
||||
} else {
|
||||
this->m_value *= factor ;
|
||||
@@ -303,4 +144,6 @@ template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MA
|
||||
template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; }
|
||||
template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; }
|
||||
|
||||
#endif /* HELPERS_HPP */
|
||||
typedef OverflowSafeInt<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
|
||||
|
||||
#endif /* OVERFLOWSAFE_TYPE_HPP */
|
156
src/core/random_func.cpp
Normal file
156
src/core/random_func.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file random_func.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "random_func.hpp"
|
||||
#include "bitmath_func.hpp"
|
||||
|
||||
uint32 _random_seeds[2][2];
|
||||
|
||||
uint32 InteractiveRandom()
|
||||
{
|
||||
const uint32 s = _random_seeds[1][0];
|
||||
const uint32 t = _random_seeds[1][1];
|
||||
|
||||
_random_seeds[1][0] = s + ROR(t ^ 0x1234567F, 7) + 1;
|
||||
return _random_seeds[1][1] = ROR(s, 3) - 1;
|
||||
}
|
||||
|
||||
uint InteractiveRandomRange(uint max)
|
||||
{
|
||||
return GB(InteractiveRandom(), 0, 16) * max >> 16;
|
||||
}
|
||||
|
||||
#ifdef MERSENNE_TWISTER
|
||||
// Source code for Mersenne Twister.
|
||||
// A Random number generator with much higher quality random numbers.
|
||||
|
||||
#define N (624) // length of _mt_state vector
|
||||
#define M (397) // a period parameter
|
||||
#define K (0x9908B0DFU) // a magic constant
|
||||
#define hiBit(u) ((u) & 0x80000000U) // mask all but highest bit of u
|
||||
#define loBit(u) ((u) & 0x00000001U) // mask all but lowest bit of u
|
||||
#define loBits(u) ((u) & 0x7FFFFFFFU) // mask the highest bit of u
|
||||
#define mixBits(u, v) (hiBit(u)|loBits(v)) // move hi bit of u to hi bit of v
|
||||
|
||||
static uint32 _mt_state[N+1]; // _mt_state vector + 1 extra to not violate ANSI C
|
||||
static uint32 *_mt_next; // _mt_next random value is computed from here
|
||||
static int _mt_left = -1; // can *_mt_next++ this many times before reloading
|
||||
|
||||
void SetRandomSeed(register uint32 seed)
|
||||
{
|
||||
register uint32 *s = _mt_state;
|
||||
_mt_left = 0;
|
||||
|
||||
seed |= 1U;
|
||||
seed &= 0xFFFFFFFFU;
|
||||
|
||||
*s = seed;
|
||||
|
||||
for (register uint i = N; i != 0; i--) {
|
||||
seed *= 69069U;
|
||||
*s++;
|
||||
*s = seed & 0xFFFFFFFFU;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32 ReloadRandom()
|
||||
{
|
||||
if (_mt_left < -1) SetRandomSeed(4357U);
|
||||
|
||||
_mt_left = N - 1;
|
||||
_mt_next = _mt_state + 1;
|
||||
|
||||
register uint32 *p0 = _mt_state;
|
||||
register uint32 *p2 = _mt_state + 2;
|
||||
register uint32 *pM = _mt_state + M;
|
||||
|
||||
register uint32 s0 = _mt_state[0];
|
||||
register uint32 s1 = _mt_state[1];
|
||||
|
||||
register uint i = 0;
|
||||
|
||||
for (i = (N - M + 1); i != 0; i--) {
|
||||
s0 = s1;
|
||||
s1 = *p2;
|
||||
*p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
|
||||
*p0++;
|
||||
*p2++;
|
||||
*pM++;
|
||||
}
|
||||
|
||||
pM = _mt_state;
|
||||
|
||||
for (i = M; i != 0; i--) {
|
||||
s0 = s1;
|
||||
s1 = *p2;
|
||||
*p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
|
||||
*p0++;
|
||||
*p2++;
|
||||
*pM++;
|
||||
}
|
||||
|
||||
s1 = _mt_state[0];
|
||||
*p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
|
||||
|
||||
s1 ^= (s1 >> 11);
|
||||
s1 ^= (s1 << 7) & 0x9D2C5680U;
|
||||
s1 ^= (s1 << 15) & 0xEFC60000U;
|
||||
s1 ^= (s1 >> 18);
|
||||
return s1;
|
||||
}
|
||||
|
||||
uint32 Random()
|
||||
{
|
||||
_mt_left--;
|
||||
if (_mt_left < 0) return ReloadRandom();
|
||||
|
||||
uint32 y = *_mt_next;
|
||||
*_mt_next++;
|
||||
|
||||
y ^= (y >> 11);
|
||||
y ^= (y << 7) & 0x9D2C5680U;
|
||||
y ^= (y << 15) & 0xEFC60000U;
|
||||
y ^= (y >> 18);
|
||||
return y;
|
||||
}
|
||||
|
||||
#else /* MERSENNE_TWISTER */
|
||||
void SetRandomSeed(uint32 seed)
|
||||
{
|
||||
_random_seeds[0][0] = seed;
|
||||
_random_seeds[0][1] = seed;
|
||||
_random_seeds[1][0] = seed * 0x1234567;
|
||||
_random_seeds[1][1] = _random_seeds[1][0];
|
||||
}
|
||||
|
||||
#ifdef RANDOM_DEBUG
|
||||
#include "../network/network_data.h"
|
||||
uint32 DoRandom(int line, const char *file)
|
||||
{
|
||||
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server))
|
||||
printf("Random [%d/%d] %s:%d\n",_frame_counter, (byte)_current_player, file, line);
|
||||
#else /* RANDOM_DEBUG */
|
||||
uint32 Random()
|
||||
{
|
||||
#endif /* RANDOM_DEBUG */
|
||||
const uint32 s = _random_seeds[0][0];
|
||||
const uint32 t = _random_seeds[0][1];
|
||||
|
||||
_random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7) + 1;
|
||||
return _random_seeds[0][1] = ROR(s, 3) - 1;
|
||||
}
|
||||
#endif /* MERSENNE_TWISTER */
|
||||
|
||||
#if defined(RANDOM_DEBUG) && !defined(MERSENNE_TWISTER)
|
||||
uint DoRandomRange(uint max, int line, const char *file)
|
||||
{
|
||||
return GB(DoRandom(line, file), 0, 16) * max >> 16;
|
||||
}
|
||||
#else /* RANDOM_DEBUG & !MERSENNE_TWISTER */
|
||||
uint RandomRange(uint max)
|
||||
{
|
||||
return GB(Random(), 0, 16) * max >> 16;
|
||||
}
|
||||
#endif /* RANDOM_DEBUG & !MERSENNE_TWISTER */
|
105
src/core/random_func.hpp
Normal file
105
src/core/random_func.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file random_func.h */
|
||||
|
||||
#ifndef RANDOM_FUNC_HPP
|
||||
#define RANDOM_FUNC_HPP
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* Apple already has Random declared */
|
||||
#define Random OTTD_Random
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
/**************
|
||||
* Warning: DO NOT enable this unless you understand what it does
|
||||
*
|
||||
* If enabled, in a network game all randoms will be dumped to the
|
||||
* stdout if the first client joins (or if you are a client). This
|
||||
* is to help finding desync problems.
|
||||
*
|
||||
* Warning: DO NOT enable this unless you understand what it does
|
||||
**************/
|
||||
|
||||
//#define RANDOM_DEBUG
|
||||
|
||||
|
||||
// Enable this to produce higher quality random numbers.
|
||||
// Doesn't work with network yet.
|
||||
// #define MERSENNE_TWISTER
|
||||
|
||||
void SetRandomSeed(uint32 seed);
|
||||
#ifdef RANDOM_DEBUG
|
||||
#define Random() DoRandom(__LINE__, __FILE__)
|
||||
uint32 DoRandom(int line, const char *file);
|
||||
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
|
||||
uint DoRandomRange(uint max, int line, const char *file);
|
||||
#else
|
||||
uint32 Random();
|
||||
uint RandomRange(uint max);
|
||||
#endif
|
||||
|
||||
uint32 InteractiveRandom(); // Used for random sequences that are not the same on the other end of the multiplayer link
|
||||
uint InteractiveRandomRange(uint max);
|
||||
|
||||
/**
|
||||
* Checks if a given randomize-number is below a given probability.
|
||||
*
|
||||
* This function is used to check if the given probability by the fraction of (a/b)
|
||||
* is greater than low 16 bits of the given randomize-number v.
|
||||
*
|
||||
* Do not use this function twice on the same random 16 bits as it will yield
|
||||
* the same result. One can use a random number for two calls to Chance16I,
|
||||
* where one call sends the low 16 bits and the other the high 16 bits.
|
||||
*
|
||||
* @param a The numerator of the fraction
|
||||
* @param b The denominator of the fraction, must of course not be null
|
||||
* @param r The given randomize-number
|
||||
* @return True if v is less or equals (a/b)
|
||||
*/
|
||||
static inline bool Chance16I(const uint a, const uint b, const uint32 r)
|
||||
{
|
||||
assert(b != 0);
|
||||
return (uint16)r < (uint16)((a << 16) / b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips a coin with a given probability.
|
||||
*
|
||||
* This macro can be used to get true or false randomized according to a
|
||||
* given probability. The parameter a and b create a percent value with
|
||||
* (a/b). The macro returns true in (a/b) percent.
|
||||
*
|
||||
* @see Chance16I()
|
||||
* @param a The numerator of the fraction
|
||||
* @param b The denominator of the fraction
|
||||
* @return True in (a/b) percent
|
||||
*/
|
||||
static inline bool Chance16(const uint a, const uint b)
|
||||
{
|
||||
return Chance16I(a, b, Random());
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips a coin with a given probability and saves the randomize-number in a variable.
|
||||
*
|
||||
* This function uses the same parameters as Chance16. The third parameter
|
||||
* must be a variable the randomize-number from Random() is saved in.
|
||||
*
|
||||
* The low 16 bits of r will already be used and can therefor not be passed to
|
||||
* Chance16I. One can only send the high 16 bits to Chance16I.
|
||||
*
|
||||
* @see Chance16I()
|
||||
* @param a The numerator of the fraction
|
||||
* @param b The denominator of the fraction
|
||||
* @param r The variable to save the randomize-number from Random()
|
||||
* @return True in (a/b) percent
|
||||
*/
|
||||
static inline bool Chance16R(const uint a, const uint b, uint32 &r)
|
||||
{
|
||||
r = Random();
|
||||
return Chance16I(a, b, r);
|
||||
}
|
||||
|
||||
extern uint32 _random_seeds[2][2];
|
||||
|
||||
#endif /* RANDOM_FUNC_HPP */
|
@@ -6,9 +6,10 @@
|
||||
#include "openttd.h"
|
||||
#include "currency.h"
|
||||
#include "news.h"
|
||||
#include "variables.h"
|
||||
#include "settings_type.h"
|
||||
#include "date_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
#include "date.h"
|
||||
|
||||
// exchange rate prefix symbol_pos
|
||||
// | separator | postfix |
|
||||
|
@@ -5,6 +5,9 @@
|
||||
#ifndef CURRENCY_H
|
||||
#define CURRENCY_H
|
||||
|
||||
#include "date_type.h"
|
||||
#include "strings_type.h"
|
||||
|
||||
enum {
|
||||
CF_NOEURO = 0,
|
||||
CF_ISEURO = 1,
|
||||
|
12
src/date.cpp
12
src/date.cpp
@@ -4,15 +4,17 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "date.h"
|
||||
#include "variables.h"
|
||||
#include "macros.h"
|
||||
#include "vehicle.h"
|
||||
#include "settings_type.h"
|
||||
#include "network/network.h"
|
||||
#include "network/network_data.h"
|
||||
#include "network/network_server.h"
|
||||
#include "functions.h"
|
||||
#include "currency.h"
|
||||
#include "window_func.h"
|
||||
#include "functions.h"
|
||||
#include "date_func.h"
|
||||
#include "vehicle_base.h"
|
||||
#include "debug.h"
|
||||
#ifdef DEBUG_DUMP_COMMANDS
|
||||
#include "saveload.h"
|
||||
#endif
|
||||
@@ -270,7 +272,7 @@ void IncreaseDate()
|
||||
char name[MAX_PATH];
|
||||
snprintf(name, lengthof(name), "dmp_cmds_%d.sav", _date);
|
||||
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
|
||||
debug_dump_commands("ddc:save:%s\n", name);
|
||||
DebugDumpCommands("ddc:save:%s\n", name);
|
||||
#endif /* DUMP_COMMANDS */
|
||||
if (_opt.autosave != 0 && (_cur_month % _autosave_months[_opt.autosave]) == 0) {
|
||||
_do_autosave = true;
|
||||
|
19
src/date_func.h
Normal file
19
src/date_func.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file date_func.h Functions related to dates. */
|
||||
|
||||
#ifndef DATE_FUNC_H
|
||||
#define DATE_FUNC_H
|
||||
|
||||
#include "date_type.h"
|
||||
|
||||
extern Year _cur_year;
|
||||
extern Month _cur_month;
|
||||
extern Date _date;
|
||||
extern DateFract _date_fract;
|
||||
|
||||
void SetDate(Date date);
|
||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||
|
||||
#endif /* DATE_FUNC_H */
|
@@ -1,11 +1,9 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file date.h */
|
||||
/** @file date_type.h Types related to the dates in OpenTTD. */
|
||||
|
||||
#ifndef DATE_H
|
||||
#define DATE_H
|
||||
|
||||
#include "openttd.h"
|
||||
#ifndef DATE_TYPE_H
|
||||
#define DATE_TYPE_H
|
||||
|
||||
/**
|
||||
* 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On
|
||||
@@ -39,10 +37,12 @@
|
||||
* be encoded in a single 32 bits date, about 2^31 / 366 years. */
|
||||
#define MAX_YEAR 5000000
|
||||
|
||||
/* Year and Date are defined elsewhere */
|
||||
typedef int32 Date;
|
||||
typedef uint16 DateFract;
|
||||
|
||||
typedef int32 Year;
|
||||
typedef uint8 Month;
|
||||
typedef uint8 Day;
|
||||
typedef uint16 DateFract;
|
||||
|
||||
struct YearMonthDay {
|
||||
Year year;
|
||||
@@ -50,14 +50,7 @@ struct YearMonthDay {
|
||||
Day day;
|
||||
};
|
||||
|
||||
extern Year _cur_year;
|
||||
extern Month _cur_month;
|
||||
extern Date _date;
|
||||
extern DateFract _date_fract;
|
||||
static const Year INVALID_YEAR = -1;
|
||||
static const Date INVALID_DATE = -1;
|
||||
|
||||
|
||||
void SetDate(Date date);
|
||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||
|
||||
#endif /* DATE_H */
|
||||
#endif /* DATE_TYPE_H */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user