mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-21 01:59:44 +00:00
Compare commits
253 Commits
| 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 |
@@ -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)
|
||||
|
||||
+1
-1
@@ -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 "----------------"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,49 @@
|
||||
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)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
+214
-52
@@ -5,7 +5,7 @@ log() {
|
||||
}
|
||||
|
||||
set_default() {
|
||||
released_version="0.6.0-beta2"
|
||||
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() {
|
||||
@@ -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"
|
||||
|
||||
@@ -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 $?
|
||||
|
||||
+4
-7
@@ -11,21 +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
|
||||
|
||||
- 1519 Full screen issues in windows
|
||||
- 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
|
||||
- 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
|
||||
- 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,12 @@ 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.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
!define APPNAME "OpenTTD" ; Define application name
|
||||
!define APPVERSION "0.6.0" ; Define application version
|
||||
!define INSTALLERVERSION 40 ; 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"
|
||||
|
||||
@@ -194,7 +194,7 @@ Function IsCachedVersion(version)
|
||||
End Function
|
||||
|
||||
Dim version
|
||||
version = "0.6.0-beta2"
|
||||
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
|
||||
|
||||
+13
-13
@@ -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
|
||||
|
||||
+15
-15
@@ -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"
|
||||
>
|
||||
|
||||
+15
-15
@@ -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"
|
||||
>
|
||||
|
||||
+25
-7
@@ -344,6 +344,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\settings.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signs.cpp">
|
||||
</File>
|
||||
@@ -372,7 +375,7 @@
|
||||
RelativePath=".\..\src\thread.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tile.cpp">
|
||||
RelativePath=".\..\src\tile_map.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\vehicle.cpp">
|
||||
@@ -386,6 +389,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\widget.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\win32.cpp">
|
||||
</File>
|
||||
@@ -498,9 +504,6 @@
|
||||
<File
|
||||
RelativePath=".\..\src\heightmap.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\helpers.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\industry.h">
|
||||
</File>
|
||||
@@ -510,9 +513,6 @@
|
||||
<File
|
||||
RelativePath=".\..\src\livery.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\macros.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\map.h">
|
||||
</File>
|
||||
@@ -654,6 +654,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\signs.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal_func.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\slope.h">
|
||||
</File>
|
||||
@@ -732,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>
|
||||
@@ -890,6 +902,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\station_cmd.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\terraform_cmd.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\timetable_cmd.cpp">
|
||||
</File>
|
||||
@@ -1197,6 +1212,9 @@
|
||||
<File
|
||||
RelativePath=".\..\src\tunnel_map.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tunnelbridge_map.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\unmovable_map.h">
|
||||
</File>
|
||||
|
||||
@@ -691,6 +691,10 @@
|
||||
RelativePath=".\..\src\settings.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signs.cpp"
|
||||
>
|
||||
@@ -728,7 +732,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tile.cpp"
|
||||
RelativePath=".\..\src\tile_map.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -747,6 +751,10 @@
|
||||
RelativePath=".\..\src\widget.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\win32.cpp"
|
||||
>
|
||||
@@ -895,10 +903,6 @@
|
||||
RelativePath=".\..\src\heightmap.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\helpers.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\industry.h"
|
||||
>
|
||||
@@ -911,10 +915,6 @@
|
||||
RelativePath=".\..\src\livery.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\macros.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\map.h"
|
||||
>
|
||||
@@ -1103,6 +1103,10 @@
|
||||
RelativePath=".\..\src\signs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal_func.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\slope.h"
|
||||
>
|
||||
@@ -1207,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"
|
||||
>
|
||||
@@ -1415,6 +1431,10 @@
|
||||
RelativePath=".\..\src\station_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\terraform_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\timetable_cmd.cpp"
|
||||
>
|
||||
@@ -1815,6 +1835,10 @@
|
||||
RelativePath=".\..\src\tunnel_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tunnelbridge_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\unmovable_map.h"
|
||||
>
|
||||
|
||||
@@ -688,6 +688,10 @@
|
||||
RelativePath=".\..\src\settings.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signs.cpp"
|
||||
>
|
||||
@@ -725,7 +729,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tile.cpp"
|
||||
RelativePath=".\..\src\tile_map.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -744,6 +748,10 @@
|
||||
RelativePath=".\..\src\widget.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\widgets\dropdown.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\win32.cpp"
|
||||
>
|
||||
@@ -892,10 +900,6 @@
|
||||
RelativePath=".\..\src\heightmap.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\helpers.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\industry.h"
|
||||
>
|
||||
@@ -908,10 +912,6 @@
|
||||
RelativePath=".\..\src\livery.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\macros.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\map.h"
|
||||
>
|
||||
@@ -1100,6 +1100,10 @@
|
||||
RelativePath=".\..\src\signs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\signal_func.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\slope.h"
|
||||
>
|
||||
@@ -1204,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"
|
||||
>
|
||||
@@ -1412,6 +1428,10 @@
|
||||
RelativePath=".\..\src\station_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\terraform_cmd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\timetable_cmd.cpp"
|
||||
>
|
||||
@@ -1812,6 +1832,10 @@
|
||||
RelativePath=".\..\src\tunnel_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\tunnelbridge_map.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\unmovable_map.h"
|
||||
>
|
||||
|
||||
+20
-15
@@ -1,6 +1,6 @@
|
||||
OpenTTD README
|
||||
Last updated: 2007-12-09
|
||||
Release version: 0.6.0-beta2
|
||||
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
|
||||
|
||||
+9
-3
@@ -66,6 +66,7 @@ screenshot.cpp
|
||||
sdl.cpp
|
||||
#end
|
||||
settings.cpp
|
||||
signal.cpp
|
||||
signs.cpp
|
||||
sound.cpp
|
||||
spritecache.cpp
|
||||
@@ -75,7 +76,7 @@ strings.cpp
|
||||
texteff.cpp
|
||||
tgp.cpp
|
||||
thread.cpp
|
||||
tile.cpp
|
||||
tile_map.cpp
|
||||
#if WIN32
|
||||
#else
|
||||
#if WINCE
|
||||
@@ -92,6 +93,7 @@ vehicle.cpp
|
||||
viewport.cpp
|
||||
waypoint.cpp
|
||||
widget.cpp
|
||||
widgets/dropdown.cpp
|
||||
#if WIN32
|
||||
win32.cpp
|
||||
#end
|
||||
@@ -132,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
|
||||
@@ -184,6 +184,7 @@ sound/sdl_s.h
|
||||
video/sdl_v.h
|
||||
settings.h
|
||||
signs.h
|
||||
signal_func.h
|
||||
slope.h
|
||||
sound.h
|
||||
sprite.h
|
||||
@@ -210,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
|
||||
@@ -264,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
|
||||
@@ -373,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
|
||||
|
||||
+10
-9
@@ -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);
|
||||
}
|
||||
|
||||
+8
-6
@@ -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);
|
||||
|
||||
+768
-694
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
|
||||
|
||||
+19
-19
@@ -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,7 +246,7 @@ 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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -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;
|
||||
}
|
||||
|
||||
+320
-316
File diff suppressed because it is too large
Load Diff
+79
-1
@@ -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 */
|
||||
|
||||
+1
-2
@@ -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 {
|
||||
|
||||
+33
-34
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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,13 +642,12 @@ 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)) {
|
||||
@@ -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);
|
||||
@@ -1348,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++;
|
||||
|
||||
+6
-11
@@ -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)
|
||||
|
||||
+4
-5
@@ -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
|
||||
|
||||
+2
-1
@@ -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};
|
||||
|
||||
+13
-10
@@ -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;
|
||||
|
||||
|
||||
@@ -4,15 +4,13 @@
|
||||
|
||||
#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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 */
|
||||
+14
-18
@@ -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);
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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 */
|
||||
+22
-7
@@ -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()
|
||||
{
|
||||
@@ -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];
|
||||
|
||||
@@ -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 */
|
||||
@@ -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.
|
||||
|
||||
+1
-1
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-4
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 */
|
||||
|
||||
+11
-9
@@ -4,18 +4,20 @@
|
||||
|
||||
#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;
|
||||
|
||||
+4
-3
@@ -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);
|
||||
|
||||
+2
-60
@@ -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"
|
||||
|
||||
|
||||
/**
|
||||
@@ -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
|
||||
@@ -187,7 +130,6 @@ static inline void ClearSingleBridgeMiddle(TileIndex t, Axis 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
|
||||
|
||||
+113
-23
@@ -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,14 +808,12 @@ 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;
|
||||
EngList_Add(&bv->eng_list, 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -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;
|
||||
|
||||
|
||||
+11
-457
@@ -5,442 +5,23 @@
|
||||
#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.clear_roughland * 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)
|
||||
{
|
||||
@@ -452,7 +33,7 @@ static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
|
||||
&_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)]);
|
||||
@@ -463,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.clear_roughland * 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);
|
||||
|
||||
+1
-2
@@ -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
-4
@@ -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;
|
||||
|
||||
+27
-16
@@ -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,9 +618,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
|
||||
return true;
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
#ifdef DEBUG_DUMP_COMMANDS
|
||||
debug_dump_commands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_player, tile, p1, p2, cmd, _cmd_text);
|
||||
#endif /* DUMP_COMMANDS */
|
||||
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)) {
|
||||
@@ -620,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
|
||||
@@ -695,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;
|
||||
|
||||
@@ -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 */
|
||||
+21
-7
@@ -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];
|
||||
|
||||
+11
-9
@@ -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();
|
||||
|
||||
+20
-19
@@ -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 */
|
||||
@@ -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;
|
||||
@@ -1654,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 */
|
||||
|
||||
|
||||
@@ -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 */
|
||||
@@ -45,7 +45,7 @@ uint8 FindFirstBit(uint32 x)
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the last set bit in a 32 bit variable.
|
||||
* 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
|
||||
@@ -55,17 +55,18 @@ uint8 FindFirstBit(uint32 x)
|
||||
* @param x The value to search
|
||||
* @return The position of the last bit set
|
||||
*/
|
||||
uint8 FindLastBit(uint32 x)
|
||||
uint8 FindLastBit(uint64 x)
|
||||
{
|
||||
if (x == 0) return 0;
|
||||
|
||||
uint8 pos = 0;
|
||||
|
||||
if ((x & 0xffff0000) != 0) { x >>= 16; pos += 16; }
|
||||
if ((x & 0x0000ff00) != 0) { x >>= 8; pos += 8; }
|
||||
if ((x & 0x000000f0) != 0) { x >>= 4; pos += 4; }
|
||||
if ((x & 0x0000000c) != 0) { x >>= 2; pos += 2; }
|
||||
if ((x & 0x00000002) != 0) { pos += 1; }
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ static inline uint8 FindFirstBit2x64(const int value)
|
||||
}
|
||||
|
||||
uint8 FindFirstBit(uint32 x);
|
||||
uint8 FindLastBit(uint32 x);
|
||||
uint8 FindLastBit(uint64 x);
|
||||
|
||||
/**
|
||||
* Clear the first bit in an integer.
|
||||
@@ -276,4 +276,49 @@ 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 */
|
||||
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
+14
-2
@@ -1,6 +1,6 @@
|
||||
/* $Id */
|
||||
/* $Id$ */
|
||||
|
||||
/** @file math_func.hpp */
|
||||
/** @file math_func.hpp Integer math functions */
|
||||
|
||||
#ifndef MATH_FUNC_HPP
|
||||
#define MATH_FUNC_HPP
|
||||
@@ -211,4 +211,16 @@ template<typename T> static inline bool IsInsideMM(const T x, const uint min, co
|
||||
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,153 +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));
|
||||
if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot allocate %i bytes", 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));
|
||||
if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot allocate %i bytes", 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));
|
||||
if (t_ptr == NULL && num_elements != 0) error("Out of memory. Cannot reallocate %i bytes", 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;
|
||||
}
|
||||
|
||||
|
||||
/** 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;
|
||||
}
|
||||
};
|
||||
#include "math_func.hpp"
|
||||
|
||||
/**
|
||||
* Overflow safe template for integers, i.e. integers that will never overflow
|
||||
@@ -286,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 */
|
||||
@@ -3,9 +3,10 @@
|
||||
/** @file random_func.cpp */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../macros.h"
|
||||
#include "../variables.h"
|
||||
#include "random_func.hpp"
|
||||
#include "bitmath_func.hpp"
|
||||
|
||||
uint32 _random_seeds[2][2];
|
||||
|
||||
uint32 InteractiveRandom()
|
||||
{
|
||||
@@ -125,7 +126,7 @@ void SetRandomSeed(uint32 seed)
|
||||
}
|
||||
|
||||
#ifdef RANDOM_DEBUG
|
||||
#include "network/network_data.h"
|
||||
#include "../network/network_data.h"
|
||||
uint32 DoRandom(int line, const char *file)
|
||||
{
|
||||
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server))
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#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
|
||||
*
|
||||
@@ -95,4 +100,6 @@ static inline bool Chance16R(const uint a, const uint b, uint32 &r)
|
||||
return Chance16I(a, b, r);
|
||||
}
|
||||
|
||||
extern uint32 _random_seeds[2][2];
|
||||
|
||||
#endif /* RANDOM_FUNC_HPP */
|
||||
|
||||
+3
-2
@@ -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,
|
||||
|
||||
+7
-5
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
+19
-3
@@ -8,8 +8,7 @@
|
||||
#include "openttd.h"
|
||||
#include "console.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "string.h"
|
||||
#include "string_func.h"
|
||||
#include "network/core/core.h"
|
||||
|
||||
#if defined(ENABLE_NETWORK)
|
||||
@@ -163,7 +162,7 @@ void SetDebugString(const char *s)
|
||||
const char *GetDebugString()
|
||||
{
|
||||
const DebugLevel *i;
|
||||
static char dbgstr[100];
|
||||
static char dbgstr[150];
|
||||
char dbgval[20];
|
||||
|
||||
memset(dbgstr, 0, sizeof(dbgstr));
|
||||
@@ -177,3 +176,20 @@ const char *GetDebugString()
|
||||
|
||||
return dbgstr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DUMP_COMMANDS
|
||||
#include "fileio.h"
|
||||
|
||||
void CDECL DebugDumpCommands(const char *s, ...)
|
||||
{
|
||||
static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
|
||||
if (f == NULL) return;
|
||||
|
||||
va_list va;
|
||||
va_start(va, s);
|
||||
vfprintf(f, s, va);
|
||||
va_end(va);
|
||||
|
||||
fflush(f);
|
||||
}
|
||||
#endif /* DEBUG_DUMP_COMMANDS */
|
||||
|
||||
@@ -129,4 +129,13 @@ const char *GetDebugString();
|
||||
}\
|
||||
}
|
||||
|
||||
void ShowInfo(const char *str);
|
||||
void CDECL ShowInfoF(const char *str, ...);
|
||||
|
||||
#ifdef DEBUG_DUMP_COMMANDS
|
||||
void CDECL DebugDumpCommands(const char *s, ...);
|
||||
#else /* DEBUG_DUMP_COMMANDS */
|
||||
static inline void DebugDumpCommands(const char *s, ...) {}
|
||||
#endif /* DEBUG_DUMP_COMMANDS */
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
|
||||
+3
-5
@@ -4,15 +4,13 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "vehicle.h"
|
||||
#include "depot.h"
|
||||
#include "functions.h"
|
||||
#include "landscape.h"
|
||||
#include "tile.h"
|
||||
#include "map.h"
|
||||
#include "table/strings.h"
|
||||
#include "saveload.h"
|
||||
#include "order.h"
|
||||
#include "window_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
DEFINE_OLD_POOL_GENERIC(Depot, Depot)
|
||||
|
||||
|
||||
+1
-20
@@ -5,10 +5,8 @@
|
||||
#ifndef DEPOT_H
|
||||
#define DEPOT_H
|
||||
|
||||
#include "direction.h"
|
||||
#include "direction_type.h"
|
||||
#include "oldpool.h"
|
||||
#include "tile.h"
|
||||
#include "variables.h"
|
||||
#include "road_map.h"
|
||||
#include "rail_map.h"
|
||||
#include "water_map.h"
|
||||
@@ -37,23 +35,6 @@ void ShowDepotWindow(TileIndex tile, VehicleType type);
|
||||
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
|
||||
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
|
||||
|
||||
#define MIN_SERVINT_PERCENT 5
|
||||
#define MAX_SERVINT_PERCENT 90
|
||||
#define MIN_SERVINT_DAYS 30
|
||||
#define MAX_SERVINT_DAYS 800
|
||||
|
||||
/**
|
||||
* Get the service interval domain.
|
||||
* Get the new proposed service interval for the vehicle is indeed, clamped
|
||||
* within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
|
||||
* @param index proposed service interval
|
||||
* @return service interval
|
||||
*/
|
||||
static inline Date GetServiceIntervalClamped(uint index)
|
||||
{
|
||||
return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a tile is a depot of the given type.
|
||||
*/
|
||||
|
||||
+15
-12
@@ -4,24 +4,27 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "functions.h"
|
||||
#include "train.h"
|
||||
#include "roadveh.h"
|
||||
#include "ship.h"
|
||||
#include "aircraft.h"
|
||||
#include "table/strings.h"
|
||||
#include "strings.h"
|
||||
#include "table/sprites.h"
|
||||
#include "gui.h"
|
||||
#include "gfx.h"
|
||||
#include "vehicle.h"
|
||||
#include "viewport.h"
|
||||
#include "command.h"
|
||||
#include "textbuf_gui.h"
|
||||
#include "viewport_func.h"
|
||||
#include "gfx_func.h"
|
||||
#include "command_func.h"
|
||||
#include "depot.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "station_map.h"
|
||||
#include "newgrf_engine.h"
|
||||
#include "spritecache.h"
|
||||
#include "strings_func.h"
|
||||
#include "window_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "player_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
|
||||
/*
|
||||
* Since all depot window sizes aren't the same, we need to modify sizes a little.
|
||||
@@ -171,14 +174,14 @@ static void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y)
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN:
|
||||
DrawTrainImage(v, x + 21, sprite_y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel);
|
||||
DrawTrainImage(v, x + 21, sprite_y, WP(w, depot_d).sel, w->hscroll.cap + 4, w->hscroll.pos);
|
||||
|
||||
/* Number of wagons relative to a standard length wagon (rounded up) */
|
||||
SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
|
||||
DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
|
||||
break;
|
||||
|
||||
case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, 1, WP(w, depot_d).sel); break;
|
||||
case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, WP(w, depot_d).sel, 1); break;
|
||||
case VEH_SHIP: DrawShipImage( v, x + 19, sprite_y - 1, WP(w, depot_d).sel); break;
|
||||
case VEH_AIRCRAFT: {
|
||||
const Sprite *spr = GetSprite(v->GetImage(DIR_W));
|
||||
@@ -273,7 +276,7 @@ static void DrawDepotWindow(Window *w)
|
||||
const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count];
|
||||
const Vehicle *u;
|
||||
|
||||
DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel);
|
||||
DrawTrainImage(v, x + 50, y, WP(w, depot_d).sel, w->hscroll.cap - 29, 0);
|
||||
DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
|
||||
|
||||
/*Draw the train counter */
|
||||
@@ -429,7 +432,7 @@ static void DepotClick(Window *w, int x, int y)
|
||||
VehicleID sel = WP(w, depot_d).sel;
|
||||
|
||||
if (WP(w, depot_d).type == VEH_TRAIN && sel != INVALID_VEHICLE) {
|
||||
WP(w,depot_d).sel = INVALID_VEHICLE;
|
||||
WP(w, depot_d).sel = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
||||
} else if (v != NULL) {
|
||||
int image = v->GetImage(DIR_W);
|
||||
|
||||
@@ -1,38 +1,11 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file direction.h */
|
||||
/** @file direction_func.h Different functions related to conversions between directions. */
|
||||
|
||||
#ifndef DIRECTION_H
|
||||
#define DIRECTION_H
|
||||
#ifndef DIRECTION_FUNC_H
|
||||
#define DIRECTION_FUNC_H
|
||||
|
||||
#include "helpers.hpp"
|
||||
|
||||
/**
|
||||
* Defines the 8 directions on the map.
|
||||
*
|
||||
* This enum defines 8 possible directions which are used for
|
||||
* the vehicles in the game. The directions are aligned straight
|
||||
* to the viewport, not to the map. So north points to the top of
|
||||
* your viewport and not rotated by 45 degrees left or right to get
|
||||
* a "north" used in you games.
|
||||
*/
|
||||
enum Direction {
|
||||
DIR_BEGIN = 0, ///< Used to iterate
|
||||
DIR_N = 0, ///< North
|
||||
DIR_NE = 1, ///< Northeast
|
||||
DIR_E = 2, ///< East
|
||||
DIR_SE = 3, ///< Southeast
|
||||
DIR_S = 4, ///< South
|
||||
DIR_SW = 5, ///< Southwest
|
||||
DIR_W = 6, ///< West
|
||||
DIR_NW = 7, ///< Northwest
|
||||
DIR_END, ///< Used to iterate
|
||||
INVALID_DIR = 0xFF, ///< Flag for an invalid direction
|
||||
};
|
||||
|
||||
/** Define basic enum properties */
|
||||
template <> struct EnumPropsT<Direction> : MakeEnumPropsT<Direction, byte, DIR_BEGIN, DIR_END, INVALID_DIR> {};
|
||||
typedef TinyEnumT<Direction> DirectionByte; //typedefing-enumification of Direction
|
||||
#include "direction_type.h"
|
||||
|
||||
/**
|
||||
* Return the reverse of a direction
|
||||
@@ -46,32 +19,6 @@ static inline Direction ReverseDir(Direction d)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration for the difference between two directions.
|
||||
*
|
||||
* This enumeration is used to mark differences between
|
||||
* two directions. If you get one direction you can align
|
||||
* a second direction in 8 different ways. This enumeration
|
||||
* only contains 6 of these 8 differences, but the remaining
|
||||
* two can be calculated by adding to differences together.
|
||||
* This also means you can add two differences together and
|
||||
* get the difference you really want to get. The difference
|
||||
* of 45 degrees left + the difference of 45 degrees right results in the
|
||||
* difference of 0 degrees.
|
||||
*
|
||||
* @note To get this mentioned addition of direction you must use
|
||||
* modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function.
|
||||
* @see ChangeDirDiff(DirDiff, DirDiff)
|
||||
*/
|
||||
enum DirDiff {
|
||||
DIRDIFF_SAME = 0, ///< Both directions faces to the same direction
|
||||
DIRDIFF_45RIGHT = 1, ///< Angle of 45 degrees right
|
||||
DIRDIFF_90RIGHT = 2, ///< Angle of 90 degrees right
|
||||
DIRDIFF_REVERSE = 4, ///< One direction is the opposit of the other one
|
||||
DIRDIFF_90LEFT = 6, ///< Angle of 90 degrees left
|
||||
DIRDIFF_45LEFT = 7 ///< Angle of 45 degrees left
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the difference between to directions
|
||||
*
|
||||
@@ -116,27 +63,6 @@ static inline Direction ChangeDir(Direction d, DirDiff delta)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration for diagonal directions.
|
||||
*
|
||||
* This enumeration is used for the 4 direction of the tile-edges.
|
||||
*/
|
||||
enum DiagDirection {
|
||||
DIAGDIR_BEGIN = 0, ///< Used for iterations
|
||||
DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor
|
||||
DIAGDIR_SE = 1, ///< Southeast
|
||||
DIAGDIR_SW = 2, ///< Southwest
|
||||
DIAGDIR_NW = 3, ///< Northwest
|
||||
DIAGDIR_END, ///< Used for iterations
|
||||
INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection
|
||||
};
|
||||
|
||||
DECLARE_POSTFIX_INCREMENT(DiagDirection);
|
||||
|
||||
/** Define basic enum properties */
|
||||
template <> struct EnumPropsT<DiagDirection> : MakeEnumPropsT<DiagDirection, byte, DIAGDIR_BEGIN, DIAGDIR_END, INVALID_DIAGDIR> {};
|
||||
typedef TinyEnumT<DiagDirection> DiagDirectionByte; //typedefing-enumification of DiagDirection
|
||||
|
||||
/**
|
||||
* Returns the reverse direction of the given DiagDirection
|
||||
*
|
||||
@@ -148,25 +74,6 @@ static inline DiagDirection ReverseDiagDir(DiagDirection d)
|
||||
return (DiagDirection)(2 ^ d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration for the difference between to DiagDirection.
|
||||
*
|
||||
* As the DiagDirection only contains 4 possible directions the
|
||||
* difference between two of these directions can only be in 4 ways.
|
||||
* As the DirDiff enumeration the values can be added together and
|
||||
* you will get the resulting difference (use modulo DIAGDIR_END).
|
||||
*
|
||||
* @see DirDiff
|
||||
*/
|
||||
enum DiagDirDiff {
|
||||
DIAGDIRDIFF_SAME = 0, ///< Same directions
|
||||
DIAGDIRDIFF_90RIGHT = 1, ///< 90 degrees right
|
||||
DIAGDIRDIFF_REVERSE = 2, ///< Reverse directions
|
||||
DIAGDIRDIFF_90LEFT = 3 ///< 90 degrees left
|
||||
};
|
||||
|
||||
/** Allow incrementing of DiagDirDiff variables */
|
||||
DECLARE_POSTFIX_INCREMENT(DiagDirDiff);
|
||||
|
||||
/**
|
||||
* Applies a difference on a DiagDirection
|
||||
@@ -214,21 +121,6 @@ static inline Direction DiagDirToDir(DiagDirection dir)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration for the two axis X and Y
|
||||
*
|
||||
* This enumeration represente the two axis X and Y in the game.
|
||||
* The X axis is the one which goes align the north-west edge
|
||||
* (and south-east edge). The Y axis must be so the one which goes
|
||||
* align the north-east edge (and south-west) edge.
|
||||
*/
|
||||
enum Axis {
|
||||
AXIS_X = 0, ///< The X axis
|
||||
AXIS_Y = 1, ///< The y axis
|
||||
AXIS_END ///< Used for iterations
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Select the other axis as provided.
|
||||
*
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user